Ejemplo n.º 1
0
        /// <summary>
        /// 这里只使用了Rental的信息没有使用Consumer的信息
        /// 这里的代码是否放错了位置????
        /// </summary>
        private double AmountForTemp(Rental02 rental)
        {
            double result = 0;

            switch (rental.Movie.PriceCode)
            {
            case Movie02.REGULAR:
                result += 2;
                if (rental.DaysRented > 2)
                {
                    result += (rental.DaysRented - 2) * 1.5;
                }
                break;

            case Movie02.NEW_RELEASE:
                result += rental.DaysRented * 3;
                break;

            case Movie02.CHILDRENS:
                result += 1.5;
                if (rental.DaysRented > 3)
                {
                    result += (rental.DaysRented - 3) * 1.5;
                }
                break;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public void MovieRental_Start()
        {
            var movie    = new Movie02("终结者", 2);
            var rental   = new Rental02(movie, 3);
            var customer = new Customer02("sinx");

            customer.AddRental(rental);
            var          desc   = customer.Statement();
            const string expect = @"Rental Record for sinx
	终结者	1.5
Amount owed is 1.5
You earned 1 frequent renter points";

            Assert.Equal(expect, desc);
        }
Ejemplo n.º 3
0
 public void AddRental(Rental02 rental)
 {
     _rentals.Add(rental);
 }