Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. class Cercle {
  2.         private double rayon;
  3.         private static double DEFAULT_RAYON = 1.0;
  4.        
  5.         void bob(double r) {
  6.                 rayon=r;
  7.         }
  8.  
  9.         public Cercle(double v)  {
  10.             rayon = v;
  11.         }
  12.        
  13.         public Cercle() {
  14.             this(DEFAULT_RAYON);
  15.         }
  16.  
  17.         public void bob(){
  18.             rayon=3.45;
  19.         }
  20.  
  21.         public double perimetre(){
  22.                 return 2*Math.PI*rayon;
  23.         }
  24.        
  25.         public static void main(String[] args){
  26.                 Cercle c1 = new Cercle(6.1);
  27.                 Cercle c2 = new Cercle(2.7);
  28.                 Cercle c3 = new Cercle();
  29.                
  30.                 System.out.printf("%f\n", c1.perimetre());
  31.                 System.out.printf("%f\n", c2.perimetre());
  32.                 System.out.printf("%f\n", c3.perimetre());
  33.         }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement