Question

Chapter 5 Assignment Read directions: In JAVA design and implement a class called Dog that contains...

Chapter 5 Assignment

Read directions: In JAVA design and implement a class called Dog that contains instance data that represents the dog's name and dog's age. Define the Dog constructor to accept and initialize instance data. Include getter and setter methods for the name and age. Include a method to compute and return the age of the dog in "person years" (seven times age of dog. Include a toString method that returns a one-time description of the dog (example below). Create a driver class Kennel, whose main() method instantiates and updates several Dog objects.

You are to create a program with a class call: Dog, and a driver class named: Kennel.

You have instance data for dog's name and dog's age. Methods including the constructor, some "getters" and "setters" for name and age. Additional method to calculate the dog's age in human years *7.    Include a "toString" method to return a one-line description of dog.

Points:

   (2 points) Create a Kennel class

     (2 points) Create Dog class

   (2 points) Create constructor method to accept and initialize instance data (dog name and age)

   (4 points) instantiate four objects (instances) of Dog, setting up each dog (4 dogs).

   (4 points) create setters and getters method (ex: setName("Maxine") changes dog name, getName() returns name

   AND getAge() returns age, and setAge(7) sets the age of dog).

   (3 points) use toString() method to print dog's name and age when called by println()

     (3 points) print 4 statements for other information not using toString() including dog's age including picking one dog and say "Happy Birthday".

   (2 points) calculate dog's age in person years (method to do this)

   (8 points) program works :     

        (Total of 2 classes (Kennel, Dog). Dog class has 7 methods (Dog, setName, getName, setAge, getAge, calcHumanYears, to_String))

                 FIRST: Print out all 4 dog's name and its age

   Each dog should be printed out with the dog information using "to_String" for print.

   SECOND: Print and give following info:

   a) allow the change of name and change of dog's age (you pick any dog to do each)

   b) for all dogs, print line include: " The dog's name is Maxine, and you are now 35 in human years " (use method to get dog's name and use method to calculate his age-in-human-years)

   c) print another line for ONE dog could be: " Today is: Wishbone's birthday. Happy Birthday Wishbone!! "    (use method to get dog's name and the age-in-human-years in the println)

   (-5 points) if no comments or messy

**** Sample output **********************************

Max is the best dog. Age: 5
Lucky is the best dog. Age: 9
Wishbone is the best dog. Age: 3
Jellybean is the best dog. Age: 1

The dog's name is not Max, it's Maxine.
The dog's age is not 1, Jellybean is 2.

The dog's name is Maxine, and you are now 35 in human years.
The dog's name is Lucky, and you are now 63 in human years.
The dog's name is Wishbone, and you are now 21 in human years.
The dog's name is Jellybean, and you are now 14 in human years.

Today is: Wishbone's 21 birthday. Happy Birthday Wishbone!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program plan: . Define the class Dog with data members to store age and name of dog. . Define member functions setter, getter

Program: Defining a class Dog which contains a instance variables to store age and name. Constructor * Initialize data member

* Driver class Kennel instantiates objects of class dog and updates values. * Compile: javac kennel.java Run java kennel. p

Sample Output: The dog name is Floppy Age is 3 Age in person years 21 The dog name is Julie Age is 6 Age in person years 42 T

Add a comment
Know the answer?
Add Answer to:
Chapter 5 Assignment Read directions: In JAVA design and implement a class called Dog that contains...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

  • Using your Dog class from earlier this week, complete the following: Create a new class called...

    Using your Dog class from earlier this week, complete the following: Create a new class called DogKennel with the following: Instance field(s) - array of Dogs + any others you may want Contructor - default (no parameters) - will make a DogKennel with no dogs in it Methods: public void addDog(Dog d) - which adds a dog to the array public int currentNumDogs() - returns number of dogs currently in kennel public double averageAge() - which returns the average age...

  • Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and...

    Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...

  • JAVA QUESTION 16 Write and submit the java source for the following class specification: The name...

    JAVA QUESTION 16 Write and submit the java source for the following class specification: The name of the class is Question_16 Class Question_16 has 3 instance variables: name of type String, age of type int and height of type double. Class Question_16 has the following methods: print - outputs the data values stored in the instance variables with the appropriate label setName - method to set the name setAge - method to set the age setHeight - method to set...

  • In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in...

    In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...

  • Java Create four classes: 1.      An Animal class that acts as a superclass for Dog and...

    Java Create four classes: 1.      An Animal class that acts as a superclass for Dog and Bird 2.      A Bird class that is a descendant of Animal 3.      A Dog class that is a descendant of Animal 4.      A “driver” class named driver that instantiates an Animal, a Dog, and a Bird object. The Animal class has: ·        one instance variable, a private String variable named   name ·        a single constructor that takes one argument, a String, used to set...

  • Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents the airline name

    Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents the airline name, flight number, and the flight’s origin and destination cities. Define the Flight constructor to accept and initialize all instance data. Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the flight. Create a driver class called FlightTest, whose main method instantiates and updates several Flight objects.

  • cs55(java) please. Write a class called Book that contains instance data for the title, author, publisher,...

    cs55(java) please. Write a class called Book that contains instance data for the title, author, publisher, price, and copyright date. Define the Book constructor to accept and initialize this data. Include setter and getter methods for all instance data. Include a toString method that returns a nicely formatted, multi-line description of the book. Write another class called Bookshelf, which has name and array of Book objects. Bookself capacity is maximum of five books. Includes method for Bookself that adds, removes,...

  • Could someone help me out. I am not sure what I should be doing. Seeing it...

    Could someone help me out. I am not sure what I should be doing. Seeing it worked out will allow me to understand what I should be doing and then I can complete it on my own. Usando 2. Complete the Dog Class: a. Using the UML Class diagram to the right declare the instance variables. A text version is available: UML Class Diagram Text Version b. Create a constructor that incorporates the type, breed, and name variables (do not...

  • In this assignment, you will implement Address and Residence classes. Create a new java project. Part...

    In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT