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

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

Change the computed instance variable displayValue to be an Optional Double rather than a Double. Its value should be nil if the contents of display.text cannot be interpreted as a Double (you’ll need to use the documentation to understand the NSNumberFormatter code). Setting its value to nil should clear the display out.

Make the display value an optional. When getting the display value, check first if there is a text, then if the text is a number and return the double value. Otherwise return nil. When setting the display value, check if it is nil. If not set the text label to the value otherwise to zero.
Continue reading “cs193p – Project #1 Assignment #1 Extra Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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