diff --git a/w5/ShapeDemo.java b/w5/ShapeDemo.java new file mode 100644 index 0000000..5c9c8ca --- /dev/null +++ b/w5/ShapeDemo.java @@ -0,0 +1,40 @@ +class Shape { + public void draw() { + System.out.println("Drawing a shape"); + } +} + +class Circle extends Shape { + @Override + public void draw() { + System.out.println("Drawing a circle"); + } +} + +class Rectangle extends Shape { + @Override + public void draw() { + System.out.println("Drawing a rectangle"); + } +} + +public class ShapeDemo { + public static void drawShape(Shape s) { + s.draw(); + } + + public static void main(String[] args) { + Shape shape = new Shape(); + Circle circle = new Circle(); + Rectangle rectangle = new Rectangle(); + + System.out.println("Testing Shape:"); + drawShape(shape); + + System.out.println("\nTesting Circle:"); + drawShape(circle); + + System.out.println("\nTesting Rectangle:"); + drawShape(rectangle); + } +} \ No newline at end of file