Update TaipanShop.java

This commit is contained in:
Vikramb987
2019-02-21 22:07:51 -07:00
committed by GitHub
parent 2395eb3298
commit 0a93de3354

View File

@@ -1,7 +1,8 @@
import java.util.Random; import java.util.Random;
import java.util.Scanner; import java.util.Scanner;
public class TaipanShop extends Player { public class TaipanShop {
private Player player;
private int cargoSpace = 60; private int cargoSpace = 60;
private int currentCargo = 0; private int currentCargo = 0;
private int opiumPrice = 16000; private int opiumPrice = 16000;
@@ -9,6 +10,21 @@ public class TaipanShop extends Player {
private int armsPrice = 160; private int armsPrice = 160;
private int generalPrice = 8; private int generalPrice = 8;
public void setPlayer(Player player) {
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public Player getPlayer(){
Player playerDummy = new Player(player);
return playerDummy;
}
public TaipanShop(Player player){
Player playerDummy = new Player(player);
this.player = playerDummy;
}
public int getCargoSpace() { public int getCargoSpace() {
return cargoSpace; return cargoSpace;
} }
@@ -60,7 +76,7 @@ public class TaipanShop extends Player {
} }
private void updatePrices(){ private void updatePrices(){
String s = "\n" + getName() + ", the price of "; String s = "\n" + player.getName() + ", the price of ";
double value = 80*Math.random(); double value = 80*Math.random();
Random rand = new Random(); Random rand = new Random();
opiumPrice = (rand.nextInt(201) + 60)*100; opiumPrice = (rand.nextInt(201) + 60)*100;
@@ -105,18 +121,18 @@ public class TaipanShop extends Player {
} }
private void printShop(){ private void printShop(){
currentCargo = getOpiumHeld()+getGuns()*10+getSilkHeld()+getArmsHeld()+getGeneralHeld(); currentCargo = player.getOpiumHeld()+player.getGuns()*10+player.getSilkHeld()+player.getArmsHeld()+player.getGeneralHeld();
if(cargoSpace - currentCargo < 0){ if(cargoSpace - currentCargo < 0){
System.out.println("Hold: Overloaded" + " Guns: " + getGuns()); System.out.println("Hold: Overloaded" + " Guns: " + player.getGuns());
}else{ }else{
System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + getGuns()); System.out.println("Hold: " + (cargoSpace-currentCargo) + " Guns: " + player.getGuns());
} }
System.out.println("-------------------------------------------------------------"); System.out.println("-------------------------------------------------------------");
System.out.println(" Opium: " + getOpiumHeld() + " Silk: " + getSilkHeld()); System.out.println(" Opium: " + player.getOpiumHeld() + " Silk: " + player.getSilkHeld());
System.out.println(" Arms: " + getArmsHeld() + " General: " + getGeneralHeld()); System.out.println(" Arms: " + player.getArmsHeld() + " General: " + player.getGeneralHeld());
System.out.println("-------------------------------------------------------------"); System.out.println("-------------------------------------------------------------");
System.out.println("Cash: " + getMoney() + " Bank: " + getBank()+"\n"); System.out.println("Cash: " + player.getMoney() + " Bank: " + player.getBank()+"\n");
System.out.println(getName() + ", present prices per unit here are:"); System.out.println(player.getName() + ", present prices per unit here are:");
System.out.println(" Opium: " + opiumPrice + " Silk: " + silkPrice); System.out.println(" Opium: " + opiumPrice + " Silk: " + silkPrice);
System.out.println(" Arms: " + armsPrice + " General: " + generalPrice); System.out.println(" Arms: " + armsPrice + " General: " + generalPrice);
} }
@@ -125,70 +141,70 @@ public class TaipanShop extends Player {
updatePrices(); updatePrices();
Scanner input = new Scanner(System.in); Scanner input = new Scanner(System.in);
boolean notDone = true; boolean notDone = true;
if (getLocation() == 1) { if (player.getLocation() == 1) {
while (notDone) { while (notDone) {
printShop(); printShop();
System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, or Quit Trading?"); System.out.println("\nShall I Buy, Sell, Visit Bank, Transfer Cargo, or Quit Trading?");
String response = input.next(); String response = input.next();
if (response.equalsIgnoreCase("B")) { if (response.equalsIgnoreCase("B")) {
boolean notDone2 = true; boolean notDone2 = true;
System.out.println("What do you wish me to buy, " + getName() + "?"); System.out.println("What do you wish me to buy, " + player.getName() + "?");
while (notDone2) { while (notDone2) {
response = input.nextLine(); response = input.nextLine();
if (response.equalsIgnoreCase("O")) { if (response.equalsIgnoreCase("O")) {
System.out.println("\nHow much Opium shall I buy, " + getName() + "? (You can afford " + getMoney() / opiumPrice + ")"); System.out.println("\nHow much Opium shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / opiumPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / opiumPrice && num >= 0) { if (num <= player.getMoney() / opiumPrice && num >= 0) {
setOpiumHeld(getOpiumHeld()+num); player.setOpiumHeld(player.getOpiumHeld()+num);
setMoney(getMoney()-num * opiumPrice); player.setMoney(player.getMoney()-num * opiumPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " Opium?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
} }
} }
} else if (response.equalsIgnoreCase("S")) { } else if (response.equalsIgnoreCase("S")) {
System.out.println("\nHow much Silk shall I buy, " + getName() + "? (You can afford " + getMoney() / silkPrice + ")"); System.out.println("\nHow much Silk shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / silkPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / silkPrice && num >= 0) { if (num <= player.getMoney() / silkPrice && num >= 0) {
setSilkHeld(getSilkHeld()+num); player.setSilkHeld(player.getSilkHeld()+num);
setMoney(getMoney()-num * silkPrice); player.setMoney(player.getMoney()-num * silkPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " Silk?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
} }
} }
} else if (response.equalsIgnoreCase("A")) { } else if (response.equalsIgnoreCase("A")) {
System.out.println("\nHow many Arms shall I buy, " + getName() + "? (You can afford " + getMoney() / armsPrice + ")"); System.out.println("\nHow many Arms shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / armsPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / armsPrice && num >= 0) { if (num <= player.getMoney() / armsPrice && num >= 0) {
setArmsHeld(getArmsHeld()+num); player.setArmsHeld(player.getArmsHeld()+num);
setMoney(getMoney() - num*armsPrice); player.setMoney(player.getMoney() - num*armsPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " Arms?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
} }
} }
} else if (response.equalsIgnoreCase("G")) { } else if (response.equalsIgnoreCase("G")) {
System.out.println("\nHow much General Cargo shall I buy, " + getName() + "? (You can afford " + getMoney() / generalPrice + ")"); System.out.println("\nHow much General Cargo shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / generalPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / generalPrice && num >= 0) { if (num <= player.getMoney() / generalPrice && num >= 0) {
setGeneralHeld(getGeneralHeld()+num); player.setGeneralHeld(player.getGeneralHeld()+num);
setMoney(getMoney() - num*generalPrice); player.setMoney(player.getMoney() - num*generalPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
} }
} }
} }
@@ -197,63 +213,63 @@ public class TaipanShop extends Player {
} else if (response.equalsIgnoreCase("S")) { } else if (response.equalsIgnoreCase("S")) {
boolean notDone2 = true; boolean notDone2 = true;
System.out.println("What do you wish me to sell, " + getName() + "?"); System.out.println("What do you wish me to sell, " + player.getName() + "?");
while (notDone2) { while (notDone2) {
response = input.nextLine(); response = input.nextLine();
if (response.equalsIgnoreCase("O")) { if (response.equalsIgnoreCase("O")) {
System.out.println("\nHow much Opium shall I sell, " + getName() + "? (You have " + getOpiumHeld() + ")"); System.out.println("\nHow much Opium shall I sell, " + player.getName() + "? (You have " + player.getOpiumHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getOpiumHeld() && num >= 0) { if (num <= player.getOpiumHeld() && num >= 0) {
setOpiumHeld(getOpiumHeld()-num); player.setOpiumHeld(player.getOpiumHeld()-num);
setMoney(getMoney() + num*opiumPrice); player.setMoney(player.getMoney() + num*opiumPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " Opium?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
} }
} }
} else if (response.equalsIgnoreCase("S")) { } else if (response.equalsIgnoreCase("S")) {
System.out.println("\nHow much Silk shall I sell, " + getName() + "? (You have " + getSilkHeld() + ")"); System.out.println("\nHow much Silk shall I sell, " + player.getName() + "? (You have " + player.getSilkHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getSilkHeld() && num >= 0) { if (num <= player.getSilkHeld() && num >= 0) {
setSilkHeld(getSilkHeld()-num); player.setSilkHeld(player.getSilkHeld()-num);
setMoney(getMoney() + num*silkPrice); player.setMoney(player.getMoney() + num*silkPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " Silk?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
} }
} }
} else if (response.equalsIgnoreCase("A")) { } else if (response.equalsIgnoreCase("A")) {
System.out.println("\nHow many Arms shall I sell, " + getName() + "? (You have " + getArmsHeld() + ")"); System.out.println("\nHow many Arms shall I sell, " + player.getName() + "? (You have " + player.getArmsHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getArmsHeld() && num >= 0) { if (num <= player.getArmsHeld() && num >= 0) {
setArmsHeld(getArmsHeld()-num); player.setArmsHeld(player.getArmsHeld()-num);
setMoney(getMoney() + num*armsPrice); player.setMoney(player.getMoney() + num*armsPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " Arms?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
} }
} }
} else if (response.equalsIgnoreCase("G")) { } else if (response.equalsIgnoreCase("G")) {
System.out.println("\nHow much General Cargo shall I sell, " + getName() + "? (You have " + getGeneralHeld() + ")"); System.out.println("\nHow much General Cargo shall I sell, " + player.getName() + "? (You have " + player.getGeneralHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getGeneralHeld() && num >= 0) { if (num <= player.getGeneralHeld() && num >= 0) {
setGeneralHeld(getGeneralHeld()-num); player.setGeneralHeld(player.getGeneralHeld()-num);
setMoney(getMoney() + num*generalPrice); player.setMoney(player.getMoney() + num*generalPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
} }
} }
} }
@@ -276,63 +292,63 @@ public class TaipanShop extends Player {
String response = input.next(); String response = input.next();
if (response.equalsIgnoreCase("B")) { if (response.equalsIgnoreCase("B")) {
boolean notDone2 = true; boolean notDone2 = true;
System.out.println("What do you wish me to buy, " + getName() + "?"); System.out.println("What do you wish me to buy, " + player.getName() + "?");
while (notDone2) { while (notDone2) {
response = input.nextLine(); response = input.nextLine();
if (response.equalsIgnoreCase("O")) { if (response.equalsIgnoreCase("O")) {
System.out.println("\nHow much Opium shall I buy, " + getName() + "? (You can afford " + getMoney() / opiumPrice + ")"); System.out.println("\nHow much Opium shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / opiumPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / opiumPrice && num >= 0) { if (num <= player.getMoney() / opiumPrice && num >= 0) {
setOpiumHeld(getOpiumHeld()+num); player.setOpiumHeld(player.getOpiumHeld()+num);
setMoney(getMoney() - num*opiumPrice); player.setMoney(player.getMoney() - num*opiumPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " Opium?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " Opium?");
} }
} }
} else if (response.equalsIgnoreCase("S")) { } else if (response.equalsIgnoreCase("S")) {
System.out.println("\nHow much Silk shall I buy, " + getName() + "? (You can afford " + getMoney() / silkPrice + ")"); System.out.println("\nHow much Silk shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / silkPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / silkPrice && num >= 0) { if (num <= player.getMoney() / silkPrice && num >= 0) {
setSilkHeld(getSilkHeld()+num); player.setSilkHeld(player.getSilkHeld()+num);
setMoney(getMoney() - num*silkPrice); player.setMoney(player.getMoney() - num*silkPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " Silk?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " Silk?");
} }
} }
} else if (response.equalsIgnoreCase("A")) { } else if (response.equalsIgnoreCase("A")) {
System.out.println("\nHow many Arms shall I buy, " + getName() + "? (You can afford " + getMoney() / armsPrice + ")"); System.out.println("\nHow many Arms shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / armsPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / armsPrice && num >= 0) { if (num <= player.getMoney() / armsPrice && num >= 0) {
setArmsHeld(getArmsHeld()+num); player.setArmsHeld(player.getArmsHeld()+num);
setMoney(getMoney() - num*armsPrice); player.setMoney(player.getMoney() - num*armsPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " Arms?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " Arms?");
} }
} }
} else if (response.equalsIgnoreCase("G")) { } else if (response.equalsIgnoreCase("G")) {
System.out.println("\nHow much General Cargo shall I buy, " + getName() + "? (You can afford " + getMoney() / generalPrice + ")"); System.out.println("\nHow much General Cargo shall I buy, " + player.getName() + "? (You can afford " + player.getMoney() / generalPrice + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getMoney() / generalPrice && num >= 0) { if (num <= player.getMoney() / generalPrice && num >= 0) {
setGeneralHeld(getGeneralHeld()+num); player.setGeneralHeld(player.getGeneralHeld()+num);
setMoney(getMoney() - num*generalPrice); player.setMoney(player.getMoney() - num*generalPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you can't afford that!"); System.out.println(player.getName() + ", you can't afford that!");
} else { } else {
System.out.println(getName() + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?"); System.out.println(player.getName() + ", how am I supposed to buy " + "'" + num + "'" + " General Cargo?");
} }
} }
} }
@@ -341,63 +357,63 @@ public class TaipanShop extends Player {
} else if (response.equalsIgnoreCase("S")) { } else if (response.equalsIgnoreCase("S")) {
boolean notDone2 = true; boolean notDone2 = true;
System.out.println("What do you wish me to sell, " + getName() + "?"); System.out.println("What do you wish me to sell, " + player.getName() + "?");
while (notDone2) { while (notDone2) {
response = input.nextLine(); response = input.nextLine();
if (response.equalsIgnoreCase("O")) { if (response.equalsIgnoreCase("O")) {
System.out.println("\nHow much Opium shall I sell, " + getName() + "? (You have " + getOpiumHeld() + ")"); System.out.println("\nHow much Opium shall I sell, " + player.getName() + "? (You have " + player.getOpiumHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getOpiumHeld() && num >= 0) { if (num <= player.getOpiumHeld() && num >= 0) {
setOpiumHeld(getOpiumHeld()-num); player.setOpiumHeld(player.getOpiumHeld()-num);
setMoney(getMoney() + num*opiumPrice); player.setMoney(player.getMoney() + num*opiumPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " Opium?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " Opium?");
} }
} }
} else if (response.equalsIgnoreCase("S")) { } else if (response.equalsIgnoreCase("S")) {
System.out.println("\nHow much Silk shall I sell, " + getName() + "? (You have " + getSilkHeld() + ")"); System.out.println("\nHow much Silk shall I sell, " + player.getName() + "? (You have " + player.getSilkHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getSilkHeld() && num >= 0) { if (num <= player.getSilkHeld() && num >= 0) {
setSilkHeld(getSilkHeld()-num); player.setSilkHeld(player.getSilkHeld()-num);
setMoney(getMoney() + num*silkPrice); player.setMoney(player.getMoney() + num*silkPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " Silk?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " Silk?");
} }
} }
} else if (response.equalsIgnoreCase("A")) { } else if (response.equalsIgnoreCase("A")) {
System.out.println("\nHow many Arms shall I sell, " + getName() + "? (You have " + getArmsHeld() + ")"); System.out.println("\nHow many Arms shall I sell, " + player.getName() + "? (You have " + player.getArmsHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getArmsHeld() && num >= 0) { if (num <= player.getArmsHeld() && num >= 0) {
setArmsHeld(getArmsHeld()-num); player.setArmsHeld(player.getArmsHeld()-num);
setMoney(getMoney() + num*armsPrice); player.setMoney(player.getMoney() + num*armsPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " Arms?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " Arms?");
} }
} }
} else if (response.equalsIgnoreCase("G")) { } else if (response.equalsIgnoreCase("G")) {
System.out.println("\nHow much General Cargo shall I sell, " + getName() + "? (You have " + getGeneralHeld() + ")"); System.out.println("\nHow much General Cargo shall I sell, " + player.getName() + "? (You have " + player.getGeneralHeld() + ")");
while (notDone2) { while (notDone2) {
int num = input.nextInt(); int num = input.nextInt();
if (num <= getGeneralHeld() && num >= 0) { if (num <= player.getGeneralHeld() && num >= 0) {
setGeneralHeld(getGeneralHeld()-num); player.setGeneralHeld(player.getGeneralHeld()-num);
setMoney(getMoney() + num*generalPrice); player.setMoney(player.getMoney() + num*generalPrice);
notDone2 = false; notDone2 = false;
} else if (num >= 0) { } else if (num >= 0) {
System.out.println(getName() + ", you don't have that many to sell!"); System.out.println(player.getName() + ", you don't have that many to sell!");
} else { } else {
System.out.println(getName() + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?"); System.out.println(player.getName() + ", how am I supposed to sell " + "'" + num + "'" + " General Cargo?");
} }
} }
} }
@@ -410,8 +426,4 @@ public class TaipanShop extends Player {
} }
} }
public static void main(String[] args){ }
TaipanShop shop = new TaipanShop();
shop.shop();
}
}