ricskooo

Untitled

Mar 2nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. package Building;
  2. import Person.Person;
  3. import java.util.Arrays;
  4.  
  5. /**
  6. * Created by Ricsko on 2017. 03. 01..
  7. */
  8. public class Room {
  9.  
  10. private final static int MAXIMUMNUMBER = 10;
  11. private static Person[] thelist = new Person[MAXIMUMNUMBER];
  12. private static int iAdd = 0;
  13. private int iRemove = 0;
  14.  
  15. public static void addPerson(Person PObject){
  16. if(iAdd < thelist.length){
  17. thelist[iAdd] = PObject;
  18. iAdd++;
  19. }
  20. }
  21.  
  22. public void removePerson(Person PObject){
  23. if(iRemove < thelist.length){
  24. if(thelist[iRemove].equals(PObject)){
  25. thelist[iRemove] = null;
  26. }
  27. }
  28. }
  29.  
  30. public void showPeopleInRoom(){
  31. for (int i = 0; i < thelist.length; i++) {
  32. System.out.println(i + "\t" +thelist[i]);
  33. }
  34. }
  35.  
  36.  
  37. @Override
  38. public boolean equals(Object o) {
  39. if (this == o) return true;
  40. if (o == null || getClass() != o.getClass()) return false;
  41.  
  42. Room room = (Room) o;
  43.  
  44. if (iAdd != room.iAdd) return false;
  45. if (iRemove != room.iRemove) return false;
  46. // Probably incorrect - comparing Object[] arrays with Arrays.equals
  47. return Arrays.equals(thelist, room.thelist);
  48. }
  49.  
  50. @Override
  51. public int hashCode() {
  52. int result = Arrays.hashCode(thelist);
  53. result = 31 * result + iAdd;
  54. result = 31 * result + iRemove;
  55. return result;
  56. }
  57.  
  58. public void kiirRoom(){
  59. System.out.println(this);
  60. }
  61.  
  62. @Override
  63. public String toString() {
  64. return "Room{" +
  65. "thelist=" + Arrays.toString(thelist) +
  66. '}';
  67. }
  68.  
  69.  
  70. }
Add Comment
Please, Sign In to add comment