Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Cat.java Class File Create a new class called Cat that includes the functionalit

ID: 3621992 • Letter: C

Question

Cat.java Class File

Create a new class called Cat that includes the functionality below
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
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.
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

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

LastNameFirstNameWeek6Prog.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

Explanation / Answer

Dear, Here is the code import java.util.Scanner; //program uses class Scanner class Cat { private String name; private int age; private double weight; private String breed; private boolean declawed; public void setName(String name) { this.name=name; } public void setBreed(String bre) { this.breed=bre; } public void setAge(int ag) { this.age=ag; } public void set(boolean decla) { this.declawed=decla; } public String getName() { return this.name; } public String getBreed() { return this.breed; } public boolean getBoolean() { return this.declawed; } public int getAge() { return age; } public void set(String nm, int ag, double wei) { name=nm; age=ag; wei=weight; } } public class catTest { public static void main(String[] args) { //instantiate cat class Cat cat1=new Cat(); //Create Scanner to obtain input from command window Scanner input = new Scanner(System.in); //inputting cat's name System.out.println("Enter a cats name:"); String name = input.next(); //input cat's age System.out.println("Enter cats age:"); int age = input.nextInt(); //input weight System.out.println("Enter cats weight:"); double weight = input.nextDouble(); //input cat's breed System.out.println("Enter cats breed:"); String breed = input.next(); System.out.println("Is your cat declawed? True or False"); boolean declawed = input.nextBoolean(); //function call to set cat1.set(name, age, weight); //set breed cat1.setBreed(breed); //displaying System.out.println("Cat's Name:"+cat1.getName()); System.out.println("Breed:"+cat1.getBreed()); //exit program System.exit(0); }//end main }//end class Hope this will help you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote