Goal: finish up and extend Blackjack-4.
Requirements and Grade Rubric
- (40%) Longer Game - There will be an overall game score and the player will be able to play multiple hands:
- Start the game score at 100 points (or $, £, €, ¥, whatever)
- Give the player 50 points every time they win a hand, deduct 50 points when they lose.
- The game will end after 5 hands/rounds
- Be sure to display the score and round # to the player in a
UILabel
. ** For full credit, make sure that an alert only pops up on a new game, not every hand. You can instead update the status label (see below) with who won or lost each hand. **
- (40%) Sound via a Helper class
- A sound is played when a player card is flipped.
- A different sound is played when the player loses a hand.
- A different sound is played when the player wins a hand.
- A separate Objective-C class that extends
NSObject
will handle the loading and playing of the sound. Hints:@import AVFoundation;
- Three private
AVAudioPlayer
ivars. Initialize these three once in theinit
method, and callprepareToPlay
to preload them. - Three public instance methods:
playDrawCardSound
,playWinSound
andplayLoseSound
. These will each call theplay
method on the appropriate ivar.
- (10%) Status Label - update a
UILabel
and display a pertinent message when something happens during the player portion of the turn. Examples: "You can Hit or Stand", "You drew an Ace", "You won the last hand", ... - (Up to 15%) Enhancements
Ideas for enhancements
- Rather than being limited to a bet of 50, the player can change their bet amount utilizing buttons. Make sure they can't bet more than they currently have. The game is over when they hit zero score or when the 5 hands are up.
- Dramatically improve the UI.
- Factor some of our Blackjack code out of
GameModel
into a new model class. Create aHandOfCards
class and instantiate two instances of it:_playerHand
and_dealerHand
. Transfer functionality such asareCardsBust:
andcalculateBestScore:
from theGameModel
class to theHandOfCards
class. - ** About Screen: + 1 to 3 points **
- ** High Scores Screen: use
NSUserDefaults
to store and retrieve the high score(s) **
Extra Credit
- (+5%) Build a fully functional iPhone/iPod Touch version.
- (+5%) Make your "Sound Helper" class a Singleton. Check out this excellent tutorial on iOS design patterns at raywenderlich.com
Deductions
- (-20%) The project won't compile. (Be sure that your sound and image resources have been imported and are in your project directory!)
- (-20%) The completed project is not installed on your iOS device.
- (-5% per feature) The project has missing/broken features from the Blackjack ICEs.
- (-??%) Egregious violations of MVC or Coding Standards
Coding Standards
- MVC!
- Separation of Concern - You should have multiple Objective-C classes, with each class having well-defined functionality accessed through a public interface.
- D.R.Y. - Don't Repeat Yourself. Repeated blocks of nearly identical code should be factored out and placed in a separate method.
- No "magic numbers" (unnamed numerical constants) - declare C style constants or enums or
#define
s instead. - Objective-C code conventions: public properties and methods declared in .h file, private ivars declared in .m and begin with an underscore, class names are capitalized, method names are in lower case.
- Well commented code. Each and every method you wrote gets a comment indicating what it does.
- There should be no compile time or run time errors.
Hints
- Besides reusability, the main advantage of MVC is that it makes it easier to update your application. As you plan out this project, think about which existing class should be handling what functionality. For example:
- Which class should call the sound methods in the "Sound Helper" class - the
GameModel
or theViewController
? - Which class should keep track of the total score and current round - the
GameModel
or theViewController
?
- Which class should call the sound methods in the "Sound Helper" class - the
Submission
- ZIP up and post to dropbox before due date. This is worth 10% of final grade. Minimum grade is 0%, Maximum grade is 115%.
- Install this on your iOS device and bring it to class.
- Document that you met the 3 major requirements, and be specific about any enhancements and extra credit you did. Paste this into the comments field of the dropbox.