Create a directory in your repository named a7 and include all of the files for this assignment in the a7 directory. Place all files within the a7 package.
- Write an Interface named Building that represents a physical structure.
- The interface should require access methods (getters) for the square footage (double) of the building and for the address (String).
- Write a class named CommercialBuilding that implements the Building interface.
- The CommercialBuilding class should include a field for the number of units in the building (int) along with an access method for the field.
- The class should set all of its fields in the constructor using arguments passed to the constructor.
- Write an exception class named IllFormedApartmentBuildingException.
- The class should have a constructor that takes a String as an argument and saves the string in a field named reason.
- The class has a toString() method that returns the string “Ill formed apartment building: “ concatenated with the reason
- Write a class named ApartmentBuilding that is a subclass of CommercialBuilding.
- The ApartmentBuilding class has additional field that indicates if there is a penthouse apartment in the building (boolean).
- The constructor should set all of the class fields using the values of the arguments passed into the constructor.
- The constructor should throw an IllFormedApartmentBuildingException if the address is null.
- The class should have access methods to get the values stored in the fields but should not contain modifier methods.
- The class should override equals, hashCode, and toString.
- Write a driver that does the following:
- It creates two objects of type ApartmentBuilding for the following apartment buildings:
- The apartment building at “35 Main Street” has 24000 square feet, 16 units, and has a penthouse apartment.
- The apartment building at “100 Oak Avenue” has 3000 square feet, 2 units, and does not have a penthouse apartment.
- Your driver should catch an IllFormedApartmentBuildingException exception and print the reason string if the exception is thrown.
- Add code to your driver to thoroughly test all of the methods in your classes.
- It creates two objects of type ApartmentBuilding for the following apartment buildings:
© 2017 – 2019, Eric. All rights reserved.