C348: iPhone Programming

Deliberate Practice Makes Perfect

Problem 8,9

Student Info
Question 1

Write the code to declare and initialise an array with 3 NSStrings (@“Tom”, @“Dick, @“Harry”)

								
Question 2

Write the code to declare and initialise an dictionary with the following items.

name : “John Doe”
age : 16 years old 
height: 1.68 m
weight: 60.5 kg


								
Question 3

What is the name of the method which will be called before a segue is executed?

								
Question 4

Write the code to display an alert view with the following information:
Title: “This is an Alert!”
Message: “Please note that the brown fox has jumped over the lazy dog”
Default Button: “Noted”
Other buttons: “Cancel”, “Oh yeah”


								
Question 5

Write the code to print out all the keys and values of a NSMutableDictionary called myMutableDictionary

								
Question 6

Write the code to delete an object “John Doe” from a NSMutableDictionary called personDictionary

								
Question 7

Write the code for the BankAccount class given the following requirements.
In the BankAccount class, declare an NSString property called name.
In the BankAccount class, declare a double property called balance. 
The checkBalance method in the BankAccount class prints the balance in the debug area
The withdraw: method in the BankAccount class is used to specify the amount of money to be withdrawn from the bank account. The method should update the balance property based on the amount of money withdrawn. The balance should never be negative.