Im doing some school homework and came across this task. I don't really know how to do that with what I have done so far. This is my code.
abstract class Shape {
abstract void draw();
}
class Circle extends Shape{
@Override
void draw() {
System.out.println("Drawing a circle");
}
}
class Rectangle extends Shape{
@Override
void draw() {
System.out.println("Drawing a rectangle");
}
}
And my main method
public static void main(String[] args)
{
List<Shape> shape = new ArrayList<>();
Shape [] shapes = new Shape[2];
Rectangle rektangel = new Rectangle();
Circle sirkel = new Circle();
shape.add(rektangel);
shape.add(sirkel);
}
Aucun commentaire:
Enregistrer un commentaire