Blame view

tp3_polymorph/tp3/hierarchic/Test.java 1.23 KB
fed1c83c   Vincent Benoist   tp2 et 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  import java.util.*;
  
  public class Test{
  
      
       
       
       
      public static void main(String[] args){
           Scanner sc = new Scanner(System.in);       
          //Choix Progression
          System.out.println("Arithmetique taper 1\n Geometrique taper 2 ");
          int choix = sc.nextInt();
          
          System.out.print("\npremier terme? ");
          double d = sc.nextDouble();
          System.out.print("\nraison? ");
          double raison = sc.nextDouble();
          Progression p;
          
          if(choix == 1){
              p= new ProgressionArithmetique(d,raison);
          } else {
              p= new ProgressionGeometrique(d,raison);
          }
          manip(p);
          
        
          
         
      }
     
      
      static void manip(Progression p){
      
          Scanner sc = new Scanner(System.in);
          System.out.print("\nnext (y/n)? ");
          char next = sc.next().charAt(0);
          while(next == 'y'){
              p.next();
              System.out.println("\n-> "+p.getTerme());
              
              System.out.print("next (y/n)? ");
              next = sc.next().charAt(0);
          }
          System.out.print("\nnb termes supplementaires? ");
          p.next(sc.nextInt());
          System.out.println("\n"+p.toString());
      }
      
  }