Merge remote-tracking branch 'origin/master'

This commit is contained in:
2019-03-25 13:26:20 -06:00
5 changed files with 49 additions and 21 deletions

View File

@@ -47,9 +47,9 @@ public class BankGUI extends Player{
VBox vbx1 = new VBox(30);
Label l1 = new Label("Player: " + getName());
Label l2 = new Label("Current Balance: " + getBank());
Label l2 = new Label("Balance: " + getBank());
Label l3 = new Label("Enter Amount: ");
Label l4 = new Label("Current cash: " + getMoney());
Label l4 = new Label("Cash: " + getMoney());
Label l5 = new Label(" ");
Button b1 = new Button("Withdraw");
@@ -100,20 +100,20 @@ public class BankGUI extends Player{
try {
int withdraw = Integer.parseInt(txtField1.getText());
if(withdraw < 0){
l5.setText("Come on " + getName() + " are you trying to fool me??? \n No negative Numbers Please");
l5.setText("Come on " + getName() + ", are you trying to fool me?\nNo negative numbers please!");
}
else if (withdraw <= getBank()) {
setMoney(withdraw + getMoney());
setBank(getBank() - withdraw);
}
else {
l5.setText("Sorry you cannot withdraw that much");
l5.setText("Sorry, you can not withdraw that much.");
}
l2.setText("Current Balance: " + getBank());
l4.setText("Current cash: " + getMoney());
l2.setText("Balance: " + getBank());
l4.setText("Cash: " + getMoney());
}
catch (Exception e) {
l5.setText("Please enter a valid value");
l5.setText("Please enter a valid response.");
}
}
}
@@ -130,20 +130,20 @@ public class BankGUI extends Player{
try {
int deposit = Integer.parseInt(txtField1.getText());
if(deposit < 0){
l5.setText("Nice Try!!! No negative Numbers Please");
l5.setText("Nice try! You can not enter negative numbers.");
}
else if (deposit <= getMoney()) {
setBank(deposit + getBank());
setMoney(getMoney() - deposit);
} else {
l5.setText("Sorry you cannot deposit that much.$");
l5.setText("Sorry, you can not deposit that much.");
}
l2.setText("Current Balance: " + getBank());
l4.setText("Current cash: " + getMoney());
l2.setText("Balance: " + getBank());
l4.setText("Cash: " + getMoney());
}
catch (Exception e) {
l5.setText("Please enter a valid value");
l5.setText("Please enter a valid response.");
}
}
}

View File

@@ -13,6 +13,7 @@ public class FileSaving extends Player implements Serializable {
* @return player
*/
public Player loadFile() {
try {
InputStream in = new FileInputStream(new File("src/saves/playerSave.txt"));
ObjectInputStream inObject = new ObjectInputStream(in);
@@ -22,7 +23,17 @@ public class FileSaving extends Player implements Serializable {
return player;
}
catch (Exception e) {
return null;
try {
InputStream in = new FileInputStream(new File("saves/playerSave.txt"));
ObjectInputStream inObject = new ObjectInputStream(in);
Player player = (Player) inObject.readObject();
in.close();
inObject.close();
return player;
}
catch(Exception e2){
return null;
}
}
}
@@ -39,7 +50,18 @@ public class FileSaving extends Player implements Serializable {
return true;
}
catch (Exception e) {
return false;
try {
FileOutputStream out = new FileOutputStream(new File("saves/playerSave.txt"));
ObjectOutputStream outObject = new ObjectOutputStream(out);
outObject.writeObject(player);
out.close();
outObject.close();
return true;
}
catch(Exception e2){
return false;
}
}
}

View File

@@ -50,8 +50,8 @@ public class LoanSharkGUI extends Player {
//Declaring all Variables
Label l1 = new Label("Player: " + getName());
Label l2 = new Label("Current Debt " + getDebt());
Label l4 = new Label("Current cash: " + getMoney());
Label l2 = new Label("Debt " + getDebt());
Label l4 = new Label("Cash: " + getMoney());
Label l3 = new Label("Enter Amount: ");
Label l5 = new Label(" ");
@@ -98,7 +98,7 @@ public class LoanSharkGUI extends Player {
if (loanAsk <= 2 * (getMoney() - getDebt()) && loanAsk >= 0) {
setDebt(getDebt() + loanAsk);
setMoney(getMoney() + loanAsk);
l4.setText("Current cash: " + getMoney());
l4.setText("Cash: " + getMoney());
} else if (loanAsk < 0) {
l5.setText("Sorry you cannot enter negative numbers");
}
@@ -126,18 +126,18 @@ public class LoanSharkGUI extends Player {
int returnAsk = Integer.parseInt(txtField1.getText());
if (returnAsk > getDebt()) {
l5.setText("You dont need to return that much");
l5.setText("You do not need to return that much.");
}
else if (returnAsk <= getDebt() && returnAsk >= 0 && getMoney() >= returnAsk) {
setDebt(getDebt() - returnAsk);
setMoney(getMoney() - returnAsk);
l4.setText("Current cash: " + getMoney());
l4.setText("Cash: " + getMoney());
}
else if(getMoney() < returnAsk) {
l5.setText("Look " + getName() + ", you are being cheap!");
}
else {
l5.setText("Sorry you cannot return a negative amount");
l5.setText("Sorry, you can not return a negative amount!");
}
l2.setText("Debt: " + getDebt());
}

View File

@@ -492,6 +492,7 @@ public class TaipanShopGUI extends Player{
*/
@Override
public void handle(ActionEvent event) {
saving.saveFile(getPlayer());
setIsPriceChanged(1);
TravelGUI travelGUI = new TravelGUI(getPlayer());
travelGUI.initializeTravel(stage);