-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuess.cpp
62 lines (59 loc) · 1.22 KB
/
Guess.cpp
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
55
56
57
58
59
60
61
//
// Guess.cpp
// assn2
//
// Created by Thomas on 2018-10-16.
// Copyright © 2018 Thomas. All rights reserved.
//
#include "Guess.h"
// constructor to assign guess
Guess::Guess(char x)
{
switch(x)
{
case 'R':
case 'r':
guess = 'R';
break;
case 'P':
case 'p':
guess = 'P';
break;
default:
guess = 'S';
break;
}
}
// constructor to assign guess with an int
Guess::Guess(int a)
{
switch(a)
{
case 0:
guess = 'R';
break;
case 1:
guess = 'P';
break;
default:
guess = 'S';
}
}
// compare guesses to know who to assign a point to
int Guess::compare(const Guess &other) const
{
int a = NULL;
if(this->guess == other.guess)
{
a = 0;
}
else if((this->guess == 'R' && other.guess == 'P') || (this->guess == 'P' && other.guess == 'S') || (this->guess == 'S' && other.guess == 'R'))
{
a = -1;
}
else if((this->guess == 'P' && other.guess == 'R') || (this->guess == 'S' && other.guess == 'P') || (this->guess == 'R' && other.guess == 'S'))
{
a = 1;
}
return a;
}