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, 23.06.2019 01:50
Create a class named majors that includes an enumeration for the six majors offered by a college as follows: acc, chem, cis, eng, his, phys. display the enumeration values for the user, then prompt the user to enter a major. display the college division in which the major falls. acc and cis are in the business division, chem and phys are in the science division, and eng and his are in the humanities division. save the file as majors.java.
Answers: 2
question
Computers and Technology, 23.06.2019 22:00
Take a critical look at three gui applications you have used—for example, a spreadsheet, a word-processing program, and a game. describe how well each conforms to the gui design guidelines listed in this chapter.
Answers: 3
question
Computers and Technology, 25.06.2019 11:30
The function of network switch is to
Answers: 1
question
Computers and Technology, 25.06.2019 15:30
Which of the following sets of acronyms is concerned with encoding data for secure transmission? wan, lan vpn, nic ipsec, ssh nat, ssl
Answers: 1
You know the right answer?
Suppose that you were given an unfinished, partially written class, which was created for a fantasy...
Questions
question
Mathematics, 29.01.2020 22:49
Questions on the website: 13722363