cs193p – Assignment #2 Task #2

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

Add a button which will re-deal all of the cards (i.e. start a new game). It should reset the score (and anything else in the UI that makes sense). In a real game, we’d probably want to ask the user if he or she is “sure” before aborting the game in process to re-deal, but for this assignment, you can assume the user always knows what he or she is doing when they hit this button.

Start by dragging out a new button onto your storyboard. Note that the blue font on a green background is not really readable. You might want to change the color of the button text or its background:

cs193p – assignment #2 task #2 - deal button
cs193p – assignment #2 task #2 – deal button

Continue reading “cs193p – Assignment #2 Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #2 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 reproduce the latest version of Matchismo we built in lecture (i.e. the one with multiple cards) and run it in the iPhone Simulator. Do not proceed to the next steps unless your card matching game functions as expected and builds without warnings or errors.

Thethe slides provided with lecture #3 contain a detailed walk through for the rest of the first assignment and all the steps described above. Follow those steps and (if you have not finished them already during the lecture) you have completed the first task of the second assignment.

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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