


This is a really lengthy question so i will answering as much as i can (due to time limit)
First we have to create the monster class.
public class Monster {
double health;
double strength;
public void Monster(){
double health= 0;
double strength =0;
}
public void Monster(double health, double strength){
this.health = health;
this.strength = strength;
}
// Getters - getHealth and getStrength
public double getHealth(){
return health;
}
public double getStrength(){
return strength;
}
//Setter - setHealth and set Strength
public double setHealth(double newHealth){
this.health = newHealth;
return health;
}
public double setStrength(double newStrength){
this.strength = newStrength;
return strength;
}
public double attack(){
return health;
}
public double takeDamage(double damage){
return (health - damage);
}
public boolean isAlive(){
if(health>0)
return true;
else
return false;
}
Comment appropriately where ever it is required. In the class basically we have initialized the the healtha and strength variables which is the data. After that the functions are declared i.e. the getter , setters , attack(), takeDamage(), isAlive().
If you look at the other class like Giant and Ogre these class have almost similar data functions. So thats were the inheritance comes into play. extends keyword is used to inherit from the base class. Using inheritance we can use the data and functions in of the base class class in subclass ( to which it is extended).
Here Monster is the base class and Giant and Ogre are the subclasses of Monster class.
Here is Giant class
public class Giant extends Monster{
public void Giant(){
health = 1000.0;
strength = 20.0;
}
@Override
public double attack(){
return
(strength*health/1000);
}
}
We can see that attack function of Giant is different from the base Monster class. So for that we override the attack() method in Giant class . Similarly we can create Ogre class . Here please keep in mind that there will a extra variable totalHits( int totalHits; ) which has to declared first and also the attack function has to be overridden.
Then comes the main function Battle. This function will contain the main method.
Inside the main function we first the get input ( The number of giants that is going to fight).
For that we can use the scanner function to the input from keyboard.
Scanner s= new Scanner(System.in);
int n = s.nextInt();
the variable n will contain the number of giants. Now we have to loop n times as the giants will all die in the end.
You can use any loop.
For easiness i'm using for loop
for( i =1; i<=n; i ++){
//all the logic of the program goes here
}
We have create an object of Giant and Ogre for simulating the battle.
Giant g = new Giant(); // Creates a giant
similarly create an object of Orge o.
now simulating the battling is basically passing the
values.
Orge will continue to fight till the giant die . So we have create
another loop inside the for loop
while( g.isAlive ){
}
When a giant attacks an Orge we pass the Giant attackdamage to Orge's Damage.
o.setHealth(o.takeDamage(g.attack()))
similarly when ogre attacks a giant.
when o.isAlive becomes false the ogre die and a new ogre is created.( create a new Ogre object)
This continues till all Giants are dead.
Add the print statements as necessary.
Please let me know if you questions as time is short to answer the question completely. I can explain further.
HIGHEST SUBMISSION Vlew All Submissions Submission 17 Submitted on 6/10/2019 12 35 PM by Jenna Saleh...
Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count of all monsters instantiated and includes a static method that generates a new random monster object. In software engineering, a method that generates new instances of classes based on configuration information is called the Factory pattern. UML Class Diagram: Monster - name: String - health: int - strength: int - xp: int + spawn(type:String): Monster + constructor (name: String, health: int, strength: int, xp:...
using C++
Requirements: . Classes you must create o Monster must be an abstract class Each monster has . an attack) o randomly generate a number between 0 and strength for each attack (Strength 10 would generate 0-10) add up all the damage done return total damage o o e a number of attacks . a number for strength used during attacking . a string representing the type » accessor for type o Goblin inherits from Monster type is "Goblin"...
Summary task: C++ language; practice combining tools(functions, arrays, different kind of loops) to solve somewhat complex problem. Description A Valiant Hero is about to go on a quest to defeat a Vile Monster. However, the Hero is also quite clever and wants to be prepared for the battle ahead. For this question, you will write a program that will simulate the results of the upcoming battle so as to help the hero make the proper preparations. Part 1 First, you...
C++ Inheritance Problem Step a: Suppose you are creating a fantasy role-playing game. In this game we have four different types of Creatures: Humans, Cyberdemons, Balrogs, and elves. To represent one of these Creatures we might define a Creature class as follows: class Creature { private: int type; // 0 Human, 1 Cyberdemon, 2 Balrog, 3 elf int strength; // how much damage this Creature inflicts int hitpoints; // how much damage this Creature can sustain string getSpecies() const; //...
Question 1. (Magician.java, Healer.java, Fighter.java,
HeroTester.java) Consider the abstract hero class and the three
subclasses shown below.
Review the hero class to see how it works (it’s in the
project/package for you already). Your job is to implement
the following subclasses. Each of the subclasses has an extra
data field that relates to their specific hero talent.
Some help with these special talents and other methods are
below.
Fighter:
‐The fighter has an extra data field called Strength and a...
Read “Instituionalizing our Demise: America vs Multiculturalism” by
Roger Kimball on pg 268 and “Reinventing America” Call for a new
national indentity” by Elizabeth Martinez on pg 275. Create a
double entry notebook for each reading selection It should be
atleast five observation and responses.
wric 268 PART 2 essay pro. exactly how and why their authors disagree. Instead of with parties in conflict as mediators do, you will nt of view designed to appeal to both sides, mediatn posing...