好文档 - 专业文书写作范文服务资料分享网站

教学设备管理系统c++ 

天下 分享 时间: 加入收藏 我要投稿 点赞

cout<<\请输入您需要修改的设备编号:\cin>>num_; for (i = 0 ; i < n ; i++) {

if(elem[i]->getNum()==num_) {

ok = true; int choice = 1; do {

system(\elem[i]->output();

cout<<\退出修改。\ cout<<\请输入您需要修改的选项:\cin>>choice;

if(choice < 1 || choice > 8) { }

switch (choice) { case 1:

elem[i]->setNum(); break;

elem[i]->setName(); break;

elem[i]->setFactory(); break;

elem[i]->setDate(); break;

elem[i]->setAmount(); break;

elem[i]->setPrrice(); break;

elem[i]->setNotes(); break;

cout<<\输入错误,请重新输入!\choice = 1; continue;

case 2:

case 3:

case 4:

case 5:

case 6:

case 7:

}

else cout<<\现无任何设备!\}

bool List::Save() {

ofstream fout; fout.open(\

fout.put(0); //清楚txt文档的数据

fout.seekp(-1,ios::end); //在txt文档中光标退格 if(fout.fail()) { } else { }

cout<<\保存成功!\ fout.close(); return true; }

bool List::Read() { int size; ifstream fin; fin.open(\ streampos pos = fin.tellg(); fin.seekg(0,ios::end); size = fin.tellg(); fin.seekg(pos);

for(int i = 0 ; i < n ; i++) { }

elem[i]->foutput(fout);

cout<<\找不到文件,保存失败!\return false; }

if(!ok) cout<<\您的输入有误!\

}

case 8: }

break;

} while (choice != 8);

if(fin.fail()) { } else { }

cout<<\读取成功!\ fin.close(); return true; }

void List::Delete() {

system(\ if(n > 0) {

int i,num_; bool ok = false;

cout<<\现有的设备编号如下:\for (i = 0 ; i < n ; i++) { }

cout<

cout<getNum()<<\

int num_,amount_,y,m,d; double prrice_;

char name_[20],factory_[30],notes_[101]; n = 0; while(size != 1) { }

fin>>num_; fin>>name_; fin>>factory_; fin>>y>>m>>d; if(fin.eof()) break; Date date_(y,m,d); fin>>amount_; fin>>prrice_; fin>>notes_;

elem[n] = new Equipment(num_,name_,amount_,prrice_); elem[n]->give(factory_,date_,notes_); n++;

cout<<\找不到文件,读取失败!\return false;

cout<<\请选择您要删除的设备编号:\cin>>num_; for (i = 0 ; i < n ; i++) {

if(elem[i]->getNum()==num_) {

ok = true; system(\elem[i]->output();

cout<<\您确定要删除此设备? (Y or N)\char str; do {

cin>>str;

if(str != 'Y' && str != 'N') { }

cout<<\输入错误,请重新输入:\

} while (str != 'Y' && str != 'N'); if(str == 'Y') { }

else cout<<\删除失败!\

ofstream fout;

fout.open(\fout.app;

elem[i]->foutput(fout); fout.close(); if(i == n-1) { } else { } n--;

cout<<\删除成功!\

Equipment *tem; tem = elem[i]; elem[i] = elem[n-1]; elem[n-1] = tem; delete [] elem[n-1]; elem[n-1] = NULL; delete [] elem[i]; elem[i] = NULL;

}

else cout<<\现无任何设备!\}

void List::Recover() { int size; ifstream fin;

fin.open(\ streampos pos = fin.tellg(); fin.seekg(0,ios::end); size = fin.tellg(); fin.seekg(pos); if(fin.fail()) { } else {

int num_,amount_,y,m,d; double prrice_;

char name_[20],factory_[30],notes_[101]; while(!fin.eof() && size != 1) { }

cout<<\恢复成功!\fin.close(); ofstream fout;

fout.open(\

fin>>num_; fin>>name_; fin>>factory_; fin>>y>>m>>d; if(fin.eof()) break; Date date_(y,m,d); fin>>amount_; fin>>prrice_; fin>>notes_;

elem[n] = new Equipment(num_,name_,amount_,prrice_); elem[n]->give(factory_,date_,notes_); n++;

cout<<\找不到文件,恢复失败!\ }

if(!ok) cout<<\您的输入有误!\

}

868sp3jjtj3blzb1bwa62p7v43zg0p00hx0
领取福利

微信扫码领取福利

微信扫码分享