Пример #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 AddNewEmp()
        /// A method to add new employee to the system
        {
            Console.Clear();
            Console.WriteLine("Please provide the following information:");
            string ID = PersonHandler.ValidatedID();

            // check if ID already exists in the system
            try
            {
                foreach (Employee emp in SupermarketDB.Instance.GetEmployees())
                {
                    if (emp.ID == ID)
                    {
                        Console.WriteLine("ID is already used");
                        return;
                    }
                }
            }
            catch { }
            Console.Write("Enter employee`s name: ");
            string   emp_name = Console.ReadLine();
            Employee New_Emp  = new Employee(emp_name, ID);

            Console.WriteLine($"New employee created! Good luck, {New_Emp.FullName}");
        }
Пример #3
0
        public static bool IsEmployeeAllowedToWork(Employee emp)
        {
            double bh      = PersonHandler.ValidateBodyHeat();
            bool   mask    = PersonHandler.IsMaskOn();
            bool   isolate = PersonHandler.ShouldBeIsolated();

            return(mask && isolate == false && PersonHandler.IsSick(bh) == false);
        }
Пример #4
0
        public static void EmployeeShiftsHistory()
        {
            ShowEmployees();
            string   string_ID = PersonHandler.ValidatedID();
            Employee emp       = EmployeeHandler.GetEmployeeByID(string_ID);

            if (emp is null)
            {
                return;
            }
            ShowEmployeeShifts(emp);
        }
Пример #5
0
        public static void ShowEmpDebt()
        {
            ShowEmployees();
            string   string_ID = PersonHandler.ValidatedID();
            Employee emp       = GetEmployeeByID(string_ID);

            if (emp is null)
            {
                return;
            }
            double WorkHoursDebt = emp.Debt / 30.0;

            Console.WriteLine($"{emp.FullName}, your debt is {emp.Debt}, which are {WorkHoursDebt} hours of work.");
        }
Пример #6
0
        /// <summary>
        /// The method checks if the customer meet with the requirements - wearing a mask, shouldn`t be isolated and bodyheat under 38.0
        /// If the customer meets with the requirements, it gets in the line.
        /// If not, prints a message.
        /// </summary>
        public static void GetInLine(Customer c)

        {
            if (c.WearingMask == true && c.ShouldBeIsolated == false && PersonHandler.IsSick(c.BodyHeat) == false)
            {
                Console.WriteLine($"{c.FullName}. Your place in line is {SuperMarketQueue.Instance.GetCustQueue().Count}");
                Console.WriteLine(); // to organize console for a better understanding
                SuperMarketQueue.Instance.AddToQueue(c);
            }
            else
            {
                Console.WriteLine($"Sorry {c.FullName}, you do not meet with the requirements. you can`t get in line.");
                Console.WriteLine(); // to organize console for a better understanding
            }
        }
Пример #7
0
        public static void EmployeesShift()
        /// A method to start / end employees shifts.
        /// the method gets the ID as input from client, checks if the ID exists in the system
        /// the method let the client choose between start & end the shift by input, and does in accordance to that
        {
            EmployeeHandler.ShowEmployees();
            string   string_ID = PersonHandler.ValidatedID();
            Employee emp       = EmployeeHandler.GetEmployeeByID(string_ID);

            if (emp is null)
            {
                return;
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"What would you like to do, {emp.FullName}?");
            sb.AppendLine("1 - Start a shift");
            sb.AppendLine("2 - End a shift");
            Console.WriteLine(sb.ToString());

            int choice = 3; // default value for the choice (if client`s input is wrong, program will get into the loop and give him another try)

            Console.Write("Your choice [1/2]: ");
            string string_choice = Console.ReadLine(); // input for client`s choice

            try { choice = int.Parse(string_choice); } // trying to parse client`s choice to int
            catch { } // if client`s input is wrong, keeps choice as 3

            switch (choice)
            {
            case 1:
                EmployeeHandler.StartShift(emp);
                break;

            case 2:
                EmployeeHandler.EndShift(emp);
                break;

            default:
                Console.WriteLine("No such option");
                EmployeesManagement();
                break;
            }
        }
Пример #8
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.");
            }
        }