Question

In: Computer Science

PLEASE MODIFY CODE IN JAVA In-line comments denote your changes and briefly describe the functionality of...

PLEASE MODIFY CODE IN JAVA
In-line comments denote your changes and briefly describe the functionality of each method or element of the class
Appropriate variable and method naming conventions are used throughout your code.
modify the Driver.java class file to do the following:
Implement the method you have chosen
Add attributes, as needed, to support the required functionality
SYSTEM REQUIREMENTS-

Each dog goes through a six- to nine month training regimen before they are put into service. Part of our process is to record and track several data points about the rescue animals.

Dogs are given the status of "intake" before training starts. Once in training, they move through a set of five rigorous phases: Phase I, Phase II, Phase III, Phase IV, and Phase V. While in training, a dog is given the status of its current training phase (e.g., "Phase I"). When a dog graduates from training, it is given the status of "in service" and is eligible for use by clients. If a dog does not successfully make it through training, it is given the status of "farm," indicating that it will live a life of leisure on a Grazioso Salvare farm.

The Animals Through years of experience, we have narrowed the list of dog breeds eligible for rescue training to the following:

• American pit bull terrier

• Beagle

• Belgian Malinois

• Border collie •

Bloodhound

• Coonhound

• English springer spaniel

• German shepherd

• German shorthaired pointer

• Golden retriever

• Labrador retriever

• Nova Scotia duck tolling retriever

• Rough collie

• Smooth collie

When we acquire a dog, we record the breed, gender, age, weight, date, and the location where we obtained them. There is usually a short lag time between when we acquire a dog and when they start training, which we document as well. Additionally, we track graduation dates, dates dogs are placed into "service," and details about the dogs' in-service placement (agency, city, country, and name, email address, phone number, and mailing address for the agency's point of contact).

DRIVER JAVA CODE

public class Driver {

public static void main(String[] args) {

// Class variables

// Create New Dog

// Method to process request for a rescue animal

// Method(s) to update information on existing animals

// Method to display matrix of aninmals based on location and status/training phase

// Method to add animals

// Method to out process animals for the farm or in-service placement

// Method to display in-service animals

// Process reports from in-service agencies reporting death/retirement

}

}


im not sure what store in databse or files means. just follow the //comments on what to put

Solutions

Expert Solution

Hi, Please find the solution. Please use the ways of coding in this answer to achieve what you need, Thanks.

import java.time.LocalDate;

public class RescueAnimal {
    int age;
    float weight;
    float height;

    public RescueAnimal() {
        placement =  new Placement();
    }

    LocalDate obtainedDate;

    String obtainedLocation;//keeping simple
    int lagtimeInHoursBeforeTraining;
    LocalDate graduationDate;
    LocalDate serviceStartDate;
    Placement placement;
    Status status;
    Breeds breeds;
    Phases phase;
    Gender gender;


    enum Gender{
        MALE,FEMALE;
    }

    enum Status {
        INTAKE, TRAINING, INSERVICE, FARM;
    }
    enum Phases {
        PHASE1, PHASE2, PHASE3, PHASE4, PHASE5;

    }


    enum Breeds {
        Americanpitbullterrier,
        Beagle,
        BelgianMalinois,
        Bordercollie,
        Bloodhound,
        Coonhound,
        Englishspringerspaniel,
        Germanshepherd,
        Germanshorthairedpointer,
        Goldenretriever, Labradoretriever,
        NovaScotiaducktollingretriever,
        Roughcollie, Smoothcollie;
    }
    public float getHeight() {
        return height;
    }

    public void setHeight(float height) {
        this.height = height;
    }
    class Placement{
        String agency,city,country,name,email,address,mailAddress,phoneNoAgency;

        @Override
        public String toString() {
            return "Placement{" +
                    "agency='" + agency + '\'' +
                    ", city='" + city + '\'' +
                    ", country='" + country + '\'' +
                    ", name='" + name + '\'' +
                    ", email='" + email + '\'' +
                    ", address='" + address + '\'' +
                    ", mailAddress='" + mailAddress + '\'' +
                    ", phoneNoAgency='" + phoneNoAgency + '\'' +
                    '}';
        }

        public String getAgency() {
            return agency;
        }

        public void setAgency(String agency) {
            this.agency = agency;
        }

        public String getCity() {
            return city;
        }

        public void setCity(String city) {
            this.city = city;
        }

        public String getCountry() {
            return country;
        }

        public void setCountry(String country) {
            this.country = country;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getMailAddress() {
            return mailAddress;
        }

        public void setMailAddress(String mailAddress) {
            this.mailAddress = mailAddress;
        }

        public String getPhoneNoAgency() {
            return phoneNoAgency;
        }

        public void setPhoneNoAgency(String phoneNoAgency) {
            this.phoneNoAgency = phoneNoAgency;
        }
    }

    @Override
    public String toString() {
        return "RescueAnimal{" +
                "age=" + age +
                ", weight=" + weight +
                ", height=" + height +
                ", obtainedDate=" + obtainedDate +
                ", obtainedLocation='" + obtainedLocation + '\'' +
                ", lagtimeInHoursBeforeTraining=" + lagtimeInHoursBeforeTraining +
                ", graduationDate=" + graduationDate +
                ", serviceStartDate=" + serviceStartDate +
                ", placement=" + placement +
                ", status=" + status +
                ", breeds=" + breeds +
                ", phase=" + phase +
                ", gender=" + gender +
                '}';
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public float getWeight() {
        return weight;
    }

    public void setWeight(float weight) {
        this.weight = weight;
    }

    public LocalDate getObtainedDate() {
        return obtainedDate;
    }

    public void setObtainedDate(LocalDate obtainedDate) {
        this.obtainedDate = obtainedDate;
    }

    public String getObtainedLocation() {
        return obtainedLocation;
    }

    public void setObtainedLocation(String obtainedLocation) {
        this.obtainedLocation = obtainedLocation;
    }

    public int getLagtimeInHoursBeforeTraining() {
        return lagtimeInHoursBeforeTraining;
    }

    public void setLagtimeInHoursBeforeTraining(int lagtimeInHoursBeforeTraining) {
        this.lagtimeInHoursBeforeTraining = lagtimeInHoursBeforeTraining;
    }

    public LocalDate getGraduationDate() {
        return graduationDate;
    }

    public void setGraduationDate(LocalDate graduationDate) {
        this.graduationDate = graduationDate;
    }

    public LocalDate getServiceStartDate() {
        return serviceStartDate;
    }

    public void setServiceStartDate(LocalDate serviceStartDate) {
        this.serviceStartDate = serviceStartDate;
    }

    public Placement getPlacement() {
        return placement;
    }

    public void setPlacement(Placement placement) {
        this.placement = placement;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Breeds getBreeds() {
        return breeds;
    }

    public void setBreeds(Breeds breeds) {
        this.breeds = breeds;
    }

    public Phases getPhase() {
        return phase;
    }

    public void setPhase(Phases phase) {
        this.phase = phase;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }
}
import java.time.LocalDate;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        RescueAnimal dog = new RescueAnimal();
        Scanner sc = new Scanner(System.in);
        Main x = new Main();
        x.rescueAnimal(dog,sc);
        System.out.println(dog);


    }
    public void rescueAnimal(RescueAnimal dog,Scanner sc){
        System.out.println("Enter weight");
        dog.setWeight(sc.nextFloat());
        System.out.println("Enter height");
        dog.setHeight(sc.nextFloat());
        System.out.println("Enter (f)for female (m) for male");
        dog.setGender(sc.next().charAt(0)=='f'? RescueAnimal.Gender.FEMALE:RescueAnimal.Gender.MALE);
        System.out.println("Is the dog in INTAKE(i), TRAINING(t), INSERVICE(s), FARM(f)?");
        char c = sc.next().toLowerCase().charAt(0);
        if(c =='i'){
            dog.setStatus(RescueAnimal.Status.INTAKE);
        }
        if(c =='s'){
            dog.setStatus(RescueAnimal.Status.INSERVICE);
        }
        if(c =='f'){
            dog.setStatus(RescueAnimal.Status.FARM);
        }
        if(c =='t'){
            dog.setStatus(RescueAnimal.Status.TRAINING);
        }
        System.out.println("Which Phase 1,2,3,4,5");
        int choice = sc.nextInt();
        if(choice==1){
            dog.setPhase(RescueAnimal.Phases.PHASE1);
        }if(choice==2){
            dog.setPhase(RescueAnimal.Phases.PHASE2);
        }if(choice==3){
            dog.setPhase(RescueAnimal.Phases.PHASE3);
        }if(choice==4){
            dog.setPhase(RescueAnimal.Phases.PHASE4);
        }if(choice==5){
            dog.setPhase(RescueAnimal.Phases.PHASE5);
        }
        System.out.println("Enter lagtimeInHoursBeforeTraining");
        dog.setLagtimeInHoursBeforeTraining(sc.nextInt());
//        System.out.println("");
        int i=1;
        for (RescueAnimal.Breeds br: RescueAnimal.Breeds.values()){
            System.out.println("Enter "+i++ + " for "+br.toString());
        }
        choice = sc.nextInt();
        dog.setBreeds(RescueAnimal.Breeds.values()[choice-1]);

        System.out.println("Enter Graduation date: dd");
        int day = sc.nextInt();
        System.out.println("Enter Graduation Date:mm");
        int month = sc.nextInt();
        System.out.println("Enter Graduation Date:yyyy");
        int year = sc.nextInt();
        LocalDate graDate = LocalDate.of(year, month, day);
        System.out.println("Service start date: dd");
         day = sc.nextInt();
        System.out.println("Service start date:mm");
         month = sc.nextInt();
        System.out.println("Service start date:yyyy");
         year = sc.nextInt();
        LocalDate serviceDate = LocalDate.of(year, month, day);
        dog.setServiceStartDate(serviceDate);
        dog.setGraduationDate(graDate);

        System.out.println("Agency name?");
//        dog.placement =  new RescueAnimal()
        RescueAnimal.Placement placement = dog.placement;
        placement.setAgency(sc.next());
        System.out.println("Agency address?");
        placement.setAddress(sc.next());
        System.out.println("Agency city?");
        placement.setCity(sc.next());
        System.out.println("Agency Country?");
        placement.setCountry(sc.next());
        System.out.println("Agency Email?");
        placement.setEmail(sc.next());
        System.out.println("Agency Mail addrsss?");
        placement.setMailAddress(sc.next());
        System.out.println("Agency Phone number?");
        placement.setPhoneNoAgency(sc.next());

        dog.setPlacement(placement);
        return;


    }
}
Sample out:


Related Solutions

JAVA programming language Please add or modify base on the given code Adding functionality Add functionality...
JAVA programming language Please add or modify base on the given code Adding functionality Add functionality for multiplication (*) Adding JUnit tests Add one appropriately-named method to test some valid values for tryParseInt You will use an assertEquals You'll check that tryParseInt returns the expected value The values to test: "-2" "-1" "0" "1" "2" Hint: You will need to cast the return value from tryParseInt to an int e.g., (int) ValidationHelper.tryParseInt("1") Add one appropriately-named method to test some invalid...
Given the following code for AES Electronic Code Block implementation for the encryption functionality. Modify the...
Given the following code for AES Electronic Code Block implementation for the encryption functionality. Modify the code to create a function named ‘encryptECB(key, secret_message)’ that accepts key and secret_message and returns a ciphertext.          #Electronic Code Block AES algorithm, Encryption Implementation from base64 import b64encode from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Random import get_random_bytes secret_message = b" Please send me the fake passport..." password = input ("Enter password to encrypt your message: ") key= pad(password.encode(), 16) cipher...
Please add comments to this code! JAVA Code: import java.text.NumberFormat; public class Item {    private...
Please add comments to this code! JAVA Code: import java.text.NumberFormat; public class Item {    private String name;    private double price;    private int bulkQuantity;    private double bulkPrice;    /***    *    * @param name    * @param price    * @param bulkQuantity    * @param bulkPrice    */    public Item(String name, double price, int bulkQuantity, double bulkPrice) {        this.name = name;        this.price = price;        this.bulkQuantity = bulkQuantity;        this.bulkPrice = bulkPrice;   ...
4. Given the following code for AES Electronic Code Block implementation for the encryption functionality. Modify...
4. Given the following code for AES Electronic Code Block implementation for the encryption functionality. Modify the code to create a function named ‘decryptECB(key, ciphertext)’ that accepts key and ciphertext and returns a plaintext. from base64 import b64decode from Crypto.Cipher import AES from Crypto.Util.Padding import pad from Crypto.Util.Padding import unpad # We assume that the password was securely shared beforehand password = input ("Enter the password to decrypt the message: ") key= pad(password.encode(), 16) ciphertext = input ("Paste the cipher...
Please add comments to this code! JAVA code: import java.util.ArrayList; public class ShoppingCart { private final...
Please add comments to this code! JAVA code: import java.util.ArrayList; public class ShoppingCart { private final ArrayList<ItemOrder> itemOrder;    private double total = 0;    private double discount = 0;    ShoppingCart() {        itemOrder = new ArrayList<>();        total = 0;    }    public void setDiscount(boolean selected) {        if (selected) {            discount = total * .1;        }    }    public double getTotal() {        total = 0;        itemOrder.forEach((order) -> {            total +=...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog {...
Can you please add comments to this code? JAVA Code: import java.util.ArrayList; public class Catalog { String catalog_name; ArrayList<Item> list; Catalog(String cs_Gift_Catalog) { list=new ArrayList<>(); catalog_name=cs_Gift_Catalog; } String getName() { int size() { return list.size(); } Item get(int i) { return list.get(i); } void add(Item item) { list.add(item); } } Thanks!
in java code Modify your program as follows: Ask the user for the number of hours...
in java code Modify your program as follows: Ask the user for the number of hours worked in a week and the number of dependents as input, and then print out the same information as in the initial payroll assignment. Perform input validation to make sure the numbers entered by the user are reasonable (non-negative, not unusually large, etc). Let the calculations repeat for several employees until the user wishes to quit the program. Remember: Use variables or named constants...
OPERATING SYSTEMS HOMEWORK: PLEASE CODE IN JAVA with comments & POST SCREENSHOTS OF OUTPUTS SCAN This...
OPERATING SYSTEMS HOMEWORK: PLEASE CODE IN JAVA with comments & POST SCREENSHOTS OF OUTPUTS SCAN This algorithm is performed by moving the R/W head back-and-forth to the innermost and outermost track. As it scans the tracks from end to end, it process all the requests found in the direction it is headed. This will ensure that all track requests, whether in the outermost, middle or innermost location, will be traversed by the access arm thereby finding all the requests. This...
JAVA CODE, BEGINERS; Please use comments to explain For all of the following words, if you...
JAVA CODE, BEGINERS; Please use comments to explain For all of the following words, if you move the first letter to the end of the word, and then spell the result backwards, you will get the original word: banana dresser grammar potato revive uneven assess Write a program that reads a word and determines whether it has this property. Continue reading and testing words until you encounter the word quit. Treat uppercase letters as lowercase letters.
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in...
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in Programming Project 8 from Chapter 2. This time ask the user to input the string “M” if the user is a man and “W” if the user is a woman. Use only the male formula to calculate calories if “M” is entered and use only the female formula to calculate calories if “W” is entered. Output the number of chocolate bars to consume as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT