/// <summary> /// 这里只使用了Rental的信息没有使用Consumer的信息 /// 这里的代码是否放错了位置???? /// </summary> private double AmountForTemp(Rental03 rental) { double result = 0; switch (rental.Movie.PriceCode) { case Movie03.REGULAR: result += 2; if (rental.DaysRented > 2) { result += (rental.DaysRented - 2) * 1.5; } break; case Movie03.NEW_RELEASE: result += rental.DaysRented * 3; break; case Movie03.CHILDRENS: result += 1.5; if (rental.DaysRented > 3) { result += (rental.DaysRented - 3) * 1.5; } break; } return(result); }
public void MovieRental_Start() { var movie = new Movie03("终结者", 2); var rental = new Rental03(movie, 3); var customer = new Customer03("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); }
public void AddRental(Rental03 rental) { _rentals.Add(rental); }