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

📄 listdriver.cc

📁 C++ class and storage
💻 CC
字号:
//listDriver.cc//ECE106 Lab#5//Name: Mo Li//Student#: 995447379//Date:Mar.09,2007#include<iostream>#include<string>#include "listDB.h"#include "studentRec.h"#include "listNode.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."<<endl;         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(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 if(!database.retrieve(stuNum, temp_ptr))      cout <<"Error: no record with student number "<<stuNum<<" exists.\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 + -