Create a class in java


Assignment:

1. Create a new class called Cat that includes the functionality below

2. The new class has the attributes of:

name - type String
age - type integer
weight - type double
breed - type String
declawed - type boolean - true for has no claws, false for has claws

3. Be sure your classes have a reasonable complement of constructor, accessor and mutator methods. Every member variable must have at least one independent accessor and one independent mutator.

4. Example:

public void setName(String name) mutator used to set name
public void setBreed(String breed) mutator used to set the breed
public void set(Boolean declawed) used to set claws or not

(You must overload the set method to set deClawed value)

public String getName() accessor used to get name
public String getBreed() accessor used to get breed
public boolean getBoolean() access used to get the value of declawed

5. Ensure you use the "this" reference from within this class when referring to every instance variable or instance method of the current object.

Prog.java Class File (Driver Program)

Write a driver program that reads in 3 pets of type Cat and prints out the name and age of all cats with claws and over 3 years old.
The following information should be read in:
Name
Age
Weight
Breed
DeClawed
Ensure you use the accessor methods to check the age and claws.
Example output of your program
Example Run:
Enter the name of Cat 1: Sam
Enter the age of Cat 1: 1
Enter the weight of Cat 1: 5
Enter the breed of Cat 1: fluffy1
Does the cat have claws? True or False?: True
Enter the name of Cat 2: Tom
Enter the age of Cat 2: 4
Enter the weight of Cat 2: 5
Enter the breed of Cat 2: fluffy2
Does the cat have claws? True or False?: True
Enter the name of Cat 3: Bob
Enter the age of Cat 3: 5
Enter the weight of Cat 3: 5
Enter the breed of Cat 3: fluffy3
Does the cat have claws? True or False?: False
The Cats over 3 with claws are:
Name: Tom
Age: 4 Years Old

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a class in java
Reference No:- TGS01935016

Now Priced at $25 (50% Discount)

Recommended (94%)

Rated (4.6/5)