コード例 #1
0
ファイル: Program.cs プロジェクト: drazen-b/OOP_Zadaca_CS
        static void DZ2()
        {
            Description description = new Description(1, TimeSpan.FromMinutes(45), "Pilot");

            Console.WriteLine(description);
            Episode episode = new Episode(10, 88.64, 9.78, description);

            Console.WriteLine(episode);

            // Assume that the number of rows in the text file is always at least 10.
            // Assume a valid input file.
            string fileName = "shows.tv";

            string[]  episodesInputs = File.ReadAllLines(fileName);
            Episode[] episodes       = new Episode[episodesInputs.Length];
            for (int i = 0; i < episodes.Length; i++)
            {
                episodes[i] = TvUtilities.Parse(episodesInputs[i]);
            }

            Console.WriteLine("Episodes:");
            Console.WriteLine(string.Join <Episode>(Environment.NewLine, episodes));
            TvUtilities.Sort(episodes);
            Console.WriteLine("Sorted episodes:");
            string sortedEpisodesOutput = string.Join <Episode>(Environment.NewLine, episodes);

            Console.WriteLine(sortedEpisodesOutput);
            File.WriteAllText("sorted.tv", sortedEpisodesOutput);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: drazen-b/OOP_Zadaca_CS
        static void DZ3()
        {
            // Assume that the number of rows in the text file is always at least 10.
            // Assume a valid input file.
            string fileName       = "shows.tv";
            string outputFileName = "storage.tv";

            IPrinter printer = new ConsolePrinter();

            printer.Print($"Reading data from file {fileName}");

            Episode[] episodes = TvUtilities.LoadEpisodesFromFile(fileName);

            Season season = new Season(1, episodes);


            printer.Print(season.ToString());
            for (int i = 0; i < season.Length; i++)
            {
                season[i].AddView(TvUtilities.GenerateRandomScore());
            }
            printer.Print(season.ToString());

            printer = new FilePrinter(outputFileName);
            printer.Print(season.ToString());
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: FC122/DZ
        static void Main(string[] args)
        {
            Description description = new Description(1, TimeSpan.FromMinutes(45), "Pilot");

            Console.WriteLine(description);
            Episode episode = new Episode(10, 88.64, 9.78, description);

            Console.WriteLine(episode);

            // Assume that the number of rows in the text file is always at least 10.
            // Assume a valid input file.
            string fileName = "shows.txt";

            string[]  episodesInputs = File.ReadAllLines(fileName);
            Episode[] episodes       = new Episode[episodesInputs.Length];
            for (int i = 0; i < episodes.Length; i++)
            {
                episodes[i] = TvUtilities.Parse(episodesInputs[i]);
            }
            Console.WriteLine("Episodes:");
            Console.WriteLine(string.Join <Episode>(Environment.NewLine, episodes));
            TvUtilities.Sort(episodes);
            Console.WriteLine("Sorted episodes:");
            string sortedEpisodesOutput = string.Join <Episode>(Environment.NewLine, episodes);

            Console.WriteLine(sortedEpisodesOutput);

            /*for(int i=0;i<3;i++)
             *      {
             *              Console.WriteLine(episodesInputs[i]);
             *      }*/


            /*Episode ep1, ep2;
             * ep1 = new Episode();
             * ep2 = new Episode(10, 64.32, 8.7);
             * int viewers = 10;
             * for (int i = 0; i < viewers; i++)
             * {
             *      ep1.AddView(GenerateRandomScore());
             *      Console.WriteLine($"{i+1}.        { ep1.GetMaxScore()}");
             * }
             * if (ep1.GetAverageScore() > ep2.GetAverageScore())
             * {
             *      Console.WriteLine($"Viewers: {ep1.GetViewerCount()}");
             * }
             * else
             * {
             *      Console.WriteLine($"Viewers: {ep2.GetViewerCount()}");
             * }*/
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Description description = new Description(1, TimeSpan.FromMinutes(45), "Pilot");

            Console.WriteLine(description);
            Episode episode = new Episode(10, 88.64, 9.78, description);

            Console.WriteLine(episode);
            Console.WriteLine("!!!!!!!!!! ############# !!!!!!!!!!!!");

            string fileName = @"C:\Users\Dino\source\repos\objektno\dz1\Zadaca1\shows.tv";

            string[]  episodesInputs = File.ReadAllLines(fileName);
            Episode[] episodes       = new Episode[episodesInputs.Length];
            for (int i = 0; i < episodes.Length; i++)
            {
                episodes[i] = TvUtilities.Parse(episodesInputs[i]);
            }
            Console.WriteLine("Episodes:");
            Console.WriteLine(string.Join <Episode>(Environment.NewLine, episodes));
            TvUtilities.Sort(episodes);
            Console.WriteLine("Sorted episodes:");
            string sortedEpisodesOutput = string.Join <Episode>(Environment.NewLine, episodes);

            Console.WriteLine(sortedEpisodesOutput);
            //Episode ep1, ep2;
            //ep1 = new Episode();
            //ep2 = new Episode(10, 64.39, 8.7);
            //int viewers = 10;
            ////s
            //for (int i = 0; i < viewers; i++)
            //{
            //    ep1.AddView(GenerateRandomScore());
            //    Console.WriteLine(ep1.GetMaxScore());
            //}
            //if (ep1.GetAverageScore() > ep2.GetAverageScore())
            //{
            //    Console.WriteLine($"Viewers: {ep1.GetViewerCount()}");
            //}
            //else
            //{
            //    Console.WriteLine($"Viewers: {ep2.GetViewerCount()}");

            //}
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: patrikmakaj/OOP-ZADACE
        static void Main()
        {
            // Assume that the number of rows in the text file is always at least 10.
            // Assume a valid input file.
            string fileName = "shows.tv";

            IPrinter printer = new ConsolePrinter();

            printer.Print($"Reading data from file {fileName}");

            List <Episode> episodes = TvUtilities.LoadEpisodesFromFile(fileName);
            Season         season   = new Season(1, episodes);

            printer.Print(season.ToString());
            foreach (var episode in season)
            {
                episode.AddView(TvUtilities.GenerateRandomScore());
            }
            printer.Print(season.ToString());

            Season copy = new Season(season);

            copy[0].AddView(1.0);
            if (copy[0].GetAverageScore() == season[0].GetAverageScore())
            {
                printer.Print("This is not the correct copy implementation!");
            }

            try
            {
                season.Remove("Pilot");
                season.Remove("Nope");
            }
            catch (TvException e)
            {
                printer.Print($"{e.Message}, Name: {e.Title}");
            }
            printer.Print(season.ToString());
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: drazen-b/OOP_Zadaca_CS
        static void DZ1()
        {
            Episode ep1, ep2;

            ep1 = new Episode();
            ep2 = new Episode(10, 64.39, 8.7);
            int viewers = 10;

            for (int i = 0; i < viewers; i++)
            {
                ep1.AddView(TvUtilities.GenerateRandomScore());
                Console.WriteLine(ep1.GetMaxScore());
            }
            if (ep1.GetAverageScore() > ep2.GetAverageScore())
            {
                Console.WriteLine($"Viewers: {ep1.GetViewerCount()}");
            }
            else
            {
                Console.WriteLine($"Viewers: {ep2.GetViewerCount()}");
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: jurajperic/oop_zadace
        static void Main(string[] args)
        {
            //Episode ep1, ep2;
            //ep1 = new Episode();
            //ep2 = new Episode(10, 64.39, 8.7);
            //int viewers = 10;

            //for (int i = 0; i < viewers; i++)
            //{
            //    ep1.AddView(TvUtilities.GenerateRandomScore());
            //    Console.WriteLine(ep1.GetMaxScore());
            //}
            //if (ep1.GetAverageScore() > ep2.GetAverageScore())
            //{
            //    Console.WriteLine($"Viewers: {ep1.GetViewerCount()}");
            //}
            //else
            //{
            //    Console.WriteLine($"Viewers: {ep2.GetViewerCount()}");
            //}



            //Description description = new Description(1, TimeSpan.FromMinutes(45), "Pilot");
            //Console.WriteLine(description);
            //Episode episode = new Episode(10, 88.64, 9.78, description);
            //Console.WriteLine(episode);

            //// Assume that the number of rows in the text file is always at least 10.
            //// Assume a valid input file.
            //string fileName = "shows.tv";
            //string[] episodesInputs = File.ReadAllLines(fileName);
            //Episode[] episodes = new Episode[episodesInputs.Length];
            //for (int i = 0; i < episodes.Length; i++)
            //{
            //    episodes[i] = TvUtilities.Parse(episodesInputs[i]);
            //}

            //Console.WriteLine("Episodes:");
            //Console.WriteLine(string.Join<Episode>(Environment.NewLine, episodes));
            //TvUtilities.Sort(episodes);
            //Console.WriteLine("Sorted episodes:");
            //string sortedEpisodesOutput = string.Join<Episode>(Environment.NewLine, episodes);
            //Console.WriteLine(sortedEpisodesOutput);
            //File.WriteAllText("sorted.tv", sortedEpisodesOutput);



            // Assume that the number of rows in the text file is always at least 10.
            // Assume a valid input file.

            string fileName       = "shows.tv";     // u TvUtilities i FilePrinter se dodaje ekstenzija .txt na fileName i outputFileName
            string outputFileName = "storage.tv";

            IPrinter printer = new ConsolePrinter();

            printer.Print($"Reading data from file {fileName}");

            Episode[] episodes = TvUtilities.LoadEpisodesFromFile(fileName);
            Season    season   = new Season(1, episodes);

            printer.Print(season.ToString());
            for (int i = 0; i < season.Length; i++)
            {
                season[i].AddView(TvUtilities.GenerateRandomScore());
            }
            printer.Print(season.ToString());

            printer = new FilePrinter(outputFileName);
            printer.Print(season.ToString());
        }