diff --git a/planetExpress/Game.java b/planetExpress/Game.java new file mode 100644 index 0000000..4271a26 --- /dev/null +++ b/planetExpress/Game.java @@ -0,0 +1,50 @@ +package planetExpress; +import java.util.Scanner; +public class Game { + + public static void main(String[] args) + { + PlanetExpress planet; + Score score; + Boolean stable = true; + + planet = new PlanetExpress(); + score = new Score(); + Scanner reader = new Scanner(System.in); + + + while (stable = true) + { + System.out.println("Choose what do you want to do next:"); + System.out.println("press \"1\" if you want to deliver"); + System.out.println("press \"2\" if you want to steal"); + System.out.println("press \"3\" if you want to eat"); + System.out.println("press \"4\" if you want to drink"); + System.out.println("press \"5\" if you want to account"); + int step = reader.nextInt(); + + switch(step) + { + case '1' : + planet.deliver(); + case '2' : + planet.steal(); + case '3' : + planet.eat(); + case '4' : + planet.drink(); + case '5' : + planet.account(); + default : + System.out.println("Invalid number"); + } + + score.setScore(planet.getThirst(), planet.getWork(), planet.getHorde(), planet.getHunger(), planet.getReceipts()); + if (planet.check() == false) + { + stable = false; + } + } + } + +} diff --git a/planetExpress/PlanetExpress.java b/planetExpress/PlanetExpress.java new file mode 100644 index 0000000..b402578 --- /dev/null +++ b/planetExpress/PlanetExpress.java @@ -0,0 +1,109 @@ +package planetExpress; + +public class PlanetExpress { + + private int thirst; + private int work; + private int horde; + private int hunger; + private int receipts; + private boolean stable; + + public PlanetExpress() { + thirst = 50; + work = 50; + horde = 50; + hunger = 50; + receipts = 50; + stable = true; + } + + public int getThirst() + { + return thirst; + } + + public int getWork() + { + return thirst; + } + + public int getHorde() + { + return thirst; + } + + public int getHunger() + { + return thirst; + } + + public int getReceipts() + { + return thirst; + } + + public void drink() + { + thirst -= 10; + work += 10; + } + + public void deliver() + { + work -= 10; + receipts += 10; + } + + public void steal() + { + horde += 10; + work += 10; + } + + public void eat() + { + hunger -= 10; + work += 10; + } + + public void account() + { + receipts -= 10; + horde -= 10; + } + + public boolean check() + { + if ((this.thirst > 80) || (this.work > 80) || (this.hunger > 80) || (this.horde < 20) || (this.receipts < 20)) + { + this.stable = false; + return false; + } + else + { + if(this.thirst > 70) + { + System.out.println("You should drink more"); + } + if(this.work > 70) + { + System.out.println("You have too much work to do"); + } + if(this.hunger > 70) + { + System.out.println("You need to eat something"); + } + if(this.horde < 30) + { + System.out.println("The horde is too low"); + } + if(this.receipts < 30) + { + System.out.println("The receipts are too low"); + } + } + return true; + } + +} diff --git a/planetExpress/Score.java b/planetExpress/Score.java new file mode 100644 index 0000000..2ea2af4 --- /dev/null +++ b/planetExpress/Score.java @@ -0,0 +1,31 @@ +package planetExpress; + +public class Score { + float score; + + public Score() { + score = 0; + } + + private float checkLow(int num) + { + return (((100 - num) * 2) / 10); + } + + private float checkHigh(int num) + { + return ((num * 2) / 10); + } + + public float setScore (int thirst, int work, int horde, int hunger, int receipts) + { + this.score = checkLow(thirst) + checkLow(work) + checkLow(hunger) + checkHigh(horde) + checkHigh(receipts); + return this.score; + } + + public float getScore () + { + return this.score; + } + +}