Q:

Create Class with another class

I decided to write my first Java Program-HotelPRO
.Classes are below:
package hotelpro;
public class Customer {

    String name;
    int PESEL;
    Room room;   
}

public class Room {
    int RoomNo;
    boolean Occupied=false;
    Room(int RoomNo){
    this.RoomNo=RoomNo;

    }   
}

package hotelpro;

public class HotelPro {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Room[] rooms=new Room[10];
          for (int i=0;i<rooms.length;i++)
          {
          rooms[i]=new Room(i);

          }

          for (int i=0;i<rooms.length;i++){
          System.out.println(rooms[i].RoomNo);
          System.out.println(rooms[i].Occupied);
          }

    }

}

So basically i created a Room with roomNumber and if its occupied.
Customer suppose to have a name,PESEL(polish id) and a room(which should be a constructor from Room class ?So all of the customers will have a room(default 0 which means no room) ) . Can You let me know how to do it ? i am pretty sure my code is wrong. 

A:

From your comment, I learned that you want a constructor for Customer. Here is one:
public class Customer {
    String name;
    int PESEL;
    Room room;

    // constructor for Customer with a room argument
    Customer(String name,int PESEL, Room room) {
        this.name=name;
        this.PESEL=PESEL;
        this.room = room;
        }
    }

    // constructor for Customer with a default room, though impractical :)
    Customer(String name,int PESEL) {
        this.name=name;
        this.PESEL=PESEL;
        this.room = new Room(0);
    }
}

Depending on the arguments passed to the Customer, the right constructor is invoked. For example, to create a Customer object with a Room assigned to it, you can do:
Room room = new Room(139);
Customer c = new Customer("Customer1", 10, room);

And to create a Customer with default room of 0, you can do this:
Customer c = new Customer("Customer1", 10);

