Browse Source

Added base class for inheritance

master
Jake Howard 5 years ago
parent
commit
ac25357c68
  1. 12
      Base.cs
  2. 5
      Product.cs
  3. 1
      product-list.csproj

12
Base.cs

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

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

1
product-list.csproj

@ -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>

Loading…
Cancel
Save