Enums
Read chapters 6, 7,8, 9.
Create an enumeration AptType representing several different types of apartment. Each type of apartment has a description, a size (square footage), and a rent amount. In the enumeration, provide public final instance variables for these. Also write a parameterized constructor that sets the values of these variables (doing this is just part of setting up the enum) The apartment types are
description | size (sq ft) | rent ($/mo) | |
studio | "Studio" | 520 | 480 |
one bedroom | "1 Bedroom" | 810 | 720 |
two bedroom | "2 Bedroom" | 1120 | 1030 |
luxury | "Luxury" | 1720 | 1780 |
☑ Add a static method rent(floor, num) which, if the apartment at that position in building is currently free, sets it as rented and (using the values from AptType) prints a message like
You are renting a 1120 square foot 2 Bedroom apartment for $1030 / month. Welcome to our building.If the apartment is already rented, print an apologetic message saying the apartment is taken. If the number requested is not valid in building (e.g., 15th floor) print an error message.
☑ In a class with a main,check that you can choose an apartment of each type from the building and rent it, but if you try to rent it again, you get an apology. Do this without ever creating a new Apartment in main.