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

Using NetBeans for JAVA, Design a class called Pet (the class file should be cal

ID: 3857400 • Letter: U

Question

Using NetBeans for JAVA, Design a class called Pet (the class file should be called Pet.java), with the following fields:

Name - The Name field holds the name of the pet

Type - The Type field holds the type of animal that the pet is

Age - The Age field holds the age of the pet (in years)

Height - The Height field holds the height of the pet (in inches)

Weight - The Weight field holds the weight of the pet (in lbs)

Legs - The Legs field holds the number of legs of the pet

The Pet class should also have the following methods:

SetName - The setName method stores a value in the Name field

GetName - The getName method returns the value of the Name field

SetType - The setType method stores a value in the Type field

GetType - The getType method returns the value of the Type field

SetAge - The setAge method stores a value in the Age field

GetAge - The getAge method returns the value of the Age field

SetHeight - The setHeight method stores a value in the Height field

GetHeight - The getHeight method returns the value of the Height field

SetWeight - The setWeight method stores a value in the Weight field

GetWeight - The getWeight method returns the value of the Weight field

SetLegs - The setLegs method stores a value in the Legs field

GetLegs - The getLegs method returns the value of the Legs field

PrintStory - The PrintStory method should display/output to the console the following message

(inserting values for the class field into the appropriate location1):

There once was a TYPE named NAME who lived in Dallas, Texas. NAME was a LEGSlegged

pet. In 2017, when it was AGE years old, NAME was HEIGHT feet tall and

WEIGHT pounds. NAME was a happy TYPE and had long and happy life.

Explanation / Answer

please copy the code into your Eclipse / Netbeans IDE with the name of Pet.java

import java.util.Scanner;

public class Pet {

/**

* The Name field holds the name of the pet

*/

String Name;

/**

* The Type field holds the type of animal that the pet is

*/

String Type;

/**

* The Age field holds the age of the pet (in years)

*/

int Age;

/**

* The Height field holds the height of the pet (in inches)

*/

int Height;

/**

* The Weight field holds the weight of the pet (in lbs)

*/

int Weight;

/**

* The Legs field holds the number of legs of the pet

*/

int Legs;

/**

* The getName method returns the value of the Name field

* @return

*/

public String getName() {

return Name;

}

/**

* The setName method stores a value in the Name field

* @param name

*/

public void setName(String name) {

Name = name;

}

/**

* The getType method returns the value of the Type field

* @return

*/

public String getType() {

return Type;

}

/**

* The setType method stores a value in the Type field

* @param type

*/

public void setType(String type) {

Type = type;

}

/**

* The getAge method returns the value of the Age field

* @return

*/

public int getAge() {

return Age;

}

/**

* The setAge method stores a value in the Age field

* @param age

*/

public void setAge(int age) {

Age = age;

}

/**

* The getHeight method returns the value of the Height field

* @return

*/

public int getHeight() {

return Height;

}

/**

* The setHeight method stores a value in the Height field

* @param height

*/

public void setHeight(int height) {

Height = height;

}

/**

* The getWeight method returns the value of the Weight field

* @return

*/

public int getWeight() {

return Weight;

}

/**

* The setWeight method stores a value in the Weight field

* @param weight

*/

public void setWeight(int weight) {

Weight = weight;

}

/**

* The getLegs method returns the value of the Legs field

* @return

*/

public int getLegs() {

return Legs;

}

/**

* The setLegs method stores a value in the Legs field

* @param legs

*/

public void setLegs(int legs) {

Legs = legs;

}

/*Using NetBeans for JAVA, Design a class called Pet (the class file should be called Pet.java), with the following fields:

The Pet class should also have the following methods:

- The PrintStory method should display/output to the console the following message

(inserting values for the class field into the appropriate location1):

*/

public void PrintStory(String TYPE,String NAME,int AGE,int HEIGHT,int WEIGHT,int LEGS){

System.out.println("There once was a "+TYPE+" named "+NAME+" who lived in Dallas, Texas. "+NAME+" was a "+LEGS+" legged"+

"pet. In 2017, when it was "+AGE+" years old, "+NAME+" was "+HEIGHT+" feet tall and "+

WEIGHT+" pounds. "+NAME+" was a happy "+TYPE+" and had long and happy life.");

}

public static void main(String[] args){

Pet petObject=new Pet();

/**

* The following code snippet helps to read the Values from Console

*/

/*Scanner sc = new Scanner(System.in);

System.out.println("ENTER Pet NAME (As Type String): ");

String name=sc.next();;

System.out.println("ENTER Pet TYPE (As Type String): ");

String type=sc.next();

System.out.println("ENTER Pet WEIGHT (As Type integer): ");

int weight=sc.nextInt();

System.out.println("ENTER Pet LEGS (As Type integer): ");

int legs=sc.nextInt();

System.out.println("ENTER Pet HEIGHT (As Type integer): ");

int height=sc.nextInt();

System.out.println("ENTER Pet AGE (As Type integer): ");

int age=sc.nextInt();;*/

/**

* Assigning Values to Variables

*/

String name="Bruno";

String type="Pug";

int weight=14;

int legs=4;

int height=5;

int age=3;

/**

* Set the Values

*/

petObject.setName(name);

petObject.setHeight(height);

petObject.setHeight(height);

petObject.setType(type);

petObject.setLegs(legs);

petObject.setWeight(weight);

petObject.setAge(age);

/**

* Get the Values

*/

String NAME=petObject.getName();

int AGE=petObject.getAge();

String TYPE=petObject.getType();

int WEIGHT=petObject.getWeight();

int LEGS=petObject.getLegs();

int HEIGHT=petObject.getHeight();

petObject.PrintStory(TYPE, NAME, AGE, HEIGHT, WEIGHT, LEGS);

}

}

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