create an interface in java that contains the following methods: boolean myPush(T element); // pushes element onto the stack; returns true if element successfully pushed, false otherwise boolean myPop(); // removes the top element of the stack; returns true if element successfully popped, false otherwise T myTop(); // if the stack is not empty returns the top element of the stack, otherwise returns null String toString(); // returns contents of the stack as a single String int size(); // return number of elements in the stack then create java file that Implements your interface that you created as a linked stack, then use the driver shown in screen shot to test. below is the code for the LLNode class public class LLNode { protected LLNode link; protected T info; public LLNode(T info) { this.info = info; link = null; } public void setInfo(T info) { this.info = info; } public T getInfo() { return info; } public void setLink(LLNode link) { this.link = link; } public LLNode getLink() { return link; } } program should output fruits cost = 35
how to create an interface in java that contains the following methods:
boolean myPush(T element); // pushes element onto the stack; returns true if element successfully pushed, false otherwise
boolean myPop(); // removes the top element of the stack; returns true if element successfully popped, false otherwise
T myTop(); // if the stack is not empty returns the top element of the stack, otherwise returns null
String toString(); // returns contents of the stack as a single String
int size(); // return number of elements in the stack
then create java file that Implements your interface that you created as a linked stack, then use the driver shown in screen shot to test. below is the code for the LLNode class
public class LLNode<T> {
protected LLNode<T> link;
protected T info;
public LLNode(T info) {
this.info = info;
link = null;
}
public void setInfo(T info) {
this.info = info;
}
public T getInfo() {
return info;
}
public void setLink(LLNode<T> link) {
this.link = link;
}
public LLNode<T> getLink() {
return link;
}
}
fruits cost = 35
Step by step
Solved in 2 steps