#include <iostream>
#include <string>

//#include "Object.h"
#include "set.h"
#include "set.cpp"

using namespace std;
using namespace uprm_icom4035;


void print_menu();
int get_option();
void add_student(set<string>& i6005, set<string>& i4035);
void add_section(set<int>& sec6005, set<int>& sec4035);
void remove_student(set<string>& i6005, set<string>& i4035);
void print_report(set<string>& i6005, set<string>& i4035);
void print_secreport(set<int>& sec6005, set<int>& sec4035);

int main(){
  int opt = 0;
  set<string> i6005, i4035;
  set<int> sec4035, sec6005;
  
  cout << "Students information program for ICOM 6005 & ICOM 4035" << endl;
  do {
    print_menu();
    opt = get_option();
    if (opt == 1){
      add_student(i6005, i4035);
    }
    else if (opt == 2){
      remove_student(i6005, i4035);
    }
    else if (opt == 3){
      print_report(i6005, i4035);
    }
    else if (opt == 4){
      add_section(sec6005, sec4035);
    }
    else if (opt == 5){
      print_secreport(sec6005, sec4035);
    }
  }
  while(opt != 6);
  cout << "Thanks for using this program!" << endl;
  exit(0);
}

 
void print_menu(){
  cout << "Menu of actions: " << endl;
  cout << "\t 1. Add Student" << endl;
  cout << "\t 2. Remove Student" << endl;
  cout << "\t 3. Print Report Student" << endl;
  cout << "\t 4. Add Section" << endl;
  cout << "\t 5. Print Report Sections" << endl;
  cout << "\t 6. Exit" << endl;
}

int get_option(){
  string str;
  cout << "Enter the option: ";
  cin >> str;
  if (str == "1"){
    return 1;
  }
  else if (str == "2"){
    return 2;
  }
  else if (str == "3"){
    return 3; 
  }
  else if (str == "4"){
    return 4;
  }
  else if (str == "5"){
    return 5;
  }
  else if (str == "6"){
    return 6;
  }
  else {
    cout << "Illegal Option : " << str << endl;
    return -1;
  }
}
   
void print_courses(){
  cout << "Courses Options: " << endl;
  cout << "\t 1. ICOM 6005 " << endl;
  cout << "\t 2. ICOM 4035 " << endl;
}
void add_student(set<string>& i6005, set<string>& i4035){
  string opt, std;
  
  print_courses();
  cout << "Enter the option: ";
  cin >> opt;
  if (opt == "1"){
    cout << "Enter the name: ";
    cin >> std;
    i6005.insert(std);
    cout << "Student " << std << " added to ICOM 6005." << endl;
  }
  else if (opt == "2"){
    cout << "Enter the name: ";
    cin >> std;
    i4035.insert(std);
    cout << "Student " << std << " added to ICOM 4035." << endl;
   
  }
  else {
    cout << "Illegal option: " << opt << endl;
  }
}

void add_section(set<int>& sec6005, set<int>& sec4035){
  string opt;
  int std;
  
  print_courses();
  cout << "Enter the option: ";
  cin >> opt;
  if (opt == "1"){
    cout << "Enter the number: ";
    cin >> std;
    sec6005.insert(std);
    cout << "Section " << std << " added to ICOM 6005." << endl;
  }
  else if (opt == "2"){
    cout << "Enter the section: ";
    cin >> std;
    sec4035.insert(std);
    cout << "Section " << std << " added to ICOM 4035." << endl;
   
  }
  else {
    cout << "Illegal option: " << opt << endl;
  }
}


void remove_student(set<string>& i6005, set<string>& i4035){
  string opt, std;
  
  print_courses();
  cout << "Enter the option: ";
  cin >> opt;
  if (opt == "1"){
    cout << "Enter the name: ";
    cin >> std;
    i6005.erase(std);
    cout << "Student " << std << " erased to ICOM 6005." << endl;
  }
  else if (opt == "2"){
    cout << "Enter the name: ";
    cin >> std;
    i4035.erase(std);
    cout << "Student " << std << " erased to ICOM 4035." << endl;
   
  }
  else {
    cout << "Illegal option: " << opt << endl;
  }
}

void print_report(set<string>& i6005, set<string>& i4035){
  set<string> temp;
  
  cout << endl;
  cout << "********************************************************"<< endl;
  cout << "Students in ICOM 6005: ";
  i6005.print(cout);
  cout << endl;
  cout << "Students in ICOM 4035: " ;
  i4035.print(cout);
  cout << endl;
  cout << "All students: " ;
  temp = i6005 + i4035;
  temp.print(cout);
  cout << endl;
  cout << "Student in both courses: ";
  temp = i6005 & i4035;
  temp.print(cout);
  cout << endl;
  cout << "Student in ICOM 6005 but not in ICOM 4035: ";
  temp = i6005 - i4035;
  temp.print(cout);
  cout << endl;
  cout << "Student in ICOM 4035 but not in ICOM 6005: ";
  temp = i4035 - i6005;
  temp.print(cout);
  cout << endl;
  cout << "********************************************************"<< endl;
  cout << endl;
  
}

void print_secreport(set<int>& sec6005, set<int>& sec4035){
  set<int> temp;
  
  cout << endl;
  cout << "********************************************************"<< endl;
  cout << "Sections in ICOM 6005: ";
  sec6005.print(cout);
  cout << endl;
  cout << "Sections in ICOM 4035: " ;
  sec4035.print(cout);
  cout << endl;
  cout << "All sections: " ;
  temp = sec6005 + sec4035;
  temp.print(cout);
  cout << endl;
  cout << "********************************************************"<< endl;
  cout << endl;
  
}
