/* * /// <summary> * /// Permet de modifier un des attributs en particulier, sans toucher aux autres * /// </summary> * /// <returns>1 si un attribut a été modifié, 0 si non</returns> * public virtual int SaisiePartielle() * { * string choix; * int sortie = 0; * int borneSub = 49; * * if (this.Description.Length <= 49) borneSub = this.Description.Length; * * //Chaque attribut est associé à un code pour pouvoir le choisir * Console.WriteLine(Affichage.Titre1("Modifier un champ")); * Console.WriteLine("Quel champ voulez-vous modifier ?\n" + * " 1. Reference (" + this.Reference + ") \n" + * " 2. Titre (" + this.Titre + ") \n" + * " 3. Description (" + this.Description.Substring(0,borneSub) + "..." + ") \n" + * " 4. Genre (" + this.GenreS + ") \n" + * " 5. Année de parution (" + this.AnneeParution + ") \n" + * " 6. ...\n"); * * //L'utilisateur fait son choix * choix = Console.ReadLine(); * * //En fonction de ce choix ... * //Pour chaque possibilité, on regarde si le choix de l'utilisateur correspond à un code * //Ou s'il a entré le nom du choix (le ToLower permet de ne pas se soucier de la casse) * if(choix.ToLower().Contains("reference") || choix.ToLower().Contains("1")) * { * this.SaisieRef(); * sortie = 1; * } * if (choix.ToLower().Contains("titre") || choix.ToLower().Contains("2")) * { * this.SaisieTitre(); * sortie = 1; * } * if (choix.ToLower().Contains("description") || choix.ToLower().Contains("3")) * { * this.SaisieDescription(); * sortie = 1; * } * if (choix.ToLower().Contains("genre") || choix.ToLower().Contains("4")) * { * this.SaisieGenre(); * sortie = 1; * } * if (choix.ToLower().Contains("parution") || choix.ToLower().Contains("5")) * { * this.SaisieAnnee(); * sortie = 1; * } * * return sortie; * }*/ #endregion /// <summary> /// Permet de modifier un des attributs en particulier, sans toucher aux autres /// </summary> /// <returns>1 si un attribut a été modifié, 0 si non</returns> public virtual void SaisiePartielle() { string choix; int borneSub = 49; //Réduit l'affichage de la description si celle-ci fait plus de 49 caractères if (this.Description.Length <= 49) { borneSub = this.Description.Length; } string desc; if (borneSub == 49) { desc = this.Description.Substring(0, borneSub) + "..."; } else { desc = this.Description; } //Chaque attribut est associé à un code pour pouvoir le choisir Console.WriteLine(Affichage.Titre1("Modifier un champ")); Console.WriteLine("Quel champ voulez-vous modifier ?\n" + " 1. Reference (" + this.Reference + ") \n" + " 2. Titre (" + this.Titre + ") \n" + " 3. Description (" + desc + ") \n" + " 4. Genre (" + this.GenreS + ") \n" + " 5. Année de parution (" + this.AnneeParution + ") \n" + this.ChoixEnfant()); //L'utilisateur fait son choix choix = Console.ReadLine(); //En fonction de ce choix ... //Pour chaque possibilité, on regarde si le choix de l'utilisateur correspond à un code //Ou s'il a entré le nom du choix (le ToLower permet de ne pas se soucier de la casse) if (choix.ToLower().Contains("reference") || choix == "1") { this.SaisieRef(); } if (choix.ToLower().Contains("titre") || choix == "2") { this.SaisieTitre(); } if (choix.ToLower().Contains("description") || choix == "3") { this.SaisieDescription(); } if (choix.ToLower().Contains("genre") || choix == "4") { this.SaisieGenre(); } if (choix.ToLower().Contains("parution") || choix == "5") { this.SaisieAnnee(); } this.SaisiePartielleEnfant(choix); }
/// <summary> /// Permet de modifier un des attributs en particulier, sans toucher aux autres /// </summary> /// <returns>1 si un attribut a été modifié, 0 si non</returns> public virtual void SaisiePartielle() { string choix; //Chaque attribut est associé à un code pour pouvoir le choisir Console.WriteLine(Affichage.Titre1("Modifier un champ")); Console.WriteLine("Quel champ voulez-vous modifier ?\n" + " 1. Nom (" + this.Nom + ") \n" + " 2. Adresse (" + this.Adresse + ") \n" + " 3. Code Postal (" + this.CodePostal + ") \n" + " 4. Ville (" + this.Ville + ") \n"); //L'utilisateur fait son choix choix = Console.ReadLine(); //En fonction de ce choix ... //Pour chaque possibilité, on regarde si le choix de l'utilisateur correspond à un code //Ou s'il a entré le nom du choix (le ToLower permet de ne pas se soucier de la casse) if (choix.ToLower().Contains("nom") || choix == "1") { this.SaisieNom(); } if (choix.ToLower().Contains("adresse") || choix == "2") { this.SaisieAdresse(); } if (choix.ToLower().Contains("code") || choix == "3") { this.SaisieCodePostal(); } if (choix.ToLower().Contains("ville") || choix == "4") { this.SaisieVille(); } }
/// <summary> /// Permet de modifier complètement la valeur de tous les attributs depuis la console /// </summary> public virtual void Saisie() { //Mise en évidence dans la console du but de la fonction Console.WriteLine(Affichage.Titre1("Saisie d'un nouveau media")); //Mise à jour des différents attributs this.SaisieRef(); this.SaisieTitre(); this.SaisieDescription(); this.SaisieGenre(); this.SaisieAnnee(); //La date d'entrée du média devient la date de dernière modification this.DateEntree = DateTime.Now; }
/// <summary> /// Retourne une chaîne de caractères contenant la valeur des attributs de la classe /// </summary> /// <returns></returns> public override string ToString() { string s = "\n"; //Ajoute un petit effet pour mettre en avant le titre lors de l'affichage s += Affichage.Titre1(this.Titre); s += "Description : " + this.Description + "\n"; s += "\nReference : " + this.Reference + "\n"; s += "Genre : " + this.GenreS + "\n"; s += "Année de Parution : " + this.AnneeParution + "\n"; s += "\nDate de saisie dans l'application : " + this.DateEntree + "\n"; return(s); }
/// <summary> /// Décrit tous les médias enregistrés dans la liste /// </summary> /// <returns>La description</returns> public override string ToString() { string s = ""; if (this.Medias.Count != 0) { s += Affichage.Titre1("Liste des médias enregistrés"); } //Cas où la liste est vide else { s += Affichage.Titre1("Aucun résultat trouvé"); } foreach (Media m in this.Medias) { s += m.ToStringMin(); } return(s); }