Add Price and it's children.
authorMichael Welch <michaelgwelch@gmail.com>
Fri, 24 Feb 2012 15:04:27 +0000 (09:04 -0600)
committerMichael Welch <michaelgwelch@gmail.com>
Fri, 24 Feb 2012 15:04:27 +0000 (09:04 -0600)
RefactoringChapter1/Movie.cs
RefactoringChapter1/Price.cs [new file with mode: 0644]
RefactoringChapter1/RefactoringChapter1.csproj

index 378248c..8139128 100644 (file)
@@ -12,7 +12,7 @@ namespace RefactoringChapter1
         public Movie(string title, int priceCode)
         {
             _title = title;
-            _priceCode = priceCode;
+            PriceCode = priceCode;
         }
 
         public int PriceCode
diff --git a/RefactoringChapter1/Price.cs b/RefactoringChapter1/Price.cs
new file mode 100644 (file)
index 0000000..dd45832
--- /dev/null
@@ -0,0 +1,31 @@
+\feffnamespace RefactoringChapter1
+{
+    public abstract class Price
+    {
+        public abstract int PriceCode { get; }
+    }
+
+    public class ChildrensPrice : Price
+    {
+        public override int PriceCode
+        {
+            get { return Movie.Childrens; }
+        }
+    }
+
+    public class NewReleasePrice : Price
+    {
+        public override int PriceCode
+        {
+            get { return Movie.NewRelease; }
+        }
+    }
+
+    public class RegularPrice : Price
+    {
+        public override int PriceCode
+        {
+            get { return Movie.Regular; }
+        }
+    }
+}
index dd5df9f..ac622ba 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+\feff<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -34,6 +34,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Movie.cs" />
+    <Compile Include="Price.cs" />
     <Compile Include="Rental.cs" />
     <Compile Include="Customer.cs" />
   </ItemGroup>