Пример #1
0
    public static void Main()
    {
        System.Console.WriteLine("IntStream");
        //IntStream
        IntStream iss = new IntStream();

        writeout(iss.next());
        writeout(iss.next());
        System.Console.WriteLine(iss.eos());
        iss.reset();
        System.Console.WriteLine(iss.eos());
        writeout(iss.next());

        while (!iss.eos())
        {
            iss.next();
        }
        System.Console.WriteLine("PrimeStream");


        //PrimeStream
        PrimeStream ps = new PrimeStream();

        for (int i = 0; i < 12; i++)
        {
            writeout(ps.next());
        }
        ps.reset();
        for (int i = 0; i < 12; i++)
        {
            writeout(ps.next());
        }
        System.Console.WriteLine("RandomStream");

        //RandomStream
        RandomStream rst = new RandomStream();

        writeout(rst.next());
        writeout(rst.next());
        writeout(rst.next());
        writeout(rst.next());

        System.Console.WriteLine("RandomWordStream");

        //RandomWordStream

        RandomWordStream rws = new RandomWordStream();
        RandomStream     rs1 = new RandomStream();
        PrimeStream      ps1 = new PrimeStream();

        for (int i = 0; i < 12; i++)
        {
            int prime = ps1.next();
            System.Console.WriteLine(rws.next(prime, rs1));
        }
    }
Пример #2
0
    public static void Main(string[] args)
    {
        IntStream test = new IntStream();

        Console.WriteLine("{0}", test.x);
        Console.WriteLine("{0}", test.next());
        Console.WriteLine("{0}", test.next());
        test.x = int.MaxValue;
        Console.WriteLine("{0}", test.eos());
        RandomStream tescik = new RandomStream();

        Console.WriteLine(tescik.x);
        tescik.reset();
        Console.WriteLine(tescik.x);
        Console.WriteLine(tescik.next());
        Console.WriteLine(tescik.eos());
        PrimeStream tescik2 = new PrimeStream();

        for (int i = 0; i < 5; i++)
        {
            Console.WriteLine(tescik2.next());
        }

        RandomWordStream a = new RandomWordStream();

        for (int i = 0; i < 20; i++)
        {
            Console.WriteLine(a.next());
        }
    }
Пример #3
0
    static void Main()
    {
        IntStream         strumNaturalny           = new IntStream();
        PrimeStream       strumPierwszych          = new PrimeStream();
        RandomStream      strumRandomowych         = new RandomStream();
        RandomWorldStream strumRandomowychStringow = new RandomWorldStream();

        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Reset strumienia.\n");
        strumNaturalny.reset();
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        Console.Write("Kolejna liczba naturalna: {0} \n", strumNaturalny.next());
        if (strumNaturalny.eos() == false)
        {
            Console.Write("\tStan eos: falsz.\n");
        }
        else
        {
            Console.Write("\tStan eos: prawda.\n");
        }
        Console.Write("Kolejna liczba pierwsza: {0} \n", strumPierwszych.next());
        Console.Write("Kolejna liczba pierwsza: {0} \n", strumPierwszych.next());
        Console.Write("Kolejna liczba pierwsza: {0} \n", strumPierwszych.next());
        Console.Write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
        Console.WriteLine("Kolejna liczba losowa: {0} ", strumRandomowych.next());
        Console.WriteLine("Kolejna liczba losowa: {0}", strumRandomowych.next());
        Console.WriteLine("Kolejna liczba losowa: {0} ", strumRandomowych.next());
        Console.Write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
        Console.Write("Kolejny losowy string: {0}\n", strumRandomowychStringow.nextL());
        Console.Write("Kolejny losowy string: {0}\n", strumRandomowychStringow.nextL());
        Console.Write("Kolejny losowy string: {0}\n", strumRandomowychStringow.nextL());
    }
Пример #4
0
    static void Main()
    {
        int              i;
        PrimeStream      ps    = new PrimeStream();
        IntStream        ins   = new IntStream();
        RandomStream     rnd   = new RandomStream();
        RandomWordStream rndws = new RandomWordStream();

        Console.WriteLine(rnd.next());
        Console.WriteLine(rnd.next());
        Console.WriteLine(rnd.next());
        Console.WriteLine(ins.next());
        Console.WriteLine(ps.next());
        Console.WriteLine(ps.next());
        Console.WriteLine(ps.next());

        Console.WriteLine(rndws.next());
        Console.WriteLine(rndws.next());
        Console.WriteLine(rndws.next());

        rnd.reset();
        ins.reset();
        ins.next();
        for (i = 0; i < 10; i++)
        {
            Console.WriteLine("{0} losowa liczba: {1}", ins.next(), rnd.next());
        }

        rndws.reset();
        ps.reset();
        for (i = 0; i < 15; i++)
        {
            Console.WriteLine("slowo o dl = {0}: {1}", ps.next(), rndws.next());
        }
        ps.reset();
        for (i = 0; i < 30; i++)
        {
            Console.WriteLine("{0} liczba pierwsza = {1}", i + 1, ps.next());
        }
        ins.reset();
        int p = 0;

        while (!ins.eos())
        {
            p = ins.next();
        }
        Console.WriteLine("najwieksza liczba typu int = {0}", p);
    }
Пример #5
0
    static void Main()
    {
        int stan = 1;

        System.Console.WriteLine("Wybierz co chcesz zrobic:");
        System.Console.WriteLine("1.Kolejna liczba naturalna");
        System.Console.WriteLine("2.Wlacz/Wylacz strumien");
        System.Console.WriteLine("3.Sprawdz stan strumienia");
        System.Console.WriteLine("4.Reset");
        System.Console.WriteLine("5.Liczba losowa");
        System.Console.WriteLine("6.Kolejne liczby pierwsze");
        System.Console.WriteLine("7.Ciagi znakow o dlugosci liczb pierwszych");
        System.Console.WriteLine("8.Wyjscie");
        IntStream   instance        = new IntStream();
        PrimeStream prime           = new PrimeStream();
        PrimeStream primeForStrings = new PrimeStream();

        while (stan == 1)
        {
            string wybor = System.Console.ReadLine();
            switch (wybor)
            {
            case "1":
            {
                int liczba = instance.next();
                if (liczba == -1)
                {
                    System.Console.WriteLine("Strumien zamkniety");
                }
                else
                {
                    System.Console.WriteLine("Liczba naturalna: " + liczba);
                }
                break;
            }

            case "2":
            {
                bool eos = instance.endofstream;
                if (eos == true)
                {
                    instance.endofstream = false;
                }
                else
                {
                    instance.endofstream = true;
                }
                break;
            }

            case "3":
            {
                System.Console.WriteLine("Stan strumienia : " + instance.eos());
                break;
            }

            case "4":
            {
                instance = new IntStream();
                System.Console.WriteLine("Ustawienia zresetowane");
                break;
            }

            case "5":
            {
                RandomStream random = new RandomStream();
                if (instance.endofstream == false)
                {
                    System.Console.WriteLine("Liczba losowa:" + random.next());
                }
                else
                {
                    System.Console.WriteLine("Strumien zamkniety");
                }
                break;
            }

            case "6":
            {
                int wynik = prime.next();
                if (wynik == -1)
                {
                    instance.endofstream = true;
                    System.Console.WriteLine("Strumien zamkniety");
                }
                else
                {
                    System.Console.WriteLine("Kolejna Liczba Pierwsza " + wynik);
                }
                break;
            }

            case "7":
            {
                RandomWordStream ciag       = new RandomWordStream();
                string           rnd_string = ciag.next();
                System.Console.WriteLine("Losowy ciag znakow: " + rnd_string);
                break;
            }

            case "8":
            {
                stan = 0;
                break;
            }

            default:
            {
                System.Console.WriteLine("Bledny wybor");
                break;
            }
            }
        }
    }