Use Shapes, Rectangles, and Squares to teach objects and inheritance in Java, tell students they’re the only ones who can complete the job for extra engagement.

  • Begin by providing a GUI (Graphical User Interface) that draws shapes on the screen.
    • Students will want to create a GUI, you’ll need to explain that they need to learn the basics first before delving into creating their own GUIs.
  • Have students draw a shape (rectangle, oval, etc.) on the screen using the built-in shape classes.
    • You’ll need to give them a quick lesson on how to use the methods of the Graphics class.
  • Next, provide a problem that the built-in shape classes do not solve (area, perimeter, etc.)
    • This creates a situation where students will have to build their own shape class to solve the given problem .
  • Tell students the built in program doesn’t have area (e.g. a getArea() method) so they’ll have to write their own.
  • Check out the files used for this assignment, including the GUI students were provided with (contained in file MyDrawings.java).

More about this tip

External Source

Interview with Brandon R. Rodriguez