Eller noget i stil af hvad jeg foreslog.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string answer;
string lang;
char* filename;
int x, y, z;
while(true){
while(true){
cout << "Please chose language, there are following langauge available: \\n" << "Danish\\n" <<"English\\n" <<"\\nPlease write which langauge you want: ";
getline (cin, lang);
if(lang == "danish" || lang == "Danish"){
filename = "danish.txt";
break;
}else{
if(lang == "english" || lang == "English"){
filename = "english.txt";
break;
}else{
system("cls");
cout << "You have not chosen a real option";
}
}
}
ifstream file(filename);
string pressNumber;
string languageSelected;
string pressEnter;
string turnsLeftStart;string turnsLeftEnd;
string winnerFoundStart;string winnerFoundEnd;
string tryAgain;
string tryAgainYes;
string loserFoundStart;
string loserFoundEnd;
string numberToHigh;
string numberToLow;
getline(file,languageSelected);
getline(file,pressEnter);
getline(file,pressNumber);
getline(file,turnsLeftStart);
getline(file,turnsLeftEnd);
getline(file,winnerFoundStart);
getline(file,winnerFoundEnd);
getline(file,tryAgain);
getline(file,tryAgainYes);
getline(file,loserFoundStart);
getline(file,loserFoundEnd);
getline(file,numberToHigh);
getline(file,numberToLow);
std::cout << languageSelected << std::endl << pressEnter << std::endl;
cin.ignore();
while(true){
cout << pressNumber;
cin >> y;
if (y>10){
cout <<numberToHigh;
cin.get();
continue;
}
if (y<0){
cout <<numberToLow;
cin.get();
continue;
}
while(true){
for(z=3;z>=0;z--){
system("cls");
cout <<turnsLeftStart<< z <<turnsLeftEnd;
cin >> x;
cin.ignore();
system("cls");
-z;
if (x == y){
system("cls");
cout << winnerFoundStart<< y << winnerFoundEnd;
cout <<tryAgain;
getline (cin, answer);
system("cls");
if (answer == "y"){
cout << tryAgainYes;
cin.get();
system("cls");
if(x == y) break;
}
if(answer == "n"){
system("cls");
if(x==y) break;
}
}
if(z==1){
system("cls");
cout <<loserFoundStart<<y <<loserFoundEnd;
cout << tryAgain;
getline (cin, answer);
system("cls");
if (answer == "y"){
cout << tryAgainYes ;
cin.get();
system("cls");
if(z == 1) break;
}
if (answer == "n"){
system("cls");
if(z==1) break;
}
}
if (answer == "y") break;
if (answer == "n") break;
}
if (answer == "y") break;
if (answer == "n") break;
}
}
if (answer == "n") break;
}
}
english.txt
You have chosen to run the program in english
Press ENTER to continue
Press a number between 0 and 10, that is to be guessed:
You have
turn(s) to guess the number between 0 and 10:
And We have a winner! The number was
...
\\nWant to try again? (Y/N):
Press Enter to start the game
\\nYou have lost, you have spend your 3 turns... The answer was
...\\n
\\nThe number must not be higher then 10\\n\\n
\\nThe number must no be lower then 0\\n\\n
skal du bare lave txt filer der er oversat linie for linie for hvert sprog og huske at lave en indføre et sprogvalg i koden for hvert sprog.