Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Building;
- import Person.Person;
- import java.util.Arrays;
- /**
- * Created by Ricsko on 2017. 03. 01..
- */
- public class Room {
- private final static int MAXIMUMNUMBER = 10;
- private static Person[] thelist = new Person[MAXIMUMNUMBER];
- private static int iAdd = 0;
- private int iRemove = 0;
- public static void addPerson(Person PObject){
- if(iAdd < thelist.length){
- thelist[iAdd] = PObject;
- iAdd++;
- }
- }
- public void removePerson(Person PObject){
- if(iRemove < thelist.length){
- if(thelist[iRemove].equals(PObject)){
- thelist[iRemove] = null;
- }
- }
- }
- public void showPeopleInRoom(){
- for (int i = 0; i < thelist.length; i++) {
- System.out.println(i + "\t" +thelist[i]);
- }
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Room room = (Room) o;
- if (iAdd != room.iAdd) return false;
- if (iRemove != room.iRemove) return false;
- // Probably incorrect - comparing Object[] arrays with Arrays.equals
- return Arrays.equals(thelist, room.thelist);
- }
- @Override
- public int hashCode() {
- int result = Arrays.hashCode(thelist);
- result = 31 * result + iAdd;
- result = 31 * result + iRemove;
- return result;
- }
- public void kiirRoom(){
- System.out.println(this);
- }
- @Override
- public String toString() {
- return "Room{" +
- "thelist=" + Arrays.toString(thelist) +
- '}';
- }
- }
Add Comment
Please, Sign In to add comment