Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +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, 15);
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);
txtvwBattleOutput.append(bcTwo.getLastAction());
bcOne.attack(arTwo);
txtvwBattleOutput.append(bcOne.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);
arTwo.AnimeLaserAttack(bcOne);
txtvwBattleOutput.append(arTwo.getLastAction());
txtvwBattleOutput.append(bcOne.getLastAction());
blnSecondBCWins = bcTwo.hasWon();
blnSecondBCWins = arTwo.hasWon();
}

blnNoWinner = !blnFirstBCWins && !blnSecondBCWins;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}}

}



Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -45,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())
Expand All @@ -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";
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

}