DESCRIPTION

In this assignment, you will design and build a program that stores an arbitrary sequence of commands that manipulate and use a drawing list. A drawing list is used to produce a graphical scene, e.g., [create a red rectangle, move it to coordinates (5,5), create a blue circle, move it to coordinates (10,2), draw the red rectangle, draw the blue circle]. While it would be fun to actually draw the shapes that we will store and manipulate in our list, we shall instead focus only on the creation and maintenance of the drawing list.

The commands that your program will be able to process are:

CREATE RECTANGLE [w] [h]

  • [w] is the required width of the rectangle
  • [h] is the required height of the rectangle
  • The origin of a created rectangle is the upper left-hand corner at (0,0)
  • The color of a created rectangle is Red

CREATE CIRCLE [r]

  • [r] is the required radius of the circle
  • The origin of a created circle is the center at (0,0)
  • The color of a created circle is Blue

SELECT [any shape number from 1..n]

  • Selects a shape to use with future commands MOVE, DRAW, COLOR, DELETE
  • n is the total number of shapes created before this command
  • If the shape number is i, then the i-th created shape is selected
  • At most one shape can be selected at a time
  • Calling SELECT on a shape that does not exist in the list will produce the following error message "ERROR: invalid shape for SELECT"

MOVE [x] [y]

  • Moves the currently selected shape's origin to the specified (x,y)
  • If no shape is selected then output "no shape selected" to the console

DRAW

  • Outputs the currently selected shape information to the console. E.g., Rectangle, Color: Red, Origin: (5,5), Width: 10, Height: 7 Circle, Color: Blue, Origin: (10,9), Radius: 12
  • If no shape is selected then output "no shape selected" to the console

COLOR [c]

  • Sets the color of the currently selected shape.
  • [c] is one of the following valid colors: Red, Blue, Yellow, Orange, Green
  • If no shape is selected then output "no shape selected" to the console

DELETE

  • Removes the selected shape from the scene
  • If no shape is selected then output "no shape selected" to the console
  • The deleted shape is no longer selected

DRAWSCENE

  • Draws all shapes in the scene using their current origins and colors
  • Output for each shape is the same as using the DRAW command

UNDO

  • "Undoes" the most recent command in the drawing list
  • UNDO can be called after UNDO, which undoes the next most recent command in the drawing list
  • Undoing a SELECT command sets the currently selected shape to the previously selected shape (which could be "no shape")
  • Undoing a MOVE command restores the selected shape to its previous position
  • Undoing a COLOR command restores the previous
  • Undoing a CREATE command deletes the shape
  • Undoing a DELETE restores the previously deleted shape to the scene. It should also restore the currently selected shape to the restored shape
  • Undoing DRAW or DRAWSCENE has no effect
  • The UNDO command is not stored on the drawing list (i.e., you cannot UNDO an UNDO)

You will start with an empty drawing list. Each command is processed as it is received, which means the shapes in the scene will be modified as certain commands are processed. Note that UNDO can undo the previously processed command, so you will need to come up with a design to accommodate that functionality and you need to use the Memento pattern to provide the necessary support for undoing the current configuration of shapes.

Your program does not need to process keyboard input, but you are welcome to include that functionality AS LONG as it is also able to process command files like the included example.

Your object-oriented design must include the Strategy, Command, and Memento patterns. You also need to create and include a UML class diagram that includes all of the classes in your project and indicates where the 3 patterns are implemented.

Use our clean-coding standards. Keep your class sizes <= 200 total lines of code.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.