/// <summary> /// copy temproom to create a cinema /// </summary> /// <param name="temp">the temproom which becomes a cinema</param> public Cinema(TempRoom temp) { areaType = temp.areaType; position = temp.position; dimension = temp.dimension; model = Image.FromFile(@"..\..\Assets\Cinema.png"); model.RotateFlip(RotateFlipType.Rotate180FlipX);//rotate image so its correctly displayed id = temp.id; }
/// <summary> /// copy temproom to create restaurant /// </summary> /// <param name="temp">temprroom which becomes a restaurant</param> public Restaurant(TempRoom temp) { areaType = temp.areaType; position = temp.position; dimension = temp.dimension; capacity = temp.capacity; model = Image.FromFile(@"..\..\Assets\Restaurant.png"); model.RotateFlip(RotateFlipType.Rotate180FlipX);//rotate image so its correctly displayed id = temp.id; }
/// <summary> /// Generate a room /// </summary> /// <typeparam name="T">type of room</typeparam> /// <param name="room">areaType of the room</param> /// <param name="temp">temperary room for constructor</param> /// <returns>instance of the given type room</returns> public IRoom GenerateRoom <T>(string room, TempRoom temp) where T : IRoom { //get the type of the room Type type = Type.GetType(room); //if type is found return a instance of that type if (type != null) { return((IRoom)Activator.CreateInstance(type, temp)); } //else if type is not found. //search the namespace/current assembly for all types that are available //make a list out of all the types and look if one of those types contain the name of the areatype //if so set that type and create an instance of it. //if not, return the temp room. else { string nspace = "Hotel"; //query for all the types var q = from x in Assembly.GetExecutingAssembly().GetTypes() where x.IsClass && x.Namespace == nspace select x; List <string> types = new List <string>(); //put the query in the list foreach (Type t in q) { types.Add(t.ToString()); } //search the list and if found return instance. foreach (string t in types) { if (t.Contains(room)) { type = Type.GetType(t); return((IRoom)Activator.CreateInstance(type, temp)); } } } return(temp); }