Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a class called Dog that contains instance data that represents the dogs name and age. In addition, the class should have the following

1. Write a class called Dog that contains instance data that represents the dogs name and age. In addition, the class should have the following methods:

  • A default constructor, which initializes name to dog and age to 0
  • A getter for each instance data
  • A setter for each instance data
  • A method toPersonYears() that computes and returns the age of the dog in person years (seven times the dogs age)
  • A toString method that returns a one-line description of the dog including name and age.

2. Write an application Kennel that instantiates two Dog objects and updates the name and age with data from the user. The program will display the information about each object (Hint: toString() method) as well as the average age in person years.

WRITING METHODS (Each problem below is a method in the class MyMethods.java)

1. Implement a method named surface that accepts 3 integer parameters named width, length, and height as user input. It will return the total surface area (6 sides) of the rectangular box it represents. The formula for Surface Area is 2(length * width) + 2(length * height) + 2(height * width)

Sample input and output: Enter width: 2 Enter length: 3 Enter height: 4 The total surface area is: 52

2. Implement a method named swapFaceValues that accepts 2 Die objects. Use the Die class developed in class. The method swaps the face values of the two die objects. For example, if die1 has face value 3 and die2 has face value 5, after the method executes, the face values of die1 and die2 will be 5 and 3, respectively.

3. To test methods above, write an application, TestMethods, that will instantiate an instance (object) of the class MyMethods to invoke the methods below. The application should have at least one invocation of each method.

Previous

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

5. What information would the team members need?

Answered: 1 week ago

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago