From ac25357c68e0c3b71b0d5f642954e1cf1119e70c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 6 May 2016 10:12:39 +0100 Subject: [PATCH] Added base class for inheritance --- Base.cs | 12 ++++++++++++ Product.cs | 5 +++-- product-list.csproj | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 Base.cs diff --git a/Base.cs b/Base.cs new file mode 100644 index 0000000..223c401 --- /dev/null +++ b/Base.cs @@ -0,0 +1,12 @@ +using System; + +namespace productlist +{ + class Base + { + public string getName() { + return this.getType().Name; + } + + } +} diff --git a/Product.cs b/Product.cs index 28e850c..54f04fa 100644 --- a/Product.cs +++ b/Product.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json; namespace productlist { - public class Product + public class Product : Base { public string name; public int version; @@ -34,7 +34,8 @@ namespace productlist } public override string ToString() { - return String.Format ("Product {0}", this.name); + string className = this.getName(); + return String.Format ("{0} {1}", className, this.name); } public string serialize() { diff --git a/product-list.csproj b/product-list.csproj index 275a0e3..08614a4 100644 --- a/product-list.csproj +++ b/product-list.csproj @@ -41,6 +41,7 @@ +