コード例 #1
0
        public static void AppendCustomerToLine()
        /// function that accepts a reference of the super market line, and append a customer to the line if it meets the requirements.
        /// if the customer join the line, a random shopping list is generated for him
        /// <input>
        /// by ValidatedID, ValidatedBodyHeat, IsMaskOn and ShouldBeIsolated methods on PersonHandler Class
        /// </input>
        /// <output>
        /// outputs by the GetInLine outputs in SuperMarketQueue class
        /// </output>
        {
            // start getting the information about the customer - ID, name, body heat, mask on, isolated
            Console.WriteLine("Please provide the following information");
            Console.Write("Enter customer`s full name: ");
            string   FullName = Console.ReadLine();
            string   cust_ID  = PersonHandler.ValidatedID();
            double   bh       = PersonHandler.ValidateBodyHeat();
            bool     mask     = PersonHandler.IsMaskOn();
            bool     isolate  = PersonHandler.ShouldBeIsolated();
            Customer c        = new Customer(FullName, cust_ID, bh, mask, isolate);

            GetInLine(c);
            if (mask && isolate == false && PersonHandler.IsSick(bh) == false)
            {
                CustomerHandler.GenerateRandomShoppingList(c);
            }
        }
コード例 #2
0
        public static void CustomerDiscoveredSick()
        {
            Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); // Console view
            Console.WriteLine("Warning! did you end your employees shifts?");
            Console.WriteLine("Shift records only made after the employee ends his shift.");
            Console.WriteLine("If there is no shift history, there will no corona alerts!");
            Console.WriteLine("Press any key to continue");
            Console.ReadLine();
            Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); // Console view
            string   cust_id = PersonHandler.ValidatedID();
            Customer c       = CustomerHandler.GetCustomerByID(cust_id);

            if (c is null)
            {
                Console.WriteLine("Customer not found");
                return;
            }
            CashRegister CoronaCashRegister         = null; // will contain the cash register the sick customer cheched out at
            DateTime?    CoronaTime                 = null; // The time of the visit
            Employee     IsolatedCashier            = null;
            IEnumerable <CashRegister> AllRegs_Temp = new List <CashRegister>(SupermarketDB.Instance.GetCashRegisters());

            foreach (CashRegister cr in AllRegs_Temp)
            // finds the cash register the sick customer checked out at, and the time of the checkout
            {
                if (cr.CustomerHistory.ContainsKey(c))
                {
                    CoronaTime         = cr.CustomerHistory[c];
                    CoronaCashRegister = cr;
                }
            }

            if (CoronaCashRegister is null)
            // if the client did not checkout at any cash register, no on should get into isolation
            {
                Console.WriteLine("At this point, there are no people who need to go into isolation.");
                return;
            }
            if (CoronaCashRegister.CashierHistory is null)
            // if there is no cashier history, we cannot check if the sick customer met anyone
            {
                Console.WriteLine("There is no cashier history! We cannot check whether employees/customers should go into isolation. ");
            }
            try
            {
                foreach (RegisterLog EmpUse in CoronaCashRegister.CashierHistory)
                {
                    if (TimeBetween(CoronaTime, EmpUse.StartTime, EmpUse.EndTime))
                    {
                        IsolatedCashier = EmpUse.UsingEmployee;
                        Console.WriteLine($"{EmpUse.UsingEmployee.FullName}, you need to get into isolation right away!");
                    }
                }
            }
            catch
            {
                Console.WriteLine("Client hasn`t checked out at any cash register");
            }
            bool IsIsolated = false;

            foreach (CashRegister cr in AllRegs_Temp)
            // for every use of the isolated cashier, the method checks which customers revealed to the cashier, and prints an isolation warning
            {
                foreach (RegisterLog EmpUse in cr.CashierHistory)
                {
                    if (EmpUse.UsingEmployee == IsolatedCashier)
                    {
                        foreach (var CustVisit in cr.CustomerHistory)
                        {
                            if (TimeBetween((DateTime?)CustVisit.Value, EmpUse.StartTime, EmpUse.EndTime))
                            {
                                IsIsolated = true;
                                Console.WriteLine($"{CustVisit.Key.FullName}, you need to get into isolation right away!");
                            }
                        }
                    }
                }
            }
            if (IsIsolated == false)
            {
                Console.WriteLine("At this point, there are no people who need to go into isolation.");
            }
        }
コード例 #3
0
ファイル: Menu.cs プロジェクト: amitassa/MamasProj
        /// <summary>
        /// The method creates 3 Employees, 6 Customers, 4 Cash Registers, 6 Product types and many products.
        /// </summary>
        public static void CreateObjectsForDebug()
        {
            CashRegister CRegister1 = new CashRegister("1");
            CashRegister CRegister2 = new CashRegister("2");
            CashRegister CRegister3 = new CashRegister("3");
            CashRegister CRegister4 = new CashRegister("4");

            Console.WriteLine("Cash reg created");


            ProductType Yogo = new ProductType("Yogurt", 6.99, "111");

            Inventory.Instance.AddProductType(Yogo);
            ProductType Koteg = new ProductType("Koteg", 7.99, "222");

            Inventory.Instance.AddProductType(Koteg);
            ProductType Antrikot = new ProductType("Antrikot", 129.99, "333");

            Inventory.Instance.AddProductType(Antrikot);
            ProductType Tea = new ProductType("Tea Box", 25.00, "444");

            Inventory.Instance.AddProductType(Tea);
            ProductType Tomatoes = new ProductType("Tomatoes", 3.99, "555");

            Inventory.Instance.AddProductType(Tomatoes);
            ProductType Zero = new ProductType("Coca Cola Zero", 2.99, "666");

            Inventory.Instance.AddProductType(Zero);

            Console.WriteLine("Product Types Created");


            Customer c1 = new Customer("Amit Assa", "11", 36.5, true, false);

            SuperMarketQueueBL.GetInLine(c1);
            CustomerHandler.GenerateRandomShoppingList(c1);
            Customer c2 = new Customer("Dana Assa", "12", 34.5, true, false);

            SuperMarketQueueBL.GetInLine(c2);
            CustomerHandler.GenerateRandomShoppingList(c2);
            Customer c3 = new Customer("Dor Assa", "13", 37.2, false, true);

            SuperMarketQueueBL.GetInLine(c3);
            CustomerHandler.GenerateRandomShoppingList(c3);
            Customer c4 = new Customer("Chen Assa", "14", 38.3, true, false);

            SuperMarketQueueBL.GetInLine(c4);
            Customer c5 = new Customer("Mike Assa", "15", 36.0, true, true);

            SuperMarketQueueBL.GetInLine(c5);
            CustomerHandler.GenerateRandomShoppingList(c5);
            Customer c6 = new Customer("Shay Assa", "16", 32.1, true, false);

            SuperMarketQueueBL.GetInLine(c6);
            CustomerHandler.GenerateRandomShoppingList(c6);

            Console.WriteLine("Customers Created");


            Employee emp  = new Employee("Yossi", "999");
            Employee emp2 = new Employee("Tanya", "998");
            Employee emp3 = new Employee("Lily", "997");

            Console.WriteLine("Employees created");


            CreateProductsDebug();
        }