Hi,
I'm studying for an exam, and I'm having some problems with the last question.
I'm in quite desperate need for help. This isn't an assignment, rather it's for me to study (and try tro remember).
The question is as follows:
1.1
A. Implement the modell above (fig. 1.1). All instance-variables(?) shall be private and have public access methods. The addApartment-method should add an apartment and the findApartment-method should return an Apartment (nbr in Apartment is unique). If there's no apartment with the actual nbr then null should be returned.
info: area = surface in squaremeters(sqrm), rentPerMonth(rent per month),
- rentPerSqrm = rentPerMonth / area
- rentPerYear = rentPerMonth * 12
B. Implement the methods totalRentPerMonth(): double and area():int in the class House. (figure 1.2)
- area():int should return the total area of all the apartments
- totalRentPerMonth():double should return the total monthly rent for all the apartments
C. Implement a class (main method) that tests all of the methods in the class. The program is to create a house and two apartments and print these out. The methods in B (above) is also to be tested.
Create the following house:
- Housenumber: 1, Address: Main Street 2, Buying price: 25 500 000
Create the following apartments for the house:
- Apartment number: 1, monthly rent: 6300, area 40(sqrm)
- Apartment number: 2, monthly rent: 8400, area 65(sqrm)
D. Write a method that updates the monthly rent for a certain apartment. The method shall take in the apartment number (nbr) and turn the new monthly rent into a parameter. If the apartment doesn't exist, nothing should be done.
- public void updateRentPerMonth( int apartmenNbr, double newRent)
The method should be in the class House.
1.2