cs193p – Assignment #3 Task #3

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

Your Playing Card game must continue to work as required from last week except that it only needs to work as a 2-card matching game (you can remove the switch or segmented control from your UI, but keep your 3-card matching infrastructure because Set is a 3-card matching game).

For convenience (and to confuse you), I will follow the tasks of this assignment slightly out of order. Let’s continue with task #3.

Remove the segmented-control element, adjust the size of the history label and slider, and move the score label and the deal button:

cs193p – assignment #3 task #3 – new layout
cs193p – assignment #3 task #3 – new layout

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Task #4

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

Use a UITabBarController to present the two games in your UI in separate tabs.

For convenience (and to confuse you), I will follow the tasks of this assignment slightly out of order. Let’s start with task #4.
Continue reading “cs193p – Assignment #3 Task #4”

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

cs193p – Assignment #3 Extra Task #3

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

Add a section (or sections) to your UICollectionView to show “found matches.” In other words, the user can scroll down in the UICollectionView (below the game) and see all of the matches they’ve found so far in the current game. The actual cards should appear (perhaps miniaturized, perhaps not, up to you). You will likely want to create a new UICollectionViewCell with 2 or 3 instances of a custom UIView subclass (that you’ve already written) as subviews and maybe some nice adornment.

The following solution will add two additional sections to the collection views. One to show the found matches, and one for the title e.g. “Matches Found:” (which could actually be implemented as header as well) …

Create a new property in the generic view-controller class to hold the matched cards and initialize it lazily:
Continue reading “cs193p – Assignment #3 Extra Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Extra Task #2

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

Let the user choose how many cards to deal in the Playing Card game. Set is standardized to 12 cards to start a game, but the Playing Card game is flexible.

Because the specifications of the assignments call this tasks simple, choose the simplest implementation, using the game settings.

Add a new property to the game settings:
Continue reading “cs193p – Assignment #3 Extra Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail