Question: Java Part B. class Dog { private String breed; private int age; private String color; public void barking() { //Code } public void hungry() {
Java
Part B.
class Dog {
private String breed;
private int age;
private String color;
public void barking() {
//Code
}
public void hungry() {
//Code
}
public void sleeping() {
//Code
}
}
Task 1.
Create a constructor with parameters to initialize the class variables.
Task 2.
Create getters and setters for the class variables.
Task 3.
Call the barking(), hungry(), and sleeping() methods in the main method for these 3 puppies: 1) Penny, 1 year old,
brown, 2) Taxi, 2 years old, gray, 3) Buddy, 4 years old, pale brown.
Task 4.
Display the age Penny. Display the color of Buddy.
Task 5.
Change the color of Penny to silver bay and display it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
