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; } } }
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; } } }
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); }
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; } } }