Added base class for inheritance
This commit is contained in:
parent
ca79e66dae
commit
ac25357c68
3 changed files with 16 additions and 2 deletions
12
Base.cs
Normal file
12
Base.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace productlist
|
||||
{
|
||||
class Base
|
||||
{
|
||||
public string getName() {
|
||||
return this.getType().Name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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() {
|
||||
|
|
|
@ -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>
|
||||
|
|
Reference in a new issue