Beispiel #1
0
        void Start()
        {
            IPencil          pencil          = new Pencil(20);
            IPencilSharpener pencilSharpener = new PencilSharpener();

            string input;

            while (true)
            {
                Console.Write("Enter a word: ");
                input = Console.ReadLine();

                if (input == "stop")
                {
                    return;
                }

                if (input == "sharpen")
                {
                    pencilSharpener.Sharpen(pencil);
                }
                else
                {
                    pencil.Write(input);
                }
            }
        }
Beispiel #2
0
        void start()
        {
            PencilSharpener pencilSharpener = new PencilSharpener();
            Pencil          pencil          = new Pencil(10);

            while (true)
            {
                Console.Write("Enter a word: ");
                string message = Console.ReadLine();

                if (message == "sharpen")
                {
                    pencilSharpener.sharpenPencil(pencil);
                }
                else if (message == "stop")
                {
                    return;
                }
                else
                {
                    pencil.write(message);
                }
            }
        }