Example #1
0
        bool Start()
        {
            string          message         = "";
            Pencil          pencil          = new Pencil(20);
            PencilSharpener pencilSharpener = new PencilSharpener();

            while (message != "stop")
            {
                message = ReadTools.ReadString("Enter a message: ");

                switch (message)
                {
                case "stop":
                    break;

                case "sharpen":
                    pencilSharpener.Sharpen(pencil);
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    Console.WriteLine("Sharpening the pencil...");
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.Green;
                    pencil.Write(message);
                    break;
                }

                Console.ResetColor();
            }

            return(LoopTools.LoopProgram());
        }
Example #2
0
        bool Start()
        {
            IObservable player = new MP3Player();

            IObserver mp3Display1 = new SimpleMP3Display(player);
            IObserver mp3Display2 = new FancyMP3Display(player);

            player.NextSong();
            player.NextSong();
            player.NextSong();

            return(LoopTools.LoopProgram());
        }
Example #3
0
        bool Start()
        {
            IStack myStack = new ArrayStack(10);

            AddValues(myStack, 20);
            Console.WriteLine();
            ProcessValues(myStack);
            Console.WriteLine();
            AddValues(myStack, 10);
            Console.WriteLine();
            CheckValues(myStack);

            return(LoopTools.LoopProgram());
        }
Example #4
0
        bool Start()
        {
            CallDataLoader    callDataLoader    = new CallDataLoader();
            TwitterDataLoader twitterDataLoader = new TwitterDataLoader();
            SensorDataLoader  sensorDataLoader  = new SensorDataLoader();
            BatchProcessor    batchProcessor    = new BatchProcessor();

            batchProcessor.Add(callDataLoader);
            batchProcessor.Add(twitterDataLoader);
            batchProcessor.Add(sensorDataLoader);

            batchProcessor.ProcessAll();

            return(LoopTools.LoopProgram());
        }
Example #5
0
        bool Start()
        {
            BookStore bookStore = new BookStore();

            Book     book1     = new Book("Dracula", 15, 5, "Bram Stoker");
            Book     book2     = new Book("Joe Speedboot", 12.5f, 3, "Tommy Wieringa");
            Magazine magazine1 = new Magazine("Time", 3.9f, 10, DayOfWeek.Friday);
            Magazine magazine2 = new Magazine("Donald Duck", 2.5f, 15, DayOfWeek.Thursday);
            CD       cd1       = new CD("Seventeen Seconds", 3.9f, 5, "The Cure");

            bookStore.Add(book1);
            bookStore.Add(book2);
            bookStore.Add(magazine1);
            bookStore.Add(magazine2);
            bookStore.Add(cd1);

            bookStore.PrintAllItems();

            return(LoopTools.LoopProgram());
        }