Command++ 2.79-B源碼
頭文件“Language.h”:
#pragma once
#define LANGUAGE_H
#include <string>
using namespace std;
string Language = "語言";
string LVS = "語言設(shè)置";
string TVS = "文本設(shè)置";
string themeSet = "主題設(shè)置";
string Math = "數(shù)學(xué)求解器";
string Set = "設(shè)置";
string quits = "退出";
string default_theme = "默認(rèn)";
string Sea_theme = "海洋";
string Cash_theme = "高貴";
string RE_theme = "生化危機";
string Old_theme = "遠古";
string Hack_theme = "黑客帝國";
string AAA_theme = "經(jīng)典";
string UnknowType = "未知字符:";
string PleaseInputASubject = "請輸入算式";
string PleaseInputANum = "請輸入一個小于999999的整數(shù)";
string BeSureOfQuit = "確定退出?";
string LanguageA = "中文";
string LanguageB = "英文";
string 未知字符,主題將改為默認(rèn) = "未知字符,主題將改為默認(rèn)";
string Close = "關(guān)機中";
string Diff = "難度:";
string 你獲得了 = "你獲得了 ";
string 分 = " 分";
string ErrorSub = "錯題";
string TureSub = "對題";
string RandSub = "隨機算式挑戰(zhàn)";
string StrF = "因式分解";
string NormalSub = "普通算式";
string StrAbs = "絕對值";
string 請選擇難度 = "請選擇難度(1 - 4):";
bool IsChinese = true;
文本LanguageValue.txt:
Chinese
本體:
#define _CRT_SECURE_NO_WARNINGS 1
#include "total.h"
#include "Language.h"
#include <iostream>
#include <math.h>
#include <stdbool.h>
#include <Windows.h>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
void ChineseV()
{
IsChinese = true;
fstream f;
f.open("Source\\LanguageValue.txt", ios::out);
f << "Chinese";
f.close();
Language.assign("語言");
LVS.assign("語言設(shè)置");
TVS.assign("文本設(shè)置");
themeSet.assign("主題設(shè)置");
Math.assign("數(shù)學(xué)求解器");
Set.assign("設(shè)置");
quits.assign("退出");
default_theme.assign("默認(rèn)");
Sea_theme.assign("海洋");
Cash_theme.assign("高貴");
RE_theme.assign("生化危機");
Old_theme.assign("遠古");
Hack_theme.assign("黑客帝國");
AAA_theme.assign("經(jīng)典");
UnknowType.assign("未知字符:");
PleaseInputASubject.assign("請輸入算式");
PleaseInputANum.assign("請輸入一個小于999999的整數(shù)\n");
BeSureOfQuit.assign("確定退出?");
LanguageA.assign("中文");
LanguageB.assign("英文");
未知字符,主題將改為默認(rèn).assign("未知字符,主題將改為默認(rèn)");
Close.assign("關(guān)機中");
Diff.assign("難度:");
你獲得了.assign("你獲得了 ");
分.assign(" 分");
ErrorSub.assign("錯題");
TureSub.assign("對題");
RandSub.assign("隨機算式挑戰(zhàn)");
StrF.assign("因式分解");
NormalSub.assign("普通算式");
StrAbs.assign("絕對值");
請選擇難度.assign("請選擇難度(1 - 4):");
}
void EnglishV()
{
IsChinese = false;
fstream f;
f.open("Source\\LanguageValue.txt", ios::out);
f << "English";
f.close();
Language.assign("Language");
LVS.assign("Language Setting");
TVS.assign("Text Setting");
themeSet.assign("Theme Setting");
Math.assign("Math");
Set.assign("Settings");
quits.assign("Quit");
default_theme.assign("Default");
Sea_theme.assign("Ocean");
Cash_theme.assign("Royal");
RE_theme.assign("Resident Evil");
Old_theme.assign("Ancient");
Hack_theme.assign("Hack");
AAA_theme.assign("Classics");
UnknowType.assign("Unknown characters:");
PleaseInputASubject.assign("Please enter the formula");
PleaseInputANum.assign("Please enter an integer less than 999999\n");
BeSureOfQuit.assign("Are you sure you want to quit?");
LanguageA.assign("Chinese");
LanguageB.assign("English");
未知字符,主題將改為默認(rèn).assign("Unknown characters, the theme will be changed to default");
Close.assign("Closing");
Diff.assign("Difficulty:");
你獲得了.assign("You got ");
分.assign(" points");
ErrorSub.assign("Wrong question");
TureSub.assign("Correct question");
RandSub.assign("Stochastic challenge");
StrF.assign("Factorization");
NormalSub.assign("Normal calculations");
StrAbs.assign("Absolute value");
請選擇難度.assign("Please select difficulty (1 - 4):");
}
void RussianV()
{
fstream f;
f.open("Source\\LanguageValue.txt", ios::out);
f << "Russian";
f.close();
Language.assign("Язык");
LVS.assign("Языковые настройки");
TVS.assign("Настройка текста");
themeSet.assign("Настройка темы");
Math.assign("Математике");
Set.assign("Параметры");
quits.assign("Покидать");
default_theme.assign("По умолчанию");
Sea_theme.assign("Океан");
Cash_theme.assign("Королевский");
RE_theme.assign("Обитель зла");
Old_theme.assign("Древний");
Hack_theme.assign("Рубить");
AAA_theme.assign("Классика");
UnknowType.assign("Неизвестные персонажи:");
PleaseInputASubject.assign("Пожалуйста, введите формулу");
PleaseInputANum.assign("Введите целое число меньше 999999\n");
BeSureOfQuit.assign("Вы уверены, что хотите бросить курить");
LanguageA.assign("Китайский");
LanguageB.assign("Английский");
未知字符,主題將改為默認(rèn).assign("Неизвестные символы, тема будет изменена на стандартную");
Close.assign("Закрытие");
Diff.assign("Трудность:");
你獲得了.assign("У вас есть ");
分.assign(" дробь");
ErrorSub.assign("Неправильный вопрос");
TureSub.assign("Правильный вопрос");
RandSub.assign("Стохастический вызов");
StrF.assign("факторизации");
NormalSub.assign("Нормальные расчеты");
StrAbs.assign("Абсолютная величина");
請選擇難度.assign("Пожалуйста, выберите сложность (1 - 4):");
}
void LanguageSet()
{
LS:
char c;
fstream f;
string str;
while (true)
{
system("cls");
cout << LanguageA << "[A]" << endl;
cout << LanguageB << "[B]" << endl;
cout << quits << "[C]" << endl;
cin >> c;
switch (c)
{
case 'A':
case 'a':
case '1':
f.open("Source\\LanguageValue.txt", ios::in);
while (f >> str)
{
if (str == "Chinese")
{
cout << "你正在使用此語言!" << endl;
Sleep(1500);
break;
}
else
{
ChineseV();
cout << "設(shè)置成功!" << endl;
Sleep(1500);
}
}
f.close();
goto LS;
break;
case 'B':
case 'b':
case '2':
f.open("Source\\LanguageValue.txt", ios::in);
while (f >> str)
{
if (str == "English")
{
cout << "You are using this language" << endl;
Sleep(1500);
break;
}
else
{
EnglishV();
cout << "Set up!" << endl;
Sleep(1500);
}
}
f.close();
goto LS;
break;
case 'C':
case 'c':
case '3':
break;
case 'D':
case 'd':
case '4':
f.open("Source\\LanguageValue.txt", ios::in);
while (f >> str)
{
if (str == "Russian")
{
cout << "You are using this language" << endl;
Sleep(1500);
break;
}
else
{
RussianV();
cout << "Set up!" << endl;
Sleep(1500);
}
}
f.close();
goto LS;
break;
default:
cout << UnknowType << c << endl;
goto LS;
break;
}
break;
}
}
void ReadJSON()
{
fstream f;
string str;
f.open("Source\\LanguageValue.txt", ios::in);
while (f >> str)
{
if (str == "Chinese")
{
ChineseV();
}
else if(str == "English")
{
EnglishV();
}
else if (str == "Russian")
{
RussianV();
}
else
{
MessageBox(0,"錯誤!LanguageValue.txt出現(xiàn)了無法解析的外部符號,自動將語言改為中文", "錯誤!!!",MB_ICONERROR);
ChineseV();
}
}
f.close();
}
void Style()
{
char c;
while (true)
{
system("cls");
cout << AAA_theme << "[A]" << endl;
cout << Sea_theme << "[B]" << endl;
cout << Cash_theme << "[C]" << endl;
cout << RE_theme << "[D]" << endl;
cout << Old_theme << "[E]" << endl;
cout << Hack_theme << "[F]" << endl;
cout << default_theme << "[G]" << endl;
cout << quits << "[H]" << endl;
cin >> c;
switch (c)
{
case 'A':
case 'a':
case '1':
system("color 70");
break;
case 'B':
case 'b':
case '2':
system("color 09");
break;
case 'C':
case 'c':
case '3':
system("color 0D");
break;
case 'D':
case 'd':
case '4':
system("color C4");
break;
case 'E':
case 'e':
case '5':
system("color 0F");
break;
case 'F':
case 'f':
case '6':
system("color 0A");
break;
case 'G':
case 'g':
case '7':
system("color 07");
break;
case 'H':
case 'h':
case '8':
goto End;
break;
default:
cout << 未知字符,主題將改為默認(rèn) << endl;
system("color 07");
break;
}
}
End:
return;
}
void quit(int times)
{
char i;
while (true)
{
hend:
cout << BeSureOfQuit << "?(Y/N)" << endl;
cin >> i;
switch (i)
{
case 'Y':
case 'y':
system("cls");
cout << Close << endl;
Sleep(times);
system("cls");
exit(0);
break;
case 'N':
case 'n':
system("cls");
break;
case '\n':
goto hend;
break;
default:
goto hend;
break;
}
break;
}
}
void Die(int s, int n , int F, int T)
{
while (true)
{
system("cls");
cout << Diff << n << endl << 你獲得了 << s << 分 << endl << ErrorSub << " : " << F << endl << TureSub << " : " << T << endl;
system("pause");
system("cls");
break;
}
}
class SubjectRandom
{
public:
SubjectRandom();
};
SubjectRandom::SubjectRandom()
{
int addN = 0;
int dif = 1;
int Life = 5;
int TuP = 0;
int FuP = 0;
char d;
int RandMax = 0;
int RandCMax = 4;
int End;
int e;
int time = 3;
int tts = 0;
int A;
int B;
int C;
cout << 請選擇難度 << endl;
cin >> d;
switch (d)
{
case '1':
addN = 10;
dif = 1;
Life = 5;
TuP = 0;
FuP = 0;
system("cls");
RandMax = 10;
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
break;
case '2':dif = 2;
addN = 5;
Life = 4;
TuP = 0;
FuP = 0;
system("cls");
RandMax = 25;
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
break;
case '3':dif = 3;
addN = 3;
Life = 3;
TuP = 0;
FuP = 0;
system("cls");
RandMax = 50;
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
break;
case '4':dif = 4;
addN = 2;
TuP = 0;
FuP = 0;
Life = 2;
system("cls");
RandMax = 100;
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
break;
default:dif = 999;
addN = 1;
TuP = 0;
FuP = 0;
Life = 1;
system("cls");
cout << "隱藏難度\n";
RandMax = 500;
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
break;
}
while (true)
{
switch (C)
{
case 0:
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
while (1) {
cout << A << " + " << B << " = ";
End = A + B;
cin >> e;
if (e == End) {
cout << "正確,得分加" << addN << endl;
tts = tts + addN;
TuP++;
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
break;
}
else {
FuP++;
cout << "錯誤,次數(shù)減1" << endl;
Life--;
break;
}
}
break;
case 1:
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
while (1) {
cout << A << " - " << B << " = ";
End = A - B;
cin >> e;
if (e == End) {
TuP++;
cout << "正確,得分加" << addN << endl;
tts = tts + addN;
break;
}
else {FuP++;
cout << "錯誤,次數(shù)減1" << endl;
Life--;
break;
}
}
break;
case 2:
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
while (1) {
cout << A << " * " << B << " = ";
End = A * B;
cin >> e;
if (e == End) {
TuP++;
cout << "正確,得分加" << addN << endl;
tts = tts + addN;
break;
}
else {
FuP++;
cout << "錯誤,次數(shù)減1" << endl;
Life--;
break;
}
}
break;
case 3:
A = rand() % RandMax;
B = rand() % RandMax;
C = rand() % RandCMax;
while (1) {
cout << A << " / " << B << " = ";
if (B == 0)
{
cout << "題目有誤,進入下一題" << endl;
break;
}
else
{
End = A / B;
cin >> e;
if (e == End) {
TuP++;
cout << "正確,得分加" << addN << endl;
tts = tts + addN;
break;
}
else {
FuP++;
cout << "錯誤,次數(shù)減1" << endl;
Life--;
break;
}
}
}
break;
}
if (Life <= 0|| tts >= 99999999 )
{
Die(tts, dif, FuP, TuP);
break;
}
}
}
void Calculator(double A,double B,char C)
{
double End;
switch (C) {
case '+':
End = A + B;
cout << "=" << End<< endl; break;
case '-':
End = A - B; cout << "=" << End<<endl; break;
case '*':
case '×':
End = A * B; cout << "=" << End<<endl; break;
case '/':
case '÷':
End = A / B; cout << "=" << End <<endl; break;
case '^':
End = pow(A, B); cout << "=" << End << endl; break;
case 'S':case 's':case '&':
End = sqrt(A); if (A <= 0) { printf("Negative numbers or 0 do not have square roots\n"); }
else { printf("%lf的平方根 = %lf",A,End); }break;
case 'c':
case 'C':
system("cls");
break;
default:
cout << "I'm sorry, but please check your command and try again, there must be something wrong with it,thank you" << endl;
break;
}
}
void Abs(int NumA)
{
int A = NumA;
int End = abs(A);
printf("| %i | = %i\n", A, End);
system("pause");
}
void Factorization()
{
}
void Settings()
{
char c;
while (true)
{
G:
system("cls");
cout << themeSet << "[A]" << "\n" << TVS << "[B]" << "\n" << LVS << "[C]" << "\n" << quits << "[D]\n";
cin >> c;
switch (c)
{
case 'A':
case 'a':
case '1':
Style();
break;
case 'B':
case 'b':
case '2':
break;
case 'C':
case 'c':
case '3':
LanguageSet();
break;
case 'D':
case 'd':
case '4':
break;
default:
goto G;
break;
}
break;
}
}
int main()
{
ReadJSON();
int quittime = 1500;
double A,B = 0;
char C = 0;
char i,i2;
SetConsoleTitle("Command Plus - v2.85f - Beta");
while (true)
{
Start:
system("cls");
cout << Math << " [A]" << endl << Set << " " << "[B]" << endl << quits << " [C]" << endl;
cin >> i;
if (i == 'A'|| i == 'a')
{
while (true)
{
system("cls");
cout<< NormalSub << " " << "[A]" << "\n" << StrAbs << " " << "[B]" << endl << StrF << " " << "[C]" << "\n" << RandSub << " " << "[D]" << endl << Set << " " << "[E]" << endl << quits << " " << "[F]" << endl;
cin >> i2;
switch (i2)
{
case 'A':
case 'a':
system("cls");
while (true)
{
cout << PleaseInputASubject << endl;
cin >> A >> C >> B;
if (C == 'Q' || C == 'q')
{
break;
}
else if (C == 'C' || C == 'c')
{
system("cls");
}
Calculator(A, B, C);
}
break;
case 'B':
case 'b':
system("cls");
int a;
cout << PleaseInputANum;
cin >> a;
Abs(a);
break;
case 'C':
case 'c':
cout << "To be conutiued\n";
Sleep(3000);
system("cls");
break;
case 'D':
case 'd':
SubjectRandom::SubjectRandom();
break;
case 'E':
case 'e':
Settings();
break;
case 'F':
case 'f':
goto Start;
break;
default:
system("cls");
cout << UnknowType << i2 << endl;
system("pause");
system("cls");
break;
}
}
}
else if (i == 'B'|| i == 'b')
{
Settings();
}
else if (i == 'C'||i == 'c')
{
system("cls");
quit(quittime);
}
else
{
cout << UnknowType << i << endl;
}
}
}