From 14e5eb2d309b8e79ec55f390bd3a5cb74d85a276 Mon Sep 17 00:00:00 2001 From: Solargale Date: Sat, 9 Mar 2019 14:28:02 -0700 Subject: [PATCH] Added basic functionality with KahootChampion --- src/ShipWarfareGUI.java | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/ShipWarfareGUI.java b/src/ShipWarfareGUI.java index a18363f..f004d5e 100644 --- a/src/ShipWarfareGUI.java +++ b/src/ShipWarfareGUI.java @@ -11,16 +11,16 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.stage.Stage; +import java.util.Random; + import static javafx.application.Application.launch; public class ShipWarfareGUI extends Application { - private Player player; + private Player player = new Player(); public static void main(String args[]){ launch(args); - ShipWarfare ship = new ShipWarfare(new Player()); - ship.peasantFleetAttack(); } private Label label1; @@ -28,6 +28,28 @@ public class ShipWarfareGUI extends Application { private Button button1; private Button button2; + public int numOfShips() { + + int numOfShipsAttacking = 0; + Random randomValue = new Random(); + if (player.getMoney() <= 100000) { + //Minimum one ship will attack, maximum 20 + numOfShipsAttacking = randomValue.nextInt(20) + 1; + } else if (player.getMoney() <= 200000) { + //Minimum 30 Ships will attack, maximum 70 + numOfShipsAttacking = randomValue.nextInt(40) + 30; + } else if (player.getMoney() <= 500000) { + //Minimum 50 ships will attack, maximum 140 + numOfShipsAttacking = randomValue.nextInt(90) + 50; + } else if (player.getMoney() > 1000000) { + //Minimum 100 ships will attack, maximum 300 ships + numOfShipsAttacking = randomValue.nextInt(3) + 100; + } + + return numOfShipsAttacking; + + } + public void setPlayer(Player player) { this.player = new Player(player); } @@ -89,11 +111,18 @@ public class ShipWarfareGUI extends Application { hBox1.getChildren().add(button1); hBox1.getChildren().add(button2); + ShipWarfareGUI ship = new ShipWarfareGUI(); + label1.setText(ship.numOfShips() + " Merchant Ships are attacking you."); + button1.setOnAction(new EventHandler(){ @Override public void handle(ActionEvent event){ label1.setText("Balance: "); System.out.println("You pressed the button."); + button1.setVisible(false); + button2.setVisible(false); + button1.setDisable(true); + button2.setDisable(true); } });