An art gallery would like to computerise their inventories. You are engaged to develop a prototype using the object-oriented programming approach. Each art piece has a title, artist name, width, height, selling price and whether the piece is a copy or an original.
You are asked to implement classes for the object-oriented application.
(a) Write a Java class that will model an art piece in the gallery. This class should have the following:
Suitable instance variables for each of the information given above.
A constructor with the appropriate actions on the instance variables.
The usual get and set methods for the instance variables selling price and whether the piece is a copy or an original.
A calculateArea() method that will return the area of the art piece.
A compareTo() method that takes as parameter another art piece, compares the areas and returns 1 of this art piece is bigger, 0 if the size is the same, and -1 if this art piece is smaller.
A toString() method that returns the values of the instance variables with descriptions.
(b) Write a test program to exercise the class written in part (a) above. The test program should have the following:
Create 4 art pieces as shown in the table below and hold them in a single suitable data structure:
Title Artist Name Width/cm Height/cm Selling Price Original? FlorEssence 2 Sidney Cheung 50 40 2100 Yes A Family I Fernando Botero 36 48 492.09 No Princesa Naranja Mersuka Dopazo 150 150 3000 Yes Dancers in blue Edgar Degas 72 108 1852.63 No
For those art pieces that are original, increase the selling price by 20%. Display the details of these art pieces BEFORE and AFTER the increase.
Use the compareTo method to compare areas of art pieces 1 and 2. Then display a message to print the details of the smaller painting.
Submit your program listing together with screenshot of your output to convince your tutor that your program is working. Your screenshot must show your name and student identification number as part of the program output.
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.