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.
The UML diagram shows three classes NPC,Barbarian and Wizard. The NPC is implemented using an interface as it is an abstract class. All datatypes and functions of both Barbarian and Wizard class are inherited by the NPC Class.The act() function is defined in both these classes as both extend NPC class.
Get Answers For Free
Most questions answered within 1 hours.