我需要班级图的帮助(为我做功课) [英] I need help with a class diagram (do my homework for me)

查看:89
本文介绍了我需要班级图的帮助(为我做功课)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人问我,什么是很好的方法?

设计一个电子表格模型(例如excel),但不要害怕,做起来很简单!

我们只需要一个不超过5或6个类的基本类图.

它应该具有以下功能:

-工作表将仅管理数字数据

-将有两种类型的单元格:
-包含固定编号的单元格
-包含公式的单元格

-公式非常简单;仅支持两种类型的运算:两个单元的减法和加法.
例如:
单元格A +单元格B;
单元格A-单元格B;

-不必担心将公式作为文本进行解析或管理,只需假设您将分别拥有三个参数(操作和两个引用的单元格).

-电子表格仅包含一列.

-不用担心图形界面或用户交互.只需执行基本模型的图即可.

一个可能的想法是让一个名为SpreadSheet的元素包含单元格的集合以及用于设置和获取单元格值的操作.如果您找到更好的方法,请使用它!

[edit]以下内容已添加到问题中,OP已将其添加为评论-OriginalGriff [/edit]

到目前为止,我认为要添加此类:SpreadSheet,Column,FormulaCell和NumericCell.我还将添加一个ICell接口.这是一个好方法吗?我试图弄清楚每个类的方法和属性,有人可以帮助新手吗? -promotcompany 1小时前



以下内容添加到问题中,OP回答了该问题-OriginalGriff [/edit]

我在考虑添加Row类并将其添加到电子表格类中.
方法
AddColumn
InsertColumn
RemoveColumn

AddRow
InsertRow
RemoveRow

SelectAllRows()
UnselectAllRows()
属性
ActiveColumn
ActiveRow
NumberOfColumns
NumberOfRows
ReadOnly

我朝着正确的方向前进吗?

[edit]不要添加答案-它只会让您知道它已经发生了.编辑您的问题,以便更好地说明您的想法,并对答案进行评论.这样,我们会收到一封电子邮件,说明您已完成!笨手笨脚的?是的.但是正在开发中... :-D [/edit]

该问题说:

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!

[edit]The following added to question as OP added it as a comment - OriginalGriff[/edit]

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? - promotcompany 1 hour ago



[edit]The following added to question as OP responded as an answer - OriginalGriff[/edit]

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?

[edit]Don''t add an answer - it only lets you know that it has happened. Edit your question so it is better illustration of what you are thinking, and comment on answers. That way we get an email to say you have done it! Cack-handed? Yes. But under development... :-D [/edit]

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?



我添加了一个可能的解决方案图片,这好吗?

http://img543.imageshack.us/i/diagram.png/



I add an image of a posibble solution, is it good?

http://img543.imageshack.us/i/diagram.png/

推荐答案

很高兴看到您的想法关于它!

您建议的课程:

SpreadSheet

FormulaCell
NumericCell

加上ICell接口.

为什么?这些类在实现电子表格时为您做了什么?他们将来会给您带来什么问题?将ICell用作接口有什么帮助?还是将来会给您带来问题?

这些问题并不是要说这是错误的-更改它",而是让您思考自己想要实现的目标.试图描述每个班级的目的可能是设计中最困难的部分,但这也是最重要的之一.如果您无法描述所需的内容,为什么会出现在其中?

我当时正在考虑添加Row类,并将其添加到电子表格类中.
方法
AddColumn
InsertColumn
RemoveColumn

AddRow
InsertRow
RemoveRow

SelectAllRows()
UnselectAllRows()
属性
ActiveColumn
ActiveRow
NumberOfColumns
NumberOfRows
ReadOnly

我在正确的方向上吗?"
我想到达那里-您已经注意到行和列之间将需要一些对称性,但是在哪里可以保留行呢?您有一个用于列的类...但这是最好的方法吗?想一想:您是否总是将电子表格整行访问?还是整个专栏?

您要对单元格采取什么行动?连续吗?在列上?在整个电子表格上?

嗯-得走了,老婆在打电话!
Glad to see you have thought about it!

Your proposed classes:

SpreadSheet
Column
FormulaCell
NumericCell

Plus a ICell interface.

Why? What do these classes do for you in implementing a spreadsheet? What problems might they give you in the future? What does implementing ICell as an interface help with? Or does it give you a problem in future?

These questions aren''t meant to say "This is wrong - change it" but to get you to think about what you are trying to achieve. Trying to describe what you want each class for is probably the hardest bit of design - but it is also one of the most important. If you can''t describe what you want it for, why is it there?

"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?"
Getting there, I think - you have noticed you will need some symmetry between the rows and the columns, but where can you keep rows? You have a class for columns... But is that the best way to do it? Think: do you always access a spreadsheet as a whole row? Or as a whole column?

What actions do you want to take on a cell? On a row? On a column? On a whole spreadsheet?

Eh up - gotta go, the wife is calling!


这篇关于我需要班级图的帮助(为我做功课)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆