-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNNPerson.m
54 lines (45 loc) · 928 Bytes
/
NNPerson.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// NNPerson.m
// lunchd
//
// Created by MacRae Linton on 3/9/10.
// Copyright 2010 Apple Inc.. All rights reserved.
//
#import "NNPerson.h"
@implementation NNPerson
@synthesize name;
@synthesize state;
@synthesize veto;
@synthesize votes;
@synthesize host;
@synthesize gameIsOver;
- (id)initWithName:(NSString *)newName
{
self = [super init];
if (self){
[self setName:newName];
[self setState:NNUndefinedState];
[self setVeto:nil];
votes = [[NSMutableArray alloc] initWithCapacity:5];
gameIsOver = NO;
}
return self;
}
- (void)voteFor:(NSString *)restaurant
{
if ([votes containsObject:restaurant]){
NSLog(@"ERROR? VOTE TWICE?");
}
if ([veto isEqualToString:restaurant]){
NSLog(@"ERROR? Vote FOR VETO?");
}
[votes addObject:restaurant];
}
- (void)giveVeto:(NSString *)restaurant
{
if (! [veto isEqual: nil]){
NSLog(@"ERROR, CAN't GIVE 2 VETOS");
}
[self setVeto:restaurant];
}
@end