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


C++ Assignment::setDescription方法代码示例

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


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

示例1: main

int main()
{

    bool quit = false;
    ifstream inputFile;
    ofstream outputFile;
    string filename;
    cout << "Assignment Manager" << endl << endl; // Title.
    char menuChoice = '9'; // Force the filename prompt.
    AssignmentFile assignments;

    // Loop the program until the user quits.
    while (!quit)
    {

        if (menuChoice == '9') // Prompt for the filename.
        {
            while (filename == "")
            {
                cout <<
                    "Enter the name of the assignment file (or 'q' to quit): ";
                cin >> filename;
                cout << endl;
                if (filename == "q" || filename == "Q")
                    // Allow the user to quit here.
                {
                    quit = true;
                    exit(0);
                }
                inputFile.open(filename);
                if (!inputFile) // If the file does not exist, create it.
                {
                    outputFile.open(filename);
                    if (!outputFile) // If the name is invalid:
                    {
                        cout << "Error: Cannot write to file." << endl << endl;
                        filename = "";
                    }
                    outputFile.close();
                }
                assignments.read(inputFile);
                    // Read the assignment data, if any.
                inputFile.close();
            }
        }

        displayMenu();
        string menuChoiceStr;
        cin >> menuChoiceStr;
        menuChoice = menuChoiceStr[0]; // Only use the first input character.
        cout << endl;

        // Create assignment variables to be populated.
        Assignment newAssignment;
        string inputAssignedDate;
        string inputDueDate;
        string inputCompletedDate;
        string inputDescription;
        string inputStatus;

        switch(menuChoice)
        {

            case '1': assignments.completed.displayAll(cout); 
                assignments.uncompleted.displayAll(cout);
                cout << endl; break;

            case '2': cout << "Enter the assigned date: ";
                cin >> inputAssignedDate;
                cout << endl << "Enter the description (no spaces): ";
                cin >> inputDescription; // Assumes the user does not enter spaces.
                cout << endl << "Enter the due date: ";
                cin >> inputDueDate;
                cout << endl << "Enter the status (assigned/completed/late): ";
                cin >> inputStatus;
                    // Take assignment data from the user.
                newAssignment.setAssignedDate(inputAssignedDate);
                newAssignment.setDueDate(inputDueDate);
                newAssignment.setDescription(inputDescription);
                newAssignment.setStatus(assignments.convertStatus(inputStatus));
                    // Create the assignment.
                if (!assignments.uncompleted.addAssignment(newAssignment))
                    // Add the assignment to the uncompleted list, if possible.
                    cout << endl << "Cannot add assignment" << endl;
                cout << endl;
                break;

            case '3': cout << "Enter the assigned date: ";
                cin >> inputAssignedDate;
                cout << endl << "Enter the new due date: ";
                cin >> inputDueDate;
                cout << endl;
                    // Take the new data from the user.
                if (!assignments.uncompleted.editAssignment(inputAssignedDate, "", inputDueDate))
                    // Edit the uncompleted assignment, if possible.
                    cout << "Cannot edit assignment" << endl << endl;
                break;

            case '4': cout << "Enter the assigned date: ";
                cin >> inputAssignedDate;
//.........这里部分代码省略.........
开发者ID:aledgin,项目名称:cs303project1,代码行数:101,代码来源:main.cpp


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