Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise : PetShopv2 points Let's Go! The PetShop is getting bigger! Using the Pet class provided, you will write and test a PetShop class with
Exercise : PetShopv2 points Let's Go! 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 train() 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. Status: Not Submitted @ PetShopv2 my A FILES PetShop.java PetShopRunner.java Pet.java 9- 10 12 19 1 public class PetShopRunner 2-1 3 boolean[] coinFlip = {true, false}; 4- String[] names = {"Fido", "Sassy", "Chance", "Dug", "Shadow", "Felix", "Fluffy", 5 "Norbert", "Hedwig", "Snuffles", "Garfield", "Milo", "Otis", "Shadowfax" "Nemo", "Dory", "Crush", "Bowser", "Yoshi", "Trevor", "Smagol", "Samwise", "Timon", "Pumbaa", "Sonic", "Gollum", "Luigi", "Koopa", "Goomba"}; 8 String[] types = {"dog", "cat", "turtle", "snake", "bearded dragon", "rabbit", "hamster", "hermit crab", "toad"}; 11 - String[] movement {"run", "walk", "crawl", "scuttle", "burrow", "slither", "Creep", "hop", "climb"}; 13 public static void main(String[] args) 14 - { 15 Pet newPet; 16 int randName; 17 int randType; 18 int randmove; int moveSpeed; 20 int flip; 21 double price; 22 PetShop theShop = new Petshop2(); 23 24 for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started