What's new

Help Pa unlock mga Boss Chegg

Kenji246

Eternal Poster
Joined
Jan 5, 2021
Posts
630
Reaction
990
Points
398
Mga master pa unlock activity ko lang po ang hirap kase nung parts na to

Eto: You do not have permission to view the full content of this post. Log in or register now.

Salamat po ng marami sa mag papaunlock
 
Last edited:
ItemSold.java


public class ItemSold {
private int invoiceNum;
private String description;
private float price;

public ItemSold(int invoiceNum, String description, float price) {
this.invoiceNum = invoiceNum;
this.description = description;
this.price = price;
}

public int getInvoiceNum() {
return invoiceNum;
}

public void setInvoiceNum(int invoiceNum) {
this.invoiceNum = invoiceNum;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}
}


DemoItemsAndPets.java

public class DemoItemsAndPets {
public static void main(String[] args) {
ItemSold item1 = new ItemSold(1001,"bucket",5.99f);
PetSold puppy = new PetSold(1002,"little bundle of cuteness",259.99f,true,true,false);

System.out.println(item1.getDescription() + " was sold for " + item1.getPrice());

System.out.println("A " + puppy.getDescription() + " was sold for " + puppy.getPrice());
System.out.println("The " + puppy.getDescription() + " Neutered status is: " + puppy.isNeutered() +
"\nAnd it is " + puppy.isHousebroken() + " that the " + puppy.getDescription() +" is housebroken");
}
}


PetSold.java


public class PetSold extends ItemSold{
private boolean vaccinated;
private boolean neutered;
private boolean housebroken;

public PetSold(int invoiceNum, String description, float price, boolean vaccinated, boolean neutered, boolean housebroken) {
super(invoiceNum, description, price);
this.vaccinated = vaccinated;
this.neutered = neutered;
this.housebroken = housebroken;
}

public boolean isVaccinated() {
return vaccinated;
}

public void setVaccinated(boolean vaccinated) {
this.vaccinated = vaccinated;
}

public boolean isNeutered() {
return neutered;
}

public void setNeutered(boolean neutered) {
this.neutered = neutered;
}

public boolean isHousebroken() {
return housebroken;
}

public void setHousebroken(boolean housebroken) {
this.housebroken = housebroken;
}

}
 

Similar threads

Back
Top