Lab 4
Get started now
## Objectives * Translate UML class diagrams into source code * Construct software which using an abstract class and polymorphism * Employ aggregation and composition in the development of software * Use javadoc to determine appropriate use of an unfamiliar class ## Resources * [FaceMaker](FaceMaker.java) * [Shape Family Documentation](lab4doc/index.html) * [WinPlotterFX JAR file](WinPlotterFX.jar) * [WinPlotterFX Documentation](WinPlotterFX.htm) ## Assignment ### 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](lab4doc/index.html). <figure>[![UML Class Diagram](shapes.png)](shapes.png)</figure> ### FaceMaker The [FaceMaker](FaceMaker.java) 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: <figure>[![Rectangle Face](rectangleFace.png)](rectangleFace.png)</figure> 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: * **Rectangle** &mdash; draws face using rectangles as shown above * **Circle** &mdash; draws face using circles for each facial component * **Triangle** &mdash; draws face using triangles for each facial component * **Labeled Rectangle** &mdash; draws face using labeled rectangles for each facial component * **Labeled Triangle** &mdash; draws face using labeled triangles for each facial component * **Random** &mdash; draws face using one of the previous shapes for each facial component 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. ### WinPlotterFX The program relies on the [WinPlotterFX](WinPlotterFX.jar) class. Prof. Jones wrote the `WinPlotterFX` class, and the documentation for the class is found [here](WinPlotterFX.htm). 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](WinPlotterFX.jar). In order to be able to access the `WinPlotterFX` class in the `.jar` file: 1. Create a **libs** folder in your IntelliJ project folder 1. Download the [WinPlotterFX.jar](WinPlotterFX.jar) file and save it in the newly created **libs** folder. 1. Select **File -> Project Structure** 1. Select **Modules** from the **Project Settings** on the left 1. Select the **Dependencies** tab on the right 1. Select the <kbd>+</kbd> on the far right 1. Select **Libraries -> Java** from the drop-down menu 1. Select the **libs** folder you created above and click **OK** 1. In the **Configure Library** dialog box that appears, accept the default settings: **Name = libs** and **Level = Project Library** 1. Click **OK** to close the **Project Structure** window You should now have access to the `edu.msoe.winplotterfx.WinPlotterFX` class in your project code. ### Details * Every class in this inheritance hierarchy, except the `Shape` class implements the `draw` method. * The `draw` methods all take a single argument, which is a reference to the `WinPlotterFX` object created at the beginning of the `main` method in the `FaceMaker` class. As a result, all shapes use the same `WinPlotterFX` object for drawing. * Each implementation of the `draw` method must use methods from the `WinPlotterFX` class to draw the desired shape. * To help you understand what you must write for each class (and how to draw each shape), read the [Javadoc for the Shape-derived classes](lab4doc/index.html). ### Sample Results <figure>[![Circle Face](circleFace.png)](circleFace.png)</figure> <figure>[![Labeled Triangle Face](labeledTriangleFace.png)](labeledTriangleFace.png)</figure> <figure>[![Random Face](randomFace.png)](randomFace.png)</figure> ### Just For Fun Once you have met the requirements of the assignment, you may enjoy doing one or more of the following: * Create a completely separate program that draws a picture of your own choosing. * Implement the `Point` class shown in the UML class diagram and add freckles to the face. As an extra challenge, try to keep the freckles only on the skin. * Use different colors for the shapes. * Draw ears and/or hair. * Use multiple shapes to represent facial components (e.g., add a pupil in the each eye). ## Lab Deliverables > See your professor's instructions for details on submission guidelines > and due dates. > * Dr. Taylor's students: See below > * All other students should refer to Blackboard > > If you have any questions, consult your instructor. ## Acknowledgment This laboratory assignment was developed [Dr. Chris Taylor](https://msoe.us/taylor/), and Prof. Sean Jones.

Monday, 16-Dec-2019 07:21:51 EST