Question: 3. Write a program named Lab24C where you will create a stack structure from scratch (not using existing Java list structures.) a. Create a

3. Write a program named Lab24C where you will create a stackstructure from scratch (not using existing Java list structures.) a. Create a

3. Write a program named Lab24C where you will create a stack structure from scratch (not using existing Java list structures.) a. Create a class named Drinks that you will make objects of. It should have the following: i. Instance variables to hold the drink name (String), container type (String), and size (int) ii. A constructor that receives a parameter for each instance variable and fills in the instance variables. iii. A String method named toString (no parameter) that returns a String with all the instance variables and labels, like we've made in other classes. b. Create a class named MyNode, that is a generic class. It should have the same instance variables and methods that the MyStackNode from the given below class. c. Create a class named MyStack, that is a generic class. It should have the same instance variables and methods that the MyStack class in the given below class Note: the toString method should start from the top of the stack and then go through the rest of the stack as it creates the String to return. d. The MyNode and MyStack should be built from scratch and not use any predefined Java list or ArrayList structures. wwwwwww e. In the main class, do the following: i. Create a MyStack object ii. For each line of drink data in the text file (Lab24C.txt), create a Drinks object and add it to the MyStack object using the push method. iii. Print the stack using the Mystack toString method. iv. Remove the first 2 objects from the stack using the pop method and print each object as you do so. (Print a statement before this that says what you are doing.) MyStack -top: MyStackNode -size: int + MyStack() + getSize(): int + isEmpty():boolean + push(o: E): void + peek(): E + pop(): E +toString(): String MyStackNode - value: E + next: MyStackNode + MyStackNode(o: E) + getValue(): E

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!