package test3; import java.util.HashMap; import java.util.Map; /** * A class that represents USB ports on a computer. Each USB port * has a unique integer port number, and it is guaranteed that there * is only one USBPort for each port number. Each USB port is either connected * or not connected to an external device of some kind (such as a * USB key, for example). * * @author EECS1030_2014_14W * */ public class USBPort { // YOU NEED TO ADD A FIELD TO COMPLETE THE MULTITON IMPLEMENTATION private int portNumber; private boolean isConnected; /** * Create a new USB port having the given port number. The USB port * is not allowed to be connected to an external device when it is * created. * * @param portNumber the port number of the USB port * @pre. portNumber >= 0 * @pre. the USB port is not connected to an external device */ private USBPort(int portNumber) { } /** * Return the port number of this USB port. * * @return the port number of this USB port */ public int getPortNumber() { } /** * Connect the port to an external device. The state of the port * does not change if the port is already connected to an external * device. */ public void connect() { } /** * Disconnect the port from the external device. The state of the port * does not change if the port is already disconnected. */ public void disconnect() { } /** * Returns true if the port is connected to an external * device, and false otherwise. * * @return true if the port is connected to an external * device, and false otherwise. */ public boolean hasConnection() { } /** * Get the USB port with the given port number. The port number must * be an integer value greater than zero. A new USB port is created if * a USB port with the given port number does not exist. If a new USB * port is created then it is created assuming that the port is not * connected to an external device. * * @param portNumber the port number of the desired USB port * @return a USB port with the desired port number * @throws IllegalArgumentException if the port number is less * than or equal to zero */ public static USBPort getPort(int portNumber) { } /** * Returns the number of USB ports that have been created. * * @return the number of USB ports that have been created */ public static int getNumberOfPorts() { } }