Question
Please check my code for errors agaisnt the assignment which is long. The parts Dog and rescueAnimals files cannot be changed nor the original given
Please check my code for errors agaisnt the assignment which is long. The parts Dog and rescueAnimals files cannot be changed nor the original given code in the Driver file only can modify where it allowed. I want mine to stay original. I think it is error free and I think it meets the assignment but need a check over please.
Competencies
In this project, you will demonstrate your mastery of the following competencies:
- Implement appropriate language constructs for an object-oriented programming language
- Write programs using object-oriented conventions in accordance with industry standard best practices
Scenario
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 C r8t Monkey.java class as your contribution to the team.
Required Pre-work
- 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.
- 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.
- Read through the code foreachclass 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
- Your team lead reminded you to demonstrateindustry standard best practicesin 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
- In a new Java file,create the Monkey class, using the specification document as a guide. The Monkey class must do the following:
- Inheritfrom the RescueAnimal class
- Implement all attributesto meet the specifications
- 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 mutatorsfor 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.
- As a reminder, you must demonstrateindustry standard best practices, such asin-line comments to denote changes and describe functionality and appropriate naming conventionsthroughout the code that you create or modify for this class.
- First, you will modify the main() method. In main(), you mustimplement menu loop that does the following:
- Displays the menuby calling the displayMenu() method. This method is in the Driver.java class.
- 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 actionbased on the value that the user entered.
- Next, you willcomplete the intakeNewDog() method. Your completed method should do the following:
- Prompt the user for input
- Include input validation. Note: The required input validation has already been included in the starter code; be sure to review it.
- Set data for all attributes based on user input
- Add the newly instantiated dog to an ArrayList
- Next, you willimplement the intakeNewMonkey() method. Before you begin, you will need to implementmonkey 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:
- 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.
- Set data for all attributes based on user input
- Add the newly instantiated monkey to an ArrayList
- Next, you willimplement 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 thereisan available animal which meets the user's input criteria, the method shouldaccess 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 alsoupdate the "reserved" attribute of the accessed animal.
- If there isnotan available animal which meets the user's input criteria, the method shouldoutput feedback to the userletting them know that no animals of that type and location are available.
- Finally, you have been asked toimplement 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 dogsorthe 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.
- 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.
now the code given for each 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; } }
rescue code
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 getAcquisitionLocation() { 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; } }
driver class
import java.util.ArrayList; import java.util.Scanner; public class Driver { private static ArrayList dogList = new ArrayList(); // Instance variables (if needed) public static void main(String[] args) { initializeDogList(); initializeMonkeyList(); // Add a loop that displays the menu, accepts the users input // and takes the appropriate action. // For the project submission you must also include input validation // and appropriate feedback to the user. // Hint: cr@8t Scanner and pass it to the necessary // methods // Hint: Menu options 4, 5, and 6 should all connect to the printAnimals() method. } // This method prints the menu options public static void displayMenu() { System.out.println(" "); 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 for testing public static void initializeMonkeyList() { } // 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().equalsIgnoreCase(name)) { System.out.println(" This dog is already in our system "); return; //returns to menu } } // Add the code to instantiate a new dog and add it to the appropriate list } // 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("The method intakeNewMonkey needs to be implemented"); } // 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("The method reserveAnimal needs to be implemented"); } // Complete printAnimals // Include the animal name, status, acquisition country and if the animal is reserved. // Remember that this method connects to three different menu items. // The printAnimals() method has three different outputs // based on the listType parameter // dog - prints the list of dogs // monkey - prints the list of monkeys // available - prints a combined list of all animals that are // fully trained ("in service") but not reserved // Remember that you only have to fully implement ONE of these lists. // The other lists can have a print statement saying "This option needs to be implemented". // To score "exemplary" you must correctly implement the "available" list. public static void printAnimals() { System.out.println("The method printAnimals needs to be implemented"); } }
BELOW IS THE CODE I DID . so when compiling them, driver class fromm above would be replaced with mine below and monkey would be added to the rest with dog rescue and driver. please I would love to see if I idid correct.
now my code for monkey
public class Monkey extends RescueAnimal { //Instance private String tailLength; private String height; private String bodyLength; private String species; //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); setGender(gender); setAge(age); setWeight(weight); setAcquisitionDate(acquisitionDate); setAcquisitionLocation(acquisitionCountry); setTrainingStatus(trainingStatus); setReserved(reserved); setInServiceCountry(inServiceCountry); setTailLength(tailLength); setHeight(height); setBodyLength(bodyLength); setSpecies(species); } //Assessor public String getSpecies() { return species; } //Mutator public void setSpecies(String species) { this.species = species; } //Accessor public String getTailLength() { return tailLength; } //mutator public void setTailLength(String tailLength) { this.tailLength = tailLength; } //acc public String getHeight() { return height; } //mut public void setHeight(String height) { this.height = height; } //acc public String getBodyLength() { return bodyLength; } //mut public void setBodyLength(String bodyLength) { this.bodyLength = bodyLength; } }
my code for driver
import java.util.ArrayList; import java.util.Scanner; public class Driver { private static ArrayList dogList = new ArrayList(); //had one for dog needed one for monkey private static ArrayList monkeyList = new ArrayList(); public static void main(String[] args) { initializeDogList(); initializeMonkeyList(); Scanner scanner = new Scanner(System.in); String choice; //starting the loop to display menu and get input from user do { displayMenu(); choice = scanner.nextLine(); //code will execute per user choice. switch (choice) { case "1": intakeNewDog(scanner); break; case "2": intakeNewMonkey(scanner); break; case "3": reserveAnimal(scanner); break; case "4": printAnimals("Dog"); break; case "5": //finish to print list of monkeys printAnimals("Monkey"); break; case "6": //need to implement and finish to print all printAnimals("Available"); break; case "q": System.out.println("Thank you, good bye!"); choice = "q"; break; default: System.out.println("Invalid choice."); break; } //continue expression }while (!choice.equals("q")); } // This method prints the menu options public static void displayMenu() { System.out.println(" "); 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 for testing public static void initializeMonkeyList() { } // 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().equalsIgnoreCase(name)) { System.out.println(" This dog is already in our system "); return; //returns to menu } } // Add the code to instantiate a new dog and add it to the appropriate list //will getall attributes for dog then add everything from user input System.out.println("Dog's breed: "); String breed = scanner.nextLine(); System.out.println("Dog's gender: "); String gender = scanner.nextLine(); System.out.println("Dog's age: "); String age = scanner.nextLine(); System.out.println("Dog's weight: "); String weight = scanner.nextLine(); System.out.println("Acquisition date: "); String acquisitionDate = scanner.nextLine(); System.out.println("Acquisition Country: "); String acquisitionCountry = scanner.nextLine(); System.out.println("Training status: "); String trainingStatus = scanner.nextLine(); System.out.println("Is dog reserved? "); boolean reserved = scanner.nextBoolean(); scanner.nextLine(); System.out.println("Dog's in-service country? "); String inServiceCountry = scanner.nextLine(); //new instance of Dog Dog dog = new Dog(name, breed, gender, age, weight, acquisitionDate, acquisitionCountry, trainingStatus,reserved, inServiceCountry); //setting type //add info to dog list dogList.add(dog); } // 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("Monkey's Name: "); String name = scanner.nextLine(); for(Monkey monkey: monkeyList) { if(monkey.getName().equalsIgnoreCase(name)) { System.out.println(" This Monkey is already in our system "); return; } } //getting species System.out.println("Monkey's species: "); String species = scanner.nextLine(); //now confirming species is allowed & prints error if not //added Squirrel monkey if (!species.equalsIgnoreCase("Capuchin") && !species.equalsIgnoreCase("Guenon") && !species.equalsIgnoreCase("Macaque") && !species.equalsIgnoreCase("Marmoset") && !species.equalsIgnoreCase("Tarmarin") && !species.equalsIgnoreCase("Squirrel Monkey")) { System.out.println("This is not an allowed species, sorry"); return; } //get info on new Monkey System.out.println("Monkey's gender: "); String gender = scanner.nextLine(); System.out.println("Monkey's age: "); String age = scanner.nextLine(); System.out.println("Monkey's weight: "); String weight = scanner.nextLine(); System.out.println("Acquisition date: "); String acquisitionDate = scanner.nextLine(); System.out.println("Acquisition Country: "); String acquisitionCountry = scanner.nextLine(); System.out.println("Tail length: "); String tailLength = scanner.nextLine(); System.out.println("Body length: "); String bodyLength = scanner.nextLine(); System.out.println("Height: "); String height = scanner.nextLine(); System.out.println("Training status: "); String trainingStatus = scanner.nextLine(); System.out.println("Is dog reserved? "); boolean reserved = scanner.nextBoolean(); scanner.nextLine(); System.out.println("Dog's in-service country? "); String inServiceCountry = scanner.nextLine(); //new monkey Monkey monkey = new Monkey(name, species, gender, age, weight, acquisitionDate, acquisitionCountry, reserved, bodyLength, height, trainingStatus, tailLength, inServiceCountry); monkeyList.add(monkey); } // Complete reserveAnimal // You will need to find the animal by animal type and in service country public static void reserveAnimal(Scanner scanner) { //getting input and finding if there are dogs in that location or monkey //and saying yes or no System.out.println("What is the animal type? "); String animalType = scanner.nextLine(); System.out.println("What is the country they are in service? "); String inServiceCountry = scanner.nextLine(); if(animalType.equalsIgnoreCase("Monkey")) { for(Monkey monkey: monkeyList) { if(monkey.getInServiceLocation().equalsIgnoreCase(inServiceCountry) && monkey.getReserved() == false) { monkey.setReserved(true); System.out.println("Reserved:" + monkey.toString()); } else { System.out.println("There are none available."); } } } else { for(Dog dog: dogList) { if(dog.getInServiceLocation().equalsIgnoreCase(inServiceCountry) && dog.getReserved()== false) { dog.setReserved(true); } else { System.out.println("There are none Available."); } } } } // Complete printAnimals // Include the animal name, status, acquisition country and if the animal is reserved. // Remember that this method connects to three different menu items. // The printAnimals() method has three different outputs // based on the listType parameter // dog - prints the list of dogs // monkey - prints the list of monkeys // available - prints a combined list of all animals that are // fully trained ("in service") but not reserved // Remember that you only have to fully implement ONE of these lists. // The other lists can have a print statement saying "This option needs to be implemented". // To score "exemplary" you must correctly implement the "available" list. public static void printAnimals(String Type) { //printing the list base on the type t if(Type.equals("Monkey")) { System.out.println("Monkey List"); for(Monkey monkey: monkeyList) { System.out.println(monkey.toString()); } } if(Type.equals("Dog")) { System.out.println("Dog List"); for(Dog dog: dogList) { System.out.println(dog.toString()); } } if(Type.equals("Available")) { System.out.println("All in service and available animals"); for(Monkey monkey: monkeyList) { if(monkey.getTrainingStatus().equalsIgnoreCase("in service") && !monkey.getReserved()) { System.out.println(monkey.toString()); } } for(Dog dog: dogList) { if(dog.getTrainingStatus().equalsIgnoreCase("in service") && !dog.getReserved()) { System.out.println(dog.toString()); } } } } }
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