Exemple #1
0
 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 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 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());
        }