Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / CSC205: Homework #5 - Drop Out Stack Due: Sunday, June 14 (at midnight) Point Worth: 20 General Requirements: Be sure to follow the instructions outlined for each class, function, etc

CSC205: Homework #5 - Drop Out Stack Due: Sunday, June 14 (at midnight) Point Worth: 20 General Requirements: Be sure to follow the instructions outlined for each class, function, etc

Computer Science

CSC205: Homework #5 - Drop Out Stack
Due: Sunday, June 14 (at midnight)
Point Worth: 20

General Requirements:
Be sure to follow the instructions outlined for each class, function, etc. EXACTLY as described.
This includes small things such as: spelling names correctly, using appropriate data types for variables / functions, etc.
Also, unless stated otherwise, all functions and [class] variables should be public and non-static (by default).
Unless stated otherwise, your final solution should NOT print any output.
You can utilize print statements for testing purposes, just be sure to delete or comment out said code before turning in your work.
Also, your main method is unimportant since it'll NOT affect your grade (and should only be used to test your work)
Tip: If you're unsure about any part of these instructions, be sure to ask for help or clarification (from the instructor).
Many details are intentionally omitted / vague since they're either trivial or something you should be able to figure out on your own.

Create a class called "DropOutStack". See Figure 1 for UML.

What is a drop out stack?
Same thing as a regular stack, except with a maximum capacity. 
Whenever a new element is added when the stack is full, the bottom-most element must be removed from the collection (see Figure 2). The new element is then inserted and the size and max capacity shouldn't change.

Be sure to keep the following stipulations in mind:
You must rely on links for its underlying data structure.
Tip: Reuse and modify class 'LinkedStack' since its generics and attributes are already established and are still important to have.
The code within interface 'StackADT' and class 'LinearNode' should be the same as they originally were.
Note: There's no 'count' attribute, however if students want to create / maintain one, that's fine.
All [four] constructors serve similar purposes and should work like so:
The starting value for attribute 'maxSize' will depend on what value the constructor's integer parameter is, otherwise if said parameter doesn't exist it should be 10 (by default).
Important: You MUST invoke the class' own mutator method to handle said assignment operation.
The constructors which have the 'T' parameter must set said element as the starting 'top' node of the collection (otherwise it should remain null).
Tip: Focus on implementing the 4th constructor (the one with two parameters) and have the other constructors invoke it, using the 'this' keyword, with appropriate arguments.
Don't forget that the "pop" and "peek" method MUST throw a [runtime] exception if the stack is empty.

Tip: For method "push", check the capacity limit AFTER inserting the element into the collection.
Hint: If the last node needs to be decoupled from the collection, then this will require us to find and modify the 'next' reference of the second-to-last node in the sequence.
Here's how the "popStack" function should work:
It should throw a [runtime] exception if it's parameter 'capacity' exceeds the stack's [current] size, otherwise ...
It'll return an array consisting of <capacity> elements that are popped from the stack (see Figure 3).
Be sure to keep the same order (in the array) as it was in the stack.
First is the top-most element
Second is second from the top
Third is third from the top
etc.
Tip: Invoke the "pop" method. This will greatly reduce the total amount of code needed for this function.
Tip: See Figure 4 for some sample test code.
The accessor and mutator methods for 'maxSize' should follow the standard template, HOWEVER, the mutator needs to throw a [runtime] exception if its parameter is LESS than the [current] number of elements within the stack

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions