Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. /**
  7. *
  8. * @author UIRDT1176
  9. */
  10. public class Ville {
  11. String nom;
  12. String pays;
  13. double nbreHabitentes;
  14. char categorie;
  15.  
  16.  
  17. public Ville(String nom, String pays, double NbreHabitentes, char Categorie) {
  18. this.nom = nom;
  19. this.pays = pays;
  20. this.nbreHabitentes = nbreHabitentes;
  21. this.categorie = categorie;
  22. }
  23.  
  24. public String getNom() {
  25. return nom;
  26. }
  27.  
  28. public String getPays() {
  29. return pays;
  30. }
  31.  
  32. public double getNbreHabitentes() {
  33. return nbreHabitentes;
  34. }
  35.  
  36. public char getCategorie() {
  37. return categorie;
  38. }
  39.  
  40. public void setNom(String nom) {
  41. this.nom = nom;
  42. }
  43.  
  44. public void setPays(String prenom) {
  45. this.pays ="";
  46. }
  47.  
  48. public void setNbreHabitentes(double NbreHabitentes) {
  49. this.nbreHabitentes = NbreHabitentes;
  50. }
  51.  
  52. public void setCategorie() {
  53. int borne[]= { 0,100,1000,100000,500000 , 1000000, 5000000, 10000000 };
  54. char Categorie[]={'!','A','B','C','D','E','E','F','G','H'};
  55. int i=0;
  56. while( i < borne.length && this.nbreHabitentes >= borne[i])
  57. {
  58. i++;
  59.  
  60. }
  61.  
  62. this.categorie = Categorie[i];
  63.  
  64.  
  65. }
  66.  
  67. public String comparer(Ville e)
  68. {
  69. if(this.nbreHabitentes == e.nbreHabitentes )
  70. {
  71. return"les deux ville ont les meme nombre d'habitentes";
  72. }
  73. else if (this.nbreHabitentes != e.nbreHabitentes)
  74. return"les deux sont pas egaux ";
  75. return null;
  76. }
  77.  
  78. public void afficher (Ville e)
  79. {
  80. System.out.println("la ville " +this.nom+ "de " +this.pays+ " a " +this.nbreHabitentes+ " nombre d'habitents" );
  81. }
  82.  
  83.  
  84. }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement