示例#1
0
        public void ClientPart(ref Client.Client cl, ref Credit.Credit[] credits, ref Bank.Bank bank, ref Worker.Worker w)
        {
            Console.Clear();
            Console.WriteLine("1) For look your credit(s)");
            Console.WriteLine("2) For add new credit");
            Console.WriteLine("3) For convert money to dollar");
            bool IsInt = int.TryParse(Console.ReadLine(), out int choose);

            if (IsInt)
            {
                if (choose == 1)
                {
                    Console.Clear();
                    foreach (var item in credits)
                    {
                        if (item.TheClient.Name == cl.Name)
                        {
                            item.Print();
                        }
                    }
                    Thread.Sleep(3000);
                    Console.Clear();
                }
                else if (choose == 2)
                {
                    Console.Clear();
                    Console.Write("Enter amonut: ");
                    decimal amount = Convert.ToDecimal(Console.ReadLine());
                    Console.WriteLine("Enter month: ");
                    int month = Convert.ToInt32(Console.ReadLine());

                    w.addOperation(new Operation.Operation(Guid.NewGuid(), $"New credit was added in {cl.Name} account", DateTime.Now));
                    Credit.Credit[] cre = new Credit.Credit[credits.Length + 1];
                    for (int i = 0; i < credits.Length; i++)
                    {
                        cre[i] = credits[i];
                    }
                    cre[cre.Length - 1] = new Credit.Credit(Guid.NewGuid(), cl, amount, month);
                    credits             = cre;
                }
                else if (choose == 3)
                {
                    Console.Clear();
                    Console.Write("Write amount: ");
                    bool isD = decimal.TryParse(Console.ReadLine(), out decimal res);
                    if (isD)
                    {
                        decimal dess = res * (17 / 10);
                        cl.Salary   += res;
                        cl.Salary   -= dess;
                        bank.Budget += dess * (17 / 10) - dess * (171 / 10);
                        bank.ProfitCalculating();
                    }
                }
            }
            else
            {
                throw new Exception("Invalid type!");
            }
        }
示例#2
0
        public void Starter()
        {
            Worker.Worker w1 = new Worker.Worker(Guid.NewGuid(), "Hakuna", "", 35, "Cart operations", 2123);
            Worker.Worker w2 = new Worker.Worker(Guid.NewGuid(), "Sun", "", 26, "Cart operations", 221);
            Worker.Worker w3 = new Worker.Worker(Guid.NewGuid(), "Moon", "", 37, "Cart operations", 1233);
            Worker.Worker w4 = new Worker.Worker(Guid.NewGuid(), "Sky", "", 40, "Cart operations", 223);
            w1.addOperation(new Operation.Operation(Guid.NewGuid(), "Cart Added", DateTime.Now));
            Worker.Worker[] workers = new Worker.Worker[4] {
                w1, w2, w3, w4
            };

            Manager.Manager m1 = new Manager.Manager(Guid.NewGuid(), "Matata", "", 46, "Main Manager", 98123);
            m1.addWorker(w1);
            m1.addWorker(w2);
            m1.addWorker(w3);
            m1.addWorker(w4);
            Manager.Manager m2 = new Manager.Manager(Guid.NewGuid(), "Glass", "", 19, "Manager", 2721);
            m2.addWorker(w1);
            m2.addWorker(w2);
            Manager.Manager m3 = new Manager.Manager(Guid.NewGuid(), "Light", "", 29, "Manager", 12671);
            m3.addWorker(w3);
            m3.addWorker(w4);
            Manager.Manager m4 = new Manager.Manager(Guid.NewGuid(), "Blue", "", 41, "Manager", 82342);
            m4.addWorker(w1);
            m4.addWorker(w3);
            Manager.Manager[] managers = new Manager.Manager[4] {
                m1, m2, m3, m4
            };

            Client.Client   c1      = new Client.Client(Guid.NewGuid(), "Matatata", "Nana", 22, 34324, "X street,New York", "Y street, New Jersey");
            Client.Client   c2      = new Client.Client(Guid.NewGuid(), "Last", "Glass", 56, 1434, "I don't work", "Y street, Vegas");
            Client.Client[] clients = new Client.Client[2] {
                c1, c2
            };

            Ceo.Ceo ceo = new Ceo.Ceo(Guid.NewGuid(), "Hakuna", "", 35, "Ceo", 100000);
            ceo.addWorker(w1);
            ceo.addWorker(w2);
            ceo.addWorker(w3);
            ceo.addWorker(w4);
            ceo.addManager(m1);
            ceo.addManager(m2);
            ceo.addManager(m3);
            ceo.addManager(m4);

            Credit.Credit cr1 = new Credit.Credit(Guid.NewGuid(), c1, 20013, 6);
            Credit.Credit cr3 = new Credit.Credit(Guid.NewGuid(), c1, 142, 2);
            Credit.Credit cr2 = new Credit.Credit(Guid.NewGuid(), c2, 41500, 3);

            m1.Ceo = ceo;
            m2.Ceo = ceo;
            m3.Ceo = ceo;
            m4.Ceo = ceo;

            Bank.Bank bank = new Bank.Bank("Time bank", 10000000, ceo);

            Credit.Credit[] credits = new Credit.Credit[3] {
                cr1, cr2, cr3
            };


            while (true)
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("1) Ceo");
                    Console.WriteLine("2) Worker");
                    Console.WriteLine("3) Manager");
                    Console.WriteLine("4) Client");
                    Console.WriteLine("5) Bank");
                    Choose(Console.ReadLine(), ref ceo, ref workers, ref managers, ref clients, ref credits, bank);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }