Complete p 22 and 23. Extract Frequent Renter Points ExtractFrequentRenterPointsP22
authorMichael Welch <michaelgwelch@gmail.com>
Mon, 6 Feb 2012 22:11:09 +0000 (16:11 -0600)
committerMichael Welch <michaelgwelch@gmail.com>
Mon, 6 Feb 2012 22:11:09 +0000 (16:11 -0600)
RefactoringChapter1/Customer.cs
RefactoringChapter1/Rental.cs

index 4320fb4..71738c3 100644 (file)
@@ -32,15 +32,7 @@ namespace RefactoringChapter1
                        foreach (Rental rental in rentals)
                        {
                                
-                               // add frequent renter points
-                               frequentRenterPoints++;
-                       
-                               // add bonus for a two day new release rental
-                               if (rental.Movie.PriceCode == Movie.NewRelease &&
-                                   rental.DaysRented > 1)
-                               {
-                                       frequentRenterPoints++;
-                               }
+                               frequentRenterPoints += rental.FrequentRenterPoints;
                                
                                // show figures for this rental
                                result += "\t" + rental.Movie.Title + "\t" +
index e624163..c51ab18 100644 (file)
@@ -54,6 +54,17 @@ namespace RefactoringChapter1
                                return result;
                        }
                }
+               
+               public int FrequentRenterPoints 
+               {
+                       get
+                       {
+                               
+                               return (Movie.PriceCode == Movie.NewRelease &&
+                                   DaysRented > 1) ? 2 : 1;
+
+                       }
+               }
        }