Skip to content

Commit 5fc63f8

Browse files
committed
spell check
1 parent c8eaaf7 commit 5fc63f8

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin/
2+
obj/
3+
*.cbp

guessGame.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
int getRand(int min, int max)
77
{
88
static const double fraction = 1.0 / (static_cast<double>(RAND_MAX) + 1.0);
9-
9+
1010
return static_cast<int>(rand() * fraction * (max - min + 1) + min);
1111
}
1212

@@ -19,7 +19,7 @@ bool getPlay()
1919
std::cout << "keep playing? [y/n]" << '\n';
2020
std::cin >> play;
2121
std::cin.ignore(32767, '\n');
22-
22+
2323
if(play == 'y')
2424
return true;
2525
else if(play == 'n')
@@ -36,25 +36,25 @@ int main()
3636
do
3737
{
3838
std::cout << "I'm thinking of a number from 1 to 100" << '\n';
39-
39+
4040
int target = getRand(1, 2);
4141
int guess(0);
42-
42+
4343
//game loop
4444
for(int attempt = 0; attempt <= 7; ++attempt)
4545
{
4646
std::cout << "guess #" << attempt << ": ";
4747
std::cin >> guess;
48-
48+
4949
//error correction for non integer input
5050
if (std::cin.fail())
5151
{
5252
std::cin.clear();
5353
std::cin.ignore(32767, '\n');
5454
std::cout << "INVALID INPUT" << '\n';
5555
}
56-
57-
//checks if the guesd is correct
56+
57+
//checks if the guess is correct
5858
else if(guess < target)
5959
std::cout << "too low" << '\n';
6060
else if(guess > target)
@@ -64,18 +64,18 @@ int main()
6464
std::cout << "YOU WIN!" << '\n';
6565
break;
6666
}
67-
67+
6868
//let's player know they lost after 7 attempts
6969
else if(attempt == 7)
7070
std::cout << "You loose" << '\n';
7171
}
72-
72+
7373
play = getPlay();
74-
74+
7575
}
7676
while(play);
77-
77+
7878
std::cout << "Thanks for playing!";
79-
79+
8080
return 0;
8181
}

0 commit comments

Comments
 (0)