Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Apartment {
- private int rooms;
- private int squareMeters;
- private int pricePerSquareMeters;
- public Apartment(int rooms, int squareMeters, int pricePerSquareMeters) {
- this.rooms = rooms;
- this.squareMeters = squareMeters;
- this.pricePerSquareMeters = pricePerSquareMeters;
- }
- public boolean larger(Apartment otherApartment) { //87.1
- if (this.rooms > otherApartment.rooms) {
- return true;
- }
- return false;
- }
- public int priceDifference(Apartment otherApartment) { //87.2
- int thisPrice = this.squareMeters * this.pricePerSquareMeters;
- int thatPrice = otherApartment.squareMeters * otherApartment.pricePerSquareMeters;
- if (thisPrice>thatPrice) {
- return thisPrice-thatPrice;
- } else {
- return thatPrice-thisPrice;
- }
- }
- public boolean moreExpensiveThan(Apartment otherApartment) { //87.3
- int thisPrice = this.squareMeters * this.pricePerSquareMeters;
- int thatPrice = otherApartment.squareMeters * otherApartment.pricePerSquareMeters;
- if (thisPrice>thatPrice) {
- return true;
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment