Feel free to follow me on twitter

CS193P – Assignment 0 & 1

Posted on Aug 2, 2013

I started the Stanford ‘Developing iPhone Applications course (CS193p) through iTunes U and must say, I’ve put in a fair few hours already. I started a couple of months ago and progressed through to around lecture 7-8 and assignment 2 however we moved house which has taken up a lot (all) of my time for the last 3-4 weeks and so I’ve decided to  start again from scratch.

Assignment 0

Following the first lecture, Paul sets a fairly trivial task of duplicating all the code from the lecture within a new Xcode project and having it run in the simulator without compiler errors or warnings. At this point, you basically have a single playing card (the app is soon to be a fully-fledged card game) which you can flip over to reveal its suit and rank. The card is drawn randomly from a deck of 52 cards each time it’s flipped over. This mainly involves incorporating the drawRandomCard method into the flipCard: method.

Assignment 1

Assignment 1 is a little trickier and requires you to go off and do a little digging through the Xcode documentation to understand the properties of UIButton along with the UISegmentedControl class (if you choose to use a segmented control over a UISwitch).  At this point you’re expected to have implemented all the code talked about in the lecture and have a fully working 12 card matching game that matches two cards based on suit and rank.

The ‘required parts of this assignment are:

-Add a further 4 cards (total of 16 cards)
-Add a segmented control to allow the user to select a 2 or 3 card matching game
-Add a label that shows the current status of the game
-Add a deal button that effectively resets the game
-Add an image to the back of the card button

The optional requirement includes adding a UISlider to allow the user to navigate through the history of play messages.

The version of Matchismo I came up with implements all of the required and optional tasks as part of this assignment. I went for a segmented control to set the number of cards to match which is disabled once the game has started. I ended up modifying CardMatchingGame to allow a 2 or 3 card matching game which also involved amending the match logic to accommodate a slightly tweaked scoring mechanism.

After adding the slider I introduced some logic to make it step when it is being interacted with based on the number of messages recorded at any given time. I stored these messages in an NSMutableArray within the model along with some code to ensure it gets no larger than 50 entries, at which point it removes the oldest entry and adds the new message to the front.

You can see my solution for Assignment 1 on GitHub here: Matchismo Assignment 1