예제 #1
0
void inline newcfg(Scheduler& schedule)
{
    cout<<"Enter a name for this configuration:: ";
    getline(cin,cfgname);
    cout<<endl;

    //Memory allocation for all the dates

    Date startDate;
    Date endDate;
    string datestring;
    cout<<"Enter the start date (<day #> <month> <year #> or <MMDDYYYY>)\n::";
    getline(cin,datestring);
    cout<<endl;
    while(!startDate.parseDateSet(datestring))
    {
        cout<<"Bad input. Examples: \"25 March 2015\", \"03252015\"\nEnter the start date (<day #> <month> <year #> or <MMDDYYYY>)\n::";
        getline(cin,datestring);
        cout<<endl;
    }
    cout<<"Enter the end date (<day #> <month> <year #> or <MMDDYYYY>)\n::";
    getline(cin,datestring);
    cout<<endl;
    while(!endDate.parseDateSet(datestring))
    {
        cout<<"Bad input. Examples: \"25 March 2015\", \"03252015\"\nEnter the end date (<day #> <month> <year #> or <MMDDYYYY>)\n::";
        getline(cin,datestring);
        cout<<endl;
    }


    //Student::setMaxShift(50);
    schedule.setMaxShifts(50);


    //Hard coded 6 students
    //Get memory for them
    string studentnames[6];
    for(int i = 0; i<6; i++)
    {
        cout<<"What is student "<<(i+1)<<"'s name?:: ";
        getline(cin,studentnames[i]);
        cout<<endl;
    }

    //Hard coded in
    string shiftnames[5] = {"Shift","Shift","Shift","Crash","Crash"};
    unsigned int shifttimes[5][2] = {{7,16},{15,24},{23,32},{7,16},{15,24}};

    schedule.init(cfgname,startDate,endDate,5,shiftnames,shifttimes,6,studentnames);

    schedule.autoblock();


    //And we're done initializing!
}
예제 #2
0
int main()
{
    #if(DEBUG == TESTCASE)
    cout<<"Hello world"<<endl;

    Scheduler scheduler;
    Date dateStart,dateEnd;
    dateStart.setDate(22,Date::SEP,2014);
    dateEnd.setDate(17,Date::OCT,2014);
    scheduler.setMaxShifts(50);
    scheduler.setMinShifts(12);
    string shiftnames[5] = {"Shift","Shift","Shift","Crash","Crash"};
    unsigned int shifttimes[5][2] = {{7,16},{15,24},{23,32},{7,16},{15,24}};
    string studentnames[6] = {"A","B","C","D","E","F"};
    scheduler.init("yayaya",dateStart,dateEnd,5,shiftnames,shifttimes,6,studentnames);

    cout<<"Autoassigning..."<<endl;
    cout<<"Wow such autoassign"<<endl;
    scheduler.autoblock();
//    scheduler.shiftList[0].block("Arbitrary");
    if(!scheduler.autoassign())
    {
        cout<<"Too many shifts for students to fulfill with their maximum"<<endl;
    }
    //cout<<scheduler.toString()<<endl;
    for(int i = 0; i <scheduler.getStudentNum(); i++)
    {
        cout << (scheduler.students()[i]).getShiftCount() << endl;
    }
    /*
    for(int i = 0; i < scheduler.getShiftNum(); i++)
    {
        cout<<scheduler.shifts()[i].toString()<<endl;
        for(int j = 0; j<0xFFFFFFF; j++);
    }
     */

    workbook wb;
    scheduleToXLS(scheduler,wb);

    wb.Dump("C:/temp/schedule.xls");


    ofstream fileo;
//    fileo.open("C:/temp/schedule.schd");
    fileo.open("C:/temp/schedule.schd", ios_base::out |ios_base::binary);
    scheduler.streamOutBinary(fileo);
    fileo.close();

    ifstream filei;
    filei.open("C:/temp/schedule.schd", ios_base::in |ios_base::binary);
//    filei.open("C:/temp/schedule.schd");
    scheduler.streamInBinary(filei);
    filei.close();

    cout<<scheduler.toString()<<endl;
    cout<<"Load complete"<<endl;


    fileo.open("C:/temp/schedule-copy.schd", ios_base::out |ios_base::binary);
//    fileo.open("C:/temp/schedule-copy.schd");
    scheduler.streamOutBinary(fileo);
    fileo.close();

    cout<<"Export 2 complete"<<endl;

    vector<Shift*> shiftvector;

    Shift::findShiftsWithDate(&shiftvector,&scheduler.dates()[0],scheduler.shifts(),scheduler.getShiftNum());
    for(int i =0; i<shiftvector.size(); i++)
    {
        cout<<shiftvector[i]->toString()<<endl;
    }

    cin.get();

    #elif (DEBUG == TEST)

    Student test1,test2,test3,test4;
    test1.setID(25);
    test1.setName("Chips");
    test2.setID(43);
    test2.setName("Icecream");

    ofstream fileo;

    fileo.open("test.student");
    test1.streamOutBinary(fileo);
    test2.streamOutBinary(fileo);
    fileo.close();

    ifstream filei;

    filei.open("test.student");
    test3.streamInBinary(filei);
    test4.streamInBinary(filei);
    filei.close();

    cout<<"This is test3:\n"<<test3.toString()<<endl;
    cout<<"This is test4:\n"<<test4.toString()<<endl;

    #else
    //Main logic
    while(state != EXIT)
    {
        switch (state)
        {
            case START:
                start(promptStart());
                break;
            case MAIN:
                mainmenu(promptMain());
                break;
            case EXIT:
                break;
        }
    }

    #endif
    cout<<"Goodbye..."<<endl;

    //Free that memory!


    //cin.get();
    return 0;
}