Начал программировать неделю назад и узнал достаточно, чтобы написать простую текстовую игру. мне было интересно, является ли это «чистым кодом» или его можно будет считать грязным? некоторые переменные определены в других файлах, но все, что я хочу знать, это чистота основного файла. Я слышал, что не стоит вкладывать операторы if, но я действительно не знаю, как еще их разместить. это все на c++
#include
#include
#include "bigtxt.h"
using namespace std;
int main() {
string item2 = "nothing";
string item3 = "nothing";
string item4 = "nothing";
string item5 = "nothing";
string item6 = "nothing";
string item7 = "nothing";
string item8 = "nothing";
string item9 = "nothing";
srand(time(NULL)); //declaring random number generator 1
int randmnumber = (rand() % 3) + 1;
int funmeter = 0;
int morelikely = (rand() % 10) + 1;
int userinput;
if (randmnumber == 1) { // this is like. toby fox's game fun meter 2
funmeter = funmeter + 5; // 5 is hardest difficulty
}
else if (randmnumber == 2) {
funmeter = funmeter + 10; // mid difficulty
}
else {
funmeter = funmeter + 15; // easiest difficulty
}
cout > userinput;
}
switch (userinput) { // players items
case 2:
cout userinput;
}
else {
cout > userinput;
}
}
else if (userinput == 1) {
if (morelikely >= 3) {
cout > userinput;
}
else cout > userinput;
}
}
cout
Подробнее здесь: https://stackoverflow.com/questions/798 ... arting-out