Answered step by step
Verified Expert Solution
Question
1 Approved Answer
GLOBALRAIN You work for Global Rain, a software engineering company that specializes in custom software design and development. As a junior software developer, you
GLOBALRAIN You work for Global Rain, a software engineering company that specializes in custom software design and development. As a junior software developer, you are part of a software development team at Global Rain that collaborates to create software solutions for entrepreneurs, businesses, and government agencies around the world. You have been newly assigned to a development team at Global Rain. This team is currently working on a project for an innovative international search and rescue animal training company, Grazioso Salvare. Grazioso Salvare is seeking a software application that will help track search and rescue animals, sometimes referred to as rescue animals. These rescue animals are obtained and trained by the company to rescue humans from difficult (or even life-threatening) situations. A portion of the work on this project has already been done. Your team lead has assigned you to create one new class and modify the existing driver class in the software application. You will deliver all the class files to the team lead, who will consolidate them with the work from other team members and present the application to your client. Directions Your team lead has given you a specification document detailing Grazioso Salvare's software needs. Other members of the Global Rain development team have already started creating the RescueAnimal.java, Dog.java, and Driver.java class files. Your team lead has asked you to modify the existing Driver.java class and create a Monkey.java class as your contribution to the team. Required Pre-work 1. To gain a clear understanding of the client's requirements, review the Grazioso Salvare Specification Document, located in the Supporting Materials section. As you read, pay close attention to the attributes and methods that you will need to implement into the program. 2. Open the Virtual Lab by clicking on the link in the Virtual Lab Access module. Then open the Eclipse IDE. Follow the Uploading Files to Eclipse Tutorial to upload the Grazioso.zip files into Eclipse. Both the tutorial and the zipped folder are located in the Supporting Materials section. The Grazioso.zip folder contains three class files. Once you upload the files, compile the code. Although the program is not complete, it should compile without error. 3. Read through the code for each class that you have been given. This will help you understand what code has been created and what code must be modified or created to meet the requirements. Once you have completed the pre-work, you are ready to begin your assigned tasks. Monkey.java Class 1. Your team lead reminded you to demonstrate industry standard best practices in all of your code to ensure clarity, consistency, and efficiency among all software developers working on the program. In your code for each class, be sure to include the following: In-line comments that denote your changes and briefly describe the functionality of each method or element of the class Appropriate variable and method naming conventions 2. In a new Java file, create the Monkey class, using the specification document as a guide. The Monkey class must do the following: o Inherit from the RescueAnimal class o Implement all attributes to meet the specifications o Include a constructor. You may use a default constructor. To score "exemplary" on this criterion, you must include the more detailed constructor that initializes values for all attributes. Refer to the constructor in the Dog class for an example. Include accessors and mutators for all implemented attributes Driver.java Class In this class, you will modify and implement several different methods. You will need to refer back to the code from the other classes to properly implement these methods. 1. As a reminder, you must demonstrate industry standard best practices, such as in-line comments to denote changes and describe functionality and appropriate naming conventions throughout the code that you create or modify for this class. 2. First, you will modify the main() method. In main(), you must create a menu loop that does the following: Displays the menu by calling the displayMenu() method. This method is in the Driver.java class. o Prompts the user for input Includes input validation. If the user inputs a value not on the menu, the program should print an error message. Takes the appropriate action based on the value that the user entered. IMPORTANT: In the Module Five milestone, you were asked to create a menu loop but were not required to include input validation. Be sure to include input validation for your Project Two submission. 3. Next, you will complete the intakeNewDog() method. Your completed method should do the following: o Prompt the user for input o Include input validation. Note: The required input validation has already been included in the starter code; be sure to review it. o Set data for all attributes based on user input Add the newly instantiated dog to an ArrayList Hint: Remember to refer to the accessors and mutators in the Dog and RescueAnimal classes as you create this method. 4. Next, you will implement the intakeNewMonkey() method. Before you do this, you will need to create a monkey ArrayList in the Driver.java class. Refer to the dog ArrayList for an example. Then, begin implementing the intakeNewMonkey() method. Your completed method should do the following: o Prompt the user for input Include input validation for the monkey's name and species type. If the user enters an invalid option, the program should print an error message. o Set data for all attributes based on user input Add the newly instantiated monkey to an ArrayList Hint: Remember to refer to the accessors and mutators in your Monkey and RescueAnimal classes as you create this method. IMPORTANT: In the Module Five milestone, you began implementing this method but were not required to include input validation. Be sure to include input validation for your Project Two submission. 5. Next, you will implement the reserveAnimal() method. Your completed method should do the following: Prompt the user for input. The user should enter their desired animal type and country. If there is an available animal which meets the user's input criteria, the method should access an animal object from an ArrayList. If there are multiple animals that meet these criteria, the program should access the first animal in the ArrayList. The method should also update the "reserved" attribute of the accessed animal. o If there is not an available animal which meets the user's input criteria, the method should output feedback to the user letting them know that no animals of that type and location are available. 6. Finally, you have been asked to implement a printAnimals() method that provides easy-to-read output displaying the details of objects in an ArrayList. To demonstrate this criterion in a "proficient" way, your implemented method must successfully print the ArrayList of dogs or the ArrayList of monkeys. To demonstrate this criterion in an "exemplary" way, your implemented method must successfully print a list of all animals that are "in service" and "available". What to Submit To complete this project, you must submit the following: Grazioso.zip (Eclipse Project File) Your submission for this project should be a zipped folder that contains all four of the following files. Use the Downloading Files from Eclipse Tutorial in the Supporting Materials section to help you download these files. What to Submit To complete this project, you must submit the following: Grazioso.zip (Eclipse Project File) Your submission for this project should be a zipped folder that contains all four of the following files. Use the Downloading Files from Eclipse Tutorial in the Supporting Materials section to help you download these files. RescueAnimal.java Class File: You were not required to make changes to this file, but you must include it as part of your submission. Dog.java Class File: You were not required to make changes to this file, but you must include it as part of your submission. Monkey.java Class File. You created this class from scratch, implementing attributes, a constructor, accessors, and mutators. You should have included in-line comments and clear variable naming conventions. Driver.java Class File. You were given some starter code within this file, and were asked to modify or implement a menu loop and methods to intake dogs, intake monkeys, reserve animals, and print animals. You were also asked to include input validation for certain methods and in- line comments describing your changes. Feedback Good start! Looks like you have attempted all of the requirements. However, some of the requirements are not functioning as expected. Please check rubric for details. 117.95 / 150 C+ Make sure you can execute your Driver class and test the requirements below. Monkey.java: Creating a Class (5-4) - Created a class that inherits from another class and implements all attributes with appropriate data structures, a constructor, accessors, and mutators to meet software requirements. Constructor initializes values for all attributes. Driver.java: Menu Loop (5-4) - Created a loop that displays a menu, reads user input, and takes action based on the input. Driver.java: intakeNewDog() Method (7-1) - Completed a method that prompts the user for input, sets data for attributes, and adds an object to an array Driver.java: intakeNewMonkey() Method (5-4) - Implements a method that prompts the user for input, sets data for attributes, and adds an object to an ArrayList Driver.java: Input Validation for Menu Loop and intakeNewMonkey() Method (5-4 & 7-1) - Validates user input by checking for invalid values and printing an error message if invalid input occurs. Driver.java: reserve Animal() Method (7-1) - Implemented a method that prompts the user for input and handles the input appropriately by accessing and updating an object's attribute or outputting feedback to the user Driver.java: printAnimals() Method (7-1) - Implements a method that provides easy-to-read output displaying the details of objects in an ArrayList To score "exemplary" you must correctly implement the "available" list. It is best to start the 7-1 assignment with your 5-4 100% completed assignment. Make sure you check the requirements for this assignment and watch the Week 7 Live Chat. URLs for the Chats can be found in the Live Chat announcement. You can resubmit. 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); setAcquisition Location (acquisitionCountry); setTrainingStatus (trainingStatus); setReserved (reserved); setInServiceCountry (inServiceCountry); } // Accessor Method public String getBreed() { return breed; } // Mutator Method public void setBreed (String dogBreed) { breed = dog Breed; } 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); setAcquisition Location (acquisitionCountry); setTrainingStatus (trainingStatus); setReserved (reserved); setInServiceCountry (inServiceCountry); } // Accessor Method public String getBreed() { return breed; } // Mutator Method public void setBreed (String dogBreed) { breed = dog Breed; } import java.sql.Array; import java.util.ArrayList; import java.util.Scanner; @SuppressWarnings ("unused") public class Driver { private static ArrayList dogList = new ArrayList (); private static ArrayList monkeyList = new ArrayList (); private static ArrayList monkeySpecies = new ArrayList (); // Instance variables (if needed) Object listDogs = new Object(); public static void main(String[] args) { initializeDogList(); initializeMonkeyList(); initializeMonkeySpecies(); Scanner scnr = new Scanner(System.in); displayMenu(); String userIn = scnr.nextLine(); while (!userIn.equals IgnoreCase("Q")) { if (userIn.equals("1")) { intakeNewDog (scnr); userIn = scnr.nextLine(); } if } if } if (userIn.equals("2")) { } intakeNewMonkey (scnr); userIn = scnr.nextLine(); (userIn.equals("3")) { } reserveAnimal (scnr); userIn = scnr.nextLine(); (userIn.equals("4")) { } if (userIn.equals("5")) { else { printAnimals("dog"); userIn = scnr.nextLine(); } if (userIn.equals("6")) { printAnimals("monkey"); userIn = scnr.nextLine(); printAnimals("available"); userIn = scnr.nextLine(); System.out.println("Invalid input"); displayMenu(); userIn = scnr.nextLine(); if (userIn.equals IgnoreCase("q")) { System.out.println("Exiting program"); scnr.close(); } // This method prints the menu options public static void displayMenu() { System.out.println(" "); System.out.println("\t\t\t\tRescue ...... } System.exit(0); } 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"); Print a list of all monkeys"); System.out.println("[5] 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() { b.... } "25.6", "05-12-2019", "United States", "intake", false, "United States"); Dog dog1 = new Dog("Spot", "German Shepherd", "male" "1", 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 for testing public static void initializeMonkeyList() { Monkey monkey1 = new Monkey("Billy", "male", "1", "25.6", "05-12-2019", "United States", "intake", false, "United States", "2", "3", "6", "Capuchin"); monkeyList.add (monkey1); } // Adding a new list for available species for monkey public static void initializeMonkeySpecies() { String species1 = new String("capuchin"); String species2 = new String("guenon"); String species3 = new String ("macaque"); String species4 = new String("marmoset"); String species5 = new String("squirrel monkey"); String species6 = new String("tamarin"); I monkeySpecies.add(species1); monkeySpecies.add(species2); monkeySpecies.add(species3); monkeySpecies.add(species4); monkeySpecies.add(species5); monkeySpecies.add(species6); // Complete the intakeNewDog method // The input validation to check that the dog is not already in the list // is done for you public static void intakeNewDog (Scanner scanner) { System.out.println("What is the dog's name?"); String name = scanner.nextLine(); for(Dog dog: dogList) { if(dog.getName().equals IgnoreCase (name)) { System.out.println(" This dog is already in our system "); return; //returns to menu } } else { try { } dog.setName(name); System.out.println("What is the dog's breed?"); dog.setBreed (scanner.nextLine()); System.out.println("What is the dog's gender?"); dog.setGender (scanner.nextLine()); System.out.println("What is the dog's age?"); dog.setAge(scanner.nextLine()); } else { try { System.out.println("What is the dog's weight"); dog.setWeight (scanner.nextLine()); System.out.println("When was the dog aquisitioned?"); dog.setAcquisitionDate(scanner.nextLine()); System.out.println("Where was the dog aquisitioned?"); dog.setAcquisition Location(scanner.nextLine()); System.out.println("What is the dog's training status?"); dog.setTraining Status (scanner.nextLine()); System.out.println("Is the dog reserved?"); dog.setReserved (scanner.nextBoolean()); if (dog.getReserved () == true) { System.out.println("What country is the dog in service?"); dog.setInServiceCountry (scanner.nextLine()); System.out.println(" Dog created "); } } catch (Exception excpt) { displayMenu(); return; System.out.println(excpt.getMessage()); System.out.println("Please try again."); displayMenu(); return; // Complete intakeNewMonkey //Instantiate and add the new monkey to the appropriate list // For the project submission you must also validate the input // to make sure the monkey doesn't already exist and the species type is allowed public static void intakeNewMonkey (Scanner scanner) { System.out.println("What is the monkey's name?"); String name = scanner.nextLine(); for (Monkey monkey: monkeyList) { if(monkey.getName().equals IgnoreCase(name)) { System.out.println(" This monkey is already in our system "); return; //returns to menu monkey.setName (name); System.out.println("What is the monkey's species?"); String species = scanner.nextLine().toLowerCase(); if (!monkeySpecies. contains (species)) { throw new Exception ("Invalid species"); } else { } monkey.setSpecies (species); System.out.println("What is the monkey's gender?"); monkey.setGender(scanner.nextLine()); System.out.println("What is the monkey's age?"); monkey.setAge(scanner.nextLine()); System.out.println("What is the monkey's weight?"); monkey.setWeight (scanner.nextLine()); System.out.println("What is the monkey's tail length?"); monkey.setTailLength(scanner.nextLine()); System.out.println("What is the monkey's height?"); monkey.setHeight (scanner.nextLine()); System.out.println("What is the monkey's body length?"); monkey.setBodyLength(scanner.nextLine()); System.out.println("When was the monkey aquisitioned?"); monkey.setAcquisitionDate(scanner.nextLine()); System.out.println("Where was the monkey aquisitioned?"); monkey.setAcquisition Location(scanner.nextLine()); System.out.println("What is the monkey's training status?"); monkey.setTrainingStatus (scanner.nextLine()); System.out.println("Is the monkey reserved?"); monkey.setReserved (scanner.nextBoolean()); if (monkey.getReserved () == true) { } System.out.println("What country is the monkey in service?"); monkey.setInServiceCountry (scanner.nextLine()); System.out.println(" Monkey created "); displayMenu(); return; catch (Exception excpt) { System.out.println(excpt.getMessage()); stem.out.println("Please try again."); displayMenu(); return; } // Complete reserveAnimal // You will need to find the animal by animal type and in service country public static void reserveAnimal (Scanner scanner) { System.out.println("Select species."); String species = scanner.nextLine(); if (species.equals IgnoreCase("dog")) { for (Dog dog: dogList) { System.out.println("Enter name of dog."); String name = scanner.nextLine(); } if(dog.getName().equals IgnoreCase (name)) { } else { } } System.out.println("Set dog reserved true or false?"); dog.setReserved (scanner.nextBoolean()); return; System.out.println("Dog does not exist."); return; } else if (species.equals IgnoreCase ("monkey")) { for (Monkey monkey: monkeyList) { } System.out.println("Enter name of monkey."); String name = scanner.nextLine(); if (monkey.getName().equalsIgnoreCase(name)) { } else { System.out.println("Set monkey reserved true or false?"); monkey.setReserved (scanner.nextBoolean()); return; } public static void printAnimals (String choice) { if (choice.equals IgnoreCase("dog")) { for (Dog dog: dogList) { } return; System.out.println("Monkey does not exist."); } if (choice.equals IgnoreCase ("monkey")) { for (Monkey monkey: monkeyList) { } System.out.println(dog.getName()); } // Gets each animal from its respective list, checks if they are reserved, and if false prints their name and species/breed. if (choice.equals IgnoreCase("available")) { for (Dog dog: dogList) { System.out.println(monkey.getName()); if (dog.getReserved ( ) false) { System.out.println(dog.getName() + " + dog.getBreed()); I == for (Monkey monkey: monkeyList) { if (monkey.getReserved () == false) { } 11 System.out.println(monkey.getName() + 11 System.out.println("Press any key to continue."); I + monkey.getSpecies ()); public class Monkey extends RescueAnimal { // Instance variable private String tailLength; private String height; private String bodyLength; private String species; } // Available monkey species String[] monkeySpecies = {"Capuchin", "Guenon", "Macaque", "Marmoset", "Squirrel Monkey", "Tamarin"}; // Constructor public Monkey (String name, String gender, String age, String weight, String acquisitionDate, String acquisitionCountry, String trainingStatus, boolean reserved, String inServiceCountry, String tailLength, String height, String bodyLength, String species) { setName (name); set Gender (gender); setAge(age); setWeight (weight); } setAcquisitionDate(acquisitionDate); setAcquisition Location (acquisitionCountry); setTrainingStatus (trainingStatus); setReserved (reserved); setInServiceCountry (inServiceCountry); set Tail Length (tailLength); setHeight (height); set Body Length (bodyLength); setSpecies (species); // Accessor methods public String getTailLength() { return tailLength; } public String getHeight() { return height; } public String getBodyLength() { return bodyLength; } public String getSpecies() { return species; } public void setTailLength (String monkeyTailLength) { tailLength = monkeyTailLength; } public void setHeight (String monkeyHeight) { height = monkeyHeight; } public void setBodyLength (String monkey BodyLength) { bodyLength = monkey BodyLength; } public void setSpecies (String monkeySpecies) { species = monkeySpecies; } import java.lang.String; public class RescueAnimal { // Instance variables private String name; private String animalType; private String gender; private String age; private String weight; private String acquisitionDate; private String acquisitionCountry; private String trainingStatus; private boolean reserved; private String inServiceCountry; // Constructor public RescueAnimal() { } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAnimalType() { return animalType; } public void setAnimalType(String animalType) { this.animalType = animalType; } public String getGender() { return gender; } public void setGender (String gender) { this.gender = gender; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public String getWeight() { return weight; } public void setWeight (String weight) { this.weight weight; } = public String getAcquisitionDate() { return acquisitionDate; } public void setAcquisitionDate(String acquisitionDate) { } this.acquisitionDate = acquisitionDate; public String getAcquisition Location () { return acquisitionCountry; } public void setAcquisitionLocation(String acquisitionCountry) { } this.acquisitionCountry = acquisitionCountry; public boolean getReserved () { return reserved; } public void setReserved (boolean reserved) { this.reserved = reserved; } public String getInServiceLocation () { return inServiceCountry; } public void setInServiceCountry (String inServiceCountry) { this.inServiceCountry = inServiceCountry; } } public String getTrainingStatus() { return trainingStatus; } public void setTrainingStatus(String trainingStatus) { this.trainingStatus = trainingStatus;
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