Question

6) Consider the following class descriptions for objects in a video game: An NPC (non-player character)...

6) Consider the following class descriptions for objects in a video game:

An NPC (non-player character) in a video game has some basic data that belongs to all entities in a game. All NPCs have a name, which is a String, health, which is an integer, and a description, which is a String. NPCs have accessor methods for each of their instance variables. NPCs also have an act() method, which is void; however, since there are no true NPCs in a video game, the act() method needs to be defined by any class that extends NPC. As such, the NPC class is abstract.

A Wizard is-an NPC that also has an integer relating to the number of times it can cast a spell per day, called numCasts. It acts by casting a spell, if it can cast.

A Barbarian is-an NPC that has an integer relating to how many times it can be enraged per day, called numRages. It acts by yelling and swinging a giant axe.

Using LucidChart or draw.io, create a UML diagram that shows the relationships between these three classes. Do not worry about defining constructors for the classes. Words you may want to use are NPC, Wizard, Barbarian, name, health, description, act, numCasts, numRage.

Homework Answers

Answer #1

6). ANSWER :

GIVENTHAT :

Short Summary :-

  • Drawn the UML diagram as per given instructions.
  • All the members name and datatype have been marked appropriately
  • Since there is no requirement to implment the classes in java, did not provide java code

UML Diagram :-

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT