コード例 #1
0
        static void Main(string[] args)
        {
            ColouredPrint.PrintInRed("Welcome to Hotel Reservation System", false, false);
            Console.WriteLine("===================================");
            HotelDetails hotelDetailsTestObj = new HotelDetails();

            hotelDetailsTestObj.AddHotel("Lakewood", 3, 110, 90, 80, 80);
            hotelDetailsTestObj.AddHotel("Bridgewood", 4, 150, 50, 110, 50);
            hotelDetailsTestObj.AddHotel("Ridgewood", 5, 220, 150, 100, 40);
            CallingMethodsClass.ChooseOption();
        }
コード例 #2
0
        //private method or calling AddHotel Method
        private static void CallAddHotel()
        {
            Console.Write("Enter the Hotel Name : ");
            string hotelName = Console.ReadLine();

label2:
            Console.Write("Enter the Hotel Rating : ");
            int hotelRating;

            try
            {
                hotelRating = Convert.ToInt32(Console.ReadLine());
            }
            catch
            {
                ColouredPrint.PrintInMagenta("Wrong value");
                goto label2;
            }
label3:
            Console.Write("Enter the Weekday Rate For Regular Customer : ");
            int weekdayRateForRegularCust;
            int weekendRateForRegularCust;
            int weekdayRateForRewardCust;
            int weekendRateForRewardCust;

            try
            {
                weekdayRateForRegularCust = Convert.ToInt32(Console.ReadLine());
            }
            catch
            {
                ColouredPrint.PrintInMagenta("Wrong value");
                goto label3;
            }
label4:
            Console.Write("Enter the Weekend Rate For Regular Customer : ");
            try
            {
                weekendRateForRegularCust = Convert.ToInt32(Console.ReadLine());
            }
            catch
            {
                ColouredPrint.PrintInMagenta("Wrong value");
                goto label4;
            }
label5:
            Console.Write("Enter the Weekday Rate For Reward Customer : ");
            try
            {
                weekdayRateForRewardCust = Convert.ToInt32(Console.ReadLine());
            }
            catch
            {
                ColouredPrint.PrintInMagenta("Wrong value");
                goto label5;
            }
label6:
            Console.Write("Enter the Weekend Rate For Reward Customer : ");
            try
            {
                weekendRateForRewardCust = Convert.ToInt32(Console.ReadLine());
            }
            catch
            {
                ColouredPrint.PrintInMagenta("Wrong value");
                goto label6;
            }
            HotelDetails hotelDetailsObj = new HotelDetails();

            hotelDetailsObj.AddHotel(hotelName, hotelRating, weekdayRateForRegularCust, weekendRateForRegularCust, weekdayRateForRewardCust, weekendRateForRewardCust);
        }