static void Main(string[] args) { try { BoundedBag <string> b = new BoundedBag <string>("ShoppingList", 10); b.insert("apple"); b.insert("eggs"); b.insert("milk"); b.saveBag("C:/test/mybag.txt"); BoundedBag <string> c = new BoundedBag <string>("ShoppingList", 10); c.loadBag("C:/test/mybag.txt"); Console.WriteLine(c.remove()); Console.WriteLine(c.remove()); Console.WriteLine(c.remove()); } catch (BagEmptyException) { Console.WriteLine("No more items remain in the bag, unable to remove."); } catch (BagFullExcepion) { Console.WriteLine("No more room in the bag, The bag is full!"); } Console.ReadKey(); }
public void isEmptyTest3() { BoundedBag <string> b = new BoundedBag <string>("bag", 3); b.insert("one"); b.remove(); Assert.IsTrue(b.isEmpty()); }
public void removeTest3() { BoundedBag <string> b = new BoundedBag <string>("bag", 3); b.insert("one"); b.insert("two"); b.insert("two"); try { b.remove(); b.remove(); } catch (BagEmptyException e) { } finally { Assert.IsFalse(b.isFull()); } }
public void removeTest1() { BoundedBag <string> b = new BoundedBag <string>("bag", 3); b.insert("one"); string s = b.remove(); Assert.IsTrue(s.Equals("one")); }
public void loadsaveTest() { BoundedBag <string> b = new BoundedBag <string>("bag", 3); b.insert("one"); b.insert("two"); b.insert("three"); b.saveBag("C:\\temp\\a1.txt"); BoundedBag <string> newb = new BoundedBag <string>("new", 3); newb.loadBag("C:\\temp\\a1.txt"); newb.remove(); Assert.IsFalse(newb.isFull()); }
public void removeTest2() { BoundedBag <string> b = new BoundedBag <string>("bag", 0); try { b.remove(); } catch (BagEmptyException e) { } finally { Assert.AreEqual("bag", b.getName()); } }
public void loadsaveTest() { BoundedBag <string> b = new BoundedBag <string>("bag", 3); b.insert("one"); b.insert("two"); b.insert("three"); b.saveBag("C:/Users/Goragottsen/Desktop/gbc/COMP2129/assignment/A101095885/A101095885/mybag.txt"); BoundedBag <string> newb = new BoundedBag <string>("new", 3); newb.loadBag("C:/Users/Goragottsen/Desktop/gbc/COMP2129/assignment/A101095885/A101095885/mybag.txt"); newb.remove(); Assert.IsFalse(newb.isFull()); }