ex2 class java

PHOTO EMBED

Mon Nov 04 2024 19:28:56 GMT+0000 (Coordinated Universal Time)

Saved by @saharmess #java

class point{
    float x;
    float y;
    public point(float x, float y) {
        this.x = x;
        this.y = y;
    }
    void affiche(){
        System.out.println("point("+x+","+y+")");
    }
    void deplacer(float dx,float dy){
        x=x+dx;
        y=y+dy;
    }
    double distance(){
        return Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
    }

public static void main(String args[]){
    point p=new point(1,3);
    p.affiche();
    
}}
content_copyCOPY