Ultima modifica da un moderatore:
Java:
public class Segmento {
private int x0;
private int y0;
private int x1;
private int y1;
//Costruttore di default
public Segmento(){
this.x0 = 0;
this.y0 = 0;
this.x1 = 0;
this.y1 = 0;
}
//Costruttore parametrico
public Segmento(int x0, int y0, int x1, int y1) {
this.x0 = x0;
this.y0 = y0;
this.x1 = x1;
this.y1 = y1;
}
public int getX0() {
return this.x0;
}
public void setX0(int x0) {
if(this.x0<=800)
this.x0 = x0;
}
public int getY0() {
return this.y0;
}
public void setY0(int y0) {
if(this.y0<=600)
this.y0 = y0;
}
public int getX1() {
return this.x1;
}
public void setX1(int x1) {
if(this.x1<=800)
this.x1 = x1;
}
public int getY1() {
return this.y1;
}
public void setY1(int y1) {
if(this.y1<=600)
this.y1 = y1;
}
public double Lunghezza(int x0, int y0, int x1, int y1){
double lunghezza1;
double lunghezza2;
lunghezza1=x0-x1;
lunghezza2=y0-y1;
return 0;
}
}
public class Rettangolo {
private Segmento lato1;
private Segmento lato2;
private Segmento lato3;
private Segmento lato4;
public Rettangolo(){
this.lato1 = new Segmento();
this.lato2 = new Segmento();
this.lato3 = new Segmento();
this.lato4 = new Segmento();
}
public Rettangolo( int x1,int x0, int y0, int y1) {
Segmento lato 1 = new Segmento (x0, x1);
this.lato2 = lato2;
this.lato3 = lato3;
this.lato4 = lato4;
}
public Segmento getLato1() {
return this.lato1;
}
public void setLato1(Segmento lato1) {
this.lato1 = lato1;
}
public Segmento getLato2() {
return this.lato2;
}
public void setLato2(Segmento lato2) {
this.lato2 = lato2;
}
public Segmento getLato3() {
return this.lato3;
}
public void setLato3(Segmento lato3) {
this.lato3 = lato3;
}
public Segmento getLato4() {
return this.lato4;
}
public void setLato4(Segmento lato4) {
this.lato4 = lato4;
}
public int Area(Segmento lato 1, Segmento lato 3){
int area;
area=this.getLato1()*this.getLato3();
}
}