Assignment #1 Task #6

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

If the user performs an operation for which he or she has not entered enough operands, use zero as the missing operand(s) (the code from the walkthrough does this already, so there is nothing to do for this task, it is just a clarification of what is required). Protect against invalid operands though (e.g. divide by zero).

As performOperation returns only numbers for the moment we just return 0 for a division through zero or square roots of negative numbers e.g.:

if (!divisor) return 0;
   ....
if (number < 0) return 0;
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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 (for example, the display in your View, the operand stack in your Model, any state you maintain in your Controller, etc.). Make sure 3 7 C 5 results in 5 showing in the display. You will have to add API to your Model to support this feature.

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”. Add a new button called “C” left to the number display and create an action “clearPressed”. Don’t forget to reduce the size of the number display accordingly.
Continue reading “Assignment #1 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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

Friday Session #1: Debugging

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

The individual lectures of the course where held each weak on Monday and Wednesday. On Fridays extra lectures were held about a special topics.

Between lecture #2 and lecture #3 the first Friday session addressed debugging. It can be found on iTunes titled “Debugger (September 30, 2011)”.
Continue reading “Friday Session #1: Debugging”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail