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 data = new 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

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 Databases Questions!