Fixed bank and loanshark
This commit is contained in:
@@ -491,7 +491,7 @@ public class TaipanShopGUI {
|
|||||||
bankButton.setOnAction(new EventHandler<ActionEvent>() {
|
bankButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
bankGUI bank = new bankGUI();
|
bankGUI bank = new bankGUI(player);
|
||||||
bank.initializeBank(stage);
|
bank.initializeBank(stage);
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
@@ -520,7 +520,7 @@ public class TaipanShopGUI {
|
|||||||
loanButton.setOnAction(new EventHandler<ActionEvent>() {
|
loanButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
loanSharkGUI loan = new loanSharkGUI();
|
loanSharkGUI loan = new loanSharkGUI(player);
|
||||||
loan.initializeLoanShark(stage);
|
loan.initializeLoanShark(stage);
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import javafx.scene.layout.VBox;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
public class bankGUI{
|
public class bankGUI{
|
||||||
private Player player = new Player();
|
private Player player;
|
||||||
/**
|
/**
|
||||||
* setter method that takes in a Player object as an argument.
|
* setter method that takes in a Player object as an argument.
|
||||||
*
|
*
|
||||||
@@ -36,19 +36,19 @@ public class bankGUI{
|
|||||||
*
|
*
|
||||||
//* @param player object of the class Player
|
//* @param player object of the class Player
|
||||||
*/
|
*/
|
||||||
//public bankGUI(Player player){
|
public bankGUI(Player player){
|
||||||
// Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
// this.player = playerDummy;
|
this.player = playerDummy;
|
||||||
//}
|
}
|
||||||
|
|
||||||
public Stage initializeBank(Stage primaryStage) {
|
public Stage initializeBank(Stage primaryStage) {
|
||||||
primaryStage.setTitle("Bank");
|
primaryStage.setTitle("Bank");
|
||||||
|
|
||||||
//Declaring each Layout
|
//Declaring each Layout
|
||||||
BorderPane brdr1 = new BorderPane();
|
BorderPane brdr1 = new BorderPane();
|
||||||
HBox hbx1 = new HBox(10);
|
HBox hbx1 = new HBox(30);
|
||||||
HBox hbx2 = new HBox(10);
|
HBox hbx2 = new HBox(30);
|
||||||
VBox vbx1 = new VBox(10);
|
VBox vbx1 = new VBox(30);
|
||||||
|
|
||||||
//Declaring all Variables
|
//Declaring all Variables
|
||||||
Label l1 = new Label("Player: " + player.getName());
|
Label l1 = new Label("Player: " + player.getName());
|
||||||
@@ -88,11 +88,11 @@ public class bankGUI{
|
|||||||
brdr1.setTop(vbx1);
|
brdr1.setTop(vbx1);
|
||||||
|
|
||||||
// Set the event handler when the deposit button is clicked
|
// Set the event handler when the deposit button is clicked
|
||||||
boolean keepGoing = true;
|
|
||||||
b1.setOnAction(new EventHandler<ActionEvent>() {
|
b1.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
int withdraw = Integer.parseInt(txtField1.getText());
|
int withdraw = Integer.parseInt(txtField1.getText());
|
||||||
|
System.out.println(withdraw);
|
||||||
if(withdraw <= player.getBank()){
|
if(withdraw <= player.getBank()){
|
||||||
player.setMoney(withdraw + player.getMoney());
|
player.setMoney(withdraw + player.getMoney());
|
||||||
player.setBank(player.getBank()-withdraw);
|
player.setBank(player.getBank()-withdraw);
|
||||||
@@ -111,6 +111,7 @@ public class bankGUI{
|
|||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event) {
|
public void handle(ActionEvent event) {
|
||||||
int deposit = Integer.parseInt(txtField1.getText());
|
int deposit = Integer.parseInt(txtField1.getText());
|
||||||
|
System.out.println(deposit);
|
||||||
if(deposit <= player.getMoney()){
|
if(deposit <= player.getMoney()){
|
||||||
player.setBank(deposit + player.getBank());
|
player.setBank(deposit + player.getBank());
|
||||||
player.setMoney(player.getMoney()-deposit);
|
player.setMoney(player.getMoney()-deposit);
|
||||||
@@ -146,7 +147,7 @@ public class bankGUI{
|
|||||||
|
|
||||||
|
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
bankGUI bank = new bankGUI();
|
bankGUI bank = new bankGUI(player);
|
||||||
bank.initializeBank(primaryStage);
|
bank.initializeBank(primaryStage);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import javafx.scene.layout.VBox;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
public class loanSharkGUI{
|
public class loanSharkGUI{
|
||||||
private Player player = new Player();
|
private Player player;
|
||||||
/**
|
/**
|
||||||
* setter method that takes in a Player object as an argument.
|
* setter method that takes in a Player object as an argument.
|
||||||
*
|
*
|
||||||
@@ -36,10 +36,10 @@ public class loanSharkGUI{
|
|||||||
*
|
*
|
||||||
//* @param player object of the class Player
|
//* @param player object of the class Player
|
||||||
*/
|
*/
|
||||||
//public loanSharkGUI(Player player){
|
public loanSharkGUI(Player player){
|
||||||
// Player playerDummy = new Player(player);
|
Player playerDummy = new Player(player);
|
||||||
// this.player = playerDummy;
|
this.player = playerDummy;
|
||||||
//}
|
}
|
||||||
|
|
||||||
public Stage initializeLoanShark(Stage primaryStage) {
|
public Stage initializeLoanShark(Stage primaryStage) {
|
||||||
primaryStage.setTitle("Loan Shark");
|
primaryStage.setTitle("Loan Shark");
|
||||||
@@ -151,7 +151,7 @@ public class loanSharkGUI{
|
|||||||
|
|
||||||
|
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
loanSharkGUI loan = new loanSharkGUI();
|
loanSharkGUI loan = new loanSharkGUI(player);
|
||||||
loan.initializeLoanShark(primaryStage);
|
loan.initializeLoanShark(primaryStage);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user