From 620fae0c572f9bf191861938991b01de41e0487b Mon Sep 17 00:00:00 2001 From: Averill G Date: Tue, 8 Mar 2016 14:23:33 -0600 Subject: [PATCH 1/6] changed attack values --- .../mrb/amazingbattlecreatures/AmazingBattleCreatures.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java index fc3e54c..342b340 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java @@ -31,7 +31,7 @@ public void duel(View vw) // Thanks to Mr Hardman for checking the original numbers! These ones work better. bcOne = new BattleCreature("Mondoise", 200, 10, 33); - bcTwo = new BattleCreature("Tuesachu", 200, 25, 15); + bcTwo = new BattleCreature("Tuesachu", 200, 25, 100); bcOne.restore(); bcTwo.restore(); From 19c4fab78fdc409333e61a351d41e45ebbfb703b Mon Sep 17 00:00:00 2001 From: PBuskell Date: Tue, 8 Mar 2016 15:20:55 -0600 Subject: [PATCH 2/6] Tuesday PM Commit: -Thanks to Mr Hardman for the assist with ending the loop conditions! -TextView for output! -TextView is Scrollable! --- .../BattleCreature.java | 9 +++- .../CyberBattleCreature.java | 41 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java index fe328cf..7725ddb 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java @@ -9,11 +9,16 @@ public class BattleCreature private int intHitPointsMaster; private int intHitPoints; // Or perhaps it should be intHealthPoints? private int intDefenceRating; - private int intOffenceRating; + protected int intOffenceRating; private boolean blnIsDefeated; - private boolean blnHasWon; + protected boolean blnHasWon; private String strLastAction; + public BattleCreature() + { + + } + public BattleCreature(String strName_PARAM, int intHitPoints_PARAM, int intDefenceRating_PARAM, diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java new file mode 100644 index 0000000..b57c08f --- /dev/null +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java @@ -0,0 +1,41 @@ +package com.example.mrb.amazingbattlecreatures; + +/** + * Created by PBuskell on 08/03/2016. + */ +public class CyberBattleCreature extends BattleCreature +{ + private int intCyberAttackAmount; + private int intCyberDefenceAmount; + + public CyberBattleCreature(String strName_PARAM, + int intHitPoints_PARAM, + int intDefenceRating_PARAM, + int intOffenceRating_PARAM, + int intCyberAttackAmount_PARAM, + int intCyberDefenceAmount_PARAM) + { + super(strName_PARAM, intHitPoints_PARAM, intDefenceRating_PARAM, intOffenceRating_PARAM); + + this.intCyberAttackAmount = intCyberAttackAmount_PARAM; + this.intCyberDefenceAmount = intCyberDefenceAmount_PARAM; + } + + public void attack(BattleCreature battcreatOpponent_PARAM) + { + if (!battcreatOpponent_PARAM.isDefeated()) + { + battcreatOpponent_PARAM.defend(super.intOffenceRating); + } + + if(battcreatOpponent_PARAM.isDefeated()) + { + super.blnHasWon = true; + } + else + { + super.blnHasWon = false; + } + } + +} From d230863b2e478a543a6c4b4c060e984ec8275b98 Mon Sep 17 00:00:00 2001 From: Averill G Date: Wed, 9 Mar 2016 13:07:47 -0600 Subject: [PATCH 3/6] 7) Modify the BattleCreature.attack() method so that strLastAction is updated with attack information from the attacking Battle Creature. --- .../mrb/amazingbattlecreatures/AmazingBattleCreatures.java | 2 ++ .../example/mrb/amazingbattlecreatures/BattleCreature.java | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java index 342b340..8526d0e 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java @@ -44,12 +44,14 @@ public void duel(View vw) if((bcTwo.isDefeated() == false) && (bcOne.isDefeated() == false)) { bcOne.attack(bcTwo); + txtvwBattleOutput.append(bcOne.getLastAction()); txtvwBattleOutput.append(bcTwo.getLastAction()); blnFirstBCWins = bcOne.hasWon(); } if((bcOne.isDefeated() == false) && (bcTwo.isDefeated() == false)) { bcTwo.attack(bcOne); + txtvwBattleOutput.append(bcTwo.getLastAction()); txtvwBattleOutput.append(bcOne.getLastAction()); blnSecondBCWins = bcTwo.hasWon(); } diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java index fe328cf..a088121 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java @@ -45,6 +45,7 @@ public void attack(BattleCreature battcreatOpponent_PARAM) if (!battcreatOpponent_PARAM.isDefeated()) { battcreatOpponent_PARAM.defend(intOffenceRating); + strLastAction = this.strName + " delivers " + intOffenceRating + " attack\n"; } if(battcreatOpponent_PARAM.isDefeated()) @@ -66,12 +67,12 @@ public void defend(int intOffenceAmount_PARAM) intHitPoints = 0; blnIsDefeated = true; blnHasWon = false; - strLastAction = strName + " is defeated."; + strLastAction = strName + " is defeated.\n"; } else if (intNetDamage > 0) { intHitPoints = intHitPoints - intNetDamage; - strLastAction = strName + " has taken " + intNetDamage + " damage."; + strLastAction = strName + " has taken " + intNetDamage + " damage.\n"; } } From 1e83f0f1aef3897afcd498796727acc658db40d5 Mon Sep 17 00:00:00 2001 From: Averill G Date: Wed, 9 Mar 2016 13:09:30 -0600 Subject: [PATCH 4/6] 7) Modify the BattleCreature.attack() method so that strLastAction is updated with attack information from the attacking Battle Creature. 8) Modify the AmazingBattleCreatures.duel() method so that the attacking Battle Creature displays its attacking info before the defending Battle Creature displays its info. The output will then consist of an attack message followed by a defence message until the duel ends. Much thanks Mr. Buskell --- .../com/example/mrb/amazingbattlecreatures/BattleCreature.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java index a088121..e017e44 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java @@ -95,5 +95,5 @@ public String getLastAction() { return strLastAction; } - +// } From 3a776b83c36bb41754fecd5921bbc85e822780fe Mon Sep 17 00:00:00 2001 From: Paul Buskell Date: Thu, 10 Mar 2016 15:02:59 -0600 Subject: [PATCH 5/6] Changed to include working Code for subclass "CyberBattleCreature". --- .../AmazingBattleCreatures.java | 20 ++++++++++-------- .../BattleCreature.java | 16 ++++++-------- .../CyberBattleCreature.java | 21 ++++++++++++------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java index fc3e54c..881e8be 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java @@ -27,31 +27,33 @@ public void duel(View vw) boolean blnSecondBCWins = false; BattleCreature bcOne; - BattleCreature bcTwo; + CyberBattleCreature cbcTwo; // Thanks to Mr Hardman for checking the original numbers! These ones work better. bcOne = new BattleCreature("Mondoise", 200, 10, 33); - bcTwo = new BattleCreature("Tuesachu", 200, 25, 15); + cbcTwo = new CyberBattleCreature("Tuesachu", 200, 25, 15, 45); bcOne.restore(); - bcTwo.restore(); + cbcTwo.restore(); txtvwBattleOutput.setText(""); while(blnNoWinner) { // Thanks to Mr Hardman for the logic assist! - if((bcTwo.isDefeated() == false) && (bcOne.isDefeated() == false)) + if((cbcTwo.isDefeated() == false) && (bcOne.isDefeated() == false)) { - bcOne.attack(bcTwo); - txtvwBattleOutput.append(bcTwo.getLastAction()); + bcOne.attack(cbcTwo); + txtvwBattleOutput.append(bcOne.getLastAction()); + txtvwBattleOutput.append(cbcTwo.getLastAction()); blnFirstBCWins = bcOne.hasWon(); } - if((bcOne.isDefeated() == false) && (bcTwo.isDefeated() == false)) + if((bcOne.isDefeated() == false) && (cbcTwo.isDefeated() == false)) { - bcTwo.attack(bcOne); + cbcTwo.cyberAttack(bcOne); + txtvwBattleOutput.append(cbcTwo.getLastAction()); txtvwBattleOutput.append(bcOne.getLastAction()); - blnSecondBCWins = bcTwo.hasWon(); + blnSecondBCWins = cbcTwo.hasWon(); } blnNoWinner = !blnFirstBCWins && !blnSecondBCWins; diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java index 7725ddb..37e60d9 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java @@ -5,19 +5,14 @@ */ public class BattleCreature { - private String strName; + protected String strName; private int intHitPointsMaster; private int intHitPoints; // Or perhaps it should be intHealthPoints? private int intDefenceRating; - protected int intOffenceRating; + private int intOffenceRating; private boolean blnIsDefeated; protected boolean blnHasWon; - private String strLastAction; - - public BattleCreature() - { - - } + protected String strLastAction; public BattleCreature(String strName_PARAM, int intHitPoints_PARAM, @@ -50,6 +45,7 @@ public void attack(BattleCreature battcreatOpponent_PARAM) if (!battcreatOpponent_PARAM.isDefeated()) { battcreatOpponent_PARAM.defend(intOffenceRating); + strLastAction = strName + " has delivered a " + intOffenceRating + " point attack!\n"; } if(battcreatOpponent_PARAM.isDefeated()) @@ -71,12 +67,12 @@ public void defend(int intOffenceAmount_PARAM) intHitPoints = 0; blnIsDefeated = true; blnHasWon = false; - strLastAction = strName + " is defeated."; + strLastAction = strName + " is defeated.\n"; } else if (intNetDamage > 0) { intHitPoints = intHitPoints - intNetDamage; - strLastAction = strName + " has taken " + intNetDamage + " damage."; + strLastAction = strName + " has taken " + intNetDamage + " damage.\n"; } } diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java index b57c08f..1e62f1b 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java @@ -6,35 +6,40 @@ public class CyberBattleCreature extends BattleCreature { private int intCyberAttackAmount; - private int intCyberDefenceAmount; public CyberBattleCreature(String strName_PARAM, int intHitPoints_PARAM, int intDefenceRating_PARAM, int intOffenceRating_PARAM, - int intCyberAttackAmount_PARAM, - int intCyberDefenceAmount_PARAM) + int intCyberAttackAmount_PARAM) { + // Call the Constructor of the parent class using the keyword "super". This will set the + // values for most of the variables (except intCyberAttackAmount) super(strName_PARAM, intHitPoints_PARAM, intDefenceRating_PARAM, intOffenceRating_PARAM); + // We need to set the new data variable here, since the parent class constructor can't + // handle it. this.intCyberAttackAmount = intCyberAttackAmount_PARAM; - this.intCyberDefenceAmount = intCyberDefenceAmount_PARAM; } - public void attack(BattleCreature battcreatOpponent_PARAM) + public void cyberAttack(BattleCreature battcreatOpponent_PARAM) { if (!battcreatOpponent_PARAM.isDefeated()) { - battcreatOpponent_PARAM.defend(super.intOffenceRating); + // We attack the opponent with our new intCyberAttackAmount! + battcreatOpponent_PARAM.defend(intCyberAttackAmount); + strLastAction = strName + " has delivered a " + intCyberAttackAmount + + "-point cyber attack!\n"; } if(battcreatOpponent_PARAM.isDefeated()) { - super.blnHasWon = true; + // We call the blnHasWon() method on our opponent using the "super" keyword + blnHasWon = true; } else { - super.blnHasWon = false; + blnHasWon = false; } } From 6faf87c76dc233556e1671e0208cd9bed66de980 Mon Sep 17 00:00:00 2001 From: Averill G Date: Mon, 14 Mar 2016 15:08:36 -0500 Subject: [PATCH 6/6] 7) Modify the BattleCreature.attack() method so that strLastAction is updated with attack information from the attacking Battle Creature. 8) Modify the AmazingBattleCreatures.duel() method so that the attacking Battle Creature displays its attacking info before the defending Battle Creature displays its info. The output will then consist of an attack message followed by a defence message until the duel ends. Much thanks Mr. Buskell --- .../AmazingBattleCreatures.java | 20 ++++---- .../amazingbattlecreatures/AnimeRobot.java | 44 ++++++++++++++++++ .../BattleCreature.java | 10 ++-- .../CyberBattleCreature.java | 46 +++++++++++++++++++ 4 files changed, 105 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/com/example/mrb/amazingbattlecreatures/AnimeRobot.java create mode 100644 app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java index 8526d0e..617e5c6 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AmazingBattleCreatures.java @@ -27,33 +27,33 @@ public void duel(View vw) boolean blnSecondBCWins = false; BattleCreature bcOne; - BattleCreature bcTwo; + AnimeRobot arTwo; // Thanks to Mr Hardman for checking the original numbers! These ones work better. bcOne = new BattleCreature("Mondoise", 200, 10, 33); - bcTwo = new BattleCreature("Tuesachu", 200, 25, 100); + arTwo = new AnimeRobot("Gun Dam", 500, 25, 15, 100); bcOne.restore(); - bcTwo.restore(); + arTwo.restore(); txtvwBattleOutput.setText(""); while(blnNoWinner) { // Thanks to Mr Hardman for the logic assist! - if((bcTwo.isDefeated() == false) && (bcOne.isDefeated() == false)) + if ((arTwo.isDefeated() == false) && (bcOne.isDefeated() == false)) { - bcOne.attack(bcTwo); + bcOne.attack(arTwo); txtvwBattleOutput.append(bcOne.getLastAction()); - txtvwBattleOutput.append(bcTwo.getLastAction()); + txtvwBattleOutput.append(arTwo.getLastAction()); blnFirstBCWins = bcOne.hasWon(); } - if((bcOne.isDefeated() == false) && (bcTwo.isDefeated() == false)) + if((bcOne.isDefeated() == false) && (arTwo.isDefeated() == false)) { - bcTwo.attack(bcOne); - txtvwBattleOutput.append(bcTwo.getLastAction()); + arTwo.AnimeLaserAttack(bcOne); + txtvwBattleOutput.append(arTwo.getLastAction()); txtvwBattleOutput.append(bcOne.getLastAction()); - blnSecondBCWins = bcTwo.hasWon(); + blnSecondBCWins = arTwo.hasWon(); } blnNoWinner = !blnFirstBCWins && !blnSecondBCWins; diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/AnimeRobot.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AnimeRobot.java new file mode 100644 index 0000000..0cd8250 --- /dev/null +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/AnimeRobot.java @@ -0,0 +1,44 @@ +package com.example.mrb.amazingbattlecreatures; + +/** + * Created by student on 11/03/2016. + */ +public class AnimeRobot extends BattleCreature +{ + + private int intAnimeLaserAttackAmount; + private int intAnimeShieldAmount; + + public AnimeRobot (String strName_PARAM, + int intHitPoints_PARAM, + int intDefenceRating_PARAM, + int intOffenceRating_PARAM, + int intAnimeLaserAttackAmount_PARAM) + + { + super(strName_PARAM, intHitPoints_PARAM, intDefenceRating_PARAM, intOffenceRating_PARAM); + + this.intAnimeLaserAttackAmount = intAnimeLaserAttackAmount_PARAM; + + } + + public void AnimeLaserAttack(BattleCreature battlecreatOpponent_PARAM) + {if(!battlecreatOpponent_PARAM.isDefeated()) + { + battlecreatOpponent_PARAM.defend(intAnimeLaserAttackAmount); + strLastAction = strName + " has exacted " + intAnimeLaserAttackAmount + " of laser damage! \n"; + } + + if(battlecreatOpponent_PARAM.isDefeated()) + { + blnHasWon = true; + } + else + { + blnHasWon = false; + }} + +} + + + diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java index e017e44..37e60d9 100644 --- a/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/BattleCreature.java @@ -5,14 +5,14 @@ */ public class BattleCreature { - private String strName; + protected String strName; private int intHitPointsMaster; private int intHitPoints; // Or perhaps it should be intHealthPoints? private int intDefenceRating; private int intOffenceRating; private boolean blnIsDefeated; - private boolean blnHasWon; - private String strLastAction; + protected boolean blnHasWon; + protected String strLastAction; public BattleCreature(String strName_PARAM, int intHitPoints_PARAM, @@ -45,7 +45,7 @@ public void attack(BattleCreature battcreatOpponent_PARAM) if (!battcreatOpponent_PARAM.isDefeated()) { battcreatOpponent_PARAM.defend(intOffenceRating); - strLastAction = this.strName + " delivers " + intOffenceRating + " attack\n"; + strLastAction = strName + " has delivered a " + intOffenceRating + " point attack!\n"; } if(battcreatOpponent_PARAM.isDefeated()) @@ -95,5 +95,5 @@ public String getLastAction() { return strLastAction; } -// + } diff --git a/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java new file mode 100644 index 0000000..1e62f1b --- /dev/null +++ b/app/src/main/java/com/example/mrb/amazingbattlecreatures/CyberBattleCreature.java @@ -0,0 +1,46 @@ +package com.example.mrb.amazingbattlecreatures; + +/** + * Created by PBuskell on 08/03/2016. + */ +public class CyberBattleCreature extends BattleCreature +{ + private int intCyberAttackAmount; + + public CyberBattleCreature(String strName_PARAM, + int intHitPoints_PARAM, + int intDefenceRating_PARAM, + int intOffenceRating_PARAM, + int intCyberAttackAmount_PARAM) + { + // Call the Constructor of the parent class using the keyword "super". This will set the + // values for most of the variables (except intCyberAttackAmount) + super(strName_PARAM, intHitPoints_PARAM, intDefenceRating_PARAM, intOffenceRating_PARAM); + + // We need to set the new data variable here, since the parent class constructor can't + // handle it. + this.intCyberAttackAmount = intCyberAttackAmount_PARAM; + } + + public void cyberAttack(BattleCreature battcreatOpponent_PARAM) + { + if (!battcreatOpponent_PARAM.isDefeated()) + { + // We attack the opponent with our new intCyberAttackAmount! + battcreatOpponent_PARAM.defend(intCyberAttackAmount); + strLastAction = strName + " has delivered a " + intCyberAttackAmount + + "-point cyber attack!\n"; + } + + if(battcreatOpponent_PARAM.isDefeated()) + { + // We call the blnHasWon() method on our opponent using the "super" keyword + blnHasWon = true; + } + else + { + blnHasWon = false; + } + } + +}