Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

24. Consider the following simplified abstract Monster class for use in a game public abstract class Monster private int health public Monster (int health) this.

image text in transcribed

image text in transcribed

image text in transcribed

24. Consider the following simplified abstract Monster class for use in a game public abstract class Monster private int health public Monster (int health) this. health health public boolean is Dead return health 0; public void take Damage (int damage) health damage; public int get Health return health; public abstract int dealDamage public string toString return Monster health "J "i a) (10 marks) There are 5 inheritance related syntax or logic errors in the Zombie subclass below. Identify these errors and suggest possible corrections for each. (Line numbers are there for your reference only and are not errors 1. public class zombie inherits Monster 2. //repeat parent data field for clarity and add new data field 3. rivate int health 4. private int numberofArms 5. public Zombie (int h) health numberof Arms (int) (Math.random 3) 9. //add new method for new data field 10 public int getNumberofArms return numberofArms; 11 //add a new method for special attack returns damage amount 12 public int chewEnemeny return 5; 13 No need to override takeDamage isDead, dealDamage toString or get Health 14 //as they are already in the super class 15

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

1. How does Kiwi Experience maintain a continual customer focus?

Answered: 1 week ago