⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arraydriver.cc

📁 C++ class and storage
💻 CC
字号:
//ECE106 Lab#5//Name: Mo Li//Student#: 995447379//Date:Mar.09,2007#include<iostream>#include<string>#include"arrayDB.h"using namespace std;studentDB database;int main(){   string command;   cin >> command;   while(!cin.eof())   {  if(command=="new"||command=="New")   {      int StuNum;      cin>>StuNum;      studentRecord* temp_ptr=new studentRecord;      temp_ptr->setStudentNumber(StuNum);      if(!database.insert(temp_ptr))      {         cout<<"Error: a record with student number "<<StuNum<<" already exists.\n";         delete temp_ptr;      }   }    else if(command=="locate"||command=="Locate")   {      int StuNum;      cin>>StuNum;      studentRecord* temp_ptr=new studentRecord;      if(database.retrieve(StuNum, temp_ptr))      temp_ptr->print();      else      cout <<"Error: no record with student number "<<StuNum<<" exists.\n";   }   else if(command=="updatename"||command=="Updatename")   {      int StuNum;      string lname, fname;      cin>>StuNum>>lname>>fname;      studentRecord* temp_ptr=new studentRecord;      if(database.retrieve(StuNum, temp_ptr))      {          temp_ptr->setLastName(lname);          temp_ptr->setFirstName(fname);          temp_ptr->print();          database.remove(StuNum);          database.insert(temp_ptr);      }      else      cout <<"Error: no record with student number "<<StuNum<<" exists.\n";   }       else if(command=="updatemark"||command=="Updatemark")   {      int StuNum, idx, mark;      cin>>StuNum>>idx>>mark;      studentRecord* temp_ptr=new studentRecord;      if(!database.retrieve(StuNum, temp_ptr))       cout <<"Error: no record with student number "<<StuNum<<" exists.\n";           else if(idx<0||idx>4)      cout<<"Error: "<<idx<<" is out of the range 0-4.\n";      else if(mark<0||mark>100)      cout<<"Error: "<<mark<<" is out of the range 0-100.\n";      else      {         temp_ptr->setMark(idx, mark);         temp_ptr->print();         database.remove(StuNum);         database.insert(temp_ptr);      }    }   else if(command=="delete"||command=="Delete")   {      int StuNum;      cin>>StuNum;      if(!database.remove(StuNum))      cout <<"Error: no record with student number "<<StuNum<<" exists.\n";     }         else if(command=="printall"||command=="Printall")   {      if(!database.isEmpty())      database.dump();      else      cout<<"Error: database is empty.\n";   }   else if(command=="printprobes"||command=="Printprobes")   {      int StuNum;      cin>>StuNum;      studentRecord* temp_ptr;      if(database.retrieve(StuNum, temp_ptr))      database.printProbes();      else      cout <<"Error: no record with student number "<<StuNum<<" exists.\n";     }         else if(command=="deleteall"||command=="Deleteall")   database.clear();            cin>>command;   }   return 0;}   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -