Exemplo n.º 1
0
        public MockProductsService()
        {
            Product product1 = new CrossCountrySki
            {
                Id           = 1,
                PricePerHour = 50,
                Name         = "Fisher",
                Size         = 150,
                BarCode      = "05454"
            };

            Product product2 = new Goggles
            {
                Id           = 2,
                PricePerHour = 15,
                Name         = "Polsport",
                BarCode      = "45454"
            };

            Product product3 = new DownHillSki
            {
                Id           = 3,
                PricePerHour = 75,
                Name         = "Salomon",
                BarCode      = "55555"
            };

            products.Add(product1);
            products.Add(product2);
            products.Add(product3);
        }
Exemplo n.º 2
0
        private static void CalculateRentTest()
        {
            Write("Podaj imię: ");
            string firstName = ReadLine();

            Write("Podaj nazwisko: ");
            string lastName = ReadLine();

            var rentee = new Man();

            rentee.FirstName = firstName;
            rentee.LastName  = lastName;

            Product item = new CrossCountrySki
            {
                Id           = 1,
                PricePerHour = 50,
                Name         = "Fisher",
                Size         = 150,
            };

            var rent = new Rent(rentee, item)
            {
                Id = 1,
            };

            // zwrot

            Thread.Sleep(TimeSpan.FromSeconds(1));

            rent.Return();

            ICalculatorFactory calculatorFactory = new CalculatorFactory();

            ICostCalculator calculator = calculatorFactory.Create(rent);

            rent.Cost = calculator.Calculate(rent);
        }