Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dreams of a Hunter- Phase 2 Right after you completed the design and implementation of the creature class, you realized that the method of having

Dreams of a Hunter- Phase 2

Right after you completed the design and implementation of the creature class, you realized that the method of having all the creatures defined under one class doesnt make since and it will lead to a lot of complication in the future when more details will be added to the game. So, you decided to update the creature class as following:

Creature

  • attackStrength: int
  • boss: bool
  • life: bool
  • size: int
  • health: int

+ creature()

+ creature(int, bool, int, int)

+ setAttackStrength (int): void

+ setBoss(bool): void

+ setLife(bool): void

+ setSize(int): void

+ setHealth(int): void

+ getType():String

+ getAttackStrength ():int

+ getBoss():bool

+ getLife (): bool

+ getSize():int

+ getHealth():int

+ toString(): String

No changed will be applied to most of attributes and methods listed in the UML of the creature class except deleting some private and public members (Check the UML of Lesson 1). The strength data member is replaced by attackStrength. The random value which will be used to set attackStrength will be in the range 1 to 3. Also, if the creature is a boss, attackStrength should be set to 3. Remember, the default constructor will set the data members to random default values within the range described in the previous phase (Project 1). The setters parameter values will be accepted as long as they are within the default range. If the values are not within the default range, set the value randomly using the same range.

You also decided to create new 4 classes to inherit form creature class, the 4 classes are: Zombie, Vampire, Monster, and Witch. The classes are described as shown below in the UMLs.

Zombie

  • zombieType: String
  • zombies: String []
  • zobmieWeakness: String
  • weaknesses: String []
  • zombieWeapon: weapon

+ Zombie()

+ Zombie(String)

+ setZombieType(String):void

+ setZobmieWeakness(String): void

+ getZobmieWeakness(): String

+ getZombieType():String

+ attack():int

+ getAttacked():void

+ toString(): String

Vampire

  • vampireType: String
  • vampires: String []
  • vampireWeakness: String
  • weaknesses: String []
  • vampireWeapon: weapon

+ vampire ()

+ vampire (String)

+ setVampireType(String):void

+ setVampireWeakness(String): void

+ getVampireWeakness (): String

+ getVampireType():String

+ attack():int

+ getAttacked():void

+ toString(): String

Monster

  • monsterType: String
  • monsters: String []
  • monsterWeakness: String
  • weaknesses: String []
  • monsterWeapon: weapon

+ Monster()

+ Monster(String)

+ setMonsterType(String):void

+ setMonsterWeakness(String): void

+ getMonsterWeaknesss(): String

+ getMonsterType():String

+ attack():int

+ getAttacked():void

+ toString(): String

Witch

  • witchType: String
  • witches: String []
  • witcheWeakness: String
  • weaknesses: String []
  • witchWeapon: weapon

+ Witch()

+ Witch(String)

+ setWitchType(String):void

+ setWitchWeakness(String): void

+ getWitchWeaknesss(): String

+ getWitchType():String

+ attack():int

+ getAttacked():void

+ toString(): String

The 4 classes are very similar, I will explain the class zombie and you should apply what you will understand on the other 3 classes. But before that, lets talk about the static arrays. For each class, the static arrays must be populated as following:

Zombie:

  • zombies={ Chemical, Radiation, Parasite}
  • weaknesses={Intelligence, Speed, Fire}

Vampire:

  • vampires={Sanguinarian, Psychic, Hybrids}
  • weaknesses={Fire, Garlic, Sunlight }

Monster:

  • monsters={Werewolves ,Lamia, Dragons}
  • weaknesses={ Thunder, ice, Paralysis}

Witch:

  • witches={ Cosmic, Magical, Shamanic}
  • weaknesses={ Salt, Vocalization, Visual}

when creating a zombie object, the type should be one of the zombies listed in the static array zombies. In the default constructor, a random one should be chosen. In the argument constructor, if the parameter doesnt match one of the zombies in the array zombies, the first element in the array should be assigned to the type. Same mechanize should be applied to the zobmieWeakness, use the static array weaknesses to complete this part.

At this level, you will leave the method getAttacked without implementation will be implemented in the next phase. The Attack method will return an integer which presents the amount of health the hunter will lose when he/she will be attacked by the zombie. This integer is calculated as following:

Zombie type (weapon is used) (weapon is Not used)

Chemical attackStrength*1* weaponStrength attackStrength*1*1

Radiation attackStrength*2* weaponStrength attackStrength*2*1

Parasite attackStrength*3* weaponStrength attackStrength*3*1

The weaponStrength is a data member in the class Weapon which will be explained later (you will need to use getWeaponStrength to have access to it). The table shows that when weapon is used the damage will be doubled. When the attack method is called, the method should state if the weapon was used or not and it should print the amount of deducted health of the hunter (the returned integer)

I am sure you have noticed that there is an object of a type weapon in each class of the 4 classes. This class is described as shown below in the UML.

Weapon

  • weaponName: String
  • weaponStrength: int

+ Weapon (String)

+ setWeaponName(String):void

+ set weaponStrength(int): void

+ getWeaponNames(): String

+ getWeaponStrength():int

+ toString(): String

The is class works as following:

  • The weaponStrength should be set to a random value in the range 1 to 3
  • When a weapon object is created (which will be done inside one of the 4 classes), the name of the class should be passed to the constructor.
  • Use the name of the class to assign the name of the weapon depending of the type of the creature (zombie, vampire, monster, witch).
  • If the passed string is zombie, the weaponName should be set to Cricket Bat.
  • If the passed string is vampire, the weaponName should be set to Quarterstaff.
  • If the passed string is monster, the weaponName should be set to flail.
  • If the passed string is witch, the weaponName should be set to Wand.

Test your game by creating 4 objects (Zombie, Vampire, Monster, and a Witch) using the default constructor. Print the status of each object. And try the attack method. Run the program 4 times to make sure the program will randomly generate all attributes of the four objects each time you run the program.

In the next phase, you will create the hunter class and make the hunter interact with the creatures. You will also implement the method getAttacked.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Give at least four examples of possible constraints.

Answered: 1 week ago