コード例 #1
0
ファイル: GuessTheAnimal.cs プロジェクト: mkbiltek2019/refer
    static void Main()
    {
        string     strFilename = "GuessTheAnimal.txt";
        AnimalNode anRoot;

        try
        {
            StreamReader sr = new StreamReader(strFilename);
            anRoot = AnimalNode.ReadNode(sr);
            sr.Close();
        }
        catch
        {
            anRoot          = new AnimalNode();
            anRoot.Question = "cat";
        }

        do
        {
            // Start playing.

            Console.Write("Think of an animal and press Enter.");
            Console.ReadLine();
            AskQuestion(ref anRoot);

            // Save the file.

            StreamWriter sw = new StreamWriter(strFilename);
            anRoot.WriteNode(sw, 0);
            sw.Close();

            // Possibly play again.

            Console.Write("Would you like to play again? ");
        }while (GetYesNo());
    }