Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -9,6 +9,7 @@ import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ShipWarfareGUI {
|
||||
@@ -31,21 +32,16 @@ public class ShipWarfareGUI {
|
||||
private Button continueButton;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* constructor; only runs when a Player object is provided. The constructor is fully encapsulated.
|
||||
*
|
||||
* @param player is a Player object that will be copied and the player instance variable is set to the copy.
|
||||
*/
|
||||
public ShipWarfareGUI(Player player){
|
||||
/**
|
||||
* constructor; only runs when a Player object is provided. The constructor is fully encapsulated.
|
||||
*
|
||||
* @param player is a Player object that will be copied and the player instance variable is set to the copy.
|
||||
*/
|
||||
public ShipWarfareGUI(Player player) {
|
||||
Player playerDummy = new Player(player);
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
//public static void main(String args[]) {
|
||||
// launch(args);
|
||||
//}
|
||||
|
||||
private int numOfPeasantShips = 0;
|
||||
private int numOfLittyShips = 0;
|
||||
@@ -58,6 +54,7 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* setter method for player
|
||||
*
|
||||
* @param player object of the class Player
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
@@ -67,6 +64,7 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* getter method for obtaining a player object.
|
||||
*
|
||||
* @return returns player object
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
@@ -76,12 +74,13 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* setter method that takes in an integer as an argument
|
||||
*
|
||||
* @param numOfPeasantShips the number of ships to be used in the peasant fleet attack
|
||||
*/
|
||||
public void setNumOfPeasantShips(int numOfPeasantShips){
|
||||
public void setNumOfPeasantShips(int numOfPeasantShips) {
|
||||
counter1++;
|
||||
this.numOfPeasantShips = numOfPeasantShips;
|
||||
if(counter1==1) {
|
||||
if (counter1 == 1) {
|
||||
startingPeasantShips = numOfPeasantShips;
|
||||
}
|
||||
|
||||
@@ -89,6 +88,7 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* The number of ships that attack is based on the amount of money one has on hand
|
||||
*
|
||||
* @return the number of ships which will attack
|
||||
*/
|
||||
public int numOfShips() {
|
||||
@@ -116,6 +116,7 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* One in two chance of running away
|
||||
*
|
||||
* @return true if the user is allowed to run, false if not, the "default" is false
|
||||
*/
|
||||
public boolean runFromShips() {
|
||||
@@ -133,7 +134,7 @@ public class ShipWarfareGUI {
|
||||
/**
|
||||
* Sets most of the labels invisible except for the "fight or run" label
|
||||
*/
|
||||
public void wipe(){
|
||||
public void wipe() {
|
||||
title.setVisible(false);
|
||||
runAwayOrLeft.setVisible(false);
|
||||
shipsRemaining.setVisible(false);
|
||||
@@ -159,6 +160,7 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* The user faces off against the peasant ships and either prevails, dies, or runs away
|
||||
*
|
||||
* @return true if the user wins, loses, or flees, it returns false otherwise
|
||||
* @throws Exception in case of errors due to the delay
|
||||
*/
|
||||
@@ -207,7 +209,8 @@ public class ShipWarfareGUI {
|
||||
} else {
|
||||
//continue;
|
||||
}
|
||||
}if(userAttacks==true) {
|
||||
}
|
||||
if (userAttacks == true) {
|
||||
report.setText(String.format("Report: Ships hit: %d, Shots missed: %d", hitCounter, missCounter));
|
||||
}
|
||||
} else {
|
||||
@@ -235,7 +238,7 @@ public class ShipWarfareGUI {
|
||||
}
|
||||
|
||||
} else {
|
||||
report.setText((String.format("Escaped %d of them %s!", howMuchRun,player.getName())));
|
||||
report.setText((String.format("Escaped %d of them %s!", howMuchRun, player.getName())));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -249,7 +252,7 @@ public class ShipWarfareGUI {
|
||||
player.setGuns(player.getGuns() - 1);
|
||||
gunFrustration = true;
|
||||
} else {
|
||||
if (numOfPeasantShips>0) {
|
||||
if (numOfPeasantShips > 0) {
|
||||
player.setHP(player.getHP() - (1 + randomValue.nextInt(10)));
|
||||
|
||||
}
|
||||
@@ -269,12 +272,12 @@ public class ShipWarfareGUI {
|
||||
userAttacks = true;
|
||||
}
|
||||
|
||||
continueToFight.setText(String.format("Shall we continue to fight? (Click the fight button or the run button)", player.getGuns()));
|
||||
continueToFight.setText(String.format("Captain, what are your orders? (Click the fight button or the run button)", player.getGuns()));
|
||||
|
||||
if (exitValue == 1) {
|
||||
wipe();
|
||||
chooseFightOrRun.setText(String.format("Ayy! We won and survived at %d%% ship status!", player.getHP()));
|
||||
calculateLoot = (startingPeasantShips *100) + randomValue.nextInt(startingPeasantShips) *200;
|
||||
calculateLoot = (startingPeasantShips * 100) + randomValue.nextInt(startingPeasantShips) * 200;
|
||||
player.setMoney(player.getMoney() + calculateLoot);
|
||||
report.setText(String.format("Our firm has earned $%,d in loot! ", calculateLoot));
|
||||
continueButton.setVisible(true);
|
||||
@@ -294,11 +297,12 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* Sets up the graphical part of ShipWarfare and includes all logic for the class
|
||||
*
|
||||
* @param stage sets the stage to which we will execute the scene of the ShipWarfare class
|
||||
* @return stage so that another class can switch to the stage
|
||||
*/
|
||||
|
||||
public Stage initializeShip(Stage stage){
|
||||
public Stage initializeShip(Stage stage) {
|
||||
setNumOfPeasantShips(numOfShips());
|
||||
|
||||
BorderPane BorderPane = new BorderPane();
|
||||
@@ -324,7 +328,6 @@ public class ShipWarfareGUI {
|
||||
continueButton.setVisible(false);
|
||||
|
||||
|
||||
|
||||
BorderPane.setPrefHeight(400.0);
|
||||
BorderPane.setPrefWidth(600.0);
|
||||
hBox.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
@@ -335,7 +338,7 @@ public class ShipWarfareGUI {
|
||||
title.setAlignment(javafx.geometry.Pos.TOP_CENTER);
|
||||
title.setContentDisplay(javafx.scene.control.ContentDisplay.CENTER);
|
||||
title.setId("Label1");
|
||||
title.setText(String.format("%d ships attacking. Would you like to Fight or Run?",numOfPeasantShips));
|
||||
title.setText(String.format("%d ships attacking. Would you like to Fight or Run?", numOfPeasantShips));
|
||||
title.setPadding(new Insets(6.0, 0.0, 0.0, 0.0));
|
||||
|
||||
continueButton.setMnemonicParsing(false);
|
||||
@@ -351,7 +354,8 @@ public class ShipWarfareGUI {
|
||||
runButton.setId("Button2");
|
||||
runButton.setMnemonicParsing(false);
|
||||
|
||||
BorderPane.setBottom(hBox);runButton.setText("Run");
|
||||
BorderPane.setBottom(hBox);
|
||||
runButton.setText("Run");
|
||||
|
||||
BorderPane.setAlignment(vBox, javafx.geometry.Pos.CENTER);
|
||||
vBox.setAlignment(javafx.geometry.Pos.TOP_CENTER);
|
||||
@@ -391,7 +395,7 @@ public class ShipWarfareGUI {
|
||||
counter++;
|
||||
chooseFightOrRun.setText("Ohh, Fight ehh?");
|
||||
try {
|
||||
if (destroyPeasantShipsOrEscape(stage)){
|
||||
if (destroyPeasantShipsOrEscape(stage)) {
|
||||
completeWipe();
|
||||
continueButton.setVisible(true);
|
||||
fightButton.setVisible(false);
|
||||
@@ -437,7 +441,7 @@ public class ShipWarfareGUI {
|
||||
chooseFightOrRun.setVisible(false);
|
||||
report.setText(("Couldn't run away"));
|
||||
try {
|
||||
if(destroyPeasantShipsOrEscape(stage)==true){
|
||||
if (destroyPeasantShipsOrEscape(stage) == true) {
|
||||
completeWipe();
|
||||
continueButton.setVisible(true);
|
||||
fightButton.setVisible(false);
|
||||
@@ -467,7 +471,7 @@ public class ShipWarfareGUI {
|
||||
|
||||
|
||||
}
|
||||
if (counter>=2){
|
||||
if (counter >= 2) {
|
||||
title.setVisible(false);
|
||||
}
|
||||
}
|
||||
@@ -484,9 +488,10 @@ public class ShipWarfareGUI {
|
||||
|
||||
/**
|
||||
* sets scene and runs stage
|
||||
*
|
||||
* @param primaryStage the stage in which the scene may be run and switched to
|
||||
*/
|
||||
public void start(Stage primaryStage){
|
||||
public void start(Stage primaryStage) {
|
||||
primaryStage = initializeShip(primaryStage);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
@@ -69,54 +69,112 @@ public class StartGUI {
|
||||
this.player = playerTemp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Start GUI the game.
|
||||
*
|
||||
* @param stage object of type Stage
|
||||
* @return returns the stage of GUI
|
||||
*/
|
||||
public Stage initializeStart(Stage stage){
|
||||
|
||||
/**
|
||||
* Creates an HBox at the center of the borderpane with a width of 200, height of 100 and spacing of 10.
|
||||
*
|
||||
*/
|
||||
borderPane.setAlignment(hBox, javafx.geometry.Pos.CENTER);
|
||||
hBox.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
hBox.setPrefHeight(100.0);
|
||||
hBox.setPrefWidth(200.0);
|
||||
hBox.setSpacing(10.0);
|
||||
|
||||
/**
|
||||
* Creates a borderpane window of width 600 and height 480.
|
||||
*
|
||||
*/
|
||||
borderPane.setPrefHeight(480.0);
|
||||
borderPane.setPrefWidth(600.0);
|
||||
|
||||
nameField.setPromptText("Enter your name.");
|
||||
/**
|
||||
* Creates a prompt text field that asks for your firm name and has a default text set to "Taipan".
|
||||
*
|
||||
*/
|
||||
nameField.setPromptText("Enter Firm Name.");
|
||||
nameField.setText("Taipan");
|
||||
|
||||
/**
|
||||
* Creates a button with text "Start"
|
||||
*
|
||||
*/
|
||||
startButton.setMnemonicParsing(false);
|
||||
startButton.setText("Start");
|
||||
|
||||
/**
|
||||
* Creates a VBox at the left of center of the borderpane.
|
||||
*
|
||||
*/
|
||||
vBox.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
|
||||
|
||||
/**
|
||||
* Creates a label with text "Do you want to start with..." to indicate the user has to choose between 2 given scenarios.
|
||||
*
|
||||
*/
|
||||
choiceLabel.setText("Do you want to start with...");
|
||||
|
||||
/**
|
||||
* Label for scenario one which is you start with five guns and no cash or debt.
|
||||
*
|
||||
*/
|
||||
gunChoice.setMnemonicParsing(false);
|
||||
gunChoice.setSelected(true);
|
||||
gunChoice.setText("Five guns and no cash (But no debt!)?");
|
||||
|
||||
gunChoice.setToggleGroup(Start);
|
||||
|
||||
/**
|
||||
* Label for scenario 2 which is you start with cash but also a debt.
|
||||
*
|
||||
*/
|
||||
cashChoice.setAlignment(javafx.geometry.Pos.TOP_LEFT);
|
||||
cashChoice.setMnemonicParsing(false);
|
||||
cashChoice.setText("Cash (and a debt)");
|
||||
cashChoice.setToggleGroup(Start);
|
||||
borderPane.setBottom(hBox);
|
||||
|
||||
/**
|
||||
* Creates a VBox at the center of the borderpane with a width of 100 and height of 200.
|
||||
*
|
||||
*/
|
||||
BorderPane.setAlignment(vBox0, javafx.geometry.Pos.CENTER);
|
||||
vBox0.setAlignment(javafx.geometry.Pos.CENTER);
|
||||
vBox0.setPrefHeight(200.0);
|
||||
vBox0.setPrefWidth(100.0);
|
||||
|
||||
/**
|
||||
* Creates a label with text "Taipan" in size 66 font and default font style.
|
||||
*
|
||||
*/
|
||||
title.setText("Taipan");
|
||||
title.setFont(new Font(66.0));
|
||||
|
||||
/**
|
||||
* Creates a label with our names as text
|
||||
*
|
||||
*/
|
||||
authors.setPrefHeight(80.0);
|
||||
authors.setPrefWidth(499.0);
|
||||
authors.setText("By Vikram Bawa, Haris Muhammad, Siddhant Dewani, Nathan Lum and Harkamal Randhawa");
|
||||
|
||||
/**
|
||||
* Puts Vbox0 in the center of the borderpane.
|
||||
*
|
||||
*/
|
||||
authors.setTextAlignment(javafx.scene.text.TextAlignment.CENTER);
|
||||
borderPane.setCenter(vBox0);
|
||||
|
||||
/**
|
||||
* Adds all the buttons and labels to their respective boxes.
|
||||
*
|
||||
*/
|
||||
hBox.getChildren().add(nameField);
|
||||
hBox.getChildren().add(startButton);
|
||||
vBox.getChildren().add(choiceLabel);
|
||||
@@ -126,6 +184,11 @@ public class StartGUI {
|
||||
vBox0.getChildren().add(title);
|
||||
vBox0.getChildren().add(authors);
|
||||
|
||||
/**
|
||||
* Adds function to the "Start" button, scenario 1 gives the player $400 and a $5000 debt at the start of the game;
|
||||
* scenario 2 gives the player 5 guns.
|
||||
*
|
||||
*/
|
||||
startButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -143,9 +206,9 @@ public class StartGUI {
|
||||
if (response.equalsIgnoreCase("Vikram")) {
|
||||
player.setMoney(999999999);
|
||||
player.setBank(999999999);
|
||||
player.setGuns(999);
|
||||
player.setHP(999999999);
|
||||
player.setCargoSpace(999999999);
|
||||
player.setGuns(0);
|
||||
player.setHP(99999999);
|
||||
player.setCargoSpace(Integer.MAX_VALUE);
|
||||
}
|
||||
setFirm(response);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Pos;
|
||||
@@ -311,7 +310,7 @@ public class TaipanShopGUI {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this method is responsible for the actual purchasing/selling of items, and the text associated with the act.
|
||||
*/
|
||||
public void shop(){
|
||||
String originalDialogue = textOut.getText();
|
||||
@@ -379,6 +378,11 @@ public class TaipanShopGUI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the shop on the given stage as a parameter.
|
||||
*
|
||||
* @param stage
|
||||
*/
|
||||
public void initializeShop(Stage stage){
|
||||
Font size14 = new Font(14.0);
|
||||
Rectangle dialogueRectangle = new Rectangle();
|
||||
@@ -473,6 +477,7 @@ public class TaipanShopGUI {
|
||||
buyButton.setPrefHeight(25.0);
|
||||
buyButton.setPrefWidth(45.0);
|
||||
buyButton.setText("Buy");
|
||||
// if the buy button is clicked, the main utility buttons are set to be invisible and the buying process begins.
|
||||
buyButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -485,6 +490,7 @@ public class TaipanShopGUI {
|
||||
|
||||
sellButton.setPrefHeight(25.0);
|
||||
sellButton.setText("Sell");
|
||||
// if the sell button is clicked, the main utility buttons are set to be invisible and the selling process begins.
|
||||
sellButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -498,6 +504,7 @@ public class TaipanShopGUI {
|
||||
sellButton.setMnemonicParsing(false);
|
||||
|
||||
bankButton.setPrefHeight(25.0);
|
||||
// opens the bank if the bank button is clicked.
|
||||
bankButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -514,6 +521,7 @@ public class TaipanShopGUI {
|
||||
cargoButton.setText("Transfer Cargo");
|
||||
cargoButton.setMnemonicParsing(false);
|
||||
cargoButton.setPrefWidth(94.0);
|
||||
// warehouse is entered when the warehouse button is clicked.
|
||||
cargoButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -527,6 +535,7 @@ public class TaipanShopGUI {
|
||||
loanButton.setMnemonicParsing(false);
|
||||
loanButton.setPrefHeight(25.0);
|
||||
loanButton.setPrefWidth(73.0);
|
||||
// loan office is entered when the loan button is clicked.
|
||||
loanButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -541,6 +550,7 @@ public class TaipanShopGUI {
|
||||
quitButton.setMnemonicParsing(false);
|
||||
quitButton.setPrefWidth(90.0);
|
||||
quitButton.setText("Quit Trading");
|
||||
// the user is free to travel once the quit button is clicked.
|
||||
quitButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -555,6 +565,7 @@ public class TaipanShopGUI {
|
||||
retireButton.setPrefWidth(49.0);
|
||||
retireButton.setText("Retire");
|
||||
retireButton.setVisible(false);
|
||||
// the user wins the game when the retire button is clicked.
|
||||
retireButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -568,6 +579,7 @@ public class TaipanShopGUI {
|
||||
opiumButton.setPrefHeight(25.0);
|
||||
opiumButton.setText("Opium");
|
||||
opiumButton.setVisible(false);
|
||||
// the opium buying/selling process starts as soon as the user clicks the opium button.
|
||||
opiumButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -589,6 +601,7 @@ public class TaipanShopGUI {
|
||||
silkButton.setMnemonicParsing(false);
|
||||
silkButton.setText("Silk");
|
||||
silkButton.setVisible(false);
|
||||
// the silk buying/selling process starts as soon as the user clicks the silk button.
|
||||
silkButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -608,6 +621,7 @@ public class TaipanShopGUI {
|
||||
armsButton.setPrefWidth(86.0);
|
||||
armsButton.setMnemonicParsing(false);
|
||||
armsButton.setVisible(false);
|
||||
// the arms buying/selling process starts as soon as the user clicks the arms button.
|
||||
armsButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -631,6 +645,7 @@ public class TaipanShopGUI {
|
||||
generalButton.setPrefWidth(86.0);
|
||||
generalButton.setText("General");
|
||||
generalButton.setVisible(false);
|
||||
// the general cargo buying/selling process starts as soon as the user clicks the general cargo button.
|
||||
generalButton.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -650,6 +665,8 @@ public class TaipanShopGUI {
|
||||
numberInput.setAlignment(javafx.geometry.Pos.CENTER_RIGHT);
|
||||
numberInput.setText("Enter amount here...");
|
||||
numberInput.setVisible(false);
|
||||
// after the user inputs a valid input into the text field and presses Z or ENTER, the buying/selling ends and
|
||||
// the user is returned to the regular shop dialogue.
|
||||
numberInput.setOnKeyPressed(new EventHandler<KeyEvent>() {
|
||||
@Override
|
||||
public void handle(KeyEvent event) {
|
||||
@@ -764,12 +781,18 @@ public class TaipanShopGUI {
|
||||
stage.setResizable(false);
|
||||
stage.setScene(root);
|
||||
|
||||
// general updates to the buttons, user stats/inventory, and text.
|
||||
buttonSetup("reset");
|
||||
updatePrices();
|
||||
defaultTextOut();
|
||||
updateStage();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* converts the user's location (an integer) to a String, and returns it.
|
||||
*
|
||||
* @return location -- the user's location as a string; the actual name of the location.
|
||||
*/
|
||||
public String getStringLocation(){
|
||||
String location;
|
||||
switch(player.getLocation()){
|
||||
@@ -784,7 +807,12 @@ public class TaipanShopGUI {
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns the user's condition based upon their current HP.
|
||||
*
|
||||
* @return shipStatus -- a representation of their ship's health in words.
|
||||
*/
|
||||
public String shipStatusString(){
|
||||
String shipStatus;
|
||||
switch(player.getHP()/10){
|
||||
@@ -803,7 +831,10 @@ public class TaipanShopGUI {
|
||||
}
|
||||
return shipStatus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* updates the text associated with the user's inventory.
|
||||
*/
|
||||
public void updateStage(){
|
||||
firm.setText(String.format("Firm: %s, %s", player.getName(), getStringLocation()));
|
||||
wItemsText.setText(String.format("\n %d\n %d\n %d\n %d", player.getwOpium(), player.getwSilk(), player.getwArms(), player.getwGeneral()));
|
||||
|
||||
@@ -41,31 +41,40 @@ public class bankGUI{
|
||||
this.player = playerDummy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the GUI for the Bank in our game.
|
||||
*
|
||||
* @param primaryStage
|
||||
* @return
|
||||
*/
|
||||
public Stage initializeBank(Stage primaryStage) {
|
||||
primaryStage.setTitle("Bank");
|
||||
|
||||
//Declaring each Layout
|
||||
/**
|
||||
* Creating all the layouts, labels, buttons, and a textfield.
|
||||
*
|
||||
*/
|
||||
BorderPane brdr1 = new BorderPane();
|
||||
HBox hbx1 = new HBox(30);
|
||||
HBox hbx2 = new HBox(30);
|
||||
VBox vbx1 = new VBox(30);
|
||||
|
||||
//Declaring all Variables
|
||||
Label l1 = new Label("Player: " + player.getName());
|
||||
Label l2 = new Label("Current Balance: " + player.getBank());
|
||||
Label l3 = new Label("Enter Amount: ");
|
||||
Label l4 = new Label("Current cash: " + player.getMoney());
|
||||
Label l5 = new Label(" ");
|
||||
|
||||
//Declaring All Buttons
|
||||
Button b1 = new Button("Withdraw");
|
||||
Button b2 = new Button("Deposit");
|
||||
Button b3 = new Button("Go back");
|
||||
|
||||
//Declaring All TextFields
|
||||
TextField txtField1 = new TextField();
|
||||
|
||||
//Creating the buttons at the bottom of the screen
|
||||
/**
|
||||
* Adds the buttons so that they are at the bottom of the screen.
|
||||
*
|
||||
*/
|
||||
hbx1.setAlignment(Pos.CENTER);
|
||||
hbx1.getChildren().add(b1);
|
||||
hbx1.getChildren().add(b2);
|
||||
@@ -73,13 +82,19 @@ public class bankGUI{
|
||||
|
||||
brdr1.setBottom(hbx1);
|
||||
|
||||
//Creating the TextField at the center of the screen
|
||||
/**
|
||||
* Adds the text field to the center of the screen.
|
||||
*
|
||||
*/
|
||||
hbx2.setAlignment(Pos.CENTER);
|
||||
hbx2.getChildren().add(l3);
|
||||
hbx2.getChildren().add(txtField1);
|
||||
brdr1.setCenter(hbx2);
|
||||
|
||||
//Creating the Labels at the top of the Screen
|
||||
/**
|
||||
* Adds the labels to the top of the screen.
|
||||
*
|
||||
*/
|
||||
vbx1.setAlignment(Pos.CENTER);
|
||||
vbx1.getChildren().add(l1);
|
||||
vbx1.getChildren().add(l2);
|
||||
@@ -87,7 +102,10 @@ public class bankGUI{
|
||||
vbx1.getChildren().add(l5);
|
||||
brdr1.setTop(vbx1);
|
||||
|
||||
// Set the event handler when the deposit button is clicked
|
||||
/**
|
||||
* Adds function to button 1 which, when clicked, withdraws money from your bank to your person but, will not let you overdraw.
|
||||
*
|
||||
*/
|
||||
b1.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -105,6 +123,10 @@ public class bankGUI{
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Adds function to button 2 which, when clicked, deposits money into your bank but, will not let you overdraw.
|
||||
*
|
||||
*/
|
||||
// Set the event handler when the withdraw button is clicked
|
||||
b2.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
@@ -124,6 +146,10 @@ public class bankGUI{
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Adds function to button 3 which, when clicked, brings you back to the Shop GUI.
|
||||
*
|
||||
*/
|
||||
b3.setOnAction(new EventHandler<ActionEvent>() {
|
||||
@Override
|
||||
public void handle(ActionEvent event) {
|
||||
@@ -135,15 +161,16 @@ public class bankGUI{
|
||||
);
|
||||
|
||||
|
||||
|
||||
//Setting the Scene and displaying it
|
||||
/**
|
||||
* Sets the window size to a width of 600 and height of 480 and displays the screen.
|
||||
*
|
||||
*/
|
||||
Scene scene = new Scene(brdr1, 600, 480);
|
||||
primaryStage.setScene(scene);
|
||||
//primaryStage.show();
|
||||
return primaryStage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void start(Stage primaryStage) {
|
||||
bankGUI bank = new bankGUI(player);
|
||||
bank.initializeBank(primaryStage);
|
||||
|
||||
Reference in New Issue
Block a user