Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi please assist with this tasks TASKs Compulsory Task 1 Follow these steps: Modify the existing Animal.java file for this task. Using the Lion class

Hi please assist with this tasks

TASKs

Compulsory Task 1 Follow these steps: Modify the existing Animal.java file for this task. Using the Lion class template, as shown in this pdf file, expand the class to have features specific to a lion: Add a field for lion type (cub, male, female). Add a method in this class which sets the lion type based on its weight (note that the weight is a derived field from the superclass). If the weight is less than 80kg, its type should be a cub. If less than 120kg, it should be female. If greater than 120kg, it is a male. Include a method that will print out a description of a lion object. Compile, save and run your file.

Compulsory Task 2

Follow these steps: Modify the existing Animal.java file for this task. Create a class called Cheetah that: Inherits from the Animal class. Makes use of at least one static field which needs to have a static setter and getter. Contains a constructor. Contains a toString() method. Has an array as one of its fields. Create an application class. Within the main method, create a Cheetah object and print out (to the screen) the details that describe this object. Compile, save and run your file.

Animal.java

 
public class Animal { private int numTeeth = 0; private boolean spots = false; private int weight = 0; public Animal(int numTeeth, boolean spots, int weight){ this.setNumTeeth(numTeeth); this.setSpots(spots); this.setWeight(weight); } public int getNumTeeth(){ return numTeeth; } public void setNumTeeth(int numTeeth) { this.numTeeth = numTeeth; } public boolean getSpots() { return spots; } public void setSpots(boolean spots) { this.spots = spots; } public int getWeight() { return weight; } public void setWeight(int weight) { this.weight = weight; } } 

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions