BEST代写-线上留学生作业代写 & 论文代写专家

成立于2015年的老牌留学生代写品牌-BEST代写提供超过百门冷热门留学学科的作业和论文代写服务。全网BEST原创,高质,准时的留学生代写。

C#代写 | Cpt S 321 Homework Assignment Spreadsheet Formula Evaluation

C#代写 | Cpt S 321 Homework Assignment Spreadsheet Formula Evaluation

本次代写是一个C#电子表格编程的assignment

Assignment Instructions:

Read each step’s instructions carefully before you write any code.
In this assignment, you will combine work from several previous homework assignments and build new
features on top of that. You will link your arithmetic expression evaluator with the spreadsheet
application.

Part 1: Edit the spreadsheet application from the “First Steps for Your Spreadsheet Application”
homework assignment so that it has the following functionality:

1. In its normal, non-editing state each cell will display the Value property of the cell in the logic
engine. Recall that this value represents the evaluation of the formula in the cell, if present. The

Text property represents what the user actually typed into that cell (which may be a formula if it
starts with ‘=’). If there is no formula in a cell, then the Value just matches the Text property.

2. When the user starts editing the cell, the cell value should change to the Text property of the
cell. When the user finishes editing it must go back to the Value. This functionality closely
resembles that of other spreadsheet applications such as Microsoft Excel.

You’ll need to use the CellBeginEdit and CellEndEdit events.

Part 2: Incorporate your expression evaluator into the spreadsheet functionality so that when the
spreadsheet is updating the value for a cell, it is properly evaluating the formula. You may assume the
following:

● Each cell only contains a formula to be evaluated if it starts with the ‘=’ character. The substring
to the right of this is the actual formula that your expression evaluator should be able to parse
and evaluate.

● No formulas will contain whitespace. It would be nice if your code handled whitespace
characters (by ignoring them), but it’s not required.

● Every formula contains only things that were required in homework HW5 and HW6: add,
subtract, multiply, divide, constants, variable names and parentheses. Some semesters will have
exponents as well. If exponents were not required in HW5 and HW6 then you don’t have to
support them here (it varies from semester to semester whether or not they’re required).

● All variable names will be cell names that start with a single capital letter character and then are
followed by a row number. Rows start at 1 in the user interface and therefore in the formulas as
well, so keep this in mind when adjusting array indices in your code (actual index in array will be
1 less).

● In HW5, we explicitly state that if variables are not set then can be default to 0. In this
assignment, you should use exceptions to handle this properly – you should not have default
values and you should not crash.

● There will be no circular references. This means that if we have some cell, say A1, it won’t have
A1 in its own formula. Also, it won’t reference any cell that in return references back to it. You
WILL have to deal with this in a future assignment, so keep that in mind. But for this assignment
right now you don’t need to worry about it.

● Since a cell’s “Value” property is a string, and you will need a double when setting variable
values during formula evaluation, consider the numerical (double) value of a cell to be:

o The numerical value parsed if double.TryParse on the value string succeeds
o 0 otherwise

There are sub-tasks within this task that require extending your expression tree code. You will need a
way for the spreadsheet to enumerate all the cell names referenced in the formula. The ExpressionTree
class that you built could have a “GetVariableNames” function that returns a list or array of all variable
names in the expression. Alternatively, it could have a reference to a function to call when it needs to
lookup a variable value. Whichever design you choose, the following must be true:

1. The world outside of your ExpressionTree class cannot edit the tree. There should be no way for
the outside world to change a child reference in any node, change a variable name or value
within any node, and so on.

2. The world outside of ExpressionTree must never have to deal with nodes. It’s not the
responsibility of objects outside this class to know how to iterate through an expression tree.
Provide an easy-to-use interface for finding relevant information about the expression.

bestdaixie

评论已关闭。