Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            AlbumFactory albumMaker = new AlbumFactory();

            Album firstAlbum = albumMaker.CreateAlbum("The Best Album", "Ivan The Singer", 2015, "Pesho The Producer", 20, 8);
            Album secondAlbum = albumMaker.CreateAlbum("The Worst Album", "Petkan Petkanov", 2005, "Gosho Producing company", 21, 10);
            Album thirdAlbum = albumMaker.CreateAlbum("Golden Album", "Dragana Draganovich", 2013, "Serbian Productions company", 18, 8);
            Album fourthAlbum = albumMaker.CreateAlbum("Platinum Album", "Dragana Draganovich", 2015, "Serbian Productions company", 22, 11);
            Album fifthAlbum = albumMaker.CreateAlbum("Just an Album", "John Smith", 2008, "Sony Music company", 19, 7);

            Catalogue catalogue = new Catalogue();

            catalogue.AddAlbum(firstAlbum);
            catalogue.AddAlbum(secondAlbum);
            catalogue.AddAlbum(thirdAlbum);
            catalogue.AddAlbum(fourthAlbum);
            catalogue.AddAlbum(fifthAlbum);

            ExecuteTask1(catalogue);
            ExecuteTask2();
            ExecuteTask3();
            ExecuteTask4();
            ExecuteTask5();
            ExecuteTask6();
            ExecuteTask8();

        }
Ejemplo n.º 2
0
        // Task 1 Create a XML file representing catalogue
        private static void ExecuteTask1(Catalogue catalogue)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(Catalogue));


            StreamWriter streamWriter = new StreamWriter(CatalogueFilePath);
            xmlSerializer.Serialize(streamWriter, catalogue);
            streamWriter.Close();

            // Printing the generated XML file to the console

            Console.WriteLine("Task 1. The XML file");

            using (StreamReader reader = new StreamReader(CatalogueFilePath))
            {
                while (!reader.EndOfStream)
                {
                    Console.WriteLine(reader.ReadLine());
                }
            }

            Console.WriteLine(new string('-', 50));
        }