----------- /4 public abstract ----------- 1 RentalPlace { private int floor; protected double area; protected double rentalPricePerM; public double double RentalPlace(int f, a, r) { floor = f; area = a; rentalPricePerM = r; } public ----------- 1 RentalPlace(RentalPlace p) { = p.floor; area = p.area; rentalPricePerM = p.rentalPricePerM; } public abstract double ----------- 1 calculateRent(); public int return ----------- 1 getFloor() { floor; } public double return getArea() { area; } } ----------- /6 public extends ----------- 1 Shop RentalPlace { private int frontSide; public double double int Shop (int f, a, r, fs) { super(f, ----------- 1 a, r); frontSide = fs; } public ----------- 1 Shop (Shop s) { super(s); ----------- 1 frontSide = s.frontSide; } public double ----------- 1 calculateRent() { return ((area * rentalPricePerM) + (frontSide * 3000.0) ); } public int ----------- 1 getFrontSide() { return frontSide; } } Exercise 3: Let’s consider the same class and its sub-classes as described in exercise 2. RentalPlace class: Building
public abstract RentalPlace { ----------- 1 ----------- /4 private int floor; protected double area; protected double rentalPricePerM; public RentalPlace(int f, double a, double r) { floor = f; area = a; rentalPricePerM = r; } public RentalPlace(RentalPlace p) { ----------- 1 = p.floor; area = p.area; rentalPricePerM = p.rentalPricePerM; } public abstract double calculateRent(); ----------- 1 public int getFloor() { return floor; } ----------- 1 public double getArea() { return area; } } public Shop extends RentalPlace { ----------- 1 ----------- /6 private int frontSide; public Shop (int f, double a, double r, int fs) { super(f, a, r); ----------- 1 frontSide = fs; } public Shop (Shop s) { ----------- 1 super(s); ----------- 1 frontSide = s.frontSide; } public double calculateRent() { ----------- 1 return ((area * rentalPricePerM) + (frontSide * 3000.0) ); } public int getFrontSide() { ----------- 1 return frontSide; } } Exercise 3: Let’s consider the same class RentalPlace and its sub-classes as described in exercise 2. Building class:
solutionfinalexamfall2015-v2.docx