public void Run()
        {
            while (true)
            {
                var data = this.dataReader.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 student = studentSystem.Get(name);

                    this.dataWriter.Write(student);
                }
                else if (command.Name == "Exit")
                {
                    break;
                }
            }
        }
Exemple #2
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    var command = commandParser.Parse(this.readInput());
                    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);
                    }
                    if (command.Name == "Exit")
                    {
                        break;
                    }
                }
                catch
                {
                    continue;
                }
            }
        }
Exemple #3
0
        public bool Execute(Command command)
        {
            switch (command.Type)
            {
            case "Create":
                var student = parser.GetStudent(command.Arguments);
                studentSystem.Add(student);
                return(true);

            case "Show":
                string name = command.Arguments[0];
                writer.PrintOutput(studentSystem.Show(name));
                return(true);

            case "Exit":

                break;
            }
            return(false);
        }
Exemple #4
0
        public void Run()
        {
            while (true)
            {
                try
                {
                    var data    = this.dataReader.Read();    // Read input from console
                    var command = commandParser.Parse(data); // Split input from 1 to several parts => 1. Name ; 2. Arguments

                    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); // Add Student
                    }
                    else if (command.Name == "Show")
                    {
                        var name = command.Arguments[0];

                        var student = studentSystem.Get(name); // Get the student with this name from all students

                        this.dataWriter.Write(student);        // Print in console current Student with his age
                    }
                    else if (command.Name == "Exit")
                    {
                        break;
                    }
                }
                catch
                {
                    continue;
                }
            }
        }