From 4f17c40fa0a7643aaf593c745bd3b0b366b49f73 Mon Sep 17 00:00:00 2001 From: Kenny Stepney Date: Tue, 17 Oct 2017 17:31:26 -0500 Subject: [PATCH 1/3] Signed-off-by: Kenny Stepney --- .project | 4 ++-- src/main/java/Colosseum.java | 14 +++++++------- src/main/java/Pokemon.java | 15 ++++++++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.project b/.project index 4b92280..f5bcc1f 100644 --- a/.project +++ b/.project @@ -6,12 +6,12 @@ - org.eclipse.buildship.core.gradleprojectbuilder + org.eclipse.jdt.core.javabuilder - org.eclipse.jdt.core.javabuilder + org.eclipse.buildship.core.gradleprojectbuilder diff --git a/src/main/java/Colosseum.java b/src/main/java/Colosseum.java index f68697b..3fc41ff 100644 --- a/src/main/java/Colosseum.java +++ b/src/main/java/Colosseum.java @@ -72,8 +72,8 @@ public class Colosseum { *

* Implement this function. */ - public static Pokemon buildPokemon() { - Pokemon tempPokemon = new Pokemon(); + public static Pokemon buildPokemon(final String name, final int health, final int attackLevel, final int defenseLevel) { + Pokemon tempPokemon = new Pokemon(name, health, attackLevel, defenseLevel); return tempPokemon; } @@ -113,15 +113,15 @@ public static void determineWinner() { public static void initializePokemon() { System.out.println("Player 1, build your Pokemon!"); System.out.println("================="); - firstPokemon = buildPokemon(); - firstPokemon.name = "Chuchu"; + firstPokemon = buildPokemon("WASIDOUSTRAP", 100, 20, 5); + //firstPokemon.name = "Chuchu"; System.out.println(""); System.out.println("Player 2, build your Pokemon!"); System.out.println("=================="); - secondPokemon = buildPokemon(); - secondPokemon.name = "Xyz"; + secondPokemon = buildPokemon("LASK", 200, 5, 10); + //secondPokemon.name = "Xyz"; } /** @@ -146,7 +146,7 @@ public static void determineOrder() { * Swap Pokemon for second outcome. */ System.out.print("second"); - Pokemon tempPokemon = new Pokemon(); + Pokemon tempPokemon; tempPokemon = firstPokemon; firstPokemon = secondPokemon; secondPokemon = tempPokemon; diff --git a/src/main/java/Pokemon.java b/src/main/java/Pokemon.java index 02229fb..0ed77bc 100644 --- a/src/main/java/Pokemon.java +++ b/src/main/java/Pokemon.java @@ -58,16 +58,21 @@ public class Pokemon { *

* Constructs a new Pokemon with a 6-sided die, 20-sided die, 0 hit points, attack level of 0, * defense level of 0, and an empty name. + * @param name name of the pokemon + * @param hitPoints health of the pokemon + * @param attackLevel attack of the pokemon + * @param defenseLevel defense of the pokemon */ - public Pokemon() { + public Pokemon(final String name, final int hitPoints, + final int attackLevel, final int defenseLevel) { final int d6num = 6; final int d20num = 20; this.d6 = new Dice(d6num); this.d20 = new Dice(d20num); - this.hitPoints = 0; - this.attackLevel = 0; - this.defenseLevel = 0; - this.name = ""; + this.hitPoints = hitPoints; + this.attackLevel = attackLevel; + this.defenseLevel = defenseLevel; + this.name = name; } /** From 3e3dbd3b2a8803143e0f40dd26dc4379f37fd430 Mon Sep 17 00:00:00 2001 From: Kenny Stepney Date: Tue, 17 Oct 2017 18:15:09 -0500 Subject: [PATCH 2/3] KEAE --- src/main/java/Colosseum.java | 82 ++++++++++++++++++++++++++++-------- src/main/java/Pokemon.java | 2 + 2 files changed, 67 insertions(+), 17 deletions(-) diff --git a/src/main/java/Colosseum.java b/src/main/java/Colosseum.java index 3fc41ff..c498665 100644 --- a/src/main/java/Colosseum.java +++ b/src/main/java/Colosseum.java @@ -72,8 +72,57 @@ public class Colosseum { *

* Implement this function. */ - public static Pokemon buildPokemon(final String name, final int health, final int attackLevel, final int defenseLevel) { - Pokemon tempPokemon = new Pokemon(name, health, attackLevel, defenseLevel); + public static Pokemon buildPokemon(final int player) { + Pokemon tempPokemon; + + String name = ""; + int health = 0; + int attack = 0; + int defense = 0; + int maxPoints = 50; + boolean isValid = false; + + while(!isValid){ + //resets the maxPoints + maxPoints = 50; + + System.out.println("Player "+player+", build your Pokemon!"); + System.out.println("================="); + + System.out.println("Enter your Pokemon's name!"); + name = myScan.next(); + + System.out.println("Enter your Pokemon's hitpoints! (1 - 50)"); + health = myScan.nextInt(); + + System.out.println("Enter your Pokemon's attack! (0 - "+maxPoints+")"); + attack = myScan.nextInt(); + + maxPoints -= attack; + + if (maxPoints < 0) { + System.out.println("Too many points in attack!\n"); + continue; + } + + System.out.println("Enter your Pokemon's defense! (0 - "+maxPoints+")"); + defense = myScan.nextInt(); + + if (defense > maxPoints){ + System.out.println("Too many points in defense!\n"); + continue; + } + + if (health < 1) { + System.out.println("Your pokemon's health \""+health+"\" is too low.\n"); + continue; + } + + isValid = true; + } + + tempPokemon = new Pokemon(name, health, attack, defense); + return tempPokemon; } @@ -90,8 +139,10 @@ public static Pokemon buildPokemon(final String name, final int health, final in *

* Implement this function. */ - public static void printWhoIsAhead() { - System.out.println("Implement me!"); + public static void printWhoIsAhead(final Pokemon firstPokemon, final Pokemon secondPokemon) { + if(firstPokemon.hitPoints > secondPokemon.hitPoints) System.out.println(firstPokemon.name+" is ahead@"); + else System.out.println(secondPokemon.name+" is ahead!"); + //System.out.println("Implement me!"); } /** @@ -101,26 +152,23 @@ public static void printWhoIsAhead() { *

* Write this function. */ - public static void determineWinner() { - System.out.println("Implement me!"); + public static void determineWinner(final Pokemon firstPokemon, final Pokemon secondPokemon) { + if(firstPokemon.hitPoints < 0) System.out.println(firstPokemon.name+" is the winner"); + else if(secondPokemon.hitPoints < 0) System.out.println(secondPokemon.name+" is the winner!"); + //Added just because + else System.out.println("It's a tie!"); } + /** * Initializes the member Pokemons. *

* You do not need to modify this function. */ public static void initializePokemon() { - System.out.println("Player 1, build your Pokemon!"); - System.out.println("================="); - firstPokemon = buildPokemon("WASIDOUSTRAP", 100, 20, 5); - //firstPokemon.name = "Chuchu"; - + firstPokemon = buildPokemon(1); System.out.println(""); - - System.out.println("Player 2, build your Pokemon!"); - System.out.println("=================="); - secondPokemon = buildPokemon("LASK", 200, 5, 10); + secondPokemon = buildPokemon(2); //secondPokemon.name = "Xyz"; } @@ -178,7 +226,7 @@ public static void main(final String[] unused) { if (!ifWinner) { ifWinner = secondPokemon.attack(firstPokemon); if (!ifWinner) { - printWhoIsAhead(); + printWhoIsAhead(firstPokemon, secondPokemon); } } @@ -188,7 +236,7 @@ public static void main(final String[] unused) { if (!ifWinner) { System.out.println("It's a tie!"); } else { - determineWinner(); + determineWinner(firstPokemon, secondPokemon); } myScan.close(); diff --git a/src/main/java/Pokemon.java b/src/main/java/Pokemon.java index 0ed77bc..1a35735 100644 --- a/src/main/java/Pokemon.java +++ b/src/main/java/Pokemon.java @@ -73,6 +73,8 @@ public Pokemon(final String name, final int hitPoints, this.attackLevel = attackLevel; this.defenseLevel = defenseLevel; this.name = name; + + if(hitPoints > Colosseum.MAX_HIT_POINTS) this.hitPoints = Colosseum.MAX_HIT_POINTS; } /** From 6d5899a94d61c84a77a18000fba470cce34abe0d Mon Sep 17 00:00:00 2001 From: Kenny Stepney Date: Tue, 17 Oct 2017 18:37:21 -0500 Subject: [PATCH 3/3] HI --- src/main/java/Colosseum.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/Colosseum.java b/src/main/java/Colosseum.java index c498665..12b587b 100644 --- a/src/main/java/Colosseum.java +++ b/src/main/java/Colosseum.java @@ -118,6 +118,11 @@ public static Pokemon buildPokemon(final int player) { continue; } + if (health > 50) { + System.out.println("Your pokemon's health \""+health+"\" is too high.\n"); + continue; + } + isValid = true; } @@ -140,7 +145,10 @@ public static Pokemon buildPokemon(final int player) { * Implement this function. */ public static void printWhoIsAhead(final Pokemon firstPokemon, final Pokemon secondPokemon) { - if(firstPokemon.hitPoints > secondPokemon.hitPoints) System.out.println(firstPokemon.name+" is ahead@"); + System.out.println(firstPokemon.name+" has "+firstPokemon.hitPoints+" hitpoints"); + System.out.println(secondPokemon.name+" has "+secondPokemon.hitPoints+" hitpoints"); + + if(firstPokemon.hitPoints > secondPokemon.hitPoints) System.out.println(firstPokemon.name+" is ahead!"); else System.out.println(secondPokemon.name+" is ahead!"); //System.out.println("Implement me!"); }