Document44

.docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

145

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

20

Uploaded by LieutenantMinkPerson650

Joel Hernandez IT-154 Project-2
//#1 Dog.java Class File public class Dog extends RescueAnimal { // Instance variable private String breed; // Constructor public Dog(String name, String breed, String gender, String age, String weight, String acquisitionDate, String acquisitionCountry, String trainingStatus, boolean reserved, String inServiceCountry) { setName(name); setBreed(breed); setGender(gender); setAge(age); setWeight(weight); setAcquisitionDate(acquisitionDate); setAcquisitionLocation(acquisitionCountry); setTrainingStatus(trainingStatus); setReserved(reserved); setInServiceCountry(inServiceCountry); } // Accessor Method public String getBreed() { return breed; } // Mutator Method public void setBreed(String dogBreed) {
breed = dogBreed; } } //#2 Driver.java Class File import java.util.ArrayList; import java.util.Scanner; public class Driver { // Instance variables (if needed) private static ArrayList<Dog> dogList = new ArrayList<Dog>(); private static ArrayList<Monkey> monkeyList = new ArrayList<Monkey>(); public static void main(String[] args) { initializeDogList(); initializeMonkeyList(); // Controls the menu traversal boolean acceptingInput = true; Scanner input = new Scanner(System.in); do { displayMenu(); String option = input.nextLine().trim().toLowerCase(); switch(option) { case "1": // Input a new dog intakeNewDog(input); break;
case "2": // Input a new monkey intakeNewMonkey(input); break; case "3": // Reserve an animal reserveAnimal(input); break; case "4": // Print all of the dogs printAnimals("dog"); break; case "5": // Print all of the monkies printAnimals("monkey"); break; case "6": // Print all non-reserved animals printAnimals("available"); break; case "q": // Quit acceptingInput = false;
break; default: System.out.println("Invalid option, please input a valid option"); break; } } while(acceptingInput); System.out.println("Goodbye"); } // This method prints the menu options public static void displayMenu() { System.out.println("\n\n"); System.out.println("\t\t\t\tRescue Animal System Menu"); System.out.println("[1] Intake a new dog"); System.out.println("[2] Intake a new monkey"); System.out.println("[3] Reserve an animal"); System.out.println("[4] Print a list of all dogs"); System.out.println("[5] Print a list of all monkeys"); System.out.println("[6] Print a list of all animals that are not reserved"); System.out.println("[q] Quit application"); System.out.println(); System.out.println("Enter a menu selection"); } // Adds dogs to a list for testing public static void initializeDogList() {
Dog dog1 = new Dog("Spot", "German Shepherd", "male", "1", "25.6", "05-12-2019", "United States", "intake", false, "United States"); Dog dog2 = new Dog("Rex", "Great Dane", "male", "3", "35.2", "02-03-2020", "United States", "Phase I", false, "United States"); Dog dog3 = new Dog("Bella", "Chihuahua", "female", "4", "25.6", "12-12-2019", "Canada", "in service", true, "Canada"); dogList.add(dog1); dogList.add(dog2); dogList.add(dog3); } // Adds monkeys to a list for testing (optional) public static void initializeMonkeyList() { Monkey monkey1 = new Monkey("Cappy", "Capuchin", "male", "1", "5.6", "15", "10", "5", "05-21- 2021", "United States", "intake", false, "United States"); Monkey monkey2 = new Monkey("Max", "Macaque", "male", "3", "15.2", "63", "53", "10", "02-29- 2002", "United States", "Phase I", false, "United States"); Monkey monkey3 = new Monkey("Tammy", "Tamarin", "female", "4", "1.6", "9", "1", "0.6", "12-21- 2012", "Canada", "in service", false, "Canada"); monkeyList.add(monkey1); monkeyList.add(monkey2); monkeyList.add(monkey3); } // Adds a new dog to `dogList` // intakeNewDog(scanner:Scanner) -> void public static void intakeNewDog(Scanner scanner) { System.out.println("What is the dog's name?"); String name = scanner.nextLine().trim();
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help