lab 7 - partie 1

This commit is contained in:
2021-11-29 20:20:20 +01:00
parent b76b39490c
commit 80c743cb15
3 changed files with 62 additions and 0 deletions

View 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;
}
}