Bonjour
Dans ce prg prenons la méthode
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public class Points1 { double x; char nom; public Points1 (char nom,double x) { this.x=x; this.nom=nom; } public void afficherCoord () { System.out.println ("Le Point "+this.nom+" a pour abscisse "+x ); } public double distance (Points1 M) { double d=this . x M . x ; return Math.abs (d); } public void deplacer (double dx) { this.x+=dx; } } public class TesterPoints1 { public static void main (String[] args) { Points1 A=new Points1 ( 'A', 2.6); A.afficherCoord (); A.deplacer (1.1); A.afficherCoord (); Points1 B=new Points1 ( 'B', 1.54); B.afficherCoord (); System.out.println ("Distance entre A et B = "+A.distance (B)); } }
il y a deux objets A et B, d'ou vient il ce M?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 public double distance (Points1 M) { double d=this . x M . x ; return Math.abs (d); }
et expliquez moi svp la ligne suivante
double d=this . x – M . x ;//surtout this . x – M . x
Et prenons la méthode suivante
dx signifie d*x n'est ce pas?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 public void deplacer (double dx) { this.x+=dx; }
merci pour vos aides svp
Partager