Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 2 (updated version of textbook 8.4; Exercise 01) (Rectanglez Class) Create a class Rectangle2 which is a copy of Rectangle of the Exercise on.

image text in transcribed

Exercise 2 (updated version of textbook 8.4; Exercise 01) (Rectanglez Class) Create a class Rectangle2 which is a copy of Rectangle of the Exercise on. In this version, each object has its own min and max constant values for length and width, that they default to 0.0 and 20.0. Add 2 new constructors; the first takes as parameter another object of type Rectanglez, and the second takes 4 parameters which are the length and width of the rectangle, and the min and max values. Update the existing constructors to adhere to the new requirement. Write a program to test the new capabilities added by class Rectangle. 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 . reset TotalAmount: 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. . Page 8 of 32 Imam University CCIS Doc. No. 006-02-20170316 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 Extended InvoiceTest that demonstrates class Extended Invoice's new capabilities. Exercise 2 (updated version of textbook 8.4; Exercise 01) (Rectanglez Class) Create a class Rectangle2 which is a copy of Rectangle of the Exercise on. In this version, each object has its own min and max constant values for length and width, that they default to 0.0 and 20.0. Add 2 new constructors; the first takes as parameter another object of type Rectanglez, and the second takes 4 parameters which are the length and width of the rectangle, and the min and max values. Update the existing constructors to adhere to the new requirement. Write a program to test the new capabilities added by class Rectangle. 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 . reset TotalAmount: 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. . Page 8 of 32 Imam University CCIS Doc. No. 006-02-20170316 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 Extended InvoiceTest that demonstrates class Extended Invoice's new capabilities

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

What are benefits of using AWS Organizations? ( Choose two. )

Answered: 1 week ago

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago