Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Part 3 (40 points). Modify the code so the user cannot directly access a tenant's Room class
  2. (i.e. avoid leaking information about the private variable “room”). The only way to evict (and
  3. possibly setting rent) should be through methods in the Apartment class. Below is an example
  4. of what you do not want to be possible. (Note: You may not simply delete the getRoom()
  5. method.)
  6. Incorrect example (current code):
  7. apartmentComplex[6] = new Apartment("Alexander", "studio");
  8. Room temp =apartmentComplex[6].getRoom();
  9. temp.evict();
  10. apartmentComplex[6].displayTennant(); // Alexander is evicted
  11. Correct example:
  12. apartmentComplex[6] = new Apartment("Alexander", "studio");
  13. Room temp =apartmentComplex[6].getRoom(); // temp should have the same information as
  14. Alexander's room
  15. temp.evict();
  16. apartmentComplex[6].displayTennant(); // Alexander is not evicted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement