Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with modifying the Driver.java Class File . You were given some starter code within this file, and were asked to modify or

I need help with modifying the 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 should have included in-line comments to describe your changes.

The Starter code for the Driver class file is below

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: create a 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");

} }

To gain a clear understanding of the clients requirements, review the Grazioso Salvare Specification Document PDF. 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 PDF to upload the Grazioso ZIP folder into Eclipse. The Grazioso.zip folder contains three starter code files: Driver.java, RescueAnimal.java, and Dog.java. Once you have uploaded the files, compile the code. Although the program is not complete, it should compile without error.

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.

You have been asked to demonstrate industry standard best practices in all the code that you create 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:

Inherit from the RescueAnimal class.

Implement all attributes to 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 takes all values for the attributes and sets them. Refer to the constructor in the Dog class for an example.

Include accessors and mutators for all implemented attributes.

In the Driver.java class, 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.

Prompts the user for input

Takes the appropriate action based on the value that the user entered

IMPORTANT: You do not need to complete all of the methods included in the menu for this milestone. Simple placeholder print statements for these methods have been included in the starter code so that you can test your menu functionality.

Next, you will need to create a monkey ArrayList in the Driver.java class. Refer to the dog ArrayList, which is included right before main(), as an example. Creating this ArrayList is necessary for the intakeNewMonkey() method, which you will implement in the next step. Though it is not required, it may be helpful to pre-populate your ArrayList with a few test monkey objects in the initializeMonkeyList() method.

Finally, you will implement the intakeNewMonkey() method in the Driver.java class. Your completed method should do the following:

Prompt the user for input.

Set data for all attributes based on user input.

Add the newly instantiated monkey to an ArrayList.

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

More Books

Students also viewed these Databases questions

Question

=+5. What is the prenatal development sequence?

Answered: 1 week ago