Example #1
0
        static void Main(string[] args)
        {
            commands commands = new commands();
            //try
            // {

            //create persons data
            Program p = new Program();

            p.persons.Add(new Human("Jenifer", "Lopez", 13, "Brunas"));
            p.persons.Add(new Human("Anna", "Skroderniece", 14, "Violetas"));
            p.persons.Add(new Human("Mikelis", "Mucinieks", 16, "Zilas"));
            p.persons.Add(new Human("Kristaps", "Kalejs", 17, "Zalas"));
            //create accounts here(note: you can not create new account if there is not profile that matches)
            int firstnumber = 12;

            p.accounts.Add(new BankAccount($"{ p.persons[p.accounts.Count].Name} {p.persons[p.accounts.Count].Surname }", 200, "EUR", firstnumber, 0));
            p.accounts.Add(new BankAccount($"{ p.persons[p.accounts.Count].Name} {p.persons[p.accounts.Count].Surname }", 200, "EUR", firstnumber, p.accounts.Count));
            p.accounts.Add(new BankAccount($"{ p.persons[p.accounts.Count].Name} {p.persons[p.accounts.Count].Surname }", 212300, "EUR", firstnumber, p.accounts.Count));
            p.accounts.Add(new BankAccount($"{ p.persons[p.accounts.Count].Name} {p.persons[p.accounts.Count].Surname }", 22300, "EUR", firstnumber, p.accounts.Count));
            commands.WriteLine("to view the command list write |/help|");
            p.ExtraLineProblem("");
            //}
            //catch
            //{
            //commands.ErrorMessage("[accounts] cannot be more than [persons], they need to be the same count!");
            //commands.ErrorMessage("delete extra [accounts] or create new [persons] and then restart console!");
            //commands.ErrorMessage("press key Enter to close console!");
            // Console.ReadLine();
            //Environment.Exit(0);
            //}
        }
Example #2
0
        private void MainDiolog(string line, bool ExtraLineProblemSender)
        {
            commands commands = new commands();
            bool     end      = false;

            while (end == false)
            {
                if (ExtraLineProblemSender == false)
                {
                    ExtraLineProblem("");
                }
                else if (line == "/exit")
                {
                    commands.Exit();
                }
                else if (line == "/help")
                {
                    commands.Help();
                }
                else if (line == "")
                {
                    commands.WriteLine("write '/help' to view command list");
                }
                else if (line == "/add.new_person")
                {
                    AddNewPerson();
                }
                else if (line.Contains("/view") && line.Substring(line.Length - 1, 1) == "]")
                {
                    commands.Check(line);
                    if (commands.check == true)
                    {
                        view(line, commands.returnlistelemnts);
                    }
                    else
                    {
                        commands.Else(line);
                    }
                }
                else
                {
                    commands.Else(line);
                }
                ExtraLineProblemSender = false;
            }
        }
Example #3
0
        public void AddNewPerson()
        {
            Program  p        = new Program();
            commands commands = new commands();
            string   name     = null;
            string   surname  = null;
            string   ageinput = null;
            int      age2;
            string   eyecolor = null;
            bool     End      = false;

            while (End == false)
            {
                commands.WriteLine("new person.age:");
                ageinput = Console.ReadLine();
                CheckStopAddNewPerson(ageinput);

                if (Int32.TryParse(ageinput, out age2))
                {
                    Int32.TryParse(ageinput, out age2);

                    commands.WriteLine("new person.name:");
                    name = Console.ReadLine();
                    CheckStopAddNewPerson(name);

                    commands.WriteLine("new person.surname:");
                    surname = Console.ReadLine();
                    CheckStopAddNewPerson(surname);

                    commands.WriteLine("new person.eyecolor:");
                    eyecolor = Console.ReadLine();
                    CheckStopAddNewPerson(eyecolor);

                    persons.Add(new Human(name, surname, age2, eyecolor));

                    commands.WriteLine($"{name} {surname} bank account:");
                    commands.WriteLine("Balance:");

                    string balance  = null;
                    string Currency = null;
                    bool   stop     = false;
                    int    Ibalance;
                    while (stop == false)
                    {
                        balance = Console.ReadLine();
                        if (Int32.TryParse(balance, out Ibalance))
                        {
                            Int32.TryParse(balance, out Ibalance);
                            commands.WriteLine("Currnecy:");
                            Currency = Console.ReadLine();

                            accounts.Add(new BankAccount($"{persons[accounts.Count].Name} {persons[accounts.Count].Surname}", Ibalance, Currency, 12, accounts.Count));
                            stop = true;
                        }
                        else
                        {
                            commands.ErrorMessage("balance must be a number!");
                        }
                    }
                    commands.WriteLine("view " + name + " profile together (Y/N)");

                    bool End2 = false;
                    while (End2 == false)
                    {
                        string answer2 = Console.ReadLine();
                        CheckStopAddNewPerson(answer2);

                        if (answer2 == "Y")
                        {
                            persons[persons.Count - 1].PersonInfo(true);
                            accounts[persons.Count - 1].BankAccountInfo(true);
                            End2 = true;
                            End  = true;
                            ExtraLineProblem("");;
                        }
                        else if (answer2 == "N")
                        {
                            End2 = true;
                            End  = true;
                            ExtraLineProblem("");;
                        }
                        else
                        {
                            commands.ErrorMessage("this is Y/N n question!");
                            End2 = false;
                        }
                    }
                }
                else
                {
                    commands.ErrorMessage("age must be a number!");
                }
            }
        }