From f32cf745b6f775aee406d5757ed7928f00262a01 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 15 Apr 2016 11:58:13 +0100 Subject: [PATCH] Add storage class to store list in memory --- Storage.cs | 29 +++++++++++++++++++++++++++++ product-list.csproj | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Storage.cs diff --git a/Storage.cs b/Storage.cs new file mode 100644 index 0000000..078b4fa --- /dev/null +++ b/Storage.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace productlist +{ + public static class Storage + { + private static List productStorageList = new List(); + + 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 (); + } + } +} + diff --git a/product-list.csproj b/product-list.csproj index b255b64..275a0e3 100644 --- a/product-list.csproj +++ b/product-list.csproj @@ -40,9 +40,10 @@ + - \ No newline at end of file +