iOS Dev – Assignment #2 – Task #1

Model-View-Controller Since a calculator is something that might be used in various situations, you decide to rewrite your code to something more reusable. One advantage of MVC is that you can exchange the view but keep your model and parts of your controller. We provide you with a template for a class called BasicCalculator. Extend that class to provide a fully functional basic calculator. This class is your model.

The provided template is similar to the one from Assignment #1, where the calculator functionality is moved to the new model class. You could either use your code from the previous assignment and adjust it or redo the changes from the previous assignment inside the new template. Here we will choose the second approach.

First link the missing number buttons to the view controller class and change the tags of the buttons accordingly.
Continue reading “iOS Dev – Assignment #2 – Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #1 – Extra Task #2

Visualize the currently active operation by letting the button be pushed until the second operand is entered.

A button can be displayed as pushed by “highlighting”. However, when the resultButtonPressed: method fires, the button is already highlighted and will be dehighlighted shortly after. Thus it is necessary to “wait a little bit” actually till the “normal button functionality” has finished before highlighting the button. This can be achieved by adding an operation on the main queue.
To remove the highlighting, add a property to hold the currently pressed button.

@property (nonatomic, strong) UIButton *currentButton;

- (IBAction)operationButtonPressed:(UIButton *)sender {
	...
	else
	{
		...
		self.currentButton.highlighted = NO;
	}
	...
	[[NSOperationQueue mainQueue] addOperationWithBlock:^{
		sender.highlighted = YES;
		self.currentButton = sender;
	}];
}

- (IBAction)resultButtonPressed:(id)sender {
	...
	self.currentButton.highlighted = NO;
}

- (IBAction)clearDisplay:(id)sender {
	...
	self.currentButton.highlighted = NO;
}
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #1 – Extra Task #1

Adapt the number of shown decimals to the actual result that is to be displayed.

Actually NSNumber does that all. Thus we just have to create an NSNumber from the number before we display it. At the same time we change all floats to doubles to reduce the problem of the “float feature” described before:

- (IBAction)operationButtonPressed:(UIButton *)sender {
    ...
    self.numberTextField.text = [NSString stringWithFormat:@"%@", 
         [NSNumber numberWithDouble:firstOperand]];        
    ...
}

- (IBAction)resultButtonPressed:(id)sender {
    ...
    self.numberTextField.text = [NSString stringWithFormat:@"%@", [NSNumber numberWithDouble:result]];
    ...
}
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #1

We provide you with a template for a calculator that already adds numbers (at least 1 and 2).
Take a close look at the implementation of this template and write the necessary code to have a fully working calculator.

Let’s have a look at the number buttons:

iOS Dev - Assignment #1 - Number Actions
iOS Dev – Assignment #1 – Number Actions

Continue reading “iOS Dev – Assignment #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #7 – Task #5

The complete specification of assignment #7 can be found as part of the stream at iTunes.

Implement the FacePamphletCanvas class and complete the implementation of the FacePamphlet class

The class (which extends GCanvas) contains three public entries:

  • A constructor that has no parameters. You can use this to perform any initialization you may need for the canvas. Note: depending on how you implement the canvas, it is entirely possible that your constructor may not need to do anything. It’s perfectly fine if that’s the case.
  • Continue reading “cs106a – Assignment #7 – Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #7 – Task #4

The complete specification of assignment #7 can be found as part of the stream at iTunes.

Implement functionality for Change Status, Change Picture, and Add Friend buttons

The next step in the process is to complete more of the implementation of the FacePamphlet class, namely the functionality for the Change Status, Change Picture, and Add Friend buttons. The main issue to remember here is that these buttons effect the current profile, if there is one. As a result, one of the first things you should think about in implementing this milestone is how you will keep track of the current profile in the application. To help introduce the notion of the current profile, you might want to update the code for the Add, Delete, and Lookup button handlers so that:

  • Whenever a new profile is added, the current profile is set to be the newly added profile. If the user tried to add a profile with the name of an existing profile, then the existing profile with that name is set to be the current profile (this is similar to the case below where the users simply looks up an existing profile).
  • Continue reading “cs106a – Assignment #7 – Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs106a – Assignment #7 – Task #3

The complete specification of assignment #7 can be found as part of the stream at iTunes.

Implement the FacePamphletDatabase class

The FacePamphletDatabase class is used to keep track of all the profiles in the social network. The class which contains five public entries:

  • A constructor that has no parameters. You can use this to perform any initialization you may need for the database. Note: depending on how you implement the database, it is entirely possible that your constructor may not need to do anything. It’s perfectly fine if that’s the case.
  • An addProfile method that is passed a FacePamphletProfile, and is responsible for adding that profile to the database. Note that profile names are unique identifiers for profiles in the database. In other words, no two profiles in the database should have the same name and the name associated with a profile will never change. So, when a new profile is being added, if there is already an existing profile with the same name, the existing profile should be replaced by the new profile. Note: depending on what data structure you use to keep track of the database, this behavior may actually be quite easy to implement.
  • Continue reading “cs106a – Assignment #7 – Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail