subject

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.

A set of classes using inheritance is used to represent animals observed at a wildlife sanctuary. A portion of the class hierarchy is shown in the following diagram.

The figure presents a diagram of a class hierarchy with three levels. The highest level has one class labeled Animal. The middle level has two classes labeled Carnivore and Herbivore. The lowest level has one class labeled Elephant. Three arrows are drawn: one from Elephant to Herbivore, one from Herbivore to Animal, and one from Carnivore to Animal.
All Animal objects have the following attributes.

A String variable indicating whether the animal is a carnivore or a herbivore
A String variable representing the animal species (e. g., lion, giraffe, zebra)
A String variable representing the name of the individual animal (e. g., Lisa, Gary, Percy)
The Animal class also contains a toString method that indicates the state of an animal.

The following table shows the intended behavior of the Animal class.

Statement Result
Animal lisa = new Animal("carnivore", "lion", "Lisa"); A new Animal object is created.
lisa. toString(); The string "Lisa the lion is a carnivore" is returned.
(a) Write the complete Animal class. Your implementation must meet all specifications and conform to the behavior shown in the table.

Question 2
The Herbivore class is a subclass of Animal. The Herbivore class does not contain any attributes or methods other than those found in the Animal class.

The constructor to the Herbivore class accepts two parameters for the species and name of the herbivore. The constructor passes those parameters along with the string literal "herbivore" to the Animal class to construct the object.

The following table shows the intended behavior of the Herbivore class.

Statement Result
Herbivore gary = new Herbivore("giraffe", "Gary"); A new Herbivore object is created.
gary. toString(); The string "Gary the giraffe is a
herbivore" is returned.
(b) Write the complete Herbivore class. Your implementation must meet all specifications and conform to the behavior shown in the table.

Question 3
The Elephant class is a subclass of Herbivore. The Elephant class contains one additional attribute not found in Herbivore: a double variable representing the length of the elephant’s tusks, in meters.

The constructor to the Elephant class accepts two parameters for the name and tusk length of the elephant. The constructor passes those parameters along with the string literal "elephant" to the Herbivore class to construct the object.

The following table shows the intended behavior of the Elephant class.

Statement Result
Elephant percy = new Elephant("Percy", 2.0); A new Elephant object is created.
percy. toString(); The string "Percy the elephant is a
herbivore with tusks 2.0 meters long" is returned.
(c) Write the complete Elephant class. Your implementation must meet all specifications and conform to the behavior shown in the table.

CAN ANYONE PROVIDE THE COLLEGEBOARD FILE FOR THE SOLUTION TO THIS FRQ? THIS IS AP COMPUTER SCIENCE A UNIT 9 FRQ.

ansver
Answers: 2

Other questions on the subject: Advanced Placement (AP)

image
Advanced Placement (AP), 22.06.2019 07:30, dawood7068
Why is terrorism a law enforcement concern? how is terrorism a violation of criminal law? what can the criminal justice system do to better prepare for future terrorist incidents?
Answers: 1
image
Advanced Placement (AP), 25.06.2019 09:10, firdausmohammed80
Describe one of your personality traits that you believe to be highly heritable and another trait that seems to be much less so. provide reasons for your answer, and explain why you would expect genetics to exert a greater impact on some personality traits than on others. 10. discuss at least 3 cultural/environmental factors that may influence behavior.
Answers: 3
image
Advanced Placement (AP), 25.06.2019 23:20, christinaS7696
You find a mysterious, dull substance on the ground and pick it up for a closer look. it is powdery, very light, and soft to the touch. the substance is most likely i. an organic mineral ii. a metallic mineral iii. a nonmetallic mineral i only ii only iii only i and ii i and iii
Answers: 1
image
Advanced Placement (AP), 27.06.2019 01:20, peteh5
Lost with this question (ap psych) 1. kaylee has a phobia. she is so afraid of spiders and insects that she avoids most outdoor activities and even refuses to go in the basement of her own house alone. provide a reason for her behavior from each of the two perspectives: learning biological/evolutionary 2. cecil is a college student who has ocd. even though his apartment is spotless, he is extremely nervous because his girlfriend is visiting his home for the first time. he is now preoccupied with thoughts that the germs in his apartment will make his girlfriend sick. in order to reduce his anxiety, he is now counting his heartbeats aloud as he washes his hands. provide a reason for his behavior from each of the three perspectives: learning biological/evolutionary psychoanalytical
Answers: 3
You know the right answer?
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the clas...

Questions in other subjects:

Konu
English, 11.10.2019 05:00