cs193p – Assignment #1 Task #5

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

Matchismo so far only displays the A♣ over and over. Fix Matchismo so that each time the card is flipped face up, it displays a different random card drawn from the
Deck property you’ve created above. In other words, Matchismo should flip through an entire deck of playing cards in random order, showing each card one at a time.

Because we will draw random cards, we should not start with the As of clubs but with the back of the card. We could do that in various ways, e.g. adjusting the story board (remove the text of the button and set the background to the correct image). If you want to adjust the button from inside the view controller, we need to add an outlet. Now we could use this outlet to access and manipulate the button as soon as the view has loaded. e.g. we could set the background and the title of the button. … because I am lazy I just call the existing method to flip the card using the outlet property as argument:

@property (weak, nonatomic) IBOutlet UIButton *cardButton;
...
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self touchCardButton:self.cardButton];
    self.flipCount = 0;
}

Continue reading “cs193p – Assignment #1 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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