SlideShare a Scribd company logo
1 of 7
Download to read offline
public class Monster {
protected String clanAffiliation;
protected int ferocity;
protected int defense;
protected int magic;
protected int treasure;
protected int health;
public Monster(String clanAffiliation, int ferocity, int defense, int magic) {
this.clanAffiliation = clanAffiliation;
this.ferocity = ferocity;
this.defense = defense;
this.magic = magic;
this.treasure = 0;
this.health = 100;
}
public String getClanAffiliation() {
return clanAffiliation;
}
public int getFerocity() {
return ferocity;
}
public int getDefense() {
return defense;
}
public int getMagic() {
return magic;
}
public int getTreasure() {
return treasure;
}
public int getHealth() {
return health;
}
public void addTreasure(int treasure) {
if (health > 0) {
this.treasure += treasure;
}
}
public void subtractTreasure(int treasure) {
if (health > 0) {
this.treasure -= treasure;
if (this.treasure < 0) {
this.treasure = 0;
}
}
}
public void addHealth(int amount) {
if (health > 0) {
health += amount;
}
}
public void subtractHealth(int amount) {
if (health > 0) {
health -= amount;
if (health < 0) {
health = 0;
}
}
}
public boolean isAlive() {
return health > 0;
}
public double getBattleScore() {
if (health <= 0) {
return 0;
}
return (ferocity + defense + magic) / 3.0;
}
public abstract void attack(Monster opponent);
public abstract void defend(double opponentBattleScore);
@Override
public String toString() {
return "Monster{" +
"clanAffiliation='" + clanAffiliation + ''' +
", ferocity=" + ferocity +
", defense=" + defense +
", magic=" + magic +
", treasure=" + treasure +
", health=" + health +
'}';
}
}
public class Orc extends Monster {
private OrcCommander commander;
public Orc(String clan, int ferocity, int defense, int magic, int treasure, int health) {
super(clan, ferocity, defense, magic, treasure, health);
}
public void setCommander(OrcCommander commander) {
this.commander = commander;
}
public OrcCommander getCommander() {
return commander;
}
public int getLeadership() {
if (this instanceof Warlord) {
Warlord warlord = (Warlord) this;
return warlord.getLeadership();
}
return 0;
}
public int getInfantryCount() {
if (this instanceof Warlord) {
Warlord warlord = (Warlord) this;
return warlord.getInfantryCount();
}
return 0;
}
public void setInfantry(Warlord warlord) {
if (this instanceof Infantry) {
Infantry infantry = (Infantry) this;
infantry.setCommander(warlord);
}
}
@Override
public void attack(Monster opponent) {
int attackScore = calculateAttackScore();
int defenseScore = opponent.calculateDefenseScore();
int damage = Math.max(attackScore - defenseScore, 0);
opponent.takeDamage(damage);
}
}
public class Warlord extends Orc {
private int leadershipRating;
private Infantry[] infantry;
public Warlord(String name, int ferocity, int defense, int magic, int leadershipRating) {
super(name, ferocity, defense, magic);
this.leadershipRating = leadershipRating;
this.infantry = new Infantry[5];
}
public int getLeadershipRating() {
return leadershipRating;
}
public void setLeadershipRating(int leadershipRating) {
if (leadershipRating >= 1 && leadershipRating <= 5) {
this.leadershipRating = leadershipRating;
} else {
System.out.println("Leadership rating must be between 1 and 5");
}
}
public Infantry[] getInfantry() {
return infantry;
}
public void addInfantry(Infantry newInfantry) {
boolean added = false;
for (int i = 0; i < infantry.length; i++) {
if (infantry[i] == null) {
infantry[i] = newInfantry;
newInfantry.setWarlord(this);
added = true;
break;
}
}
if (!added) {
System.out.println("Could not add Infantry - this Warlord already has 5 Infantry in their
command.");
}
}
public void removeInfantry(Infantry infantryToRemove) {
for (int i = 0; i < infantry.length; i++) {
if (infantry[i] == infantryToRemove) {
infantry[i] = null;
infantryToRemove.setWarlord(null);
break;
}
}
}
public void soundBattleCry() {
if (getHealth() > 0) {
int boost = leadershipRating * 5;
System.out.println(getName() + " sounds their battle cry, boosting the health of their Infantry by " +
boost);
for (Infantry soldier : infantry) {
if (soldier != null) {
soldier.receiveHealthBoost(boost);
}
}
} else {
System.out.println(getName() + " cannot sound their battle cry - they are dead.");
}
}
}
public class Infantry extends Monster {
private Warlord commander;
public Infantry(String clan, int ferocity, int defense, int magic, int treasure, int health, Warlord
commander) {
super(clan, ferocity, defense, magic, treasure, health);
this.commander = commander;
}
public Warlord getCommander() {
return commander;
}
public void setCommander(Warlord commander) {
this.commander = commander;
}
public void attack(Monster monster) {
if (this.getHealth() <= 0 || monster.getHealth() <= 0) {
return;
}
double battleScore = (this.getFerocity() + this.getDefense() + this.getMagic()) / 3.0;
if (this.commander != null && this.commander.getLeadership() > 0) {
battleScore *= 1.5;
}
if (monster instanceof Warlord) {
battleScore *= 0.5;
}
if (battleScore > monster.getBattleScore()) {
int damage = (int) Math.round(battleScore - monster.getBattleScore());
monster.setHealth(monster.getHealth() - damage);
if (monster.getHealth() <= 0 && monster instanceof Orc) {
((Orc) monster).removeInfantry(this);
}
}
}
}
public class Goblin extends Monster {
private Goblin swornEnemy;
public Goblin(String clanAffiliation, int ferocity, int defense, int magic, int treasure, int health,
Goblin swornEnemy) {
super(clanAffiliation, ferocity, defense, magic, treasure, health);
this.swornEnemy = swornEnemy;
}
public Goblin getSwornEnemy() {
return swornEnemy;
}
public void setSwornEnemy(Goblin swornEnemy) {
this.swornEnemy = swornEnemy;
}
}
public class Manticore extends Monster {
private String clanAffiliation;
public Manticore(String clanAffiliation, int ferocity, int defense, int magic, int treasure, int health) {
super(clanAffiliation, ferocity, defense, magic, treasure, health);
this.clanAffiliation = clanAffiliation;
}
public String getClanAffiliation() {
return clanAffiliation;
}
public void setClanAffiliation(String clanAffiliation) {
this.clanAffiliation = clanAffiliation;
}
@Override
public double getBattleScore() {
return (getFerocity() + getDefense() + getMagic()) / 3.0 * 1.5;
}
}
public abstract void attack (Monster opponent): public abstroct vaid befend double ononpublic
class Warlord extends Orc { private int leadershipRating; private Infantry[] infantry; public
Warlord(String name, int ferocity, int defense, int magic, int leadershipRating) { super(name,
ferocity, defense, magic); this. leadershipRating = leadershipRating; this. infantry = new Infantry [5
]; 3 public int getleadershipRating() ( return leadershipRating; (3) public void
setLeadershipRating(int leadershipRating) { if (leadershipRating >=1 s& leadershipRating <=5 ) f
this, leadershipRating = leadershipRating; 3 else System.out. println("Leadership rating must be
between 1 and 5 ); 3 3 public Infantry[] getinfantry () { return infantry; 3 public void addInfantry
(Infantry newinfantry) & boolean added = false; for (Int 1=0;1< infantry, 1ength; 1++)< if (infantry [i]
=n= nu11) { infantry [1]= newinfantry; newinfantry, setwarlord(this); added = true; break; ) 3 if
(ladded) { System,out, println("Could not add Infantry. this Wariord already has 5 Infantry in th (
comsand. "); 3 public void removeInfantry (Infantry infantry ToRemove) if. for { int 1 * 3;1< infantry.
Length; 1+} i If (infantry[ 1 in infantryToremove) {public class Infantry extends Monster { private
Warlord commander; public Infantry(String clan, int ferocity, int defense, int magic, int treasure, int
health, Warlord commander) { super(clan, ferocity, defense, magic, treasure, health); this .
commander = commander; 3 public Warlord getCommander() { return commander; 3 public void
setCommander(Warlord commander) ( this. commander = commander; 3 public void
attack(Monster monster) ( return; 7 double battlescore - (this, getferocity ()+ this.getDefense() +
this.getMagic()) 3.0 ; if (this. commander I= nu11 && this. commander.getLeadership ( ) > ) {
battlescore =1.5 3 if (monster instanceof Warlord) & battlescore 0.5; 3 if (battlescore >
monster.getBattlescore()) { int damage = (int) Math. round (battleScore - monster.
getBattlescore()); monster.setHealth(monster, getHealth() - damage); If (monster, gethealth ( ) <=
0&& monster instanceof Orc) { ((orc) monster). removeInfantry(this); 3public class Goblin extends
Monster { private Goblin swornEnemy; public Goblin(String clanAffiliation, int ferocity, int defense,
int magic, int treasure, int health, Goblin sworntnemy) & super(clandffiliation, ferocity, defense,
magic, treasure, health); this. swornenemy = swornEnemy; 3 public Goblin getswornemony() &
return swornEnemy; 3 public void setSwornEnemy (Goblin swornEnemy) & this. swornEnemy =
swornEnemy; l

More Related Content

More from addtechglobalmarketi

pular Madde 5 Aadaki durumda orijinal kaynak materyal b.pdf
pular  Madde 5  Aadaki durumda orijinal kaynak materyal b.pdfpular  Madde 5  Aadaki durumda orijinal kaynak materyal b.pdf
pular Madde 5 Aadaki durumda orijinal kaynak materyal b.pdfaddtechglobalmarketi
 
Puede crear numerosas vistas personalizadas para usar con to.pdf
Puede crear numerosas vistas personalizadas para usar con to.pdfPuede crear numerosas vistas personalizadas para usar con to.pdf
Puede crear numerosas vistas personalizadas para usar con to.pdfaddtechglobalmarketi
 
publie elass h 1 pahlte clamsia axcends A pablie clann Main .pdf
publie elass h 1 pahlte clamsia axcends A pablie clann Main .pdfpublie elass h 1 pahlte clamsia axcends A pablie clann Main .pdf
publie elass h 1 pahlte clamsia axcends A pablie clann Main .pdfaddtechglobalmarketi
 
Puede una empresa ser buena en responsabilidad social corpo.pdf
Puede una empresa ser buena en responsabilidad social corpo.pdfPuede una empresa ser buena en responsabilidad social corpo.pdf
Puede una empresa ser buena en responsabilidad social corpo.pdfaddtechglobalmarketi
 
Provide three evidences with scholar reference that support.pdf
Provide three evidences with scholar  reference that support.pdfProvide three evidences with scholar  reference that support.pdf
Provide three evidences with scholar reference that support.pdfaddtechglobalmarketi
 
Provincial Government The name of the representative of the .pdf
Provincial Government The name of the representative of the .pdfProvincial Government The name of the representative of the .pdf
Provincial Government The name of the representative of the .pdfaddtechglobalmarketi
 
Prpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdf
Prpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdfPrpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdf
Prpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdfaddtechglobalmarketi
 
Provide three evidences with reliable reference that suppor.pdf
Provide three evidences with reliable  reference that suppor.pdfProvide three evidences with reliable  reference that suppor.pdf
Provide three evidences with reliable reference that suppor.pdfaddtechglobalmarketi
 
Provide the Independent variables Dependent variables a.pdf
Provide the Independent variables Dependent variables a.pdfProvide the Independent variables Dependent variables a.pdf
Provide the Independent variables Dependent variables a.pdfaddtechglobalmarketi
 
Provide your example of a firm or a small business from the .pdf
Provide your example of a firm or a small business from the .pdfProvide your example of a firm or a small business from the .pdf
Provide your example of a firm or a small business from the .pdfaddtechglobalmarketi
 
Provide the steps for the following In order to install sof.pdf
Provide the steps for the following In order to install sof.pdfProvide the steps for the following In order to install sof.pdf
Provide the steps for the following In order to install sof.pdfaddtechglobalmarketi
 
Provide land use land cover images and photos using shape.pdf
Provide land use land cover images and photos  using shape.pdfProvide land use land cover images and photos  using shape.pdf
Provide land use land cover images and photos using shape.pdfaddtechglobalmarketi
 
Provide SQL that creates two database tables Employee and D.pdf
Provide SQL that creates two database tables Employee and D.pdfProvide SQL that creates two database tables Employee and D.pdf
Provide SQL that creates two database tables Employee and D.pdfaddtechglobalmarketi
 
Provide examples of risk and responsibilities relating to ts.pdf
Provide examples of risk and responsibilities relating to ts.pdfProvide examples of risk and responsibilities relating to ts.pdf
Provide examples of risk and responsibilities relating to ts.pdfaddtechglobalmarketi
 
Provide an example of a user interface such as a webbased.pdf
Provide an example of a user interface such as a webbased.pdfProvide an example of a user interface such as a webbased.pdf
Provide an example of a user interface such as a webbased.pdfaddtechglobalmarketi
 
Provide an example of an unintentional tort Discuss 3 occas.pdf
Provide an example of an unintentional tort Discuss 3 occas.pdfProvide an example of an unintentional tort Discuss 3 occas.pdf
Provide an example of an unintentional tort Discuss 3 occas.pdfaddtechglobalmarketi
 
Program 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfProgram 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfaddtechglobalmarketi
 
Programming Assignment 3 CSCE 3530 Introduction to Comput.pdf
Programming Assignment 3 CSCE 3530  Introduction to Comput.pdfProgramming Assignment 3 CSCE 3530  Introduction to Comput.pdf
Programming Assignment 3 CSCE 3530 Introduction to Comput.pdfaddtechglobalmarketi
 
Prove the following by induction 1ini32nn+122n+12nn3.pdf
Prove the following by induction 1ini32nn+122n+12nn3.pdfProve the following by induction 1ini32nn+122n+12nn3.pdf
Prove the following by induction 1ini32nn+122n+12nn3.pdfaddtechglobalmarketi
 
Provide a design for a cryptography problem which was illus.pdf
Provide a design for a cryptography problem which was illus.pdfProvide a design for a cryptography problem which was illus.pdf
Provide a design for a cryptography problem which was illus.pdfaddtechglobalmarketi
 

More from addtechglobalmarketi (20)

pular Madde 5 Aadaki durumda orijinal kaynak materyal b.pdf
pular  Madde 5  Aadaki durumda orijinal kaynak materyal b.pdfpular  Madde 5  Aadaki durumda orijinal kaynak materyal b.pdf
pular Madde 5 Aadaki durumda orijinal kaynak materyal b.pdf
 
Puede crear numerosas vistas personalizadas para usar con to.pdf
Puede crear numerosas vistas personalizadas para usar con to.pdfPuede crear numerosas vistas personalizadas para usar con to.pdf
Puede crear numerosas vistas personalizadas para usar con to.pdf
 
publie elass h 1 pahlte clamsia axcends A pablie clann Main .pdf
publie elass h 1 pahlte clamsia axcends A pablie clann Main .pdfpublie elass h 1 pahlte clamsia axcends A pablie clann Main .pdf
publie elass h 1 pahlte clamsia axcends A pablie clann Main .pdf
 
Puede una empresa ser buena en responsabilidad social corpo.pdf
Puede una empresa ser buena en responsabilidad social corpo.pdfPuede una empresa ser buena en responsabilidad social corpo.pdf
Puede una empresa ser buena en responsabilidad social corpo.pdf
 
Provide three evidences with scholar reference that support.pdf
Provide three evidences with scholar  reference that support.pdfProvide three evidences with scholar  reference that support.pdf
Provide three evidences with scholar reference that support.pdf
 
Provincial Government The name of the representative of the .pdf
Provincial Government The name of the representative of the .pdfProvincial Government The name of the representative of the .pdf
Provincial Government The name of the representative of the .pdf
 
Prpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdf
Prpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdfPrpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdf
Prpugh shicti the bloset fides 1 rightventikiele+3 Fxet.pdf
 
Provide three evidences with reliable reference that suppor.pdf
Provide three evidences with reliable  reference that suppor.pdfProvide three evidences with reliable  reference that suppor.pdf
Provide three evidences with reliable reference that suppor.pdf
 
Provide the Independent variables Dependent variables a.pdf
Provide the Independent variables Dependent variables a.pdfProvide the Independent variables Dependent variables a.pdf
Provide the Independent variables Dependent variables a.pdf
 
Provide your example of a firm or a small business from the .pdf
Provide your example of a firm or a small business from the .pdfProvide your example of a firm or a small business from the .pdf
Provide your example of a firm or a small business from the .pdf
 
Provide the steps for the following In order to install sof.pdf
Provide the steps for the following In order to install sof.pdfProvide the steps for the following In order to install sof.pdf
Provide the steps for the following In order to install sof.pdf
 
Provide land use land cover images and photos using shape.pdf
Provide land use land cover images and photos  using shape.pdfProvide land use land cover images and photos  using shape.pdf
Provide land use land cover images and photos using shape.pdf
 
Provide SQL that creates two database tables Employee and D.pdf
Provide SQL that creates two database tables Employee and D.pdfProvide SQL that creates two database tables Employee and D.pdf
Provide SQL that creates two database tables Employee and D.pdf
 
Provide examples of risk and responsibilities relating to ts.pdf
Provide examples of risk and responsibilities relating to ts.pdfProvide examples of risk and responsibilities relating to ts.pdf
Provide examples of risk and responsibilities relating to ts.pdf
 
Provide an example of a user interface such as a webbased.pdf
Provide an example of a user interface such as a webbased.pdfProvide an example of a user interface such as a webbased.pdf
Provide an example of a user interface such as a webbased.pdf
 
Provide an example of an unintentional tort Discuss 3 occas.pdf
Provide an example of an unintentional tort Discuss 3 occas.pdfProvide an example of an unintentional tort Discuss 3 occas.pdf
Provide an example of an unintentional tort Discuss 3 occas.pdf
 
Program 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfProgram 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdf
 
Programming Assignment 3 CSCE 3530 Introduction to Comput.pdf
Programming Assignment 3 CSCE 3530  Introduction to Comput.pdfProgramming Assignment 3 CSCE 3530  Introduction to Comput.pdf
Programming Assignment 3 CSCE 3530 Introduction to Comput.pdf
 
Prove the following by induction 1ini32nn+122n+12nn3.pdf
Prove the following by induction 1ini32nn+122n+12nn3.pdfProve the following by induction 1ini32nn+122n+12nn3.pdf
Prove the following by induction 1ini32nn+122n+12nn3.pdf
 
Provide a design for a cryptography problem which was illus.pdf
Provide a design for a cryptography problem which was illus.pdfProvide a design for a cryptography problem which was illus.pdf
Provide a design for a cryptography problem which was illus.pdf
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

public class Monster protected String clanAffiliation pro.pdf

  • 1. public class Monster { protected String clanAffiliation; protected int ferocity; protected int defense; protected int magic; protected int treasure; protected int health; public Monster(String clanAffiliation, int ferocity, int defense, int magic) { this.clanAffiliation = clanAffiliation; this.ferocity = ferocity; this.defense = defense; this.magic = magic; this.treasure = 0; this.health = 100; } public String getClanAffiliation() { return clanAffiliation; } public int getFerocity() { return ferocity; } public int getDefense() { return defense; } public int getMagic() { return magic; } public int getTreasure() { return treasure; } public int getHealth() { return health; } public void addTreasure(int treasure) { if (health > 0) { this.treasure += treasure; } } public void subtractTreasure(int treasure) { if (health > 0) { this.treasure -= treasure; if (this.treasure < 0) {
  • 2. this.treasure = 0; } } } public void addHealth(int amount) { if (health > 0) { health += amount; } } public void subtractHealth(int amount) { if (health > 0) { health -= amount; if (health < 0) { health = 0; } } } public boolean isAlive() { return health > 0; } public double getBattleScore() { if (health <= 0) { return 0; } return (ferocity + defense + magic) / 3.0; } public abstract void attack(Monster opponent); public abstract void defend(double opponentBattleScore); @Override public String toString() { return "Monster{" + "clanAffiliation='" + clanAffiliation + ''' + ", ferocity=" + ferocity + ", defense=" + defense + ", magic=" + magic + ", treasure=" + treasure + ", health=" + health + '}'; } } public class Orc extends Monster { private OrcCommander commander;
  • 3. public Orc(String clan, int ferocity, int defense, int magic, int treasure, int health) { super(clan, ferocity, defense, magic, treasure, health); } public void setCommander(OrcCommander commander) { this.commander = commander; } public OrcCommander getCommander() { return commander; } public int getLeadership() { if (this instanceof Warlord) { Warlord warlord = (Warlord) this; return warlord.getLeadership(); } return 0; } public int getInfantryCount() { if (this instanceof Warlord) { Warlord warlord = (Warlord) this; return warlord.getInfantryCount(); } return 0; } public void setInfantry(Warlord warlord) { if (this instanceof Infantry) { Infantry infantry = (Infantry) this; infantry.setCommander(warlord); } } @Override public void attack(Monster opponent) { int attackScore = calculateAttackScore(); int defenseScore = opponent.calculateDefenseScore(); int damage = Math.max(attackScore - defenseScore, 0); opponent.takeDamage(damage); } } public class Warlord extends Orc { private int leadershipRating; private Infantry[] infantry; public Warlord(String name, int ferocity, int defense, int magic, int leadershipRating) { super(name, ferocity, defense, magic);
  • 4. this.leadershipRating = leadershipRating; this.infantry = new Infantry[5]; } public int getLeadershipRating() { return leadershipRating; } public void setLeadershipRating(int leadershipRating) { if (leadershipRating >= 1 && leadershipRating <= 5) { this.leadershipRating = leadershipRating; } else { System.out.println("Leadership rating must be between 1 and 5"); } } public Infantry[] getInfantry() { return infantry; } public void addInfantry(Infantry newInfantry) { boolean added = false; for (int i = 0; i < infantry.length; i++) { if (infantry[i] == null) { infantry[i] = newInfantry; newInfantry.setWarlord(this); added = true; break; } } if (!added) { System.out.println("Could not add Infantry - this Warlord already has 5 Infantry in their command."); } } public void removeInfantry(Infantry infantryToRemove) { for (int i = 0; i < infantry.length; i++) { if (infantry[i] == infantryToRemove) { infantry[i] = null; infantryToRemove.setWarlord(null); break; } } } public void soundBattleCry() { if (getHealth() > 0) {
  • 5. int boost = leadershipRating * 5; System.out.println(getName() + " sounds their battle cry, boosting the health of their Infantry by " + boost); for (Infantry soldier : infantry) { if (soldier != null) { soldier.receiveHealthBoost(boost); } } } else { System.out.println(getName() + " cannot sound their battle cry - they are dead."); } } } public class Infantry extends Monster { private Warlord commander; public Infantry(String clan, int ferocity, int defense, int magic, int treasure, int health, Warlord commander) { super(clan, ferocity, defense, magic, treasure, health); this.commander = commander; } public Warlord getCommander() { return commander; } public void setCommander(Warlord commander) { this.commander = commander; } public void attack(Monster monster) { if (this.getHealth() <= 0 || monster.getHealth() <= 0) { return; } double battleScore = (this.getFerocity() + this.getDefense() + this.getMagic()) / 3.0; if (this.commander != null && this.commander.getLeadership() > 0) { battleScore *= 1.5; } if (monster instanceof Warlord) { battleScore *= 0.5; } if (battleScore > monster.getBattleScore()) { int damage = (int) Math.round(battleScore - monster.getBattleScore()); monster.setHealth(monster.getHealth() - damage); if (monster.getHealth() <= 0 && monster instanceof Orc) { ((Orc) monster).removeInfantry(this);
  • 6. } } } } public class Goblin extends Monster { private Goblin swornEnemy; public Goblin(String clanAffiliation, int ferocity, int defense, int magic, int treasure, int health, Goblin swornEnemy) { super(clanAffiliation, ferocity, defense, magic, treasure, health); this.swornEnemy = swornEnemy; } public Goblin getSwornEnemy() { return swornEnemy; } public void setSwornEnemy(Goblin swornEnemy) { this.swornEnemy = swornEnemy; } } public class Manticore extends Monster { private String clanAffiliation; public Manticore(String clanAffiliation, int ferocity, int defense, int magic, int treasure, int health) { super(clanAffiliation, ferocity, defense, magic, treasure, health); this.clanAffiliation = clanAffiliation; } public String getClanAffiliation() { return clanAffiliation; } public void setClanAffiliation(String clanAffiliation) { this.clanAffiliation = clanAffiliation; } @Override public double getBattleScore() { return (getFerocity() + getDefense() + getMagic()) / 3.0 * 1.5; } } public abstract void attack (Monster opponent): public abstroct vaid befend double ononpublic class Warlord extends Orc { private int leadershipRating; private Infantry[] infantry; public Warlord(String name, int ferocity, int defense, int magic, int leadershipRating) { super(name, ferocity, defense, magic); this. leadershipRating = leadershipRating; this. infantry = new Infantry [5 ]; 3 public int getleadershipRating() ( return leadershipRating; (3) public void setLeadershipRating(int leadershipRating) { if (leadershipRating >=1 s& leadershipRating <=5 ) f this, leadershipRating = leadershipRating; 3 else System.out. println("Leadership rating must be
  • 7. between 1 and 5 ); 3 3 public Infantry[] getinfantry () { return infantry; 3 public void addInfantry (Infantry newinfantry) & boolean added = false; for (Int 1=0;1< infantry, 1ength; 1++)< if (infantry [i] =n= nu11) { infantry [1]= newinfantry; newinfantry, setwarlord(this); added = true; break; ) 3 if (ladded) { System,out, println("Could not add Infantry. this Wariord already has 5 Infantry in th ( comsand. "); 3 public void removeInfantry (Infantry infantry ToRemove) if. for { int 1 * 3;1< infantry. Length; 1+} i If (infantry[ 1 in infantryToremove) {public class Infantry extends Monster { private Warlord commander; public Infantry(String clan, int ferocity, int defense, int magic, int treasure, int health, Warlord commander) { super(clan, ferocity, defense, magic, treasure, health); this . commander = commander; 3 public Warlord getCommander() { return commander; 3 public void setCommander(Warlord commander) ( this. commander = commander; 3 public void attack(Monster monster) ( return; 7 double battlescore - (this, getferocity ()+ this.getDefense() + this.getMagic()) 3.0 ; if (this. commander I= nu11 && this. commander.getLeadership ( ) > ) { battlescore =1.5 3 if (monster instanceof Warlord) & battlescore 0.5; 3 if (battlescore > monster.getBattlescore()) { int damage = (int) Math. round (battleScore - monster. getBattlescore()); monster.setHealth(monster, getHealth() - damage); If (monster, gethealth ( ) <= 0&& monster instanceof Orc) { ((orc) monster). removeInfantry(this); 3public class Goblin extends Monster { private Goblin swornEnemy; public Goblin(String clanAffiliation, int ferocity, int defense, int magic, int treasure, int health, Goblin sworntnemy) & super(clandffiliation, ferocity, defense, magic, treasure, health); this. swornenemy = swornEnemy; 3 public Goblin getswornemony() & return swornEnemy; 3 public void setSwornEnemy (Goblin swornEnemy) & this. swornEnemy = swornEnemy; l