Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dreams of a Hunter You fall asleep after a long day and you had this wired dream about yourself hunting Zombies, Demons, Ghosts, Vampires, Monsters

Dreams of a Hunter

You fall asleep after a long day and you had this wired dream about yourself hunting Zombies, Demons, Ghosts, Vampires, Monsters and Witches. It was a scary dream, but it was fun at the same time. You wake up scared and you remembered every detail about the dream. In the dream you were attacked by all these creatures and you were hunting them using a set of weapons you have. Some creatures were stronger than others. Next day, you had the same dream, only this time you started remembering more details.

You told your friends about these dreams and everyone told you that you should do something about this. Some suggested to create an RPG (role-playing game) game about these dreams. Again, you kept having more dreams about hunting these creatures most of the nights. You start writing notes about your dreams to use them in the process of creating the game.

You decided to use Java to design and implement this game, your first step is to build a class called creature. The following UML (Unified Modeling Language) define the class creature based on the notes you wrote after your last dreams.

creature

  • type: String
  • strength: int
  • weakness: String
  • boss: bool
  • life: bool
  • size: int
  • health: int
  • attack: String
  • allWeakness: String []
  • allAttacks: String []
  • allCreaters: String []

+ creature()

+ setType(String): void

+ setStrength(int): void

+ setWeakness(String): void

+ setBoss(bool): void

+ setLife(bool): void

+ setSize(int): void

+ setHealth(int): void

+ setAttack(String): void

+ getType():String

+ getStrength():int

+ getWeakness():String

+ getBoss():bool

+ getLife (): bool

+ getSize():int

+ getHealth():int

+ getAttack():String

+ toString(): String

+ attack(): int

+ attacked(String): void

Class description:

allWeakness, allAttacks and allCreaters are pre-defined static array of strings. Populate these arrays as following:

allCreaters: Zombies, Demons, Ghosts, Vampires, Monsters and Witches

allWeakness: garlic, silver, water, holy books, ritual, fire, light.

allAttacks: bite, fire ball, magic Spell, acid attack, spiritual attack, smash attack, voodoo.

In the default constructor, most of the data members need to be initialized randomly. Make sure to use the setters. Also, use the three static arrays to assign values to type, attack and weakness. The values of strength, size and health should be in the range from 25 to 100. If the creature is a boss, strength, size and health must have the value of 100. Also, life variable should be set to true.

Make sure to override the method toString to return string about the status of the creature. Attack method will be useful when you create your character in next phase (the hunter). For now, the attack method returns an integer which is calculated as following.

Attack type: returned integer

bite (0+1)*2 =2

fire ball (1+1)*2 =4

magic Spell (2+1)*2 =6

acid attack (3+1)*2 =8

spiritual attack (4+1)*2 =10

smash attack (5+1)*2 =12

voodoo. (6+1)*2 =14

note that you can use the array allAttacks to calculate the returned integer. Use the index of the attack (in the allAttacks array) that match the attack of the creature and add one to it, then multiply the results by 2. This returned value will be subtracted from the player health the hunter (Phase 2, will be explained in Lesson 2).

The attacked method will be called when the creature is attacked by the hunter, this method updates the health variable as following: first, check if the creature is a life, if thats not a life, show a message to state that the creature is dead. Otherwise, if the string parameter (presents the attack of the hunter will be explained in phase 2) match the creature weakness, subtract 10 from the health of the creature. Otherwise, subtract 5. In this method, you need to make sure the health will not be below zero. Whenever the health of the creature gets to zero or below, change the life variable to false and state that the creature is dead.

Create multiple creatures (5 at least), print their states at the beginning, call the method attacked 4 times for each object creature (2 attacks match the weakness and 2 attacks do not match the weakness of the creature). Print their states after the 4 attacks for each creature.

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

How will the members be held accountable?

Answered: 1 week ago

Question

a. Do team members trust each other?

Answered: 1 week ago

Question

a. How will the leader be selected?

Answered: 1 week ago