/**========================================================================= RestArea.class It is simulate a rest area on high way. It displaies the information on a panel which is a few miles ahead of it about the available parking spots for both cars and trucks. ===========================================================================*/ import java.util.*; public class RestArea { final int MAX_CARS = 80; final int MAX_TRUCKS = 50; private String name; private int availableCars; private int availableTrucks; public RestArea( ) { name = "None"; availableCars = 0; availableTrucks = 0; } public RestArea(String nm, int car, int truck) { name = nm; availableCars = car; availableTrucks = truck; } // Mutators public void setName(String nm) { name = nm; } public void setAvailableCars(int car) { availableCars = car; } public void setAvailableTrucks(int truck) { availableTrucks = truck; } // Accessors public String getName( ) { return name; } public int getAvailableCars( ) { return availableCars; } public int getAvailableTrucks( ) { return availableTrucks; } public void displayParkingInfo( ) { updateParkingInfo( ); System.out.println("The current available parking spots in " + name + " for car is: " + getAvailableCars( )); System.out.println("The current available parking spots in " + name + " for truck is: " + getAvailableTrucks( )); System.out.println( ); } public void updateParkingInfo( ) { Random rand = new Random( ); availableCars = MAX_CARS - rand.nextInt(MAX_CARS + 1); availableTrucks = MAX_TRUCKS - rand.nextInt(MAX_TRUCKS + 1); } }