Esempio n. 1
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    var command = commandParser.Parse(Console.ReadLine());

                    if (command.Name == "Create")
                    {
                        var name  = command.Arguments[0];
                        var age   = int.Parse(command.Arguments[1]);
                        var grade = double.Parse(command.Arguments[2]);

                        studentSystem.Add(name, age, grade);
                    }
                    else if (command.Name == "Show")
                    {
                        var name = command.Arguments[0];

                        var student = studentSystem.Get(name);

                        Console.WriteLine(student);
                    }
                    else if (command.Name == "Exit")
                    {
                        break;
                    }
                }
                catch
                {
                    continue;
                }
            }
        }
Esempio n. 2
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    var data    = this.consoleDataReader.Read();
                    var command = commandParser.Parse(data);
                    if (command.Name == "Create")
                    {
                        var name  = command.Arguments[0];
                        var age   = int.Parse(command.Arguments[1]);
                        var grade = double.Parse(command.Arguments[2]);

                        studentSystem.Add(name, age, grade);
                    }
                    else if (command.Name == "Show")
                    {
                        var name           = command.Arguments[0];
                        var currentStudent = studentSystem.Get(name);
                        this.consoleDataWriter.Write(currentStudent);
                    }
                    else if (command.Name == "Exit")
                    {
                        break;
                    }
                }
                catch
                {
                    continue;
                }
            }
        }
        public static void Main()
        {
            StudentSystem studentSystem = new StudentSystem();

            while (true)
            {
                string[] studentInfo = Console.ReadLine().Split();

                string action = studentInfo[0];

                if (action == "Create")
                {
                    string name  = studentInfo[1];
                    int    age   = int.Parse(studentInfo[2]);
                    double grade = double.Parse(studentInfo[3]);

                    Student student = new Student(name, age, grade);

                    studentSystem.Add(name, student);
                }
                else if (action == "Show")
                {
                    var name = studentInfo[1];

                    Student student = studentSystem.Get(name);

                    if (student != null)
                    {
                        Console.WriteLine(student);
                    }
                }
                else if (action == "Exit")
                {
                    break;
                }
            }
        }