task 13.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, it’s 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,

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

task 13.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, it’s 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,

1
2
3
4
5
6
7
8
9
10
11
12
13
16
17
20
21
24
25
28
29
52
53
36
57
58
59
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.setNum Teeth (numTeeth);
this.setSpots(spots);
this.setWeight (weight);
}
public int getNum Teeth() { return numTeeth; }
public void setNum Teeth (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; }
Transcribed Image Text:1 2 3 4 5 6 7 8 9 10 11 12 13 16 17 20 21 24 25 28 29 52 53 36 57 58 59 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.setNum Teeth (numTeeth); this.setSpots(spots); this.setWeight (weight); } public int getNum Teeth() { return numTeeth; } public void setNum Teeth (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; }
public class Lion extends Animal {
public Lion(int numTeeth, boolean spots, int weight) {
super (numTeeth, spots, weight);
}
Transcribed Image Text:public class Lion extends Animal { public Lion(int numTeeth, boolean spots, int weight) { super (numTeeth, spots, weight); }
Expert Solution
steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY