Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class that will model a Dog. We are interested in developing an application that will keep track of every Dog in a certain

Write a class that will model a Dog. We are interested in developing an application that will keep track of every Dog in a certain locality. The properties of a Dog that needs to be captured in a Dog class are: name, weight and years, which could be defined as String, int and int respectively. Every Dog entered into the application will be modeled as a Dog object. These properties should be kept secure from tampering and hence, the class will need to encapsulate these properties.

The client programs of the class will access and change these properties using appropriate getters and setters.

The class should have a method called obtainSize , that will return the size of the dog. Size is a string variable and can take the value of small, medium, large . (Size is not an instance variable). The method obtainSize will determine the size based on the following conditions. If the weight is <= 10, the size is small, else if the weight is between 10 and 30 ( inclusive) the size is medium. For all weights more than 30, size is large. The method obtainSize, returns the value of size. This method takes in no argument from the client programs.

The dog class also needs constructors, both default and full-argument overloaded. Whenever a new dog enters the system, the constructors are used to create new dog objects. Those dogs that are new to the system( for example a new puppy) , but dont have a registered credentials, are created using default constructors, and the properties can be set later on. The class should also provide overloaded constructors that can be used to create new Dog objects.

write the class code for Dog class in Java

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

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

What is performance and fault management?

Answered: 1 week ago