April 2019
Intermediate to advanced
360 pages
9h 17m
English
The first class in our solution is the Roaster class. This class allows for the instantiation of multiple Roaster objects. The class contains a constructor method and an add() method for adding components to a roaster, and a display() method for displaying a roaster's components list:
import java.util.LinkedList;public class Roaster { private LinkedList<String> components; public Roaster() { components = new LinkedList<>(); } public void add(String component) { components.addLast(component); } public void display() { System.out.println("\n\nROASTER BUILD:"); for (int i=0; i<components.size(); i++) { System.out.println(components.get(i)); } }}
As shown in the preceding code, the java.util.LinkedList package was imported because ...
Read now
Unlock full access