c# - Rooms and Guests (object add to another object?) -


basically creating hotel check in kind of system , wanting create rooms 1-100 when create new object guest want assign guest room object if me. here have far guest , room class.

edit: sorry not making clear asking. wanting know how can connect guest object room object using leadname property if possible? , best way store these rooms , properties such guests staying in them etc?

roomclass:

 using system;  using system.collections.generic;  using system.linq;  using system.text;  using system.threading.tasks;  namespace hotel_check_in {  public class room     {      public int roomnumber;      public string roomtype;      public string smokingallowed;      public boolean booked;      private guest leadname;       public room()      { }     } } 

guest class:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks;  namespace hotel_check_in {     public class guest     {        public string leadname;        public int roomnumber;         public guest(string name, int roomn)        {           leadname = name;           roomnumber = roomn;        }     }     } 

try getting lead. made guest public instead of private.

using system;  using system.collections.generic;  using system.linq;  using system.text;    namespace hotel_check_in  {      class program      {          static void main(string[] args)          {              string lead = "johnsmith";              room room = room.rooms.asenumerable()                  .where(x => x.leadname.leadname == lead).firstordefault();          }      }      public class room      {          public static list<room> rooms = null;          public int roomnumber;          public string roomtype;          public string smokingallowed;          public boolean booked;          public guest leadname;            public room(int numberofrooms)          {              (int = 1; <= numberofrooms; i++)              {                  room newroom = new room();                  rooms.add(newroom);                  newroom.roomnumber = i;              }          }        }      public class guest      {          public string leadname;          public int roomnumber;            public guest(string name, int roomn)          {              leadname = name;              roomnumber = roomn;          }      }      }


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -