Assuming the Pet class is defined as follows:check the code public class Pet { private String petType;
Question:
Assuming the Pet class is defined as follows:check the code
public class Pet {
private String petType;
private String petName;
private int petAge;
private int dogSpaces;
private int catSpaces;
private int daysStay;
private double amountDue;
public Pet(String petType, String petName, int petAge, int dogSpaces, int catSpaces, int daysStay, double amountDue) {
this.petType = petType;
this.petName = petName;
this.petAge = petAge;
this.dogSpaces = dogSpaces;
this.catSpaces = catSpaces;
this.daysStay = daysStay;
this.amountDue = amountDue;
}
// Getters and setters for each field
// ...
}
// Dog class extending Pet
public class Dog extends Pet {
private int dogSpaceNumber;
private double dogWeight;
private boolean grooming;
public Dog(String petName, int petAge, int dogSpaces, int daysStay, double amountDue, int dogSpaceNumber, double dogWeight, boolean grooming) {
super("Dog", petName, petAge, dogSpaces, 0, daysStay, amountDue);
this.dogSpaceNumber = dogSpaceNumber;
this.dogWeight = dogWeight;
this.grooming = grooming;
}
// Getters and setters for the Dog-specific fields
public int getDogSpaceNumber() {
return dogSpaceNumber;
}
public void setDogSpaceNumber(int dogSpaceNumber) {
this.dogSpaceNumber = dogSpaceNumber;
}
public double getDogWeight() {
return dogWeight;
}
public void setDogWeight(double dogWeight) {
this.dogWeight = dogWeight;
}
public boolean isGrooming() {
return grooming;
}
public void setGrooming(boolean grooming) {
this.grooming = grooming;
}
// ... Additional methods, if any
}
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch