views:

113

answers:

4

Someone asked me this, what will be a good aproach?

Design a model of a spreadsheet (like excel), but don’t be afraid, do it very simple!

We only need a basic class diagram with no more than 5 or 6 classes.

It should have the following features:

  • The sheet will only manage numeric data

  • There will be two types of cells:

  • Cells that contain a fix number
  • Cells that contain a formula

  • The formulas are very straightforward; just support two types of operations: subtraction and addition of two cells. Eg: Cell A + Cell B; Cell A - Cell B;

  • Don't worry about parsing or managing the formulas as text, just suppose that you will have the three parameters separately (the operation and the two referenced cells).

  • The spreadsheet will only contain one column.

  • Don't worry about the graphic interface or user interactions. JUST DO THE DIAGRAM OF THE BASIC MODEL.

One possible idea is to have an element call SpreadSheet that contains a collection of Cells and the operations to set and get cells values. If you find a better approach, use it!

So far i think on adding this classes: SpreadSheet, Column, FormulaCell and NumericCell. I also will add a ICell interface. Is this a good approach? I trying to figure out the methods and properties of each classes, can someone help a newbie?

A: 

You're on to a good start. Next, you have to decide what each class can do, and what member data each class will contain.

As for the diagram itself, there are different notation standards (though often very similar). What standard are they using in the class?

What I wonder is: what about rows?

FrustratedWithFormsDesigner
I was thinking on adding a Row class and adding this to spreadsheet:
PromotCompany
+1  A: 

Some questions to help you on your way.

  • What does the Spreadsheet class do? How is it distinguished from the Column class?
  • What does the Column class contain?
  • How are a FormulaCell and a NumericCell the same? How are they different?
  • What does a FormulaCell contain?
  • If you change a NumericCell, what needs recalculating? How does that recalculation get done?

Once you answer those questions, you'll be much further along adding properties and methods to your classes.

abelenky
A: 

I was thinking in adding a Row class and add this for the spreadsheet class

Methods

AddColumn

InsertColumn

RemoveColumn

AddRow

InsertRow

RemoveRow

SelectAllRows()

UnselectAllRows()

Properties

ActiveColumn

ActiveRow

NumberOfColumns

NumberOfRows

ReadOnly

I'm on the right direction?

Promotcompany
@Promotcompany You have the possibility to edit your question for additional information. ou should also read the FAQ (link in topbar on the right) so you better understand how this website works. Follow-up should be done by editing the question, not by giving answers. Regarding your work : Try to present it in a more readable way, a diagram or so. You should do that anyway for yourself, and you can add that to your homework. It will definitely add value to it. If you save the diagram as png, you can even upload it in your question. People will be more likely to help you that way.
Joris Meys
A: 

CAn someone helps to point me to the right direction, the question said:

•The spreadsheet will only contain one column

should i add a column class or not?

promotcompany
@promotcompany: Please delete this answer and try to use one account only.
Joris Meys