1 package dev2019; import java.util.Scanner ; public class Chanson { private St
1 package dev2019; import java.util.Scanner ; public class Chanson { private String titre ; private String chanteur ; private String compositeur; private int duree; public Chanson(String titre, String chanteur) { this.titre = titre; this.chanteur = chanteur; compositeur=null ; duree=0 ; } public Chanson() { titre=null ; chanteur=null ; compositeur=null ; duree=0 ; } public void saisir(){ Scanner s=new Scanner(System.in) ; titre=s.nextLine() ; chanteur=s.next() ; compositeur=s.next() ; duree=s.nextInt() ; } 2 public String getTitre() { return titre; } public String getCompositeur() { return compositeur; } public void setDuree(int duree) { this.duree = duree; } public int getDuree() { return duree; } public void ecouterChanson() { for(int i=0;i<duree;i++) System.out.println("lire flux"); } public void afficher() { System.out.println("Titre:"+titre+"\nChanteur:"+chanteur+ "\nCompositeur:"+compositeur+"\nDurée"+duree); }} package dev2019; public class Album { public final int SINGLE=1; public final int LONG_PLAY=2; private final int NB_CHANS_MAXI1=2; private final int NB_CHANS_MAXI2=10; private String titreAlbum; 3 private int typeAlbum; private Chanson[] chanson; private int nbChanson; public Album(String titre, int typeAlbum) { this.titreAlbum=titre; if(typeAlbum==SINGLE) chanson=new Chanson[NB_CHANS_MAXI1]; else if(typeAlbum==LONG_PLAY) chanson=new Chanson[NB_CHANS_MAXI2]; } public void ajouter(Chanson c) { if (nbChanson<chanson.length) { int i=0; while(i<nbChanson && chanson[i]!=null) i++; chanson[i]=c; nbChanson++; }} public int rechercherChanson(String titre) { boolean trouve=false; int i=0; int val=-1; System.out.println("nb=="+chanson.length); while (i<chanson.length && !trouve) { if (chanson[i]!=null && chanson[i].getTitre().equals(titre)) { trouve=true; 4 val=i; } i++; } return val;} public void supprimerChanson(String titre) { boolean trouve=false; int i=0; int val=-1; while (i<chanson.length && !trouve) { if (chanson[i]!=null && chanson[i].getTitre().equals(titre)) { trouve=true; chanson[i]=null; nbChanson--; } i++; }} public void lireAlbum() { for(int i=0;i<chanson.length;i++) if (chanson[i]!= null) chanson[i].ecouterChanson(); }} package dev2019; public class Test { public static void main(String[] args) { Album al=new Album("Succès", 2); Chanson ch1=new Chanson("la liberté", "Soulking"); Chanson ch2=new Chanson("Oh ya alem", "Samara"); al.ajouter(ch1); 5 al.ajouter(ch2); int i=al.rechercherChanson("la bohème"); if (i!=-1) al.supprimerChanson("la bohème"); al.lireAlbum(); } } uploads/Geographie/ corrigedevoir-2019.pdf
Documents similaires
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/HVCnhBN7wiuee7XOrAR7IbJZpMN9MHRzuFMA33HA06aPtSzlWcjtoKEdG3eLLI7a0mokMW4swtxZE5UeGkWbevSZ.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/DySkGxoKTSTXjhEqDfmwuoftaR6NPc5ngxbAZNAAgaaIKIXfH20a7ykbz4HshvaAPG0QfkXQGsa7DPTVgUgEK2FQ.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/zuX9t9T5MxoBoviu3XwZzKK3NWjU9sfTdlpOovpLWQyCexH60pK9Saz9BimaqQ6HUadFIJyR4aqgXuamrjhc5o23.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/7PRKqb0tOyZqUQnFJfjnUjCsm3PRxwdWgtWLf4aIOxjGxdCbLkv4okzj1xEOqlJ6FOIvhcMc3oNPe6gUHCUixTv8.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/ObJxPROEPCHjL0aKKAzlyIMJbulukaE2ZmuhvkISLaHtt3Ih4sf3IPzmfa8kNy3SXPPfsb4Fih01dfaLHNsRQjNG.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/QTzOuhMpZ7sOWvIAKVlCmEomOdR9eF0i7VGy98I7WshpflzEyMlXyjaURQ7g3L1A4XtkRH7ZjykXsFrvTJRHti17.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/l9MLhCZxbTQxjO4bMgSryghyraSf3dkm93K34y7MLPu5ULuGaDPKMevkRUp969qjKhZGSyn9NKDRt1bmFmJfZ9Gr.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/EDQzPpzHZqdkNR6EleqHaGETrgcJTgVBaESaNMRbfOon8Gir8PS0hJAx2ugSwQE0TZGMRC9QvCy0uBLVRQdG1KaN.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/dzTdIayxlN7gUl7NaSeAJTEpBtc9NIxomgfDQ2zrX8wmc9QJ5JCf3tbfEeRF8euM37M4rUygH6XliIAllSeX82DV.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/oFGATg8FnZF6rt6AaPfdludDoYBWtd7vS91XfUFOMLdzXdrVB6nzOYR6x648wXmkqlkKDHfVkeFfZoMEIdVbCdJa.png)
-
25
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Sep 11, 2022
- Catégorie Geography / Geogra...
- Langue French
- Taille du fichier 0.2241MB