当前位置: 首页>>代码示例>>C++>>正文


C++ Student::getApplications方法代码示例

本文整理汇总了C++中Student::getApplications方法的典型用法代码示例。如果您正苦于以下问题:C++ Student::getApplications方法的具体用法?C++ Student::getApplications怎么用?C++ Student::getApplications使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Student的用法示例。


在下文中一共展示了Student::getApplications方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleAssignPressed

void MenuStartAdmin::handleAssignPressed(Button *pButton) {
    MenuStartAdmin::instance()->erase();
    
    //Get a course selection from user
    
    //Get course list
    const std::string* courses;
    int count;
    Database::instance()->getCourses(&courses, count);
    //Show dialog
    DialogListSelector *pCourseSelector = new DialogListSelector("Assign TA: Select a Course", courses, count);
    if (pCourseSelector->show() != STATE_SUCCESS) {
        delete pCourseSelector;
        MenuStartAdmin::instance()->draw();
        return;
    }
    std::string strCourse = pCourseSelector->getSelectedValue();
    delete pCourseSelector;
    
    //Show list of applications
    
    Queue<TaApplication*>* pApplications = Database::instance()->getApplications(strCourse);
    if (pApplications == 0 || pApplications->isEmpty()) {
        DialogYesNo* pMsg = new DialogYesNo("No applicants available for " + strCourse, DIALOG_MESSAGE);
        pMsg->show();
        delete pMsg;
        MenuStartAdmin::instance()->draw();
        return;
    }
    //Create str[] from queue for listDialog
    std::string* pStrApplications = new std::string[pApplications->getSize()];
    Node<TaApplication*>* pCur = pApplications->front();
    int i = 0;
    while (pCur != 0) {
        if (pCur->value->getStatus() == STATUS_PENDING) {
            pStrApplications[i] =  pCur->value->getStudentID();
            i++;
        }
        pCur = pCur->m_pNext;
    }
    if (i == 0) {
        //No applicants pending
        DialogYesNo* pMsg = new DialogYesNo("No applicants available for " + strCourse, DIALOG_MESSAGE);
        pMsg->show();
        delete pMsg;
        MenuStartAdmin::instance()->draw();
        return;
    }
    //Show the dialog
    DialogListSelector *pDia = new DialogListSelector("Assign TA: Select an Applicant", pStrApplications, i);
    if (pDia->show() != STATE_SUCCESS) {
        delete pDia;
        delete [] pStrApplications;
        MenuStartAdmin::instance()->draw();
        return;
    }
    std::string strApplication = pDia->getSelectedValue();
    delete [] pStrApplications;
    delete pDia;
    
    //Get the selected application
    
    TaApplication* pApp = 0;
    pCur = pApplications->front();
    while (pCur != 0) {
        if (strApplication.find(pCur->value->getStudentID()) != std::string::npos) {
            pApp = pCur->value;
        }
        pCur = pCur->m_pNext;
    }
    if (pApp == 0) {
        MenuStartAdmin::instance()->draw();
        return;
    }
    Student *pStu = Database::instance()->getStudent(pApp->getStudentID());
    if (pStu == 0) {
        return;
    }
    if (pStu->getApplications() != 0 && pStu->getApplications()->getSize() > 1) {
        pCur = pStu->getApplications()->front();
        while (pCur != 0) {
            if (pCur->value != pApp) {
                pCur->value->setStatus(STATUS_CLOSED);
                pCur->value->saveToFile();
            }
            pCur = pCur->m_pNext;
        }
    }
    pApp->setStatus(STATUS_ACCEPTED);
    pApp->saveToFile();
    DialogYesNo* pMsg = new DialogYesNo("Student " + pApp->getStudentID() + " has been assigned as TA.", DIALOG_MESSAGE);
    pMsg->show();
    delete pMsg;
    MenuStartAdmin::instance()->draw();
}
开发者ID:ShawnEllis,项目名称:CuTAES,代码行数:95,代码来源:MenuStartAdmin.cpp


注:本文中的Student::getApplications方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。