public class Rectangle extends Shape{
Rectangle(Double w, Double h)
{
super(dim -> dim[0] > 0 && dim[1] > 0, dim -> dim[0] * 2 + dim[1] * 2 ,dim -> dim[0] * dim[1],new Double[]{w, h});
}
static void DrawRectangle( )
{
final String asterisk = "*";
for(int i = 0; i <= w; i++)
{
for(int j = 0; j <= h; j++)
{
System.out.print(asterisk);
}
System.out.println();
}
}
}
public class Main {
public static void main(String[] args) {
Rectangle rectangle = new Rectangle(10d, 10d);
rectangle.draw();
}
}
class Shape implements ShapeDrawer {
private Double weight;
private Double height;
public Shape(Double weight, Double height) {
this.weight = weight;
this.height = height;
}
@Override
public void draw() {
final String asterisk = "*";
for(int i = 0; i <= weight; i++) {
for(int j = 0; j <= height; j++) {
System.out.print(asterisk);
}
System.out.println();
}
}
public Double getWeight() {
return weight;
}
public void setWeight(Double weight) {
this.weight = weight;
}
public Double getHeight() {
return height;
}
public void setHeight(Double height) {
this.height = height;
}
}
class Rectangle extends Shape {
Rectangle(Double w, Double h) {
super(w, h);
}
@Override
public void draw() {
final String sharp = "#";
for(int i = 0; i <= super.getWeight(); i++) {
for(int j = 0; j <= super.getHeight(); j++) {
System.out.print(sharp);
}
System.out.println();
}
}
}
interface ShapeDrawer {
void draw();
}