Add storage class to store list in memory

This commit is contained in:
Jake Howard 2016-04-15 11:58:13 +01:00
parent b7e983070c
commit f32cf745b6
2 changed files with 31 additions and 1 deletions

29
Storage.cs Normal file
View file

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
namespace productlist
{
public static class Storage
{
private static List<Product> productStorageList = new List<Product>();
public static void Add(Product p) {
productStorageList.Add (p);
}
private static void listProducts() {
if (productStorageList.Count < 1) {
Console.WriteLine ("No Products found!");
return;
}
foreach (Product p in productStorageList) {
p.display ();
}
}
public static void List() {
listProducts ();
}
}
}

View file

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