Brick CAD

CAD systems are used by engineers to design products ranging from paper clips to jumbo jets. Using a CAD system an engineer creates, edits, and views a model of the product. In some cases the model is so detailed that it can be fed as input directly to machinery that manufactures the product.

A brick is a pretty simple product. It has three editable attributes: height, width, and length. These must be positive doubles. Here are some ways to view a brick:

Brick CAD is a CAD system for designing bricks. It has all of the same basic features as a CAD system for designing jumbo jets, but without the troubling complexity of the underlying model and the resulting product.

Your job is to implement Brick CAD following the specification below.

Brick CAD in Action

Here's a screen shot of Brick CAD

At this point in time the user has used the view menu to open five views of the current brick model. There is a front view, a top view, two side views, and a data (dimension) view.

Note that the views are internal frames contained within a desktop frame. (See below for hints on how to do this in Swing.)

The user can edit the height, width, or length of the model either using the dimension view or using the edit menu.

For example, selecting "Set height" on the edit menu pops up an input dialog box:

The user types in a new height and presses the OK button. If the new height is invalid (for example a negative number), then an error dialog box appears. Otherwise, the height of the model is edited. This causes all open views that care about the height of the model to automatically redraw themselves:

Of course models can be saved to and read from files using the file menu. Other file menu options include new (close all views of the current model, prompt the user to save any changes, set the current model to a new model with default dimensions), save as, open, save, and exit.

Here's Brick CAD as an executable jar file: brickCAD.jar

The Brick CAD Use Cases

A use case represents some function a user can ask the system to perform.

Brick CAD users are engineers.

Brick CAD use cases can be grouped into three packages:

Edit Model Use Cases

Inside the edit model package we find the following six use cases:

The <<include>> arrow indicates that the edit height function calls (directly or indirectly) the update open views function as a subroutine.

Typically, a package of use cases manifests itself as a menu and a use case manifests itself as a menu item.

A use case scenario shows a typical interaction that occurs when a use case is executed. For example, the main scenario for the edit height use case looks like this:

Engineer: selects edit height item on the edit menu
Brick CAD: displays a dialog box prompting the user for a new height
Engineer: enters new height
Brick CAD: updates height of the model
Brick CAD: updates all open views

Here's another scenario:

Engineer: selects edit height item on the edit menu
Brick CAD: displays a dialog box prompting the user for a new height
Engineer: enters new height
Brick CAD: realizes new height is invalid and displays an error dialog.

Note that users can undo and redo the edit commands.

View Model use Cases

Open/Save Model Use Cases

In this diagram we see that the "save model" use case generalizes the "save model as" use case. In other words, "save as" is a special case of "save".

Here's the main scenario for the open model use case:

Engineer: selects open from the file menu
Brick CAD: prompts user to save current model if there are unsaved changes
Engineer: agrees to save current model
Brick CAD: saves current model, closes all open views of this model, displays open file dialog for name of file to be opened.
Engineer: selects file to be opened
Brick CAD: reads model from file, sets the current model to be this model. (Note: there are no open views initially)

Scenarios for exit and new model are similar.

Design

Brick CAD is a customization of the MVC Framework:

Implementation

Complete the implementation of MVC framework. Your implementation should be reusable.

Implement Brick CAD as a customization of the MVC framework.