Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please do questions a,b, and c. 7. This question involves managing the costs associated with animal adoption at an animal shelter Animals are defined by

please do questions a,b, and c. image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
7. This question involves managing the costs associated with animal adoption at an animal shelter Animals are defined by the following Animal class public class Animal 7. Constructs on Animal object with name n, type t, age a, and cost c/ public Animal(String n, String t, double a, int c) /* implementation not shown) y Returns the type of the animal (for example, "dog" or "cat")/ public String setType) { /* implenentation not shown) - Returns the age of the animal when it arrived at the shelter, in years / public double getage) { /* implementation not showny /" Returns the cost, in dollars, of adopting the animal public int getCost() implementation not shown 1 W There may be instance variables, constructors, and methods that are not shown Information about an animal shelter is stored in an Animalshelter object, which contains a list of the animals at the shelter. You will write two methods of the animal shelter class public class Animal Shelter C 7 A list of animals at the shelter, sorted by the age of the animal when it arrived at the shelter, from least to greatest Guaranteed not to be null and to contain only non null entries private ArrayListcaninal alzaninais; / Creates and returns new Animal object, as described in part () private Animal createlewinimal(String name, string type, double ace) Y to be implemented in part (a) / ) /** Adds an animal to the list allannals, described in part (5) public void addAnnal(String nane, string type, double age) IV to be implemented in part (0) 1/ There may be instance variables, constructors, and methods that are not shown animas IVONG (a) Write the Animalshelter method create animal. The method creates and returns a new Animal object. The animals name is given by the name parameter the animalstorie given by the type parameter, and the animal's age when it enters the shelter is given by the age parameter As animals come into the shelter the adoption cost in dollar, is determined by the well them and the number of animals of the same type, according to the following rules, . If the age of the animal is less than one year and the shelter has fewer than 5 animals with the given type, the cost is $25 . If the age of the animal is less than one year and the shelter has 5 or more animals with the given type, the cost is $20 Otherwise, the cost is $15. Complete method create animal Creates and returns new Animal object, described in part (a) private Animal create nal(String fame, String type, double age B EES (b) Write the Animal Shelter method addAnimal The method creates a new Animal object with name ane type ArrayList allanimals so that the sorted order of the list is maintained. The list is ordered by animal age from east to greatest Assume that create nimel works as specified. regardless of what you wrote for part ()You must te cresterately to received Complete method addAnisal. /** Adds an animal to the list all Animals, described in part (0) public void addaninal(String nane, String type, double age) B 1 ili 1/10000 (c) The programmer would like to add a method called petimalistInterest, which returns the animal that has been shown the greatest interromputers, www measured as the number of people who have asked Questions about the animal since the animal ved at the shelter Write a description of how you would change the Antal and Animalster classes in order to support this modification Make sure to include the following in your response Write the method hender for the gostinterest method Identify any new or modified variables, constructors of methods aside from the stainterest method Domet write the program code for Describe for each new or revised variable, constructor, or method, how it would change or be implemented including and you do not method. Do not write the program code for this change B /

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_2

Step: 3

blur-text-image_3

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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

Explain what a cloud computing is ?

Answered: 1 week ago