Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Part 3 (40 points). Modify the code so the user cannot directly access a tenant's Room class
- (i.e. avoid leaking information about the private variable “room”). The only way to evict (and
- possibly setting rent) should be through methods in the Apartment class. Below is an example
- of what you do not want to be possible. (Note: You may not simply delete the getRoom()
- method.)
- Incorrect example (current code):
- apartmentComplex[6] = new Apartment("Alexander", "studio");
- Room temp =apartmentComplex[6].getRoom();
- temp.evict();
- apartmentComplex[6].displayTennant(); // Alexander is evicted
- Correct example:
- apartmentComplex[6] = new Apartment("Alexander", "studio");
- Room temp =apartmentComplex[6].getRoom(); // temp should have the same information as
- Alexander's room
- temp.evict();
- apartmentComplex[6].displayTennant(); // Alexander is not evicted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement