cs193p – Assignment #1 Task #4

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

Use lazy instantiation to allocate and initialize this property (in the property’s getter)
so that it starts off with a full deck of PlayingCards.

Use the getter to check if there is a valid deck. If not, initialize one …

#import "PlayingCardDeck.h"
...
- (Deck *)deck
{
    if (!_deck) {
        _deck = [[PlayingCardDeck alloc] init];
    }
    return _deck;
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #3

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

Add a private property of type Deck * to the CardGameViewController

If you have added test code for the last task, don’t forget to remove it …

… import the deck class and add the property.

#import "Deck.h"
...
@property (nonatomic, strong) Deck *deck;

… nothing more to do for this task …

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #2

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

Be sure to include all the code for the four classes shown in the first two lectures: Card, Deck, PlayingCard and PlayingCardDeck. You must type this code in (e.g., do not copy and paste it from somewhere). The whole point of this Required Task is to gain experience editing code in Xcode and to get used to Objective-C syntax.

Start implementing the classes provided on the slides of lecture #2. The base structure of the Card class has already been added during the lecture. Add its public interface and the match method.
Continue reading “cs193p – Assignment #1 Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #1

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

Follow the detailed instructions in the lecture slides (separate document) to build and run Matchismo in the iPhone Simulator in Xcode 5. Do not proceed to the next steps unless your card flips back and forth as expected and builds without warnings or errors.

The first part of the slides provided with lecture #2 describe the classes for task 2, followed by a detailed walk through of the demonstration from lecture #2. Follow those steps and (if you have not finished them already during the lecture) you have completed the first task of the first assignment.

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Extra Task

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

Add a UISlider to your UI which travels through the history of the currently-being- played game’s flips and display it to the user (moving the slider will modify the contents of the text label you created for Required Task #3 to show its state over the course of the game). When you are displaying past flips, you probably want the text label to be grayed out (with alpha) or something so it’s clear that it’s “the past.” Also, you probably don’t want that text label from Required Task #3 to ever be blank (except at the very start of the game, of course). And every time a new flip happens, you probably want to “jump to the present” in the slider. Implementing this extra credit item will require you to familiarize yourself with UISlider’s API and to add a data structure to your Controller to keep track of the history. It can be implemented in fewer than a dozen lines of code.

Add a new property to hold the history information and initialize it using its getter:
Continue reading “cs193p – Assignment #1 Extra Task”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #7

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

Make the back of the card be an image (UIImage) rather than an Apple logo.

Add an image to your project (e.g. cardback.png), create an UIImage from it, use it when the back of the card is shown, and remove it when it is face up:

- (void)updateUI
{
    UIImage *cardBackImage = [UIImage imageNamed:@"cardback.png"];
    
    for (UIButton *cardButton in self.cardButtons) {
        ...
        if (!card.isFaceUp) {
            [cardButton setImage:cardBackImage 
                        forState:UIControlStateNormal];            
        } else {
            [cardButton setImage:nil forState:UIControlStateNormal];
        }
    }
    ...
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #6

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

Disable the game play mode control (i.e. the UISwitch or UISegmentedControl from Required Task #5) when flipping starts and re-enable it when a re-deal happens (i.e. the Deal button is pressed).

Disable the control element in flipCard:

- (IBAction)flipCard:(UIButton *)sender
{
    self.cardModeSelector.enabled = NO;
    ...
}

… and enable it in dealButtonPressed:

- (IBAction)dealButtonPressed:(UIButton *)sender {
    ...
    self.cardModeSelector.enabled = YES;
    ...
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail