示例#1
0
        static void Main(string[] args)
        {
            CashRegister register1 = new CashRegister("CR1");
            CashRegister register2 = new CashRegister();

            //Store store = new Store();
            //store.AddCashRegister(register1);
            //store.AddCashRegister(register2);

            register1.AddItem(58.5);
            register1.AddItem(5.9);
            register1.AddItem(5.5);
            register1.AddItem(18);
            register1.AddItem(5.59);

            register2.AddItem(52.5);
            register2.AddItem(15.5);
            register2.AddItem(53.5);
            register2.AddItem(544.5);

            Console.WriteLine();
            PrintReport(register1);

            Console.WriteLine();
            register2.Name = "CR2";
            PrintReport(register2);
            Console.WriteLine();

            //store.PrintReport();
            PrintStoreReport();
            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            CashRegister cr1 = new CashRegister();

            Console.WriteLine($"Adding an item worth 2.70 to Cash Register 1");
            Console.WriteLine($"Adding an item worth 3.45 to Cash Register 1");
            Console.WriteLine($"Adding an item worth 5.97 to Cash Register 1");
            cr1.AddItem(2.70);
            cr1.AddItem(3.45);
            cr1.AddItem(5.97);

            CashRegister cr2 = new CashRegister();

            Console.WriteLine($"Adding an item worth 12.52 to Cash Register 2");
            Console.WriteLine($"Adding an item worth 1.43 to Cash Register 2");
            Console.WriteLine($"Adding an item worth 15.57 to Cash Register 2");
            Console.WriteLine($"Adding an item worth 5.15 to Cash Register 2");
            cr2.AddItem(12.52);
            cr2.AddItem(1.43);
            cr2.AddItem(15.57);
            cr2.AddItem(5.15);

            Console.WriteLine("Cash Register CR1 Total: {0}", cr1.Total);
            Console.WriteLine("Cash Register CR1 Number of Items: {0}", cr1.NumberOfItems);
            Console.WriteLine("Cash Register CR2 Total: {0}", cr2.Total);
            Console.WriteLine("Cash Register CR2 Number of Items: {0}", cr2.NumberOfItems);

            Console.WriteLine("Total money from all cash registers: {0}", CashRegister.totalMoneyAllCRs);
            Console.WriteLine("Total items from all cash registers: {0}", CashRegister.totalItemsAllCRs);
        }
示例#3
0
        static void Main(string[] args)
        {
            CashRegister cr1 = new CashRegister();

            Console.WriteLine("Adding a total of 2.70 to cash register 1");
            Console.WriteLine("Adding a total of 3.45 to cash register 1");
            Console.WriteLine("Adding a total of 1.43 to cash register 1");
            Console.WriteLine("Adding a total of 5.97 to cash register 1");
            Console.WriteLine("Adding a total of 12.52 to cash register 1");

            cr1.AddItem(2.70);
            cr1.AddItem(3.45);
            cr1.AddItem(1.43);
            cr1.AddItem(5.97);
            cr1.AddItem(12.52);

            CashRegister cr2 = new CashRegister();

            Console.WriteLine("Adding a total of 4.70 to cash register 2");
            Console.WriteLine("Adding a total of 7.45 to cash register 2");
            Console.WriteLine("Adding a total of 1.43 to cash register 2");
            Console.WriteLine("Adding a total of 3.97 to cash register 2");
            Console.WriteLine("Adding a total of 13.52 to cash register 2");

            cr2.AddItem(4.70);
            cr2.AddItem(7.45);
            cr2.AddItem(1.43);
            cr2.AddItem(3.97);
            cr2.AddItem(13.52);

            Console.WriteLine("Cash Register Cr1 Total >> {0}", cr1.total);
            Console.WriteLine("Cash Register Cr1 Number of items >> {0}", cr1.numberOfItems);
            Console.WriteLine("Cash Register Cr2 Total >> {0}", cr2.total);
            Console.WriteLine("Cash Register Cr2 Number of items >> {0}", cr2.numberOfItems);

            Console.WriteLine("Total money from all registers : {0}", CashRegister.AllCRS);
            Console.WriteLine("Total items from all registers : {0}", CashRegister.TotalitemsAllcrs);
        }
示例#4
0
 public void AddCashRegister(CashRegister cashRegister)
 {
     cashRegisters.Add(cashRegister);
 }
示例#5
0
 public Store(CashRegister cashRegister)
 {
     cashRegisters = new List <CashRegister>();
     AddCashRegister(cashRegister);
 }
示例#6
0
 private static void PrintReport(CashRegister register)
 {
     Console.WriteLine("Total cash in {0} is: {1:C} ", register.Name, register.GetTotalCash());
     Console.WriteLine("Total Items count in {0} is: {1} ", register.Name, register.GetTotalItems());
 }
示例#7
0
 static void AddItem(CashRegister register, double price)
 {
     register.AddItem(price);
 }