Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

fter learning about the Stack Abstract Data Type (ADT), you decide to develop a program that will arrange Professor Ahmads Compact Disc (CD) collection into

fter learning about the Stack Abstract Data Type (ADT), you decide to develop a program that will arrange Professor Ahmads Compact Disc (CD) collection into unique stacks. It turns out that all his CDs are just in one giant pile and going through them will take a lot of time. The hope is that going through them once and placing each of them in the appropriate stack will prevent them from ending up in one giant pile again. Professor Ahmad tells you that he would like his music collection to be broken into five different stacks. The first stack will be for any music that is not in English. The next stack will be for all of his Rush CDs. There should also be a separate stack for all his Pink Floyd CDs. There should be another stack for all his Iron Maiden CDs. Any remaining music that is in English should go into a separate stack. These should be the five stacks. Also, there should be a sixth stack where any CD should go once it has been removed from the appropriate stack and this stack will be the one where a CD that is currently in a CD player will go so that it will be clear which CDs are currently in use and not in their appropriate stack. This program should give the user many different options. The first is to pick up a CD from the giant pile and enter its information. Based on this information the program should place the CD into the appropriate stack. There should be a separate option to look at the top of each stack. There should also be a separate option to remove the top CD from each stack. When the user chooses to remove the top CD from a stack it should be put in the in-use stack. There should also be an option that gives the size of all the stacks. There should also be a separate option to display the contents of each stack. Finally, there should be an option that displays the total number of CDs that are in all of the stacks combined. Whether to develop this program with an array-based approach or link-based approach is an open question. The array-based approach can be thought of as better modeling the real-world where a stack of CDs can only be so high before it might fall or fail to fit on a shelf. The link-based approach allows for unlimited sizes of stacks and while this may not model the real world very well, it is the more challenging approach. The decision of which approach to go with is left up to you as a software developer. The first step in this development process is to develop the Compact Disc class which would hold the name of the artist, the name of the album, and the language of the lyrics. This should class should exhibit object-oriented principles by making the instance variables private and having the appropriate accessor and mutator methods to allow access and manipulation of the attributes of a CD. This class also should override the toString method from the Object class so that all information about the CD is returned in String form. After the development of the Compact Disc class, the .java file for the StackInterface should be included in the project and it should be edited to include a size method. Its method signature should be as follows: public int size() Then the BoundedStackInterface and/or UnboundedStackInterface should be included in the project without any changes. Then depending on which implementation is selected either the ArrayStack class or LinkedStack class should be included in the project. Whichever one is selected should override the toString method from the Object class and implement the new size method required in the updated StackInterface interface. If the LinkedStack class is selected then the LLNode class will also have to be included without any changes. Then StackUnderFlowException and potentially StackOverFlowException should also be included in the project without any changes. While this program only manages stacks of CDs it is required that you use parameterized types so that you can see that these classes can be easily adapted to other data types. Finally develop a prototype of the program that will arrange Professor Ahmads CDs. Please make sure to place at least two CDs in each stack and then look at the top of each stack, finally attempt to remove a CD from a stack and make sure it ends up in the in-use stack. Please demonstrate this with a number of CDs.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions