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 – Lecture #2 – Xcode 5

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

Lecture #2 provides a short walk through of the Xcode developing environment. The first half of the lecture discusses the various classes of the model for the playing card game. The second is a life demonstration on how to start a project in Xcodes, placing buttons and labels in Storyboard and connecting them to the view controller.

At the end of the lecture the app called Matchismo displays a playing card and allows to flip it to show both sides of the card.

The code for this lecture is available at github.

The lecture as well as its slides (which include a complete walk through of the demo from the lecture and most of assignment #1) are available via iTunes called “2. Xcode 5”.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Extra Task #6

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

Make this a two player game. There’s no need to go overboard here. Think of a simple UI and a straightforward implementation that make sense.

Create a new property to hold the separate scores of the players and another one to know the current player:

@property (strong, nonatomic) NSMutableArray *playerScores; // of NSNumber
@property (nonatomic) int currentPlayer;
...
- (NSMutableArray *)playerScores
{
    if (!_playerScores) {
        _playerScores = [NSMutableArray arrayWithObjects:@0, @0, nil];
    }
    return _playerScores;
}

Continue reading “cs193p – Assignment #3 Extra Task #6”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Extra Task #5

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

Knowing how to find Sets in the remaining cards also would allow you to let the user cheat. Have a button that will show them a Set (if available). It’s up to you how you want to show it, but maybe some little indicator (a star or something) on each of the 3 cards?

Start by adding a new button in storyboard:

cs193p - assignment #3 extra task #5
cs193p – assignment #3 extra task #5

Continue reading “cs193p – Assignment #3 Extra Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Extra Task #4

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

You could add better score-keeping to the Set part of this application if you can figure out an algorithm for calculating whether a Set exists in the current cards in play. Then you can penalize the user not only for mismatches, but for clicking the “deal 3 more cards” button if he or she missed a Set. You’d also know when the game was “over” (because the user would click on “deal 3 more cards” and there would be no more cards in the deck and no more Sets to choose).

Create a new public method in the card-matching-game model which returns the first set of matching cards. The first possible combination of cards is just the first cards. Generate an array of their indexes with a simple for loop. Then check if the combination is valid (e.g. contains no unplayable card). Separate the first card and from the others using helper functions to check if they match. If they do, return those cards otherwise get the next possible combination, and start again with the checks:
Continue reading “cs193p – Assignment #3 Extra Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail