Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP ME WITH THIS PROBLEM AS QUICK AS YOU CAN. That would really help me out greatly. THANK YOU! age = class Dog {

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

PLEASE HELP ME WITH THIS PROBLEM AS QUICK AS YOU CAN. That would really help me out greatly. THANK YOU! age = class Dog { int age; String name; public Dog (String dogName, int dogAge) { dogAge; name = dogName; } public void bark() { System.out.println("Woof! Woof!"); } public int getAge() { return age; } public String getName() { return name; } public int getAgeinHumanYears() { return age*7; } } Modify the Dog class as follows: - Add a breed member variable (String - Add a parameter to the constructor so that a value for breed is passed - Add a getAge Category method that will return one of the following String values: - "puppy" if the age of the dog is 1 or less - "young dog" if the age of the dog is greater than 1 and less than 4 - "adult if the age of the dog is between 4 and 10 - "aging dog" if the age of the dog is greater than 10 Use if-then-else chained statements Use the main method below to make sure your Dog class has been modified correctly Add one more Dog object with values of your choice for name, age, and breed. public static void main( String [ ] args ) { Dog spike = new Dog("Spike", 4, "Labrador"); Dog max = new Dog("Max", 1, "Chihuahua"); Dog bolt = new Dog("Bolt", 2, "Corgi"); System.out.println(spike); System.out.println(max); System.out.println(bolt); } class Dog { int age; String name; public Dog (String dogName, int dogAge) { age = dogAge; ; name = dogName; } public void bark() { System.out.println("Woof! Woof!"); } public int getAge() { return age; } public String getName() { return name; } public int getAgeinHumanYears(){ return age*7; } } Notice how the getAgein Human Years method simply multiplies the dog's age by 7. That is a simplistic calculation. Dogs do not age at a rate of 7 human years for each year in dog years. According to the American Veterinary Medical Association: The first year of a dog's life is 15 years of a human's life. The second year of a dog's life equals about nine years for a human. And after that, very human year equals five years for a dog. Modify the getAgein Human Years method to implement the American Veterinary Medical Association guidelines given above. Each dog object is printed as an id that does not give any information about the object attributes. To fix that, add a toString method that will return a String with all the information about the dog. The string returned should include: the dog's name, age, breed, age category (puppy, young dog, adult, or aging dog), and age in human years. The program has to look like when you run it OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-lubuntu0.18.04.4) javac -classpath .:/run_dir/junit-4.12. jar -d . Dog.java Main.java > java -classpath ../run_dir/junit-4.12.jar Main Spike is a 4 years old Labrador adult who is 34 years old in human years. Max is a 1 years old Chihuahua puppy who is 15 years old in human years. Bolt is a 2 years old Corgi young dog who is 24 years old in human years. Chance is a 12 years old Hound aging dog who is 74 years old in human years

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

What jobs exist now? LO1

Answered: 1 week ago

Question

=+4 Develop and deliver the CCT program.

Answered: 1 week ago

Question

=+5 Evaluate whether the CCT program was effective.

Answered: 1 week ago

Question

=+Identify the type of global assignment for which CCT is needed.

Answered: 1 week ago