ricskooo

Untitled

Mar 7th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public class Room {
  2. private final int MAXPEOPLE;
  3. private Person[] person; //SZOBÁKBAN TARTÓZKODÓ EMBEREK
  4. Building build;
  5.  
  6. public Room(int maxPeople) {
  7. this.MAXPEOPLE = maxPeople;
  8. this.person = new Person[MAXPEOPLE];
  9. }
  10.  
  11. public void addPerson(Person object){
  12. for (int i = 0; i < person.length; i++) {
  13. if(object.isEmployee() && person[i] == null){
  14. person[i] = object;
  15. break;
  16. }
  17. }
  18. }
  19.  
  20. public void removePerson(Person object){
  21. for (int i = 0; i < person.length; i++) {
  22. if(object.isEmployee()){
  23. person[i] = null;
  24. break;
  25. }
  26. }
  27. }
  28.  
  29. public int getMAXPEOPLE() {
  30. return MAXPEOPLE;
  31. }
  32.  
  33. public Person[] getPerson() {
  34. return person;
  35. }
  36.  
  37. public void setPerson(Person object) {
  38. for (int i = 0; i < person.length; i++) {
  39. if (person[i] == null) {
  40. person[i] = new Person(object.getName(), object.getAge(), object.isEmployee());
  41. }
  42. }
  43. }
  44.  
  45. @Override
  46. public String toString() {
  47. return "Room{" +
  48. "MAXPEOPLE=" + MAXPEOPLE +
  49. ", person=" + Arrays.toString(person) +
  50. ", build=" + build +
  51. '}';
  52. }
  53. }
Add Comment
Please, Sign In to add comment