next up previous contents index
Next: Bref rappel des opérations Up: Un exemple dans chaque Previous: Point et ColorPoint in

 

Point et ColorPoint in Java 

class Point extends Object {
        protected int x;
        void setx(int x) { this.x = x;}
        int  getx() { return x;}
}

class ColorPoint extends Point { protected String c; void setx(String c) { this.c = c.clone();} String getcol() { return c;} }

Point p; ColorPoint q;

p.setx(3); q.setx(4); q.setcol("blue"); System.out.println("Point at " +p.getx().toString() +" "+q.getcol() +" Colorpoint at " +q.getx().toString() +"\n");;



Roberto DiCosmo
Mon Jun 3 18:29:31 MET DST 1996