Assignment 2: Spreadsheet Engine

Informal Description

"We want to corner the market on spreadsheets embedded in web pages and wireless devices. To start with, we want to build a reusable spreadsheet engine that we can use as the back end for multiple kinds of user interfaces.

A spreadsheet consists of a collection of cells, arranged in a two dimensional grid. A cell may contain a value (a number or string), or it may contain a formula (a mathematical expression which may refer to other cells). The displayable value for a cell is always a string; in the case of a formula, the displayable value is calculated dynamically from the formula. The engine should take care of keeping track of the cells of the spreadsheet, keeping track of the data or formulas entered into each cell, and calculating the current value of each formula. Cells within the spreadsheet are referenced with the standard spreadsheet notation A1, A2,...,B1,B2,... where the letter is the column and the number is the row."

Project Plan

The development of the spreadsheet will proceed in phases, where each phase builds upon the previous one and each phase has a complete cycle of design and implementation.

Phase 1 (basic functions): Design and implement a basic engine which contains a Spreadsheet class, a Cell class, and methods for putting numeric or string values into cells (no formulas yet). Put these classes into a package named "spreadsheet.engine" (in other words, put them into a package named "engine" inside a package named "spreadsheet"). Create a simple engine client, outside the spreadsheet package, which fulfulls the following scenario.

Phase 1 Scenario

  1. User types "set A1 2.34"
  2. System responds "OK"
  3. User types "set B2 hello"
  4. System responds "OK"
  5. User types "display"
  6. System displays the spreadsheet on the terminal as follows:
       A         B
    1  2.34
    2            hello

(The "set" command takes a cell address as its first argument, and either a number or a string as its second argument. The "display" command takes no arguments, and displays the current spreadsheet by printing it to System.out.)

Phase 2 (formulas) will add formulas to the capabilities of the engine and test client. Phase 3 (UI) will add a graphical user interface. Be sure to allow for these future phases in your code for phase 1, and be sure that your basic engine doesn't assume a particular UI. In particular, don't embed user interface details like I/O into your engine, except for debugging output statements which you can turn off in the production release.

Deliverables

Class diagram, Java code, and output of one or more test runs.