Example #1
0
        static void Main(string[] args)
        {
            Random myRand = new Random();

            ////create random strings for testing Counter
            RandomStringDataSource myString1 = new RandomStringDataSource(myRand, 10);
            RandomStringDataSource myString2 = new RandomStringDataSource(myRand, 100);
            RandomStringDataSource myString3 = new RandomStringDataSource(myRand, 1000);

            Console.WriteLine(myString1.str);
            Console.WriteLine(myString1.CountWords());
            Console.WriteLine();

            Console.WriteLine(myString2.str);
            Console.WriteLine(myString2.CountWords());
            Console.WriteLine();

            Console.WriteLine(myString3.str);
            Console.WriteLine(myString3.CountWords());
            Console.WriteLine();


            ////read .txt files for testing Counter
            //////make sure the files exist
            ////if (File.Exists("Whales.txt"))
            ////{
            ////    Console.WriteLine("It Exists!");
            ////}
            ////else
            ////{
            ////    Console.WriteLine("Nope, not here!");
            ////}

            FileDataSource myFile1 = new FileDataSource("Whales.txt");
            FileDataSource myFile2 = new FileDataSource("Color.txt");

            Console.WriteLine(myFile1.str);
            Console.WriteLine(myFile1.CountWords());
            Console.WriteLine();

            Console.WriteLine(myFile2.str);
            Console.WriteLine(myFile2.CountWords());
            Console.WriteLine();


            //read webpages for testing Counter
            InternetDataSource myWebpage1 = new InternetDataSource("https://en.wikipedia.org/wiki/Whale");
            InternetDataSource myWebpage2 = new InternetDataSource("https://en.wikipedia.org/wiki/Color");

            Console.WriteLine(myWebpage1.str);
            Console.WriteLine(myWebpage1.CountWords());
            Console.WriteLine();

            Console.WriteLine(myWebpage2.str);
            Console.WriteLine(myWebpage2.CountWords());
            Console.WriteLine();


            Console.ReadLine(); //pause
        }
Example #2
0
        static void Main(string[] args)
        {
            Random myRand = new Random();
            
            ////create random strings for testing Counter
            RandomStringDataSource myString1 = new RandomStringDataSource(myRand, 10);
            RandomStringDataSource myString2 = new RandomStringDataSource(myRand, 100);
            RandomStringDataSource myString3 = new RandomStringDataSource(myRand, 1000);

            Console.WriteLine(myString1.str);
            Console.WriteLine(myString1.CountWords());
            Console.WriteLine();

            Console.WriteLine(myString2.str);
            Console.WriteLine(myString2.CountWords());
            Console.WriteLine();

            Console.WriteLine(myString3.str);
            Console.WriteLine(myString3.CountWords());
            Console.WriteLine();

 
            ////read .txt files for testing Counter
            //////make sure the files exist
            ////if (File.Exists("Whales.txt"))
            ////{
            ////    Console.WriteLine("It Exists!");
            ////}
            ////else
            ////{
            ////    Console.WriteLine("Nope, not here!");
            ////}

            FileDataSource myFile1 = new FileDataSource("Whales.txt");
            FileDataSource myFile2 = new FileDataSource("Color.txt");

            Console.WriteLine(myFile1.str);
            Console.WriteLine(myFile1.CountWords());
            Console.WriteLine();

            Console.WriteLine(myFile2.str);
            Console.WriteLine(myFile2.CountWords());
            Console.WriteLine();


            //read webpages for testing Counter
            InternetDataSource myWebpage1 = new InternetDataSource("https://en.wikipedia.org/wiki/Whale");
            InternetDataSource myWebpage2 = new InternetDataSource("https://en.wikipedia.org/wiki/Color");

            Console.WriteLine(myWebpage1.str);
            Console.WriteLine(myWebpage1.CountWords());
            Console.WriteLine();

            Console.WriteLine(myWebpage2.str);
            Console.WriteLine(myWebpage2.CountWords());
            Console.WriteLine();


            Console.ReadLine(); //pause
        }