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 new text label (UILabel) to your user-interface which shows everything that has been sent to the brain (separated by spaces). For example, if the user has entered 6.3 Enter 5 + 2 *, this new text label would show6.3 5 + 2 *. A good place to put this label is to make it a thin strip above the display text label. Don’t forget to have the C button clear this too. All of the code for this task should be in your Controller (no changes to your Model are required for this one). You do not have to display an unlimited number of operations and operands, just a reasonable amount.

Create a new label above the number display in the storyboard, change the alignment to “right”, remove its text and create a new outlet called “history”.
Continue reading “Assignment #1 Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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 4 operation buttons:

  • sin : calculates the sine of the top operand on the stack.
  • cos : calculates the cosine of the top operand on the stack.
  • sqrt : calculates the square root of the top operand on the stack.
  • π: calculates (well, conjures up) the value of π. Examples: 3 π * should put three times the value of π into the display on your calculator, so should 3 Enter π *, so should π 3 *. Perhaps unexpectedly, π Enter 3 * + would result in 4 times π being shown. You should understand why this is the case. NOTE: This required task is to add π as an operation (an operation which takes no arguments off of the operand stack), not a new way of entering an operand into the display.

Add four additional buttons called “sin”, “cos”, “sqrt” and “pi” by copying one of the existing operator buttons and adjust the performOperation function in CalculatorBrain.m:
Continue reading “Assignment #1 Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #1 Task #2

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

Your calculator already works with floating point numbers (e.g. if you touch the buttons 3 Enter 4 / it will properly show the resulting value of 0.75), however, there is no way for the user to enter a floating point number. Remedy this. Allow only legal floating point numbers to be entered (e.g. “192.168.0.1” is not a legal floating point number). Don’t worry too much about precision in this assignment.

Add an additional button on the left hand side of the zero button, by copying one of the number buttons. Add a new property userIsInTheMiddleOfEnteringAFloat to CalculatorViewController.m, synthesize it and adjust the digitPressed andenterPressed functions:
Continue reading “Assignment #1 Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #1 Task #1

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

The first assignment is an extension of the calculator built in lecture #2.

Follow the walk-through instructions (separate document) to build and run the calculator in the iPhone Simulator. Do not proceed to the next steps unless your calculator functions as expected and builds without warnings or errors.

Basically this is solved by code at the end of lecture #2. However, limited time during the lecture prevented the instructor from finishing everything, thus we have to add subtraction and division as operands to CalculatorBrain.m:
Continue reading “Assignment #1 Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail