COMP 304B Object-Oriented Software Design -- Assignment 1
COMP 304B Object-Oriented Software Design - Assignment 1
Practical information
- Due date: Friday January 30, 2004 before 23:55.
- Team size == 2 (pair programming) !
- Each team submits only one full solution.
Use the index.html template provided on the
assignments page. Use exactly this
format to specify names and IDs of the team members.
The other team member must submit a single
index.html file containing only the coordinates of
both team members. This will allow us to put in grades for
both team members in WebCT. Beware: after the submission deadline
there is no way of adding the other team member's
index.html file and thus no way of entering a grade !
- Your submission must be in the form of a simple HTML
file (index.html) with explicit references to
all submitted files as well as inline inclusion of
images. See the general assignments page for an
index.html template.
- The submission medium is
WebCT.
- To get insight into the assignment workload, provide the number of hours you spent
on this assignment.
Goals
This assignment will make you familiar with unit testing
and object-oriented GUI programming in Python/Tkinter.
Your assignment should clearly present:
- The tests corresponding to the requirements listed below.
- An implementation of the requirements given below.
This mostly consists of implementing methods of the class
SpreadsheetGridView
- The results of the tests on your implementation.
Upload all source and result files to WebCT and provide
links to them from your index.html file.
Requirements
The ultimate goal is to build a fully functional spreadsheet application.
Such an application needs a GUI and that is the focus of this assignment.
In a later assignment, using the ``Observer Design Pattern'', we will
construct a system with keeps the data in the spreadsheet in a single place
(the subject), with multiple observers showing views of
that data (and updating whenever the subject changes).
In this assignment, you need to complete and develop a unittest suite for the SpreadsheetGridView
class in the file SSGridView_start.py. SpreadsheetGridView
will contain the static as well as dynamic description of a single observer.
An instantance of SpreadsheetGridView with for example
rows=4
columns=8
cellHeight=18
cellWidth=50
padHor=10
padVer=20
looks like
The static aspects of SpreadsheetGridView
The static aspects of SpreadsheetGridView are provided in the file SSGridView_start.py.
You must add the dynamics.
The window contains a button "Print View" which will bring up a file selection dialog.
It allows for the generation of a Postscript file containing the spreadsheet image.
The "Quit View" button will close the window (as will the "X" in the right hand corner
of the window - this event is caught by the Window Manager and passed on to the application).
The canvas on which the spreadsheet grid appears can be larger than the window and so
scroll bars are provided. Note how this means that screen coordinates need not be identical to
canvas coordinates.
The spreadsheet grid currently only contains empty cells. In later prototypes cells may
contain a string representation of entered data (actually, of the result of evaluating the formula in that cell
when in viewing mode and the formula itself when in editing mode).
The spreadsheet grid has exactly two mobile rectangles on it. A thick black rectangle
selectedCellFrame outlines the currently selected (for entering data) cell.
A thin blue rectangle overCellFrame outlines the
cell the mouse is currently over.At any point in time, the coordinates of the cell the mouse is over
will be displayed in blue in a rectangle at the top of the window. The empty field to the right of
that will in a future prototype display the formula in the currently selected cell.
The dynamic aspects of SpreadsheetGridView
- Whenever the mouse moves over the drawarea canvas, the blue overCellFrame rectangle
is moved to the "nearest" actual grid cell (the mouse might namely be over the canvas but
outside the grid).
- For efficiency reasons, the overCellFrame rectangle should only
be moved if when the mouse moves to a different cell.
- When mouse button 1 is clicked over the drawarea canvas, the black selectedCellFrame rectangle
is moved to the (nearest) cell the mouse is over.
- For efficiency reasons, the selectedCellFrame rectangle should only
be moved if when the mouse moves to a different cell.
- Pressing the Up, Down, Left, and Right keyboard arrows moves the selectedCellFrame
rectangle in the appropriate direction. Note how this is done modulo the height and width of
the grid: when moving Left and reaching the end of the grid, the next selected cell will be
the first of the next row. Similarly in other directions.
- Note how the previous implies that if one presses any one of the buttons as many times as
there are cells in the grid, one should get back to the same cell.
- Pressing a key in the drawarea will currently only check whether the key
is in the set of valid keys. Later, the actual string entered will
be validated and stored (in the subject).
Valid keys are listed in the given SpreadsheetGridView.
If an invalid key is entered, the InvalidKeyError exception should be raised.
- Pressing backspace should be ignored.
Unit Testing
You must produce a list of tests (mention their type) to check whether the above requirements are satisfied
in an implementation.
These test should be implemented in a file test.py using the
PyUnit testing framework.
Resources
- SSGridView_start.py contains the (starting point of)
SpreadsheetGridView class definition.
- application_start.py demonstrates how to
create multiple instances of SpreadsheetGridView (in separate
Toplevel windows).
- minitest.py demonstrates how it is possible to
non-interactively test a Python/Tkinter GUI. This small demonstration
does not use the unittest framework.
References
Hans Vangheluwe January 2004.