Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Room {
- private final int MAXPEOPLE;
- private Person[] person; //SZOBÁKBAN TARTÓZKODÓ EMBEREK
- Building build;
- public Room(int maxPeople) {
- this.MAXPEOPLE = maxPeople;
- this.person = new Person[MAXPEOPLE];
- }
- public void addPerson(Person object){
- for (int i = 0; i < person.length; i++) {
- if(object.isEmployee() && person[i] == null){
- person[i] = object;
- break;
- }
- }
- }
- public void removePerson(Person object){
- for (int i = 0; i < person.length; i++) {
- if(object.isEmployee()){
- person[i] = null;
- break;
- }
- }
- }
- public int getMAXPEOPLE() {
- return MAXPEOPLE;
- }
- public Person[] getPerson() {
- return person;
- }
- public void setPerson(Person object) {
- for (int i = 0; i < person.length; i++) {
- if (person[i] == null) {
- person[i] = new Person(object.getName(), object.getAge(), object.isEmployee());
- }
- }
- }
- @Override
- public String toString() {
- return "Room{" +
- "MAXPEOPLE=" + MAXPEOPLE +
- ", person=" + Arrays.toString(person) +
- ", build=" + build +
- '}';
- }
- }
Add Comment
Please, Sign In to add comment