// Java (хороший пример)
interface Shape {
double area();
}
class Rectangle implements Shape {
private final double width;
private final double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
public double area() {
return width * height;
}
}
class Square implements Shape {
private final double side;
public Square(double side) {
this.side = side;
}
public double area() {
return side * side;
}
}
// Java (хороший пример)
interface Shape {
double area();
}
class Rectangle implements Shape {
private final double width;
private final double height;
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
public double area() {
return width * height;
}
}
class Square implements Shape {
private final double side;
public Square(double side) {
this.side = side;
}
public double area() {
return side * side;
}
}