How to assign an object to another object
<p>I'm trying to model a program with 3 classes; Hotel, Room and Guest. I've already looked around on the site and altough some problems were similar, I didn't come across mine. The problem I have is that I'm not able to set a specific guest to a specific room. The code I have is as follows:</p>

<pre><code>class Hotel{
  Room[] rooms;
  Hotel() {
    rooms = new Room[10];
    Guest Rob = new Guest("Rob");
    for (int j=0; j&lt;rooms.length;j++){
      rooms[j] = new Room(null);
    }
  }

  Guest checkIn(Guest){
    for (int i=0; i&lt;rooms.length; i++){
      if(rooms[i]!=null){
        rooms[i] = Guest;
        return;
      }
    }
 }

  public static void main(String[] args) {
    new Hotel();
  }
}

class Room{
  Guest guest;

  Room (Guest n){
    this.guest = n;
  }
}

class Guest{
  String guestname;

  Guest(String n) {
    this.guestname = n; 
  }
}
</code></pre>

<p>Which is as far as I'm right now. I managed to create new guests, but now I want to be able to check for null in rooms (starting with the first room in the aray), and assign the guest to the first room in the array with null. 
I already made a method which I believe can do this; checkIn(Guest), but I'm unsure about what should be put inside to actually set the (guest) to the room[i].</p>

<p>Any help would be greatly appreciated. Apologies for any formating errors, this is my first post here.</p>

<p>Kind regards,</p>

<p>Rob</p>