Vous êtes sur la page 1sur 6

Ele Akacha Groupe01

public interface Forme3D {


double volume();
}

public interface Movable {


void moveUp(int x);
void moveDown (int x);
void moveLeft (int x);
void moveRight (int x);
}

public class Point {


private int x,y;
Point(){};
Point(int x,int y){
this.x=x;
this.y=y;
}

public int getY() {


return y;
}

public void setY(int y) {


this.y = y;
}

public int getX() {


return x;
}

public void setX(int x) {


this.x = x;
}

}
Ele Akacha Groupe01

public abstract class FormeGeometrique {


private Point centre;
FormeGeometrique(Point centre){
this.centre=centre;
}
public Point getCentre() {
return centre;
}

public void setCentre(Point centre) {


this.centre = centre;
}

abstract double surface();

public void deplacer(int dxy){

public String toString(){


return "("+centre+")";
}
}
Ele Akacha Groupe01

public class Rectangle extends FormeGeometrique implements Movable {


private int largeur;
private int longeur;

Rectangle(Point centre,int largeur,int longeur){


super(centre);
this.largeur=largeur;
this.longeur=longeur;
}

public int getLargeur() {


return largeur;
}

public void setLargeur(int largeur) {


this.largeur = largeur;
}

public int getLongeur() {


return longeur;
}

public void setLongeur(int longeur) {


this.longeur = longeur;
}

public void moveUp(int x) {

public void moveDown(int x) {

public void moveLeft(int x) {

public void moveRight(int x) {

double surface() {
return longeur*largeur;
}

public String toString(){


return "rectangle de centre: "+super.toString()+" de largeur "+largeur+" de
longeur "+longeur+"et de surface= "+surface();
}
}
Ele Akacha Groupe01

public class Rectangle extends FormeGeometrique implements Movable {


private int largeur;
private int longeur;

Rectangle(Point centre,int largeur,int longeur){


super(centre);
this.largeur=largeur;
this.longeur=longeur;
}

public int getLargeur() {


return largeur;
}

public void setLargeur(int largeur) {


this.largeur = largeur;
}

public int getLongeur() {


return longeur;
}

public void setLongeur(int longeur) {


this.longeur = longeur;
}

public void moveUp(int x) {


this.centre.getY()=+x;
}

public void moveDown(int x) {


this.centre.getY()=-x;
}

public void moveLeft(int x) {


this.centre.getX()=-x;
}

public void moveRight(int x) {


this.centre.getX()=+x;
}

double surface() {
return longeur*largeur;
}

public String toString(){


return "rectangle de centre: "+super.toString()+" de largeur "+largeur+" de
longeur "+longeur+"et de surface= "+surface();
}
}
Ele Akacha Groupe01

public class Cercle extends FormeGeometrique implements Movable{


private float rayon;

Cercle(Point centre,float rayon){


super(centre);
this.rayon=rayon;
}

public float getRayon() {


return rayon;
}

public void setRayon(float rayon) {


this.rayon = rayon;
}

public float diametre(){


return rayon*2;
}

public void moveUp(int x) {


this.centre.getY()=+x;
}

public void moveDown(int x) {


this.centre.getY()=-x;
}

public void moveLeft(int x) {


this.centre.getX()=-x;
}

public void moveRight(int x) {


this.centre.getX()=+x;
}

double surface() {
return Math.PI*rayon*rayon;
}
public String toString(){
return "cercle de centre"+super.toString()+" et de rayon "+rayon+" diametre
"+diametre()+" et de surface= "+surface();
}
}

public class Carre extends Rectangle{


double largeur=largeur;
Carre(double largeur){
super(largeur);
}

public String toString(){


return super.toString();
}
}
Ele Akacha Groupe01

public class BoiteCarre extends Carre implements Forme3D {

BoiteCarre(int largeur) {
super(largeur);
}

public double volume() {


return largeur*largeur;
}

public String toString(){


return super.toString()+" et de volume= "+volume();
}
}

public class TestForme {


public static void main(String[] args){
FormeGeometrique[] formes= new FormeGeometrique[3];

Rectangle f0=new Rectangle((1.2),7,8);


Carre f1=new Carre(7.5);
Cercle f2=new Cercle((2.4),5);

formes=[f0,f1,f2];

}
}

Vous aimerez peut-être aussi