public void GivenRatingReturnRequiredRating()
        {
            RegularCustomer regularCustomer = new RegularCustomer();

            hotelSystem.AddHotel(new Hotel("Lakewood", 5, 10000, 11000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Bridgewood", 4, 5000, 6000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Ridgewood", 3, 20000, 21000, regularCustomer));
            Assert.AreEqual(5, hotelSystem.hotelList[0].rating);
        }
        public void GivenWeekendAndWeekdayRatesReturnWeekendRateForRegularCustomer()
        {
            RegularCustomer regularCustomer = new RegularCustomer();

            hotelSystem.AddHotel(new Hotel("Lakewood", 10000, 11000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Bridgewood", 5000, 6000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Ridgewood", 20000, 21000, regularCustomer));
            Assert.AreEqual(11000, hotelSystem.hotelList[0].weekendRatesForCustomer);
        }
        public void GivenHotelCheckName()
        {
            string          hotelName = "Lakewood";
            int             ratesForRegularCustomer = 10000;
            RegularCustomer regularCustomer         = new RegularCustomer();
            Hotel           hotel = new Hotel(hotelName, ratesForRegularCustomer, regularCustomer);

            hotelSystem.AddHotel(hotel);
            Assert.AreEqual("Lakewood", hotelSystem.hotelList[0].name);
        }
        public void GivenHotelOptionsReturnCheapestHotelForRegularCustomer()
        {
            RegularCustomer regularCustomer = new RegularCustomer();

            hotelSystem.AddHotel(new Hotel("Lakewood", 10000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Bridgewood", 5000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Ridgewood", 20000, regularCustomer));
            string[] dates         = "10Dec2020,11Dec2020".Split(",");
            Hotel    cheapestHotel = hotelSystem.GetCheapestHotel(dates);

            Assert.AreEqual("Bridgewood", cheapestHotel.name);
        }
        public void GivenWeekendAndWeekdayRateReturnBestRatedRestaurantForRegularCustomerWithRegexValidation()
        {
            RegularCustomer regularCustomer = new RegularCustomer();

            hotelSystem.AddHotel(new Hotel("Lakewood", 4, 80, 80, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Bridgewood", 3, 110, 50, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Ridgewood", 5, 100, 40, regularCustomer));
            string[] dates         = "10Dec2020,11Dec2020".Split(",");
            Hotel    cheapestHotel = hotelSystem.GivenWeekendAndWeekdayRateReturnBestRatedRestaurantForCustomerWithRegexValidation(dates);

            Assert.AreEqual("Ridgewood", cheapestHotel.name);
        }
        public void GivenWeekendAndWeekdayRateReturnBestRatedRestaurantForRegularCustomer()
        {
            RegularCustomer regularCustomer = new RegularCustomer();

            hotelSystem.AddHotel(new Hotel("Lakewood", 4, 10000, 11000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Bridgewood", 5, 5000, 6000, regularCustomer));
            hotelSystem.AddHotel(new Hotel("Ridgewood", 3, 20000, 21000, regularCustomer));
            string[]   dates = "10Dec2020,11Dec2020".Split(",");
            DateTime[] date  = new DateTime[2];
            date[0] = DateTime.Parse(dates[0]);
            date[1] = DateTime.Parse(dates[1]);
            Hotel cheapestHotel = hotelSystem.GetHotelWithBestRating(date);

            Assert.AreEqual(5, cheapestHotel.rating);
        }
Ejemplo n.º 7
0
 private void button1_Click(object sender, EventArgs e)
 {
     HideElements();
     if (textBox1.Text.Trim().Equals(""))
     {
         label6.Show();
     }
     else
     {
         RegularCustomer customer = new RegularCustomer(textBox1.Text);
         customer.DisplayBoard = displayBoard;
         textBox2.Text         = customer.BuyTickets();
         CleanTextboxes();
     }
 }
Ejemplo n.º 8
0
   static void Main()
   {
      Customer aRegularCustomer = new RegularCustomer();
      FrequentCustomer aFrequentCustomer = new FrequentCustomer();
      aRegularCustomer.CustNum = 2514;
      aRegularCustomer.custBalance = 765.00;
      aFrequentCustomer.custNum = 5719;
      aFrequentCustomer.CustBalance = 2500.00;
      aFrequentCustomer.DiscountRate = 0.15;
      Console.WriteLine("\naRegularCustomer #{0} owes {1}",
         aRegularCustomer.CustNum,
         aRegularCustomer.CustBalance.ToString(C2));
      Console.WriteLine("\naFrequentCustomer #{0 would owe {1} without the discount",
         aFrequentCustomer.CustNum,
         aFrequentCustomer.CustBalance.ToString(C2)); 
      double newBal = (1 - aFrequentCustomer.DiscountRate) *
         aFrequentCustomer.CustBalance;
      Console.WriteLine("...with {0} discount, customer owes {1}",
         aFrequentCustomer.discountRate.ToString("P"), newBal.ToString("C"));
}
Ejemplo n.º 9
0
        static void Main()
        {
            //create a new billing system
            BillingSystem billingSystem = new BillingSystem(4);

            //create some customers
            RegularCustomer regularCustomer1 = new RegularCustomer("Customer1");
            RegularCustomer regularCustomer2 = new RegularCustomer("Customer2", 100.5);
            VIPCustomer     vIPCustomer1     = new VIPCustomer("Customer3", "Tel-Aviv");
            VIPCustomer     vIPCustomer2     = new VIPCustomer("Customer4", "Jerusalem", 1000);

            ////we can't create a Customer class instance
            //Customer customer = new Customer("Customer5");

            //Add Customers to the billing system
            //would be better to add an overload taking parmas array
            try
            {
                Console.WriteLine($"adding 4 customers");
                billingSystem.AddCustomer(regularCustomer1);
                billingSystem.AddCustomer(vIPCustomer1);
                billingSystem.AddCustomer(regularCustomer2);
                billingSystem.AddCustomer(vIPCustomer2);
            }
            catch (TooManyCustomersException e)
            {
                Console.WriteLine($"Max customers reached: {e.MaxCustomersAllowed}");
            }

            //print the system before change
            Console.WriteLine(billingSystem);

            //Calling the UpdateBalane
            billingSystem.UpdateBalance(amountToAdd);
            Console.WriteLine($"Adding {amountToAdd} to all Customers\nVip should get 80% of the amount: {amountToAdd * 0.8}\nAnd Regular customers should get 100%\n");

            //print the system after change
            Console.WriteLine(billingSystem);

            try
            {
                Console.WriteLine(billingSystem[2, "Customer1"]);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine($"Argument Exception !: {e.Message}");
            }

            #region Sorting Exmp
            Console.WriteLine("Sorting Customers by default Icomparer [by Id]");
            billingSystem.Sort();
            Console.WriteLine(billingSystem);
            Console.WriteLine("Sorting Customers by a specified Icomparer [by balance]");
            billingSystem.Sort(new CompareCustomerByBalance());
            Console.WriteLine(billingSystem);
            Console.WriteLine("Sorting Customers by a specified Icomparer [by name(Generic implementation)]");
            billingSystem.Sort(new CompareCustomerByNameGeneric());
            Console.WriteLine(billingSystem);
            #endregion

            for (int i = 0; i < billingSystem.Length; i++)
            {
                if (!(billingSystem[i] is IAdressable adressable))
                {
                    continue;
                }
                Console.WriteLine(adressable.GetAdress());
            }

            #region Exc #7
            Random rnd = new Random();

            CustomerService customerService = new CustomerService();
            billingSystem.OnUnreasonableCustomerBalance += customerService.OnUnreasonableCustomerBalance;

            AccountingClerk accountingClerk = new AccountingClerk();
            billingSystem.OnUnreasonableCustomerBalance += accountingClerk.OnUnreasonableCustomerBalance;

            billingSystem.DoToAllCustomers(c => { c.AddToBalance(rnd.Next(2000001)); });
            #endregion
        }
Ejemplo n.º 10
0
    public static void Main(string[] args)
    {
        RegularCustomer rc = new RegularCustomer(2134, "Tom Cruise", "Credit Card");

        Console.WriteLine("Custmer ID: {0}\nCustomer Name: {1}\nPayment Method: {2}", rc.CustId, rc.CustName, rc.Payment);
    }
Ejemplo n.º 11
0
 public void SetupTest()
 {
     _customer = CustomerMother.GetCustomer1();
 }
Ejemplo n.º 12
0
 public Hotel(string hotelName, int rating, int weekdayRatesForRegularCustomer, int weekendRatesForRegularCustomer, RegularCustomer regularCustomer)
 {
     this.name   = hotelName;
     this.rating = rating;
     this.weekdayRatesForCustomer = weekdayRatesForRegularCustomer;
     this.weekendRatesForCustomer = weekendRatesForRegularCustomer;
 }
Ejemplo n.º 13
0
 public Hotel(string name, int weekdayRatesForRegularCustomer, int weekendRatesForRegularCustomer, RegularCustomer regularCustomer)
 {
     this.name = name;
     this.weekdayRatesForCustomer = weekdayRatesForRegularCustomer;
     this.weekendRatesForCustomer = weekendRatesForRegularCustomer;
 }
Ejemplo n.º 14
0
 public Hotel(string name, int ratesForRegularCustomer, RegularCustomer regularCustomer)
 {
     this.name = name;
     weekdayRatesForCustomer = ratesForRegularCustomer;
 }