cs193p – Project #3 Assignment #3 Task #4

Please note, this blog entry is from a previous course. You might want to check out the current one.

Neither of your MVCs in this assignment is allowed to have CalculatorBrain appear anywhere in its non-private API.

For now we have only the calculator view controller, make sure to make the calculator brain private:

    private var brain = CalculatorBrain()

The complete code for the task #4 is available on GitHub.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #3 Assignment #3 Task #3

Please note, this blog entry is from a previous course. You might want to check out the current one.

Add a new button to your calculator’s user-interface which, when touched, segues to a new MVC (that you will have to write) which graphs the program in the CalculatorBrain at the time the button was touched using the memory location M as the independent variable. For example, if the CalculatorBrain contains sin(M), you’d draw a sine wave. Subsequent input to the Calculator must have no effect on the graph (until the graphing button is touched again).

Currently we have not really space left to add another button. For now add the graph button in the top left corner – maybe we move it in the extra tasks later on – and add some sensible autolayout constraints.

cs193p - Project #3 Assignment #3 Task #3 - Graph Button
cs193p – Project #3 Assignment #3 Task #3 – Graph Button

Continue reading “cs193p – Project #3 Assignment #3 Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #3 Assignment #3 Task #2

Please note, this blog entry is from a previous course. You might want to check out the current one.

Rename the ViewController class you’ve been working on in Assignments 1 and 2 to be CalculatorViewController.

Rename the filename, by selecting the filename and clicking one additional time:

cs193p - Project #3 Assignment #3 Task #2 - Rename Filename
cs193p – Project #3 Assignment #3 Task #2 – Rename Filename

Continue reading “cs193p – Project #3 Assignment #3 Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #3 Assignment #3 Task #1

Please note, this blog entry is from a previous course. You might want to check out the current one.

You must begin this assignment with your Assignment 2 code, not with any in-class demo code that has been posted. Learning to create new MVCs and segues requires experiencing it, not copy/pasting it or editing an existing storyboard that already has segues in it.

… cross my heart …

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #2 Assignment #2 Extra Task #3

Please note, this blog entry is from a previous course. You might want to check out the current one.

Add a new method, evaluateAndReportErrors(). It should work like evaluate() except that if there is a problem of any kind evaluating the stack (not just unset variables or missing operands, but also divide by zero, square root of a negative number, etc.), instead of returning nil, it will return a String with what the problem is (if there are multiple problems, you can simply return any one of them you wish). Report any such errors in the display of your calculator (instead of just making it blank or showing some weird value). You must still implement evaluate() as specified in the Required Tasks above, but, if you want, you can have evaluate() return nil if there are any errors (not just in the “unset variable” or “not enough operands” case). The push and perform methods should still return Double? (which is kind of a wasted evaluation, but we want to be able to evaluate your Extra Credit separate from the Required Tasks).

The definitions of the unary and binary operations get new parameters to pass optional error-test methods (and all their occurrences need to be adjusted for the new parameter):
Continue reading “cs193p – Project #2 Assignment #2 Extra Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #2 Assignment #2 Extra Task #2

Please note, this blog entry is from a previous course. You might want to check out the current one.

Add Undo to your Calculator. In Assignment 1’s Extra Credit, you might have added “backspace”. Here we’re talking about combining both backspace and actual undo into a single button. If the user is in the middle of entering a number, this Undo button should be backspace. When the user is not in the middle of entering a number, it should undo the last thing that was done in the CalculatorBrain.

Just for cosmetics change the name of the backspace button to “CE”:

cs193p - Project #2 Assignment #2 Extra Task #2 - Undo Button
cs193p – Project #2 Assignment #2 Extra Task #2 – Undo Button

Continue reading “cs193p – Project #2 Assignment #2 Extra Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail