Exemple #1
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());
    }
    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());
        }
    }
            public override int element(int liczba)
            {
                int rozmiar = this.size();

                if (liczba == 0)
                {
                    lista.Add(2);
                    pr.next();
                }
                if (liczba <= rozmiar)
                {
                    return(lista[liczba]);
                }
                else
                {
                    int g = liczba - rozmiar;

                    PrimeStream prime = new PrimeStream();



                    for (int i = 0; i < g; i++)
                    {
                        lista.Add(pr.next());
                    }
                }
                licznik = liczba;
                return(lista[liczba]);
            }
    public static void Main()
    {
        IntStream        stream = new IntStream();
        PrimeStream      prime  = new PrimeStream();
        RandomStream     rand   = new RandomStream();
        RandomWordStream word   = new RandomWordStream();

        Console.WriteLine("Next z klasy IntStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(stream.next());
        }
        Console.WriteLine("Next z klasy PrimeStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(prime.next());
        }

        Console.WriteLine("Next z klasy RandomStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(rand.next());
        }

        Console.WriteLine("Next z klasy RandomWordStream");
        for (int i = 0; i <= 5; i++)
        {
            Console.WriteLine(word.next());
        }
    }
    public static void Main()
    {
        var primeStream  = new PrimeStream();
        var intStream    = new IntStream();
        var stringStream = new RandomWordStream();

        Console.WriteLine("How many strings do you want to generate?");
        Console.WriteLine("(Enter a number smaller than 1 to generate the entire stream)");
        var input = Console.ReadLine();
        int amount;

        if (!int.TryParse(input, out amount))
        {
            Console.WriteLine("Invalid input!");
            return;
        }

        if (amount <= 0)
        {
            while (!stringStream.Eos())
            {
                Console.WriteLine("{0}) {1} characters: {2}", intStream.Next(), primeStream.Next(), stringStream.Next());
            }
        }
        else
        {
            for (int i = intStream.Next(); i < amount; i++)
            {
                Console.WriteLine("{0}) {1} characters: {2}", intStream.Next(), primeStream.Next(), stringStream.Next());
            }
        }
    }
Exemple #6
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));
        }
    }
Exemple #7
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);
    }
Exemple #8
0
    public static void Main(string[] args)
    {
        IntStream intStream;

        intStream = new IntStream();

        Console.WriteLine("\nTesting IntStream: \n");

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

        Console.WriteLine("\nTesting PrimeStream: \n");
        PrimeStream primeStream;

        primeStream = new PrimeStream();

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

        Console.WriteLine("\nTesting RandomStream: \n");
        RandomStream randomStream;

        randomStream = new RandomStream();

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

        primeStream.reset();
        Console.WriteLine("\nTesting RandomWordStream: \n");
        RandomWordStream randomWordStream;

        randomWordStream = new RandomWordStream(randomStream, primeStream);

        for (int i = 0; i < 10; i++)
        {
            Console.WriteLine(randomWordStream.next());
        }
    }
Exemple #9
0
        static void Main(string[] args)
        {
            PrimeStream ps = new PrimeStream();
            int         x  = 10000;
            Stopwatch   sp = new Stopwatch();

            sp.Start();
            foreach (var prime in ps)
            {
                Console.WriteLine(prime);
                x--;
                if (x == 0)
                {
                    break;
                }
            }
            sp.Stop();
            Console.WriteLine("Took " + sp.ElapsedMilliseconds + "ms to complete.");
            Console.WriteLine("Hello World!");
        }
Exemple #10
0
 public RandomWordStream()
 {
     rnd = new RandomStream();
     ps  = new PrimeStream();
 }
Exemple #11
0
 public Pierwsze()
 {
     pulcheria = new List <int>();
     eudoksja  = new PrimeStream();
 }
Exemple #12
0
 public RandomWordStream()
 {
     primeStream  = new PrimeStream();
     randomStream = new RandomStream();
 }
Exemple #13
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;
            }
            }
        }
    }
Exemple #14
0
 public RandomWordStream(RandomStream randStream,
                         PrimeStream primeStream)
 {
     this.randStream  = randStream;
     this.primeStream = primeStream;
 }
 public Lista_Primow()
 {
     lista   = new List <int>();
     licznik = 0;
     pr      = new PrimeStream();
 }
Exemple #16
0
 public RandomWordStream()
 {
     ps = new PrimeStream();
     rs = new RandomStream();
 }
Exemple #17
0
 public RandomWordStream()
 {
     lucjan = "";
     p      = new PrimeStream();
     r      = new RandomStream();
 }
Exemple #18
0
 public PrimeCollection()
 {
     ps = new PrimeStream();
 }
Exemple #19
0
 public RandomWordStream()
 {
     this.rs = new RandomStream(); // 97 122
     this.ps = new PrimeStream();
 }