(ExtendedInvoice Class) This exercise extends the Invoice class described in Exercise 1 of the Lab 01. Recall that the Invoice class have 4 instance variables (partNumber, partDescription, quantity, pricePerItem), a no-argument constructor, another constructor that initializes the four instance variables, set and get method for each instance variable, and getInvoiceAmount method. We need to use a static variable totalInvoiceAmount to store the all invoice amounts inside the class.
please solve it with java and put screenshots of the code
-----------------------------------------------------------
public class Invoice {
privateStringnumber;
privateStringdescription;
privateintquantity;
privatedoubleprice;
publicInvoice(){
this.number=number;
this.description=description;
this.quantity=quantity;
this.price=price;
}
publicInvoice(Stringnumber,Stringdescription,intquantity,doubleprice){
setNumber(number);
setDescription(description);
setQuantity(quantity);
setPrice(price);
}
publicStringgetNumber(){
returnnumber;
}
publicvoidsetNumber(Stringnumber){
this.number=number;
}
publicStringgetDescription(){
returndescription;
}
publicvoidsetDescription(Stringdescription){
this.description=description;
}
publicintgetQuantity(){
returnquantity;
}
publicvoidsetQuantity(intquantity){
if(quantity<0)
quantity=0;
this.quantity=quantity;
}
publicdoublegetPrice(){
returnprice;
}
publicvoidsetPrice(doubleprice){
if(price<0)
price=0;
this.price=price;
}
publicdoublegetInvoiceAmount(){
if(quantity<=0 || price<=0)
return0;
returnquantity*price;
}
publicStringtoString(){
return"number = "+number+", description ="+description+", quantity ="+quantity+", price ="+price;
}
}
Step by step
Solved in 2 steps with 3 images