/** * Creates a new hard drive storage with a given capacity. In this case the name of the storage * is a default name. * * @param capacity the capacity in MByte * @throws ParameterException when the capacity is not valid */ public HarddriveStorage(double capacity) throws ParameterException { if (capacity <= 0) { throw new ParameterException("HarddriveStorage(): Error - capacity <= 0."); } name = "HarddriveStorage"; this.capacity = capacity; init(); }
/** * Creates a new hard drive storage with a given name and capacity. * * @param name the name of the new hard drive storage * @param capacity the capacity in MByte * @throws ParameterException when the name and the capacity are not valid */ public HarddriveStorage(String name, double capacity) throws ParameterException { if (name == null || name.length() == 0) { throw new ParameterException("HarddriveStorage(): Error - invalid storage name."); } if (capacity <= 0) { throw new ParameterException("HarddriveStorage(): Error - capacity <= 0."); } this.name = name; this.capacity = capacity; init(); }