From 9efd0fea95d540b3912bc13f30bde800633b8d97 Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Tue, 16 Apr 2024 16:31:25 -0400 Subject: [PATCH 1/9] main 3 classes --- Character.java | 0 Main.java | 3 +++ Opponent.java | 3 +++ 3 files changed, 6 insertions(+) create mode 100644 Character.java create mode 100644 Main.java create mode 100644 Opponent.java diff --git a/Character.java b/Character.java new file mode 100644 index 00000000..e69de29b diff --git a/Main.java b/Main.java new file mode 100644 index 00000000..c1b42232 --- /dev/null +++ b/Main.java @@ -0,0 +1,3 @@ +public class Main { + +} diff --git a/Opponent.java b/Opponent.java new file mode 100644 index 00000000..af1bd026 --- /dev/null +++ b/Opponent.java @@ -0,0 +1,3 @@ +public class Opponent { + +} From ac7a6805f999c1f144943906f0dc42bbf7f3fe5f Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Tue, 16 Apr 2024 16:34:34 -0400 Subject: [PATCH 2/9] main classes --- Character.java | 6 ++++++ Main.java | 4 ++++ Opponent.java | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/Character.java b/Character.java index e69de29b..620f8722 100644 --- a/Character.java +++ b/Character.java @@ -0,0 +1,6 @@ +public class Character{ + +public static void main(String[] args) { + +} +} \ No newline at end of file diff --git a/Main.java b/Main.java index c1b42232..1095e004 100644 --- a/Main.java +++ b/Main.java @@ -1,3 +1,7 @@ public class Main { + + +public static void main(String[] args) { } +} diff --git a/Opponent.java b/Opponent.java index af1bd026..056fcf85 100644 --- a/Opponent.java +++ b/Opponent.java @@ -1,3 +1,7 @@ public class Opponent { + + +public static void main(String[] args) { } +} From d0f0710fa31b029d8f1ff4d892f02e6b93417980 Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Tue, 16 Apr 2024 17:38:21 -0400 Subject: [PATCH 3/9] work meeting #1 --- Character.java | 33 ++++++++++++++++++++++ Enemy.java | 28 +++++++++++++++++++ Game.java | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ Main.java | 7 ----- Opponent.java | 7 ----- 5 files changed, 135 insertions(+), 14 deletions(-) create mode 100644 Enemy.java create mode 100644 Game.java delete mode 100644 Main.java delete mode 100644 Opponent.java diff --git a/Character.java b/Character.java index 620f8722..28a2c9cc 100644 --- a/Character.java +++ b/Character.java @@ -1,5 +1,38 @@ public class Character{ +//attributes +public int health; +public int experience; +public int maxSpeed; +public int maxStrength; + +//constructor +public Character(int health, int experience, int maxSpeed, int maxStrength){ + this.health = health; + this.experience = experience; + this.maxSpeed = maxSpeed; + this.maxStrength = maxStrength; +} + +//methods +public void kick(Enemy e){ + //-5 points to enemy + System.out.println("Enemy has suffered a kick"); + int damage = 5; + e.health -= damage; +} + +public void shoot(Enemy e){ + // -10 points to enemy + System.out.println("Enemy is down with a grave injury"); + int damage = 10; + e.health -= damage; +} + +public void printStatus(){ + System.out.println("Health: " + health); +} + public static void main(String[] args) { } diff --git a/Enemy.java b/Enemy.java new file mode 100644 index 00000000..c9fe3212 --- /dev/null +++ b/Enemy.java @@ -0,0 +1,28 @@ +public class Enemy { +//attributes +public int health; + +//constructor +public Enemy(int health){ + this.health = health; +} + +//methods +public void kick(Character c){ + //-5 points to protagonist + System.out.println("Your troop has suffered a kick"); + int damage = 5; + c.health -= damage; +} + +public void shoot(Character c){ + // -10 points to protagonist + System.out.println("A member of your troop is down with a grave injury"); + int damage = 10; + c.health -= damage; +} + +public static void main(String[] args) { + +} +} diff --git a/Game.java b/Game.java new file mode 100644 index 00000000..f2a4ad11 --- /dev/null +++ b/Game.java @@ -0,0 +1,74 @@ +import java.util.Scanner; +import java.util.Random; + +public class Game { + public Enemy enemy; + public Character character; + + public Game(){ + this.enemy = new Enemy(10); + this.character = new Character(10, 5, 5, 5); + } + + public void checkIn(Character c){ + c.printStatus(); + } + + //getRandomNumber within range + public int getRandomNumber(int min, int max){ + Random random = new Random(); + return random.nextInt(max - min) + min; + } + + //overloaded getRandomNumber without range + public int getRandomNumber(){ + Random random = new Random(); + return random.nextInt(); + } + +public static void main(String[] args) { + boolean end = false; + Scanner sc = new Scanner(System.in); + Game game = new Game(); + + System.out.println("Your battle with the enemy has started."); + do{ + //enemy attacks character + game.enemy.kick(game.character); + + //checks to see if character has lost battle + if (game.character.health == 0) { + end = true; + System.out.println("Sorry you lost the battle."); + } + else if (game.enemy.health == 0 && game.character.health != 0){ + end = true; + System.out.println("Congrats you won the battle!"); + } + + System.out.println("Do you wish to attack the enemy or to see the status of your troops?"); + String order = sc.nextLine().toLowerCase(); + if (order.equals("attack")){ + //choose random number between range + int x = game.getRandomNumber(1, 2); + //based on random number, character chooses an attack + if (x == 1){ + game.character.kick(game.enemy); + } else { + game.character.shoot(game.enemy); + } + } else { + System.out.println("The captain has ordered the troop to retreat"); + game.checkIn(game.character); + } + + } while (end != true); + + sc.close(); + +} +} + +//NOTES TO US +// Need to fix how battle ends. Character can't keep playing after health = 0 +// Create human class and let enemy and character inherit from there. diff --git a/Main.java b/Main.java deleted file mode 100644 index 1095e004..00000000 --- a/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Main { - - -public static void main(String[] args) { - -} -} diff --git a/Opponent.java b/Opponent.java deleted file mode 100644 index 056fcf85..00000000 --- a/Opponent.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Opponent { - - -public static void main(String[] args) { - -} -} From e0c4ac8b9ce76ad841876f7db6236ef538e2fe05 Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Tue, 16 Apr 2024 17:41:20 -0400 Subject: [PATCH 4/9] work notes --- work.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 work.txt diff --git a/work.txt b/work.txt new file mode 100644 index 00000000..35a4911e --- /dev/null +++ b/work.txt @@ -0,0 +1,8 @@ +Work Meeting #1: 4/16/23 +Accomplished: basic structure of game and classes +To-Do: +- Need to fix how battle ends. Character can't keep playing after health = 0 +- Create human class and let enemy and character inherit from there. + + + From 862a686aa27003e072534bd4812f78d7c224be54 Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Thu, 18 Apr 2024 12:07:51 -0400 Subject: [PATCH 5/9] FP Workshop #1 --- Character.java | 39 --------------------------------------- Enemy.java | 28 ---------------------------- Game.java | 9 +++++---- Human.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 71 deletions(-) delete mode 100644 Character.java delete mode 100644 Enemy.java create mode 100644 Human.java diff --git a/Character.java b/Character.java deleted file mode 100644 index 28a2c9cc..00000000 --- a/Character.java +++ /dev/null @@ -1,39 +0,0 @@ -public class Character{ - -//attributes -public int health; -public int experience; -public int maxSpeed; -public int maxStrength; - -//constructor -public Character(int health, int experience, int maxSpeed, int maxStrength){ - this.health = health; - this.experience = experience; - this.maxSpeed = maxSpeed; - this.maxStrength = maxStrength; -} - -//methods -public void kick(Enemy e){ - //-5 points to enemy - System.out.println("Enemy has suffered a kick"); - int damage = 5; - e.health -= damage; -} - -public void shoot(Enemy e){ - // -10 points to enemy - System.out.println("Enemy is down with a grave injury"); - int damage = 10; - e.health -= damage; -} - -public void printStatus(){ - System.out.println("Health: " + health); -} - -public static void main(String[] args) { - -} -} \ No newline at end of file diff --git a/Enemy.java b/Enemy.java deleted file mode 100644 index c9fe3212..00000000 --- a/Enemy.java +++ /dev/null @@ -1,28 +0,0 @@ -public class Enemy { -//attributes -public int health; - -//constructor -public Enemy(int health){ - this.health = health; -} - -//methods -public void kick(Character c){ - //-5 points to protagonist - System.out.println("Your troop has suffered a kick"); - int damage = 5; - c.health -= damage; -} - -public void shoot(Character c){ - // -10 points to protagonist - System.out.println("A member of your troop is down with a grave injury"); - int damage = 10; - c.health -= damage; -} - -public static void main(String[] args) { - -} -} diff --git a/Game.java b/Game.java index f2a4ad11..7413c613 100644 --- a/Game.java +++ b/Game.java @@ -2,14 +2,15 @@ import java.util.Random; public class Game { - public Enemy enemy; - public Character character; + public Human enemy; + public Human character; public Game(){ - this.enemy = new Enemy(10); - this.character = new Character(10, 5, 5, 5); + this.enemy = new Human("enemy", 10, 5, 0, true); + this.character = new Human("human", 10, 5, 5, false); } +//everything below this, go through to seperate battle and game classes public void checkIn(Character c){ c.printStatus(); } diff --git a/Human.java b/Human.java new file mode 100644 index 00000000..9989f667 --- /dev/null +++ b/Human.java @@ -0,0 +1,46 @@ +public class Human{ + +//attributes +public String name; +public int health; +public int experience; +public int alliance; +public boolean isEnemy; + +//constructor +public Human(String name, int health, int experience, int alliance, boolean isEnemy){ + this.name = name; + this.health = health; + this.experience = experience; + this.alliance = alliance; + this.isEnemy = isEnemy; +} + +//methods +public void kick(Human h){ + //-5 points to enemy + System.out.println(h.name + " has suffered a kick"); + int damage = 5; + h.health -= damage; +} + +public void shoot(Human h){ + // -10 points to enemy + System.out.println(h.name + "is down with a grave injury"); + int damage = 10; + h.health -= damage; +} + +public String toString(){ + return "Name: " + name + + "\nHealth: " + health + + "\nExperience: " + experience + + "\nAlliance: " + alliance + + "\nisEnemy: " + isEnemy; +} + +public static void main(String[] args) { + Human h = new Human("enemy", 10, 5, 0, true); + System.out.println(h); +} +} \ No newline at end of file From c14f0c1d5b3f26b00ec802dab91ebe4a34b0a606 Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Thu, 18 Apr 2024 12:09:13 -0400 Subject: [PATCH 6/9] work notes --- work.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/work.txt b/work.txt index 35a4911e..22b0ac1b 100644 --- a/work.txt +++ b/work.txt @@ -4,5 +4,9 @@ To-Do: - Need to fix how battle ends. Character can't keep playing after health = 0 - Create human class and let enemy and character inherit from there. - +FP Workshop #1: 4/18 +Accomplished: figuring out structure of classes +To-Do: +- seperate battle and game class +- battle & non-battle classes From 7c7e70de16159b13abc63b5a1274c4175833f834 Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Sat, 20 Apr 2024 16:09:39 -0400 Subject: [PATCH 7/9] updates to game --- Battle.java | 3 +++ Game.java | 2 ++ nonBattle.java | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 Battle.java create mode 100644 nonBattle.java diff --git a/Battle.java b/Battle.java new file mode 100644 index 00000000..4c108673 --- /dev/null +++ b/Battle.java @@ -0,0 +1,3 @@ +public class Battle { + +} diff --git a/Game.java b/Game.java index 7413c613..fdc2ad43 100644 --- a/Game.java +++ b/Game.java @@ -4,10 +4,12 @@ public class Game { public Human enemy; public Human character; + public Scanner sc; public Game(){ this.enemy = new Human("enemy", 10, 5, 0, true); this.character = new Human("human", 10, 5, 5, false); + this.sc = new Scanner(System.in); } //everything below this, go through to seperate battle and game classes diff --git a/nonBattle.java b/nonBattle.java new file mode 100644 index 00000000..e2da64db --- /dev/null +++ b/nonBattle.java @@ -0,0 +1,3 @@ +public class nonBattle { + +} From 7015124e8c06488954b7ac8633406323e70a939e Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Sat, 20 Apr 2024 16:15:19 -0400 Subject: [PATCH 8/9] battle updates --- Battle.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Battle.java b/Battle.java index 4c108673..82919cf5 100644 --- a/Battle.java +++ b/Battle.java @@ -1,3 +1,11 @@ public class Battle { + public Human character; + public Human enemy; + + Battle() + + public static void main(String[] args) { + + } } From ee89f39bf56914517a635f5edcc9bdab0cd3656b Mon Sep 17 00:00:00 2001 From: Zoe Neil Date: Sat, 20 Apr 2024 16:47:47 -0400 Subject: [PATCH 9/9] updates to battle --- Battle.java | 53 ++++++++++++++++++++++++++++++++++++++++++++---- Game.java | 58 +++++++++++------------------------------------------ 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/Battle.java b/Battle.java index 82919cf5..68599425 100644 --- a/Battle.java +++ b/Battle.java @@ -1,11 +1,56 @@ public class Battle { - public Human character; - public Human enemy; + public Game game; + boolean end; + + Battle(Game g){ + this.game = g; + this.end = false; + } + + public void battle(){ + System.out.println("Your battle with the enemy has started."); + do{ + //enemy attacks character + game.enemy.kick(game.character); + + //checks to see if character has lost battle + if (game.character.health == 0) { + System.out.println("Sorry you lost the battle."); + this.end = true; + } + else if (game.enemy.health == 0 && game.character.health != 0){ + System.out.println("Congrats you won the battle!"); + this.end = true; + } + + System.out.println("Do you wish to attack the enemy or to see the status of your troops?"); + String order = game.sc.nextLine().toLowerCase(); + if (order.equals("attack")){ + //choose random number between range + int x = game.getRandomNumber(1, 2); + //based on random number, character chooses an attack + if (x == 1){ + game.character.kick(game.enemy); + } else { + game.character.shoot(game.enemy); + } + } else { + System.out.println("The captain has ordered the troop to retreat"); + System.out.println(game.character); + } + + } while (end != true); + } - Battle() public static void main(String[] args) { - + Game game = new Game(); + Battle battle = new Battle(game); + battle.battle(); } } + +//NOTES TO US +// Need to fix how battle ends. Character can't keep playing after health = 0 +// Make sure check status works diff --git a/Game.java b/Game.java index fdc2ad43..a7477bd3 100644 --- a/Game.java +++ b/Game.java @@ -5,16 +5,13 @@ public class Game { public Human enemy; public Human character; public Scanner sc; + public boolean gameEnd; public Game(){ this.enemy = new Human("enemy", 10, 5, 0, true); this.character = new Human("human", 10, 5, 5, false); this.sc = new Scanner(System.in); - } - -//everything below this, go through to seperate battle and game classes - public void checkIn(Character c){ - c.printStatus(); + this.gameEnd = false; } //getRandomNumber within range @@ -29,49 +26,18 @@ public int getRandomNumber(){ return random.nextInt(); } + //game method + public void gameMethod(){ + System.out.println("Your game has started."); + if (character.name == "insert whatever ending condition we want for the game here") + gameEnd = true; + System.out.println("Your game has ended."); + //return + } + public static void main(String[] args) { - boolean end = false; - Scanner sc = new Scanner(System.in); Game game = new Game(); - - System.out.println("Your battle with the enemy has started."); - do{ - //enemy attacks character - game.enemy.kick(game.character); - - //checks to see if character has lost battle - if (game.character.health == 0) { - end = true; - System.out.println("Sorry you lost the battle."); - } - else if (game.enemy.health == 0 && game.character.health != 0){ - end = true; - System.out.println("Congrats you won the battle!"); - } - - System.out.println("Do you wish to attack the enemy or to see the status of your troops?"); - String order = sc.nextLine().toLowerCase(); - if (order.equals("attack")){ - //choose random number between range - int x = game.getRandomNumber(1, 2); - //based on random number, character chooses an attack - if (x == 1){ - game.character.kick(game.enemy); - } else { - game.character.shoot(game.enemy); - } - } else { - System.out.println("The captain has ordered the troop to retreat"); - game.checkIn(game.character); - } - - } while (end != true); - - sc.close(); + game.gameMethod(); } } - -//NOTES TO US -// Need to fix how battle ends. Character can't keep playing after health = 0 -// Create human class and let enemy and character inherit from there.