I have been working on this for 2 days and I am just so lost. I really need help. Here is what I need to program. I am using Spanish instead of Chinese. We are mainly focus on single arrays and functions
The game will begin by displaying the entire word for a number (Yi). The player has to guess what number it is (One).
1. Every time the player gets it correct, they get a point
2. After 5 points, they are ready to advance to the next level
3. The player should also have an option to quit rather than progressing
In the next level, one letter is left out of the word and the player has to provide the missing letter (S_i for 10). The player has to guess the missing letter.
1. Every time the player gets it correct, they get a point
2. After 5 points, they are ready to advance to the next level
3. The player should also have an option to quit rather than progressing
In the third and final level, 2-to-3 letters are left out of the word (if the word is longer than 2 letters…there must always be at least one letter displayed)
4. The player wins when they get 5 points at this level
5. The player can quit early if they want.
Here is my code. I am having trouble with getting the users answer to match with the random Spanish word that is given to them so that if they type in the correct word it will give them a point.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <iostream>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <ctime>
using namespace std;
//prototypes
const int SIZE = 21;
int score = 0;
void welcome();
void read_guess(char english_number[]);
bool again();
int main()
{
char english_guess[SIZE];
welcome(); //call the welcome function
srand(time(0));
do
{
score = 0;
char english_guess[SIZE];
read_guess(english_guess);
}
while (again());
return 0;
}
void welcome()
{
cout << "Welcome to Learn to Count in Spanish game. " << endl;
cout << "There are 3 levels. \nLevel 1 you will be given a word and you "
<< "will need to guess the number it is associated with. "
<< "\nLevel 2 you will be given a word and the number, but the word "
<< "will be missing a letter. You will need to guess the letter to "
<< "move on. \nLevel 3 you will be given a word, but it will be missing "
<< "2-3 letter. You will need to guess those letters. \nAt each level "
<< "when you get it correct you get 1 point when you get up to 5 points "
<< "you will advance to the next level. \nYou are able to quit after each "
<< "round of guessing. \n \n \n " << endl;
}
void read_guess(char english_guess[])
{
srand(time(0));
char spanish_num[10][10];
strcpy(spanish_num[0], "Uno");
strcpy(spanish_num[1], "Dos");
strcpy(spanish_num[2], "Tres");
strcpy(spanish_num[3], "Cuatro");
strcpy(spanish_num[4], "Cinco");
strcpy(spanish_num[5], "Seis");
strcpy(spanish_num[6], "Siete");
strcpy(spanish_num[7], "Ocho");
strcpy(spanish_num[8], "Nueve");
strcpy(spanish_num[9], "Diez");
int rand_spanish = rand() % 10;
cout << "Please enter the English number word for: " << spanish_num[rand_spanish] << endl;
cin.get(english_guess, 100, '\n');
cin.ignore(100, '\n');
cout << "The guess you enter was: " << english_guess << endl;
}
bool again()
{
bool yes = false;
char response = 'n';
cout << "Would you like to continue? Y or N " << endl;
cin >> response;
cin.ignore(100, '\n');
if (response == 'y' || response == 'Y')
yes = true;
return yes;
}
|