subject

Suppose that you were given an unfinished, partially written class, which was created for a fantasy role-playing game. There are four different types of creatures in this game: humans, cyberdemons, balrogs, and elves. One problem with this implementation is that it is unwieldy to add new creatures. You have to modify the class to make it more robust and extensible. In this game, we have four different types of creatures: humans, cyberdemons, balrogs, and elves. Rewrite the class to use inheritance, which will eliminate the need for the variable type: • The Creature class should be the base class. • The classes Demon , Elf, and Human should be derived from Creature. • The classes Cyberdemon and Balrog should be derived from Demon. • You will need to rewrite the getSpecies( ) and getDamage( ) functions so they are appropriate for each class. The getDamage( ) function in each class should only compute the damage appropriate for that object. The total damage is then calculated by combining the results of getDamage( ) at each level of the inheritance hierarchy. As an example, invoking getDamage( ) for a Balrog object should invoke getDamage( ) for the Demon object, which should invoke getDamage( ) for the Creature object. This will compute the basic damage that all creatures inflict, followed by the random 5% damage that demons inflict, followed by the double damage

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:00
You need a reliable network for about twenty-five computers that will be distributed across a large building. it is important that the network be relatively cheap. which topology should you use?
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
Singing in the rain: this first part of the film shows the early history of motion picture. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theater productions? explain.
Answers: 1
question
Computers and Technology, 24.06.2019 10:20
Identify the publisher in this citation: carter,alan.a guide to entrepreneurship.new york: river’2008.print.
Answers: 3
You know the right answer?
Suppose that you were given an unfinished, partially written class, which was created for a fantasy...
Questions