#ifndef MAIN_C#define MAIN_C#include #include #include #include #include #include #include “Teacher.h“int main (){ cout << “Welcome to Teacher‘s Course Elect System!\n“ << endl; string course_name; int course_id; int course_weekly_hours; int course_total_hours; int course_priority; multimap < int COURSE* mycompare > courses; cout << “Enter course name: “ << endl; while (cin >> course_name) { if (course_name.compare(“0“) == 0) { break; } cout << “Enter course number: “ << endl; cin >> course_id; cout << “Enter course weekly hours: “ << endl; cin >> course_weekly_hours; cout << “Enter course total hours: “ << endl; cin >> course_total_hours; if (course_total_hours < course_weekly_hours) { cerr << “ERROR: total hours should be greater than weekly hours!“ << endl; cout << “Enter course total hours: “ << endl; cin >> course_total_hours; } cout << “Enter course priority: “ << endl; cin >> course_priority; COURSE* c = new COURSE(course_name course_id course_weekly_hours course_total_hours course_priority); courses.insert(pair(course_priority c)); cout << “Enter next course name (0 to end): “ << endl; } multimap < int COURSE* mycompare >::iterator it; cout << “Summary of courses: “ << endl; for ( it = courses.begin(); it != courses.end(); it++) { cout << “Course number: “ << it->second->get_course_number() << “ Course name: “ << it->second->get_course_name() << “ Course priority: “ << it->second->get_course_priority() << “ Weekly hours: “ << it->second->get_weekly_hours() << “ Total hours: “ << it->second->get_total_hours() << endl; } cout << endl; map < int TEACHER* > teachers; string teacher_name; int teacher_id; int desired_total_hours; int expectation; cout << “Enter teacher‘s information: “ << endl << endl; cout << “Enter teacher‘s name: “ << endl; while (cin >> teacher_name) { if (teacher_name.compare(“0“) == 0) break; cout << “Enter teacher‘s id: “ << endl; cin >> teacher_id; cout << “Enter teacher “ << teacher_name << “‘s desired work hours: “ << endl; cin >> desired_total_hours; TEACHER* t = new TEACHER(teacher_name teacher_id desired_total_hours); cout << “Enter teacher “ << teacher_name << “‘s course selection: “ << endl; cout << “Course name: “ << endl; while (cin >> course_name) { if (course_name.compare(“0“) == 0) break; bool found = false; for ( it = courses.begin(); it != courses.end(); it++) { if (it->second->get_course_name() == course_name) { found = true; break; } } if (!found) { cerr << “Selected course is not offered. Enter another course!“ << endl; continue; }
共有 条评论
评论
共有 条评论