lab 7 - partie 1
This commit is contained in:
37
src/lab7_Classe_et_tableaux/Rectangle.java
Normal file
37
src/lab7_Classe_et_tableaux/Rectangle.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package lab7_Classe_et_tableaux;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* @author Rémi Heredero
|
||||
* @Klagarge
|
||||
*/
|
||||
public class Rectangle {
|
||||
private double width;
|
||||
private double height;
|
||||
private Color color;
|
||||
|
||||
public Rectangle(double width, double height){
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
color = Color.RED;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
String s = "Rectangle size : ";
|
||||
s += this.width;
|
||||
s += " x ";
|
||||
s += this.height;
|
||||
s += "\n Color: ";
|
||||
s += this.color;
|
||||
return s;
|
||||
}
|
||||
|
||||
public void changeColor(Color c) {
|
||||
this.color = c;
|
||||
}
|
||||
|
||||
public double area() {
|
||||
return this.width * this.height;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user