archive
/
product-list
Archived
1
Fork 0

Added base class for inheritance

This commit is contained in:
Jake Howard 2016-05-06 10:12:39 +01:00
parent ca79e66dae
commit ac25357c68
3 changed files with 16 additions and 2 deletions

12
Base.cs Normal file
View File

@ -0,0 +1,12 @@
using System;
namespace productlist
{
class Base
{
public string getName() {
return this.getType().Name;
}
}
}

View File

@ -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() {

View File

@ -41,6 +41,7 @@
<Compile Include="Product.cs" />
<Compile Include="UI.cs" />
<Compile Include="Storage.cs" />
<Compile Include="Base.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>