public static void DoSliced(CartHandle accounted)
    {
        int amount;
        int quotient  = 0;
        int remainder = 0;
        int handle    = 0;

        Console.WriteLine("Please enter number of Sliced Ham to be purchased: ");
        amount = Convert.ToInt32(Console.ReadLine());
        int amountDouble = amount;

        handle = quotient = Math.DivRem(amount, 5, out remainder);
        Sliced newCart = new Sliced(handle, "5");

        if (quotient > 0)
        {
            accounted.AddSliced(newCart);
        }
        if (remainder > 0)
        {
            handle  = remainder = Math.DivRem(remainder, 3, out amountDouble);
            newCart = new Sliced(handle, "3");
            Console.WriteLine("this is the remainder " + amountDouble);

            accounted.AddSliced(newCart);
            if (amountDouble > 0)
            {
                Console.WriteLine("Please enter a valid Pack");
            }
        }
        accounted.PrintS();
    }
Exemple #2
0
        public unsafe void TestToString()
        {
            var str = "1234567890";

            fixed(char *ptr = str)
            {
                var s = new Sliced <char>(ptr, (nuint)str.Length);
                var a = s.ToString();

                Assert.AreEqual(a, "1234567890");
            }
        }
Exemple #3
0
        public unsafe void TestToArray()
        {
            var arr = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            fixed(int *ptr = arr)
            {
                var s = new Sliced <int>(ptr, (nuint)arr.LongLength);
                var a = s.ToArray();

                Assert.AreEqual(a, new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            }
        }
Exemple #4
0
        public unsafe void TestStackAlloc()
        {
            var ptr = stackalloc[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var s   = new Sliced <int>(ptr, 10u);

            Assert.AreEqual(s.First, 1);
            Assert.AreEqual(s[1], 2);
            var t = s.Tail;

            Assert.AreEqual(t.First, 2);
            Assert.AreEqual(t[3], 5);
        }
Exemple #5
0
        public unsafe void Test1()
        {
            var arr = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            fixed(int *ptr = arr)
            {
                var s = new Sliced <int>(ptr, (nuint)arr.LongLength);

                Assert.AreEqual(s.First, 1);
                Assert.AreEqual(s[1], 2);
                var t = s.Tail;

                Assert.AreEqual(t.First, 2);
                Assert.AreEqual(t[3], 5);
            }
        }
Exemple #6
0
        public unsafe void TestSlice()
        {
            var arr = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            fixed(int *ptr = arr)
            {
                var s = new Sliced <int>(ptr, (nuint)arr.LongLength);
                var a = s.Slice(2);

                Assert.AreEqual(a.First, 3);
                var b = s.SliceTo(3);

                Assert.AreEqual(b.Last, 3);
                var c = s.Slice(1, 3);

                Assert.AreEqual(c.First, 2);
                Assert.AreEqual(c.Last, 3);
            }
        }
Exemple #7
0
 public void AddSliced(Sliced GroceryToBeAdded)
 {
     _Sliced.Add(GroceryToBeAdded);
 }