(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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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;

    }

}

Exercise 3 (extended version of textbook 7.11 that was given in Lab
01)
(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.
Provide the following static methods
resetTotalAmount : resets the value of totalInvoiceAmount to 0.
updateTotalAmount: private method that takes 2 parameters; subtracts
the first parameter from the totalInvoiceAmount and adds the second to it.
getTotalAmount: returns the value of totalInvoiceAmount.
Transcribed Image Text:Exercise 3 (extended version of textbook 7.11 that was given in Lab 01) (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. Provide the following static methods resetTotalAmount : resets the value of totalInvoiceAmount to 0. updateTotalAmount: private method that takes 2 parameters; subtracts the first parameter from the totalInvoiceAmount and adds the second to it. getTotalAmount: returns the value of totalInvoiceAmount.
Modify
the
existing
constructor
with
arguments
to
call
the
static
updateTotalAmount, where the first parameter is 0 and the second is the invoice
amount (don't call getInvoiceAmount).
Modify the existing setQuantity to call the static updateTotalAmount, where the
first parameter is the old value of the invoice amount and the second is the new invoice
amount using the new value of the quantity. Similarly, modify setPricePerItem by
considering the new value of setPricePerItem.
Based on InvoiceTest class, write a test app named ExtendedInvoiceTest that
demonstrates class ExtendedInvoice's new capabilities.
Transcribed Image Text:Modify the existing constructor with arguments to call the static updateTotalAmount, where the first parameter is 0 and the second is the invoice amount (don't call getInvoiceAmount). Modify the existing setQuantity to call the static updateTotalAmount, where the first parameter is the old value of the invoice amount and the second is the new invoice amount using the new value of the quantity. Similarly, modify setPricePerItem by considering the new value of setPricePerItem. Based on InvoiceTest class, write a test app named ExtendedInvoiceTest that demonstrates class ExtendedInvoice's new capabilities.
Expert Solution
steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY