Answered step by step
Verified Expert Solution
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.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started