[Solved] Add/get methods for lists of objects from different classes


The source code of Room is wrong. Basically, when you get or add something, you are creating a new room. Use the this qualifier to reference to the current room.

public int getBedNumber(int i){
    return this.beds.get(i).getNumber();
 }
 public List<Bed> getList() {
     return this.beds;
 }
 public void add(Bed beds) 
 {
        this.beds.add(beds);
 }

1

solved Add/get methods for lists of objects from different classes