[go: up one dir, main page]

0% found this document useful (0 votes)
12 views5 pages

2-3 Assignment Write A Class

assignment 2

Uploaded by

b19e86a01r07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

2-3 Assignment Write A Class

assignment 2

Uploaded by

b19e86a01r07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

2-3 Assignment: Write a Class

public class Pet {

private String petType;

private String petName;

private int petAge;

private int dogSpace;

private int catSpace;

private int daysStay;

private double amountDue;

public Pet(String petType, String petName, int petAge, int dogSpace, int
catSpace, int daysStay, double amountDue) {

this.petType = petType;

this.petName = petName;

this.petAge = petAge;

this.dogSpace = dogSpace;

this.catSpace = catSpace;

this.daysStay = daysStay;

this.amountDue = amountDue;

// Accessor and Mutator methods for each attribute

public String getPetType() {

return petType;

}
public void setPetType(String petType) {

this.petType = petType;

public String getPetName() {

return petName;

public void setPetName(String petName) {

this.petName = petName;

public int getPetAge() {

return petAge;

public void setPetAge(int petAge) {

this.petAge = petAge;

public int getDogSpace() {

return dogSpace;

public void setDogSpace(int dogSpace) {

this.dogSpace = dogSpace;

}
public int getCatSpace() {

return catSpace;

public void setCatSpace(int catSpace) {

this.catSpace = catSpace;

public int getDaysStay() {

return daysStay;

public void setDaysStay(int daysStay) {

this.daysStay = daysStay;

public double getAmountDue() {

return amountDue;

public void setAmountDue(double amountDue) {

this.amountDue = amountDue;

public void checkin() {


System.out.println(petName + " has checked in.");

public void checkOut() {

System.out.println(petName + " has checked out. Total Amount Due: $"


+ amountDue);

public class Dog extends Pet {

private int dogSpaceNbr;

private double dogWeight;

private boolean grooming;

public Dog(String petType, String petName, int petAge, int dogSpace, int
catSpace, int daysStay, double amountDue,

int dogSpaceNbr, double dogWeight, boolean grooming) {

super(petType, petName, petAge, dogSpace, catSpace, daysStay,


amountDue);

this.dogSpaceNbr = dogSpaceNbr;

this.dogWeight = dogWeight;

this.grooming = grooming;

public int getDogSpaceNbr() {

return dogSpaceNbr;

public void setDogSpaceNbr(int dogSpaceNbr) {


this.dogSpaceNbr = dogSpaceNbr;

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;

public void checkin() {

super.checkin();

System.out.println("Dog Space Number: " + dogSpaceNbr + ", Weight: "


+ dogWeight + "kg, Grooming: " + (grooming ? "Yes" : "No"));

You might also like