Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

language: java Q: PetShopRunner.java: Pet.java: PetShop.java: please give typed code, explanation, and output thank you! The PetShop is getting bigger! Using the Pet class provided,

language: java
Q:
image text in transcribed
PetShopRunner.java:
image text in transcribed
Pet.java:
image text in transcribed
PetShop.java:
image text in transcribed
please give typed code, explanation, and output thank you!
The PetShop is getting bigger! Using the Pet class provided, you will write and test a PetShop class with the following instance variables and functionality An ArrayList of Pets called roster, which will contain all Pets An floating-point variable, cashonHand, which will represent how much money the PetShop currently has. The PetShop should begin its day with $500. A method rosterSize() which will return the current size of the roster A method getCashOnHand(), which will return how much cash the Petshop currently has. A method getPet(int n), which will return the nth pet from the roster A method acquirePet(Pet thePet), which will add the instance variable of type Pet to the roster, but only if the PetShop can afford its cost. The Pet's cost should be deducted from the amount of cash on hand. This method should return a boolean value indicating whether or not the Pet was able to be acquired. A method sellPet(Pet thePet), which will remove the given Pet from the roster, and add the given Pet's price to the amount of cash on hand. This function should return a boolean value indicating whether or not the Pet was in the roster to be removed A method findPet(String name) that will look for and return the index of a Pet with the input name A method trainPet(Pet thePet), which will invoke the input Pet's traind method. This method should return true if it is able to train the Pet, and false if it is not able to do so. A method sortPetsByType(), which should arrange the Pets in the roster according to their Type A method sortPetsByName(), which should arrange the Pets in the roster according to their Name A method showcasePets(), which will traverse the roster, invoking each Pet's move and doTrick() methods. A valid toString method, which will print each pet in the roster on a separate line. 3 1 public class Pet ShopRunner 2- public static void main(String[] args) { S boolean[] coinFlip - {true false): 6 - String[] names- {"Fido" "Sassy""chance toug "Shadow Felix Fluffy 7 "Norbert", "Hedwig", "Snuffles Garfield Milootis "Shadowfax) 8 "Nemo", "Dory", "Crush" "BowserYoshi Trevor SmagolSamwise" 9 Timon", "Pumbaa", "Sonic Gollum uiginkoopan Goomba 10 - String types (dog) "catIturtlesnakeh bearded dragon 11 rabbit "hamster Thermit crab toad 12 - String() movement {"runwalk crawl scuttle", "burrow Slithers 13 creep", "hop", "climb"); 14 Pet newPet; 15 int randName; 16 int randType; 17 int randMove; 18 int moveSpeed; 19 int flips double price; 21 PetShop theShop - new PetShop(); 22 23 for (int 1; i 1 9 public string gets return a; 3 public string pettype() return type; 2 public double petcost) return cost; 1 public double getPrice) return prices > 36 37 40 41 I public void move() System.out.printiname the type oveType. sovespeed.feet.); > public void doTrick(string trick) if (isTrained) System.out.println(nonethe.type does trick . "."); 3 else 46 System.out.println("the type "looks confused by the command."); ) 51 52 53 54 55 56 57 sa- 32 se 61 62 public void train() isTrained - true 2 65 66 DISRESS public string tostring() string summarynane the type moveType - "5" (movespeed * 1e) - feet per minute and is If (isTrained) sumary "nat Sunary trained name is being sold for 5 " + price: return summarys 1 import java.util.ArrayList; 2 public class Pet Shop 3- { 4 5} 6

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

How likely is this public to act on information it receives?

Answered: 1 week ago