Question
Implement a Tray class that will use a concatenated list internally (java.util.LinkedList). It is not necessary to address the class generically, i. you can omit
Implement a Tray class that will use a concatenated list internally (java.util.LinkedList). It is not necessary to address the class generically, i. you can omit type parameters.
public class ZasobnikTester {
public static void main(String[] args) {
Zasobnik zasobnik = new Zasobnik();
for (int i = 1; i <= 100; i++) {
//
we insert the element at the top of the tray
zasobnik.insert(i);
}
for (int i = 1; i <= 500; i++) {
//
we select the element from the top of the tray
zasobnik.select();
}
System.out.println(zasobnik.select());
System.out.println("Expected result: 500");
System.out.println(zasobnik.elementOnTheTop());
System.out.println("Expected result: 499");
System.out.println(zasobnik.getSize());
System.out.println("Expected result: 499");
while (!zasobnik.isEmpty()) {
zasobnik.select();
}
System.out.println(zasobnik.getSize());
System.out.println("Expected result: 0");
}
}
import java.util.LinkedList;
public class Zasobnik {
private LinkedList
public void insert(int prvok) {
...
}
public int select() {
.....
}
}
public int elementOnTheTop() {
}
public int getSize() {
}
public boolean isEmpty()
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started