Question
java: code given: class Dog { private String breed; private int age; private String color; public void barking() { //Code } public void hungry() {
java:
code given:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started