Assignment 5: Beyond g OOD: A Simple Spreadsheet, Part 1 PDF

Title Assignment 5: Beyond g OOD: A Simple Spreadsheet, Part 1
Author Maitreyee Joshi
Course Object-Oriented Design
Institution Northeastern University
Pages 9
File Size 409.3 KB
File Type PDF
Total Downloads 30
Total Views 150

Summary

Assignment 5...


Description

Assignment 5: Beyond gOOD: A Spreadsheet, Part 1 Due: Thu 10/31 at 8:59pm; self-evaluation due Fri 11/01 at Starter files: code.zip

1 Working in pairs Note: This assignment is to be completed with a partner. You will sign up with y handin server from this assignment onwards. You will not be able to submit su assignments until you are part of a team on the handin server. Note: If you do not know (or remember) how to request teams, follow these inst request teams no later than Wednesday night Oct 23 at 9pm — if you have no teammate by then, we will randomly assign you one. Although the expected work is not simply double of what it was in earlier assignm assignment behooves mutual cooperation and pair programming. Please make a p and tackle the assignment in a systematic manner. Dividing the work and then m day before it is due is a recipe for disaster. This assignment requires you to self-l enforce each other’s efforts and learning.

1.1 Submission logistics You will need to work with your partner to submit the self-eval. As with the code submit a single self-eval for the team. However, you will likely need to sit with yo the phone as you should agree on all the responses. Recall that once you have ope you may not resubmit the code.

2 Context

All of us have encountered spreadsheets before: grids of cells whose contents are value, or a formula that evaluates some function over inputs from other cells. Fan can include graphs, images, formatted text, etc. — but we don’t need to consider now. Spreadsheets are actually a fairly sophisticated functional programming environm contain functions of a fixed number of arguments, or of a range of values; they ca conditionals to select among options; by creating a bunch of similar, consecutive simulate fixed-length iteration. The only thing they prohibit is cyclic reference: n upon its own value as one of its inputs. Moreover, if we edit any of the cells, every upon it will automatically get re-evaluated to incorporate the new input value. (T example of what is known as dataflow programming, and it’s a very powerful and model.) In the next few assignments, we will build an application that lets us load, edit an spreadsheets. We may start from a blank file, or from some input (that may have b application or by some other, unrelated one).

2.1 Description of spreadsheets A (professional) spreadsheet contains one or more worksheets, each of which con of cells In this project we will only need to support one worksheet per file so “sp

Row indices are also numbered starting from 1...but fortunately, we just use numb of letters. (In this naming scheme, there is no row or column with index 0.) We have provided the Coord class for you to describe cell coordinates in a spread also contains two static methods to convert column indices to names and vice v

2.2 Cell contents An individual spreadsheet cell may: be blank contain a value contain a formula If a cell contains a value, then at minimum your spreadsheets must support boolean values double values String values

A formula is one of a value a reference to a rectangular region of cells in the spreadsheet a function applied to one or more formulas as its arguments Consider the following tiny spreadsheet, that takes four values (in cells A1 throug them as two pairs of (x, y) coordinates, and computes the distance between them into cell A3. It then determines whether that distance is less than 10, and places t We write the instructions down in plain English here; we’ll give a more concrete s program to use later. Let A1 equal 3

Let B3 equal TRUE if A3 is less than 10, otherwise FALSE

2.3 Evaluating cells Cells that contain values (as described above) just evaluate to themselves. As desc formula can take as inputs references to other cells (or groups of cells). Evaluatin therefore may require evaluating other formulas as well. No formula is permitted to refer to itself, though, either directly or indirectly, sin to an infinite regress. (One simple direct example would be “Let A1 equal A1 plus indirect example would be “Let A1 equal B1, and let B1 equal A1 plus 1”.) Such an e happen, so detecting and preventing it is important. Moreover, any formula that d these erroneous formulas must itself be in error.

3 Beyond gOOD: A Simple Spreadsheet Application We will build this application progressively using the classic Model-View-Control this assignment we will focus on the model of this application. There is almost no assignment: you must use the above description and broad ideas to design the in implementation of the model. You are deliberately not being told about the fine d controller and views will need or do. You are also not being told about how exactl will receive a description from the user (it would not be relevant to the model). Here are some aspects to think about: What does the model represent? The model should be able to support at least the three types of values describ you might support additional ones. The model should be able to support references to cells and to finite rectangu though you might try to support additional features. The model should be able to support various formulas, although we’ve only see differences, products, square roots, and comparisons. Note that some formula multiplication) can take references of any size, while others (like subtraction o only take references to single cells. You should consider carefully how to supp

3.1 How is the spreadsheet seen? Spreadsheets intrinsically can be viewed in several ways: As a graphical grid of cells, showing their evaluated values As a graphical grid of cells, showing their raw contents (e.g. the text of the form each cell) As a text file describing their contents ... Below we show a text file describing the spreadsheet example above, along with o formula (just for demonstration purposes). Each row consists of a cell name, a sp contents of the cell as the remainder of the line. (Lines beginning with a # are com through D1 contain values; cells A2 through A4 contain formulas. # Creates the four coordinates A1 3 B1 4 C1 9 D1 12 # Computes delta-x^2 A2 =(PRODUCT (SUB C1 A1) (SUB C1 A1)) # Computes delta-y^2 B2 =(PRODUCT (SUB D1 B1) (SUB D1 B1)) # Computes the rest of the distance formula A3 =(SQRT (SUM A2:B2)) B3 =(< A3 10) # Computes the distance formula all in one step A4 =(SQRT (SUM (PRODUCT (SUB C1 A1) (SUB C1 A1)) (PRODUCT (SUB D1 B

Formulas are written with a leading =, and are followed by an s-expression describ

Any function names or cell references that appear in a formula will be parsed as s expression. A cell reference can be either a single cell name (e.g. A5), or two cell n colon (i.e. C42:D53) where the second cell’s column and row are no smaller than t and row.

3.2 How is a spreadsheet read? We will provide you with a parser for s-expressions; you do not have to figure out yourselves. The parser will take in a String containing the expression to be read the = sign) and return a value of type SExp corresponding to that expression (or w IllegalArgumentException if the string could not be correctly parsed).

We will also provide you with a parser for the spreadsheet-as-text file format abo will be slightly more involved. Because we do not know how you are choosing to i spreadsheets, we will provide you with a class with the following signature: public final class WorksheetReader { public static T read(WorksheetBuilder builder, Readable reada }

This method is parameterized by whatever type you choose to implement your sp read the contents of the provided Readable, and determine the contents of your order to actually build the spreadsheet, though, it relies on a builder that you mus supply. The WorksheetBuilder interface has only two methods on it: public interface WorksheetBuilder { WorksheetBuilder createCell(int col, int row, String contents); T createWorksheet(); }

The first method takes in a column and row index (both counting from 1) and the cell. Your implementation of this method should determine what kind of data this and record this information in your model somehow. Th

d

th d

t

th

k h

t

h

fill d i

If

dt d

4 What to do 1. Design a model to represent a spreadsheet. This may consist of one or m abstract classes, concrete classes, enums, etc. Consider carefully what ope support, what invariants it assumes, etc. You may assume that the number in a spreadsheet can each be represented by a positive int, but you may n additional assumptions about them.

2. Document your model well. Be sure to document clearly what each type what purpose it serves and why it belongs in the model. If your model assu explain them clearly and concisely.

3. Implement your model. If some method of your model cannot be implem requires details you think may be revealed in future assignments, you may body blank for now — but leave a comment inside the method body explain and what details you’re waiting for. If your implementation makes addition about invariants (beyond those asserted by the interface), document them.

4. Implement at least four functions: A SUM function, that adds up all the values of all of its arguments. Its a references of arbitrary size, and the sum should cover all the values in t referenced. Any arguments whose contents are blank or not numeric sh there are no numeric arguments at all, the default value is zero. A PRODUCT function, that multiplies all the values of all of its argumen could be references of arbitrary size. Any arguments whose contents ar numeric should be ignored. If there are no numeric arguments at all, th zero. (Yes, zero: I don’t know why professional spreadsheet programs c instead of one, but they did.) A < function, that takes exactly two values and returns whether the fi second If either value is missing or is not a number the function shoul

prohibited in your model implementation. Hint: Doing this well is trickier t first.

6. Ensure that you can evaluate cells. Hint: Doing this well is trickier than i We’re not extremely concerned with efficiency, but your code should not b

7. Test your model thoroughly.

8. Create a class edu.cs3500.spreadsheets.BeyondGood with a main met program. Your main method should expect a command-line of the followin -in s o m e f i l n a-eval s o m e c l n a

For example, one valid command line would be -in posn-distances.gOO The first two arguments specify a filename to read in. Your program must construct a model from it. The second two arguments specify a cell whose want to evaluate. If a cell has a problem, then print out a one-line message "Error in where Z42 is whatever cell is broken, and where the additional message details you want. If multiple cells have problems, then print a one-line m error. If no cells are in error, then you must fully evaluate the requested cel value. (Numbers should simply be printed using String.format("%f", should be printed in double-quotes, and any quotes within the string sh with a backslash...and any backslashes should be escaped with another instance, "Jack says \"hi\". Jill has one backslash \\ here." If the command-line is malformed, print an error and exit.

9. Again: Test your model thoroughly. W

ill

th

th

h

it t

t f

thi

i

t i

assignments until you are part of a team on the handin server. If you do not know (or remember) how to request teams, follow these instructio teams no later than Wednesday Wednesday night at 9pm — if you have not requested a te will randomly assign you one. Submit all Java files you created or used in this assignment A text README file explaining your design. Your README file should give the of what the purposes are for every class, interface, etc. that you include in you they can quickly get a high-level overview of your code. It does not replace the Javadoc! At least three input files that your model can process. Two of them should wo the third should trigger an evaluation error. The two working files should be s from each other, and should demonstrate all the features of your model that y As with previous assignments, please submit a zip containing only the src/ an with no surrounding directories, so that the autograder recognizes your packa do not include your output/ or .idea/ directories — they’re not useful!

6 Grading standards For this assignment, you will be graded on the design of your model interface(s), in terms of clarity, flexibility, and how pl support needed functionality; the appropriateness of your representation choices for the data, and the adeq documented class invariants (please comment on why you chose the represen code); the forward thinking in your design, in terms of its flexibility, use of abstractio the correctness and style of your implementation; the thoroughness of your example files in demonstrating all the features of yo the comprehensiveness and correctness of your test coverage....


Similar Free PDFs