Esempio n. 1
0
    public void Run()
    {
        while (true)
        {
            string[]      tokens  = reader.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).ToArray();
            string        command = tokens[0];
            List <string> args    = tokens.Skip(1).ToList();

            if (command == "Bender")
            {
                nationBuilder.AssignBender(args);
            }
            else if (command == "Monument")
            {
                nationBuilder.AssignMonument(args);
            }
            else if (command == "Status")
            {
                string result = nationBuilder.GetStatus(args[0]);
                writer.WriteLine(result);
            }
            else if (command == "War")
            {
                nationBuilder.IssueWar(args[0]);
            }
            else if (command == "Quit")
            {
                string result = nationBuilder.GetWarsRecord();
                writer.WriteLine(result);
                break;
            }
        }
    }
Esempio n. 2
0
    public void Run()
    {
        bool isRunning = true;

        while (isRunning)
        {
            var tokents = reader.Read().Split(' ').ToList();
            var command = tokents[0];
            tokents.RemoveAt(0);

            switch (command)
            {
            case "Bender":
                nationsBuilder.AssignBender(tokents);
                break;

            case "Monument":
                nationsBuilder.AssignMonument(tokents);
                break;

            case "Status":
                writer.Write(nationsBuilder.GetStatus(tokents[0]).ToString());
                break;

            case "War":
                nationsBuilder.IssueWar(tokents[0]);
                break;

            case "Quit":
                writer.Write(nationsBuilder.GetWarsRecord().ToString());
                isRunning = false;
                break;
            }
        }
    }