Lab 4: Inheritence with Shapes



While you don't need to have knowledge about JavaFX to complete this assignment, it makes use of JavaFX. As a result, you'll need to have JavaFX installed on your computer and configured in IntelliJ. Use one of the following guides to get this done:



Shape Implementations

Your assignment is to write the Shape, Triangle, LabeledTriangle, Rectangle, LabeledRectangle, and Circle classes. The classes are part of an inheritance hierarchy that is shown in the UML class diagram below. Note that the Shape class is an abstract class. Also, be sure that your implementation adheres to the visibility modifiers shown in the diagram.

Place each of these classes in a package that uses your MSOE username as the name.

Implementation specific details for these classes is found in the javadoc.

UML Class Diagram


The FaceMaker class has already been partially implemented. Once you have implemented the Shape and Rectangle classes, you should be able to run the FaceMaker program and see a face made of rectangles displayed.

The program makes use of the classes that you must implement to create the following:

Rectangle Face

You will need to refactor the FaceMaker class and add additional functionality as described below.

When completed, your program should ask the user for the desired type of shapes to use when generating the face. The user should be able to select any of the following options:

If the user enters something other than the one of the above options, then the program should draw a face using a randomly selected shape type for each facial component. For example, the program may draw a rectangle for the head, a labeled rectangle for the right eye, a triangle for the left eye, and circles for the nose and mouth.


The program relies on the WinPlotterFX class. Prof. Jones wrote the WinPlotterFX class, and the documentation for the class is found here. You will need to download and then add the WinPlotterFX.jar file to your build path (see instructions below).

Accessing the .jar File

For this assignment, you will need to make use of the WinPlotterFX.jar.

In order to be able to access the WinPlotterFX class in the .jar file:

  1. Create a lib folder in your IntelliJ project folder
  2. Download the WinPlotterFX.jar file and save it in the newly created lib folder.
  3. Select File -> Project Structure
  4. Select Modules from the Project Settings on the left
  5. Select the Dependencies tab on the right
  6. Select the + on the far right
  7. Select Libraries -> Java from the drop-down menu
  8. Select the lib folder you created above and click OK
  9. In the Configure Library dialog box that appears, accept the default settings: Name = lib and Level = Project Library
  10. Click OK to close the Project Structure window

You should now have access to the edu.msoe.winplotterfx.WinPlotterFX class in your project code.


Sample Results

Circle Face

Labeled Triangle Face

Random Face

Just For Fun

Once you have met the requirements of the assignment, you may enjoy doing one or more of the following:


This laboratory assignment was developed Dr. Chris Taylor, and Prof. Sean Jones.


See your professor's instructions for details on submission guidelines and due dates.