Пример #1
0
        static void Main(string[] args)
        {
            // create a CD
            //CD cd = new CD();
            //cd.Name = "RockBand - Human";
            CD cd = new CD()
            {
                Name = "RockBand - Human"
            };

            // create songs

            // biisien pituudet sekunneissa

            // 2 min 0 sec
            Song song1 = new Song()
            {
                Name = "First Song", Length = 120
            };
            // 3 min 01 sec
            Song song2 = new Song()
            {
                Name = "Second Song", Length = 181
            };
            // 4 min 02 sec
            Song song3 = new Song()
            {
                Name = "Third Song", Length = 242
            };

            // add songs to cd
            cd.Songs.Add(song1);
            cd.Songs.Add(song2);
            cd.Songs.Add(song3);

            // print cd
            Console.WriteLine($"CD name is {cd.Name}");
            Console.WriteLine($"- songs count {cd.SongsCount}");
            foreach (Song song in cd.Songs)
            {
                Console.WriteLine($"  - {song.Name} {song.LengthMinSec}");
            }
            Console.WriteLine(cd.ToString());

            CD cd2 = new CD()
            {
                Name = "Nightwish - Endless Forms Most Beautiful"
            };
            string documents
                = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            // \\storage\homes\M3286\Dox\Documents\Songs.csv
            // Tiedostosta lataamista!

            cd2.LoadSongs(documents + @"\Songs.csv");
            // print cd
            Console.WriteLine($"CD2 name is {cd2.Name}");
            Console.WriteLine($"- songs count {cd2.SongsCount}");
            foreach (Song song in cd2.Songs)
            {
                Console.WriteLine($"  - {song.Name} {song.LengthMinSec}");
            }
            Console.WriteLine(cd2.ToString());
        }