cs193p – Assignment #1 Task #4

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

Add a button called “Deal” 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.

Create a new button in storyboard:

cs193p - assignment #1 task #4
cs193p – assignment #1 task #4

Connect it to a new action method which resets the game and the flipCount property and finally calls updateUI to update the view:

- (IBAction)dealButtonPressed:(UIButton *)sender {
    self.game = nil;
    self.flipCount = 0;
    [self updateUI];

The complete code is available on github.


Leave a Reply

Your email address will not be published.