Example #1
0
 public virtual Room CheckIn(Client client)
 {
     //Using LINQ to selecte the room needed for check-in
     var queryRoom =
                    from room in this.Rooms
                    where room.IsFree && room.IsCleaned && room.Kind == client.RoomToRent
                    select room;
     if (queryRoom.Count() == 0)
     {
         queryRoom =
                    from room in this.Rooms
                    where room.IsFree && room.IsCleaned && (int)room.Kind > (int)client.RoomToRent
                    select room;
     }
     if (queryRoom.Count() == 0)
     {
         throw new FacilityException("No free rooms!");
     }
     Room selectedRoom = queryRoom.First();
     client.Id = selectedRoom.RoomNumber;
     //When room is CheckedIn - it becomes NOT free and NOT clean
     selectedRoom.IsFree = false;
     selectedRoom.IsCleaned = false;
     return selectedRoom;
     //Returns the room
 }
 public bool CheckOut(Client client)
 {
     if (this.WorkPlace == null)
     {
         throw new PersonException("I'm unemployed! Please hire me!");
     }
     return this.WorkPlace.CheckOut(client);
 }
 public bool GiveRoom(Client client)
 {
     RoomKind clientsRoom = client.RoomToRent;
     if (client.RequestRentRoom(clientsRoom))
     {
         Room takenRoom = this.CheckIn(client);
         this.WorkPlace.TakenRooms.Add(takenRoom);
         this.WorkPlace.CollectMoney(client.PayForRoom());
         return true;
     }
     else
     {
         //Remove person from clients
         this.WorkPlace.Clients.Remove(client);
         return false;
     }
 }
 public string TryCheckOutRoom(Client client)
 {
     StringBuilder info = new StringBuilder();
     if (CheckOut(client))
     {
         info.AppendFormat("The client was checked out successfully").AppendLine();
         //Triger event RoomEventHandle which is reposible to clean the room
         if (this.RoomCleanEvent != null)
         {
             this.RoomCleanEvent(this, new RoomEventArgs((ushort)client.Id));
             info.AppendLine("Room was cleaned");
         }
     }
     else
     {
         info.AppendFormat("There is client like that in this room ! - Can't check out").AppendLine();
     }
     return info.ToString();
 }
 //Method used to triger the event WakeupCallEvent used for WakeUpCall
 public void WakeUpCall(ushort timer, Client requestor)
 {
     //Subsrcibe for event
     this.WakeupCallEvent += new Receptionist.CustomEventHandler(AlarmClock);
     if (this.WakeupCallEvent != null)
     {
         //Triger event
         this.WakeupCallEvent(this, new WakeupEventArgs(timer, requestor.Name));
     }
 }
Example #6
0
 public virtual bool CheckOut(Client client)
 {
     //Returns bool if the room is checked-out successfully
     var queryRoom =
                    from room in this.TakenRooms
                    where client.Id == room.RoomNumber
                    select room;
     if (queryRoom.Count() == 0)
     {
         try
         {
             throw new FacilityException("There is client like that in this room !");
         }
         catch
         {
             return false;
         }
     }
     Room selectedRoom = queryRoom.First();
     //Room is setted to free but not clean
     selectedRoom.IsCleaned = false;
     selectedRoom.IsFree = true;
     client = null;
     //Delete the client
     //Remove the room from the list of taken rooms
     this.TakenRooms.Remove(selectedRoom);
     return true;
 }
 public string EducateClient(Client client)
 {
     client.EducationLevel++;
     return string.Format("{0} has educated client {1} to level {2} of golf", this.Name, client.Name, client.EducationLevel);
 }
Example #8
0
        public static void GeneralTest()
        {
            //Creating some Clients
            Client firstClient = new Client("Jim Morrison", 203.54M,RoomKind.Double);
            Client secondClient = new Client("Ruppert Wane", 1882.33M, RoomKind.Single);
            Client thirdClient = new Client("Ann Smith", 4022.09M, RoomKind.Double);
            Client fourtClient = new Client("Martin Oliver", 1020.77M, RoomKind.Single);
            Client fifthClient = new Client("Gennifer Green", 7233.12M, RoomKind.Triple);

            //Creating some facilities
            Hotel hotelRome = new Hotel("Hotel Rome",Category.FourStar, numberOfPools: 3);
            Motel motelVega = new Motel("Motel Vega",Category.TwoStar, numberOfParkingPlaces: 50);
            Chalet chaletViva = new Chalet("Viva Chalet",Category.ThreeStar, numberOfSkiLifts: 3);
            SeaHotel sunnyBeachHotel = new SeaHotel("Sunny Beach Hotel",Category.FiveStar, numberOfPools: 5, numberOfBeachSpots: 250);
            //For Golf and Spa facility
            GolfFacility golfPravec = new GolfFacility(numberOfHoles: 18, dificultyLevel: 10);
            GolfAndSpa spaAndGolfPravec = new GolfAndSpa("Spa and Gold Complex Pravec",Category.FiveStar, golfPravec, numberOfPools: 2);

            //Creating rooms
            Room singleRoom = new Room(RoomKind.Single);
            Room doubleRoom = new Room(RoomKind.Double);
            Room tripleRoom = new Room(RoomKind.Triple);
            Room apartment = new Room(RoomKind.Apartment);

            //Add number of rooms to given facility
            hotelRome.AddRoomsToFacility(singleRoom, 2);
            hotelRome.AddRoomsToFacility(doubleRoom, 3);
            hotelRome.AddRoomsToFacility(apartment, 1);
            motelVega.AddRoomsToFacility(tripleRoom, 3);
            spaAndGolfPravec.AddRoomsToFacility(apartment, 2);
            spaAndGolfPravec.AddRoomsToFacility(doubleRoom, 2);
            chaletViva.AddRoomsToFacility(singleRoom);
            sunnyBeachHotel.AddRoomsToFacility(apartment, 200);

            //Creating personel
            Manager firstManager = new Manager("Bill McBrain", 3040.44M);
            Manager secondManager = new Manager("Vince Carter", 4000.33M);
            Housekeeping firstHousekeeper = new Housekeeping("Nick Watch", 500.40M);
            Housekeeping secondHousekeeper = new Housekeeping("Judy Baker", 500.40M);
            GolfInstructor golfInstructor = new GolfInstructor("James Dean", 1405M);

            //Create some receptionists
            Receptionist receptionist = new Receptionist("Pesho Armqnov", 930.94M);
            Receptionist receptionistPenka = new Receptionist("Penka  Ivanova", 346.49M);
            receptionist.AddLanguages(Languages.RU, Languages.DE, Languages.BG);
            receptionistPenka.AddLanguages(Languages.DE);

            //Process hotel
            //
            Console.WriteLine("Hotel info\n");
            //Getting managers
            hotelRome.HirePersonel(firstManager);

            //Hire some Personel
            firstManager.HirePersonel(firstHousekeeper);
            firstManager.HirePersonel(receptionist);

            //Housekeepers are waiting for orders
            firstHousekeeper.WaitingForOders(receptionist);

            //Add some clients
            hotelRome.Clients.Add(firstClient);
            hotelRome.Clients.Add(secondClient);

            //Print some personel
            Console.WriteLine("Some personel:");
            Console.WriteLine(hotelRome.GetPersonalByType(typeof(Receptionist)));
            Console.WriteLine(hotelRome.GetPersonalByType(typeof(Housekeeping)));

            //Test receptionists
            TestComunications(receptionist);

            Console.WriteLine("Before Check in :");
            Console.WriteLine("{0}'s balance: {1}", hotelRome.FacilityName, hotelRome.Finance);
            Console.WriteLine("{0}'s balance: {1}\n", firstClient.Name, firstClient.Ballance());

            //Check IN all the clients
            Console.WriteLine(receptionist.TryGivingRooms());

            Console.WriteLine("After Check in :");
            Console.WriteLine("{0}'s balance: {1}", hotelRome.FacilityName, hotelRome.Finance);
            Console.WriteLine("{0}'s balance: {1}\n", firstClient.Name, firstClient.Ballance());

            //List of taken rooms and all in hotel
            Console.WriteLine(hotelRome.ListTakenRooms());
            Console.WriteLine(hotelRome.ListRooms());

            //Check out
            Console.WriteLine(receptionist.TryCheckOutRoom(firstClient));
            //Status of the rooms after check out of 1 client
            Console.WriteLine("After check out: ");
            Console.WriteLine(hotelRome.ListTakenRooms());
            Console.WriteLine(hotelRome.ListRooms());
            Console.WriteLine("End of info about the hotel\n");
            ///
            ///END OF HOTEL

            //
            //
            //Process Golf and Spa
            Console.WriteLine("Golf and Spa info\n");
            //Getting managers
            spaAndGolfPravec.HirePersonel(secondManager);

            //Hire some Personel
            secondManager.HirePersonel(secondHousekeeper);
            secondManager.HirePersonel(golfInstructor);
            secondManager.HirePersonel(receptionistPenka);

            //Housekeepers are waiting for orders
            secondHousekeeper.WaitingForOders(receptionistPenka);

            //Add some clients
            spaAndGolfPravec.Clients.Add(thirdClient);
            spaAndGolfPravec.Clients.Add(fourtClient);
            spaAndGolfPravec.Clients.Add(fifthClient);

            //Print some personel
            Console.WriteLine("Some personel:");
            Console.WriteLine(spaAndGolfPravec.GetPersonalByType(typeof(Manager)));
            Console.WriteLine(spaAndGolfPravec.GetPersonalByType(typeof(GolfInstructor)));

            //Test receptionists
            TestComunications(receptionistPenka);
            Console.WriteLine("Before Check in :");
            Console.WriteLine("{0}'s balance: {1}", spaAndGolfPravec.FacilityName, spaAndGolfPravec.Finance);
            Console.WriteLine("{0}'s balance: {1}\n", thirdClient.Name, thirdClient.Ballance());

            //Check IN all the clients
            Console.WriteLine(receptionistPenka.TryGivingRooms());

            //Golf instuctor teaching client
            Console.WriteLine(golfInstructor.EducateClient(fourtClient));

            Console.WriteLine("After Check in :");
            Console.WriteLine("{0}'s balance: {1}", spaAndGolfPravec.FacilityName, spaAndGolfPravec.Finance);
            Console.WriteLine("{0}'s balance: {1}\n", thirdClient.Name, thirdClient.Ballance());
            ////List of taken rooms

            //List of taken rooms and all in golf and spa complex
            Console.WriteLine(spaAndGolfPravec.ListTakenRooms());
            Console.WriteLine(spaAndGolfPravec.ListRooms());

            //Check out
            Console.WriteLine(receptionistPenka.TryCheckOutRoom(fourtClient));

            //Status of the rooms after check out of 1 client
            Console.WriteLine("After check out: ");
            Console.WriteLine(spaAndGolfPravec.ListTakenRooms());
            Console.WriteLine(spaAndGolfPravec.ListRooms());
            Console.WriteLine("End of info about the Golf and Spa\n");
        }