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

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

Add a ᐩ/- operation which changes the sign of the number in the display. Be careful with this one. If the user is in the middle of entering a number, you probably want to change the sign of that number and allow typing to continue, not force an enter like other operations do. On the other hand, if the user is not in the middle of typing a number, then this operation would work just like any other unary operation (e.g. cos).

Change the label of one of the “invisible” buttons to the +/- sign:
Continue reading “cs193p – Project #1 Assignment #1 Extra Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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

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

When the user hits an operation button, put an = on the end of the UILabel you added in the Required Task above. Thus the user will be able to tell whether the number in the Calculator’s display is the result of a calculation or a number that the user has just entered. Don’t end up with multiple occurrences of = in your UILabel.

When the display value is set – which is basically every time an operation button is pressed – add the “=” to the history label but only if there is something to show:

    var displayValue: Double {
            ...
            let stack = brain.showStack()
            if !stack!.isEmpty {
                history.text = stack! + " ="
            }
        ...
    }

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #1 Assignment #1 Extra Task #1

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

Implement a “backspace” button for the user to touch if they hit the wrong digit button. This is not intended to be “undo,” so if the user hits the wrong operation button, he or she is out of luck! It is up to you to decide how to handle the case where the user backspaces away the entire number they are in the middle of typing, but having the display go completely blank is probably not very user-friendly.

Change the label of one of the “invisible” buttons to “BS”:
Continue reading “cs193p – Project #1 Assignment #1 Extra Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #1 Assignment #1 Task #6

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

Avoid the problems listed in the Evaluation section below. This list grows as the quarter progresses, so be sure to check it again with each assignment.


Hopefully, we covered that …

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #1 Assignment #1 Task #5

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

Add a C button that clears everything (your display, the new UILabel you added above, etc.). The Calculator should be in the same state as it is at application startup after you touch this new button.

Add an additional row of buttons, one with the label “C” and the rest without labels. It is easiest to remove all autolayout constraints and rebuild them similar to the lecture.
Continue reading “cs193p – Project #1 Assignment #1 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #1 Assignment #1 Task #4

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

Add a UILabel to your UI which shows a history of every operand and operation input by the user. Place it at an appropriate location in your UI.

Add the UILabel at the top of the Storyboard, align it with the left and top guard and resize it to the right hand side guard. Align the display label with the bottom of the new label and remove its top constraint. Add a vertical constraint between the labels, and the missing suggested constraints for the new label. Finally repair the changed constraints for the buttons allowing to “move” their frames.
Continue reading “cs193p – Project #1 Assignment #1 Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #1 Assignment #1 Task #3

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

Add the following operations to your Calculator:
a. sin: calculates the sine of the top operand on the stack
b. cos: calculates the cosine of the top operand on the stack
c. π: calculates (well, conjures up) the value of π. For example, 3 π × should put three times the value of π into the display on your calculator. Ditto 3 ↲ π x and also π 3 ×.

Change the empty labels of the three buttons on the right hand side to “sin”, “cos” and “pi”:
Continue reading “cs193p – Project #1 Assignment #1 Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail