예제 #1
0
        /// <summary>
        /// Allows you to create an album.
        /// </summary>
        /// <param name="library"></param>
        private void CreateAlbum(LibraryAlbum library)
        {
            int conf;
            int valid;

            do
            {
                _view.DisplayText("Ajout d'album selectioné :\n");
                Album album = _view.AskForAlbum();
                var   done  = library.AddAlbum(album);
                do
                {
                    Track track = _view.AskForTrack(album);
                    album.AddTrack(track);
                    valid = _view.AskForNumber("Voulez vous ajouter un autre morceau ? \t1 - Oui\t2 - Non");
                } while (valid == 1);
                album.TimeCalculator();

                conf = _view.AskForNumber("Voulez vous ajouter un autre album ? \t1 - Oui\t2 - Non");
            } while (conf == 1);
        }
예제 #2
0
        /// <summary>
        /// Starts the app.
        /// </summary>
        public void Start()
        {
            int valid;

            _view.DisplayText("Bienvenue dans la gestion d'album !");

            var serdes  = new PersistanceXml();
            var library = new LibraryAlbum();
            var al1     = new Album("12345", "Black album", "Metallica", "Trash", 1991);
            var m1      = new Track("Nothing else matter", 5, 10, "Metallica", "Black album", "Power ballad", 1991, 1);

            var al2 = new Album("12346", "Ok Computer", "Radiohead", "Art rock", 1997);
            var m2  = new Track("Karma Police", 4, 33, "Radiohead", "Ok Computer", "Rock", 1997, 1);
            var m3  = new Track("Exit music(for a film)", 5, 22, "Radiohead", "Ok Computer", "Rock", 1997, 1);

            al1.AddTrack(m1);
            al2.AddTrack(m2);
            al2.AddTrack(m3);
            al1.TimeCalculator();
            al2.TimeCalculator();
            library.AddAlbum(al2);
            library.AddAlbum(al1);
            var  playlist = new Playlist();
            var  aff      = playlist.AddTrack("12346", "Karma Police", library);
            int  hour1    = 0;
            Time time1    = playlist.TimeCalculator(ref hour1);

            _view.DisplayTimeList(time1, hour1);
            do
            {
                valid = _view.DisplayMenu();

                switch (valid)
                {
                case 1:
                    _view.DisplayText("Voici la liste des albums enregistrés\nClé de l'album :\tTitre de l'album :\tDurée :\t\tArtist :\tGenre :\t\tAnnée :");
                    DisplayListAlbum(library);
                    break;

                //OK
                case 2:
                    ViewAlbum(library);
                    break;

                //OK
                case 3:
                    CreateAlbum(library);
                    break;

                //OK
                case 4:
                    DeleteAlb(library);
                    break;

                //OK
                case 5:
                    UpdateAlbum(library);
                    break;

                //OK
                case 6:
                    DeleteTrackLib(library);
                    break;

                //ok
                case 7:
                    AddTrackLib(library);
                    break;

                // ok
                case 8:
                    library = new LibraryAlbum(serdes.Deserialize());
                    break;

                //pas ok
                case 9:
                    serdes.Serialize(library);
                    break;

                //pas ok
                case 10:
                    AddTrackInList(library, playlist);
                    break;

                case 11:
                    DisplayPlaylist(playlist);
                    break;

                case 12:
                    ListBy(library);
                    break;

                case 13:
                    PlayListSorting(playlist);
                    break;

                default:
                    _view.DisplayText("Saisie incorrect !");
                    break;
                }
            } while (valid != 14);
        }