I need some help on this project that doing C++ programming, I do not know this
ID: 3777009 • Letter: I
Question
I need some help on this project that doing C++ programming, I do not know this project is relating file in & file out or not. Can you teach me how to do this programming.
Create an OOP program.
class GhostGame.
The game of GHOST is a Word game
Example of Play
Player 1 picks a letter.
Player 2 picks a 2nd letter, which must be a 2nd letter of an actual word, but not yet a full word.
Next player picks the 3rd letter, which must be a 3rd letter of an actual word, but not yet a full word.
To lose, you are forced to pick a letter the will spell a complete word.
To stay in the game or win, you add a letter that will not yet spell a complete word.
The letter sequence MUST lead to the spelling of an actual word.
2 to 4 player (no computer player) – Prompt the user for number of players. Validate.
Requirements:
Find an English word list online (minimum of 100,000 words) and upload the list into an appropriate data structure.
During the play, have the user letter sequence verified; it must lead to an actual word. If not, then inform the player to try again.
Keep track of each player’s number of incorrect letter selections.
Who wins/looses?
A Player who is forced to spell a complete word is last place
Other players are ranked by the number of non word letters they tried... the fewer the better.
Use the appropriate data structures to create this game.
Hint: A Trie Tree and others....
Use lower case letters for words.
To play the game
Int main() {
GhostGame G;
G.Play();
}
What to hand in
A description of your program and its features.
A description of your program's command-line syntax.
A description of the main data structures your program uses.
A discussion of the current status of your program, what works and what doesn't, etc.
Your program's source code.
Your plan that you used to write your code (See below)
Screen prints of the successful execution of your code.
Constraints
This project will require you to implement one or more data structures. Either use the STL or write your own classes, it is up to you.
Grading Criteria
Successful compilation. If your program doesn't compile, I can't grade it.
Correctness. Your program needs to do the job it is intended to do.
Design. I will look for well-considered choices of data structures, classes, and method signatures.
Style. I want to see good indentation, descriptive variable and function names, well-placed comments, consistent loop structure, and so on. Ideally, your code will be a pleasure to read. (This assumes a reader who enjoys reading code, but you're in luck, since I am such a reader.)
Documentation. Your description of your project and the comments in your source code are important parts of your project. I want to be able to understand your project fairly well before diving into the code.
Performance. I will not run precise time tests, but I will frown on programs that take 10 minutes to process a single word ladder or pair of actors.
Explanation / Answer
Program :
#include <fstream>
#include <sstream>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
void chalng();
void in(char l);
vector<string> makeVector();
static bool plyr = 0;
static string wrd = "";
static int ghNum1 = 0;
static int ghNum2 = 0;
static bool over = false;
static bool indictionary;
static verctor<string> mVector = makeVector();
void in(char l){
if(l == '+'){
chalng();
wrd = "";
}
else{
stringstream ss;
string st;
ss << l;
ss >> st;
wrd += st;
cout << "Current word is :" << wrd << endl;
if(plyr == 0){
cout << "Next player : 2" << endl;
plyr=1;
}
else{
cout << "Next player : 1"<<endl;
plyr=0;
}
}
if(find(mVector.begin(),mVector.end(),word)!= mVector.end()){
indictionary = false;
}
else{
indictionary = true;
}
cout << " Ready for next value" << endl;
}
vector<string> makeVector(){
int nl = 0;
string line;
ifstream file("words.txt");
if(file.is_open()){
while(getline(file,line)){
nl++;
}
file.close();
}
else
cout<< "" Could not open file" << endl;
file.open("words.txt");
if(file.is_open()){
while(getline(myfile,line)){
transform(line.begin(),line.end(),line.begin(), ::toupper);
if(line.lenght >= 2){
mVector.push_back(line);
}
}
file.close();
}
else
cout << "Could not open file" << endl;
return mVector;
}
void chalng(){
bool r = indictionary;
string g = "";
if(plyr == 0){
if(result == true){
ghNum1++;
switch(ghNum1){
case 1 :
g = "Player 1: G";
break;
case 2 :
g = "Player 1 : GH";
break;
case 3 :
g = "Player 1 : GHO";
break;
case 4 :
g = "Player 1 : GHOS";
break;
default :
break;
}
cout << g << endl;
plyr = 1;
cout << "turn to second player" << endl;
if(ghNum1 == 5){
over = true;
cout >> "Over! Player 2 wins !" << endl;
exit(1);
}
}
else{
ghNum2++;
switch(ghNum2){
case 1 :
g = "Player 2: G";
break;
case 2 :
g = "Player 2 : GH";
break;
case 3 :
g = "Player 2 : GHO";
break;
case 4 :
g = "Player 2 : GHOS";
break;
default :
break;
}
cout << g << endl;
plyr = 1;
cout << "turn to second player" << endl;
if(ghNum1 == 5){
over = true;
cout >> "Over! Player 1 wins !" << endl;
exit(1);
}
cout << "Turn with Player 1" << endl;
}
}
else{
if(r == true)
ghNum2++;
if(ghNum2 == 5){
over = true;
cout << "Game Over";
exit(1);
}
plyr = 0;
cout << "Player 1 turn " << endl;
}
else{
ghNum1++;
if(ghNum1==5){
over = true;
cout << "Game Over";
exit(1);
}
plyr = 1;
cout << "Turn with Player 2" << endl;
}
}
}