Exemple #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("\nIntStream");
            IntStream inst = new IntStream();

            Console.WriteLine(inst.next1());
            Console.WriteLine(inst.next1());
            Console.WriteLine(inst.next1());
            Console.WriteLine(inst.next1());
            Console.WriteLine(inst.eos());
            inst.reset();
            Console.WriteLine(inst.next1());

            Console.WriteLine("\nPrimeStream");
            PrimeStream ps = new PrimeStream();

            Console.WriteLine(ps.next1());
            Console.WriteLine(ps.next1());
            Console.WriteLine(ps.next1());
            Console.WriteLine(ps.next1());
            Console.WriteLine(ps.eos());
            ps.reset();
            Console.WriteLine(ps.next1());

            Console.WriteLine("\nRandomStream");
            RandomStream rs = new RandomStream();

            Console.WriteLine(rs.next1());
            Console.WriteLine(rs.next1());
            Console.WriteLine(rs.next1());
            Console.WriteLine(rs.next1());
            Console.WriteLine(rs.eos());
            rs.reset();
            Console.WriteLine(rs.next1());

            Console.WriteLine("\nRandomWordStream");
            RandomWordStream rws = new RandomWordStream();

            Console.WriteLine(rws.next());
            Console.WriteLine(rws.next());
            Console.WriteLine(rws.next());
            Console.WriteLine(rws.next());
            Console.WriteLine(rws.eos());
            rws.reset();
            Console.WriteLine(rws.next());
            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            RandomWordStream rws = new RandomWordStream();

            Console.WriteLine("Opcje:");
            Console.WriteLine("1  -- Wypisuje string");
            Console.WriteLine("2  -- Sprawdza, czy strumień się zakończył");
            Console.WriteLine("3  -- Resetuje strumień");
            Console.WriteLine("cokolwiek innego -- Kończy program");


            bool done = false;

            while (!done)
            {
                int option = int.Parse(Console.ReadLine());
                switch (option)
                {
                case 1:
                    Console.WriteLine(rws.next());
                    break;

                case 2:
                    Console.WriteLine("EOS = {0}", rws.eos() ? "true" : "false");
                    break;

                case 3:
                    rws.reset();
                    Console.WriteLine("Zresetowano strumień");
                    break;

                default:
                    done = true;
                    break;
                }
            }
        }