Question: The assignment contains two . java files. The Artwork.java file is the class file for Artwork objects. Do NOT change the Artwork class. The second

The assignment contains two .java files. The Artwork.java file is the class file for Artwork
objects. Do NOT change the Artwork class.
The second file, Stack.java, is incomplete. This file contains the main method and the
skeleton of the lab. The methods are the following:
public void push(Artwork artwork)
//This method takes an `Artwork` object as a parameter and
adds it to the top of the stack. It essentially "pushes" the
artwork onto the stack, making it the newest element.
public Artwork pop()
//This method removes and returns the topmost `Artwork`
object from the stack. It "pops" the artwork off the stack,
effectively removing it from the collection.
public Artwork peek()
//This method retrieves, but does not remove, the top
`Artwork` object from the stack. It allows you to peek at the
topmost artwork without removing it from the stack.
public void sortAscendingByyear()
//This method sorts the artworks in the stack in ascending
order based on their year attribute. It rearranges the
artworks so that the oldest artworks come first and the
newest ones come last.
public void sortAscendingByName()
//Like the previous method, this one sorts the artworks in
ascending order, but based on the artist's name. It rearranges
the artworks alphabetically by the artist's name.
public void display()
//This method simply displays all the elements of the stack.
It typically prints out each artwork's details, such as the
artist's name, title, medium, year, and value, starting from
the top of the stack and moving downwards.
Requirements: Your task is to complete Stack.java as instructed in the comments to
produce the necessary output. On the way, you must follow the following requirements.
1. You must NOT change the main method.
2. Do NOT change any of the method headers provided in Stack.java nor the any part
of methods.
3. Feel free to write as many new methods, class variables as you need in Stack.java.
4. The data file will contain more information when grading.
Sample output: Use this to format the print statements.
Initialize a stack:
Is the stack empty? true
-----------------------------
Input some elements on the stack:
Artwork "Mona Lisa" by Da Vinci pushed onto the stack
Artwork "Starry Night" by Van Gogh pushed onto the stack
Artwork "Guernica" by Picasso pushed onto the stack
Artwork "David" by Michelangelo pushed onto the stack
Artwork "The Night Watch" by Rembrandt pushed onto the stack
Stack elements:
Artist: Rembrandt, Title: The Night Watch, Medium: Oil, Year: 1642, Value: 1500000.0
Artist: Michelangelo, Title: David, Medium: Marble, Year: 1504, Value: 180000.0
Artist: Picasso, Title: Guernica, Medium: Oil, Year: 1937, Value: 200000.0
Artist: Van Gogh, Title: Starry Night, Medium: Oil, Year: 1889, Value: 120000.0
Artist: Da Vinci, Title: Mona Lisa, Medium: Oil, Year: 1503, Value: 100000.0
The top object in the stack is: Artwork{artistName='Rembrandt', title='The Night Watch',
medium='Oil', year=1642, value=1500000.0}
-----------------------------
Artworks sorted in ascending order by year
Stack elements:
Artist: Da Vinci, Title: Mona Lisa, Medium: Oil, Year: 1503, Value: 100000.0
Artist: Michelangelo, Title: David, Medium: Marble, Year: 1504, Value: 180000.0
Artist: Rembrandt, Title: The Night Watch, Medium: Oil, Year: 1642, Value: 1500000.0
Artist: Van Gogh, Title: Starry Night, Medium: Oil, Year: 1889, Value: 120000.0
Artist: Picasso, Title: Guernica, Medium: Oil, Year: 1937, Value: 200000.0
-----------------------------
Artworks sorted in ascending order by artist name
Stack elements:
Artist: Da Vinci, Title: Mona Lisa, Medium: Oil, Year: 1503, Value: 100000.0
Artist: Michelangelo, Title: David, Medium: Marble, Year: 1504, Value: 180000.0
Artist: Picasso, Title: Guernica, Medium: Oil, Year: 1937, Value: 200000.0
Artist: Rembrandt, Title: The Night Watch, Medium: Oil, Year: 1642, Value: 1500000.0
Artist: Van Gogh, Title: Starry Night, Medium: Oil, Year: 1889, Value: 120000.0
-----------------------------
Artwork "Mona Lisa" by Da Vinci popped from the stack
Artwork "David" by Michelangelo popped from the stack
-----------------------------
Stack elements:
Artist: Picasso, Title: Guernica, Medium: Oil, Year: 1937, Value: 200000.0
Artist: Rembrandt, Title: The Night Watch, Medium: Oil, Year: 1642, Value: 1500000.0
Artist: Van Gogh, Title: Starry Night, Medium: Oil, Year: 1889, Value: 120000.0
-----------------------------
do not use any java built in methods instead create your own

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!