Exemplo n.º 1
0
void inline mainmenu(unsigned char input)
{
    switch(input)
    {
        case 'a':
            scheduler.autoassign();
            state = MAIN;
            break;
        case 'b':
            state = SHIFT;
            break;
        case 'c':
            state = STUDENT;
            break;
        case 'd':
            scheduleToXLS(scheduler,output);
            output.Dump(filepath);
            state = MAIN;
            break;
        case 'z':
            state = EXIT;
            break;
    }

}
Exemplo n.º 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;
}