ios xcode
sura_hBuild the MatchCard App Game
The UI does not have to be identical- feel free to experiment with a different setup as long as its intuitive to the user and you can code the logic.
But I'd like to see a similar logic. If you change the UI controls or scoring scheme for the players, please make a note of it when you submit your assignment.
#import "CardGameViewController.h"
@interface CardGameViewController ()
@end
NSArray *validSuits, *validRanks;
@implementation CardGameViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
validSuits = @[@"♠",@"♣",@"♥",@"♦"];
validRanks = @[@"A",@"2",@"3",@"4",@"5",@"6",@"7", @"8",@"9",@"10",@"J",@"Q",@"K"];
NSLog(@"Displaying suits\n");
for (int i=0; i < validSuits.count; i++)
{
NSLog(@"Suit at index %d is %@\n",i, validSuits[i]);
}
NSLog(@"Displaying ranks\n");
for (int i=0; i < validRanks.count; i++)
{
NSLog(@"Rank at index %d is %@\n",i, validRanks[i]);
}
[self resetTheGame];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)resetTheGame
{
yourScore = phoneScore = 0;
lblExplanation.text = @"";
[self updateScores];
}
-(void)updateScores
{
NSString *scoreText = [NSString stringWithFormat:@"Your score is %d", yourScore];
lblYourScore.text = scoreText;
scoreText = [NSString stringWithFormat:@"Phone's score is %d", phoneScore];
lblPhoneScore.text = scoreText;
}
- (IBAction)gameReset:(id)sender {
[self resetTheGame];
}
- (IBAction)touchedCard:(UIButton *)sender {
//UIButton *pButton = (UIButton *)sender;
if ([sender.currentTitle length])
{
//When the card front is showing - flip it to show the back for both cards
[sender setBackgroundImage:[UIImage imageNamed:@"CardBack.jpg"] forState:UIControlStateNormal];
[sender setTitle:@"" forState:(UIControlStateNormal)];
[btn2 setBackgroundImage:[UIImage imageNamed:@"CardBack.jpg"] forState:UIControlStateNormal];
[btn2 setTitle:@"" forState:(UIControlStateNormal)];
lblExplanation.text = @"";
}
else
{
//When the card back is showing - flip it to show the rank and suit for both cards
//Add your logic here to decide who scores higher and why
//Display the updated score and results to the user
}
}
@end
#import <UIKit/UIKit.h> @interface CardGameViewController : UIViewController { int yourScore; int phoneScore; IBOutlet UIButton *btn2; IBOutlet UILabel *lblYourScore; IBOutlet UILabel *lblPhoneScore; IBOutlet UILabel *lblExplanation; } - (IBAction)touchedCard:(UIButton *)sender; - (IBAction)gameReset:(id)sender; @end
- 9 years ago
- 120
- NEED THIS DONE ASAP!!!!!!!! ITS ATTACHED> NEED IT DONE before 10pm CENTRAL STANDARD!! IF CANT COMPLETE DONT REPLY!!!
- AR310 Egyptian Art Assitance
- biological psychology assignment 8
- for essays Guru
- Smart-Solutions
- Current social problem in our society for SOCIOLOGY CLASS
- 4 essays, 200 words each APA Format
- Human captial Trends
- Joe stopped for a beer at the Turn-a-Round Lounge in Small Town on his way home from work. He ran...
- Transformational Leaders