示例#1
0
        public static void CompositeExercise()
        {
            // Make new empty "Study" playlist
            PlayList studyPlaylist = new PlayList("Study");

            // Make "Synth Pop" playlist and Add 2 songs to it.
            PlayList synthPopPlaylist = new PlayList("Synth Pop");
            Song     synthPopSong1    = new Song("Girl Like You", "Toro Y Moi");
            Song     synthPopSong2    = new Song("Outside", "TOPS");

            synthPopPlaylist.Add(synthPopSong1);
            synthPopPlaylist.Add(synthPopSong2);

            // Make "Experimental" playlist and Add 3 songs to it,
            // then set playback speed of the playlist to 0.5x
            PlayList experimentalPlaylist = new PlayList("Experimental");
            Song     experimentalSong1    = new Song("About you", "XXYYXX");
            Song     experimentalSong2    = new Song("Motivation", "Clams Casino");
            Song     experimentalSong3    = new Song("Computer Vision", "Oneohtrix Point Never");

            experimentalPlaylist.Add(experimentalSong1);
            experimentalPlaylist.Add(experimentalSong2);
            experimentalPlaylist.Add(experimentalSong3);
            float slowSpeed = 0.5f;

            experimentalPlaylist.SetPlaybackSpeed(slowSpeed);

            // Add the "Synth Pop" playlist to the "Experimental" playlist
            experimentalPlaylist.Add(synthPopPlaylist);

            // Add the "Experimental" playlist to the "Study" playlist
            studyPlaylist.Add(experimentalPlaylist);

            // Create a new song and set its playback speed to 1.25x, play this song,
            // get the name of glitchSong → "Textuell", then get the artist of this song → "Oval"
            Song  glitchSong  = new Song("Textuell", "Oval");
            float fasterSpeed = 1.25f;

            glitchSong.SetPlaybackSpeed(fasterSpeed);
            glitchSong.Play();
            String name   = glitchSong.GetName();
            String artist = glitchSong.GetArtist();

            Console.WriteLine("The song name is " + name);
            Console.WriteLine("The song artist is " + artist);

            // Add glitchSong to the "Study" playlist
            studyPlaylist.Add(glitchSong);

            // Play "Study" playlist.
            studyPlaylist.Play();

            // Get the playlist name of studyPlaylist → "Study"
            Console.WriteLine("The Playlist's name is " + studyPlaylist.GetName());
        }