void quitgame(int Conf/*1--Confirm, 0--no confirm*/) { char ch; if(Conf) { window(20,9,60,15); textbackground(LIGHTGRAY); textcolor(RED); clrscr(); gotoxy(1,6); cprintf("-----------------------------------------"); gotoxy(1,1); cprintf("-------------- Exit Game ----------------"); textcolor(MAGENTA); gotoxy(16,2); cprintf("Warning!"); gotoxy(2,3); cprintf("Do you really want to quit this game?"); textcolor(LIGHTGREEN); while(1) { gotoxy(15,4); cprintf("OK? [Y/N] "); ch=getch(); if(ch=='Y'||ch=='y') break; else if(ch=='N'||ch=='n') { JudgeKey(); return; } } } window(1,1,80,25); textbackground(BLACK); textcolor(LIGHTGRAY); clrscr(); exit(0); }
/* 如: CREATE TABLE student( name char(20), id int, class char(10), ); */ bool userDatabase::CreateTable(){ kTable newTable; int Size = mySql.sqlWord.size(); if(Size < 3) return false; newTable.name = mySql.sqlWord[2]; int i = 3; string name; int type,unit,iskey; // if(i < Size) for(; i < Size; i++){ type = -1; unit = 0; iskey = 0; //提取姓名 name = mySql.sqlWord[i]; i ++; //提取种类 if(canRead(i)) type = JudgeType(i); if(type == -1) return false; i++; //判断单位 if(canRead(i) && mySql.sqlWord[i] != ","){ if(type == 2){ unit = JudgeUnit(i); i++; } if(canRead(i) && mySql.sqlWord[i] != ","){ iskey = JudgeKey(i); } } if(!newTable.addColumn(name,type,unit,iskey)){ cout << "[Error] The table have the same column!" << endl; return false; } //判断主键 } Size = newTable.columnName.size(); if(FindTable(newTable.name) != -1){ cout << "[Error] Table is existing!" << endl; return false; } if((int)newTable.columnName.size() == 0){ cout << "[Error] Can't create a empty table!" << endl; return false; } //-------------------------------------------------------------------- cout << "[OK] Creating tables success." << endl; kLine::MakeLine(60); cout << "Table's name is" << " [" << newTable.name << "]" << endl; cout << setiosflags(ios::left); cout << setw(15) << "ColumnName"; cout << setw(10) << "type"; cout << setw(10) << "unit"; cout << setw(15) << "key" << endl; for(int i = 0; i < Size; i++){ //列名字 cout << setw(15) << newTable.columnName[i]; //列种类 if(newTable.columnType[i] == 1) cout << setw(10) << "int"; if(newTable.columnType[i] == 2) cout << setw(10) << "char"; // cout << setw(10) << newTable.columnUnit[i]; if(newTable.isKey[i] & (1 << 0)) cout << setw(15) << "[PRIMARY KEY] "; if(newTable.isKey[i] & (1 << 1)) cout << setw(8) << "[UNIQUE] "; if(newTable.isKey[i] & (1 << 2)) cout << setw(10) << "[NOT NULL]"; cout << endl; } kLine::MakeLine(60); myTable.push_back(newTable); return true; };
void main() { JudgeKey(); }
void JudgeKey() { int key,a,b,n=0; long m; initscreen(); for(;;) { for(;!kbhit();) /*计时器*/ { gotoxy(56,2); if(t%500==0) m=t/500; cprintf("%ld",m); t++; if(m==MAXTIME) { littlewin(0); JudgeKey(); } delay(100); } /*计时器结束*/ ++n; a=x; b=y; key=bioskey(0); if(key==UP) /*判断按键*/ { if(y==5) continue; gotoxy(x,--y); WIN; } else if(key==DOWN) { if(y==20) continue; else if(y==5&&x!=60) continue; else if(y==7&&x!=50) continue; else if(y==9&&x!=40) continue; else if(y==11&&x!=30) continue; else if(y==13&&x!=20) continue; else if(y==15&&x!=25) continue; else if(y==17&&x!=55) continue; gotoxy(x,++y); WIN; } else if(key==LEFT) { if(x==20) continue; gotoxy(--x,y); WIN; } else if(key==RIGHT) { if(x==60) continue; gotoxy(++x,y); WIN; } else if(key==0x11b) quitgame(1); else continue; /*判断结束*/ cprintf("\1"); /*输出图形*/ gotoxy(a,b); printf(" "); gotoxy(x,y); sound(300); /*输出声音*/ delay(1000); nosound(); } /*输出结果*/ littlewin(1); quitgame(0); }