ex2 tp 1

PHOTO EMBED

Mon Nov 04 2024 22:03:49 GMT+0000 (Coordinated Universal Time)

Saved by @saharmess #java

public class point{
    float x;
    float y;
    
    public point(float x,float y){
        this.x=x;
        this.y=y;
    }
    void afficher(){
        System.out.println("point("+x+","+y+")");
    }
    void deplacer(float a,float b){
        x=a;
        y=b;
    }
    float getAbscisse(){
        return this.x;
    }
    float getOrdonne(){
        return this.y;
    }
    public String toString(){
       String ch;
       ch="le point est "+ this.x +"\t"+this.y;
       return ch;
    }
    public Boolean equals(point po){
        return po!= null && po.equals(this.x) && po.equals(this.y);}
    public static void main (String []  args){
    point p=new point(19,4);
    p.afficher();
    System.out.println(p);
    p.deplacer(6,8);
    p.afficher();
    point p2=new point(6,8.0f);
    point p3=new point(4.0f, 2.0f);
    System.out.println("p est egal a p2:"+p.equals(p2));
    System.out.println("p est egal a p3:"+p.equals(p3));

   
            }
}
content_copyCOPY