Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            List <Biisi> songList = new List <Biisi>();

            songList.Add(new Biisi("Juodaan kaljaa ", 3.53));
            songList.Add(new Biisi("Tippa tappaa ", 7.24));
            songList.Add(new Biisi("Juodaan kaljaa ", 2.33));
            songList.Add(new Biisi("Joulupukin muori ", 3.54));
            songList.Add(new Biisi("Master of puppets ", 6.54));
            songList.Add(new Biisi("Symphony of destruction ", 5.54));

            CD cd = new CD("Eino-papan parhaat", "Eikka", songList);

            var timeSpan = TimeSpan.FromMinutes(cd.CalculateLenght());
            int seconds  = timeSpan.Seconds;
            int minutes  = timeSpan.Minutes;

            Console.WriteLine(cd.ToString());
            Console.WriteLine("Total lenght: " + minutes + "min " + seconds + "sec");
            Console.WriteLine();
            Console.WriteLine(cd.GetCount() + " songs");


            Console.WriteLine(cd.ToString());
            foreach (var item in cd.BiisiLista)
            {
                Console.WriteLine(item.Name + item.Duration);
            }
        }
Ejemplo n.º 2
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());
        }