Untitled
unknown
plain_text
2 years ago
859 B
5
Indexable
Air Traffic Control Simulator // create a simulator class class Simulator { // define variables private int maxPlanes = 10; private int numPlanes = 0; private List<Plane> planes = new ArrayList<Plane>(); // constructor public Simulator() { } // add a plane to the simulator public void addPlane(Plane plane) { if (numPlanes < maxPlanes) { planes.add(plane); numPlanes++; } else { System.out.println("Too many planes in the simulator!"); } } // remove a plane from the simulator public void removePlane(Plane plane) { if (numPlanes > 0) { planes.remove(plane); numPlanes--; } else { System.out.println("No more planes in the simulator!"); } } // get the number of planes in the simulator public int getNum
Editor is loading...