C++实现停车场管理系统(3)

WaitQueue->head->next = q->next;
            if (q == WaitQueue->rear)
                WaitQueue->rear = WaitQueue->head;
            CarBase->CarStack[CarBase->top] = t;
            free(q);
        }
        else cout << "便道里没有车..." << endl;
    }
    else cout << "挺车场里没有车..." << endl;
}

void CarSystem::ShowLeaveInfo(CarNode *p, int room)    //汽车离站时缴费显示
{
    CTime end_time = CTime::GetCurrentTime();
    p->leave.year = end_time.GetYear();
    p->leave.month = end_time.GetMonth();
    p->leave.day = end_time.GetDay();
    p->leave.hour = end_time.GetHour();
    p->leave.min = end_time.GetMinute();
    printf("\n离开车辆的车牌号为:");
    cout << p->num;
    cout << "\n到达时间为: " << p->reach.year << " 年 " << p->reach.month << " 月 " << p->reach.day << " 日 " << p->reach.hour << " 时  " << p->reach.min << " 分";
    cout << "\n离开时间为: " << p->leave.year << " 年 " << p->leave.month << " 月 " << p->leave.day << " 日 " << p->leave.hour << " 时  " << p->leave.min << " 分";
    cout << "\n应交费用为: " << ((p->leave.hour - p->reach.hour) * 60 + (p->leave.min - p->reach.min)) * 100 << " 元";
    free(p);
}

void CarSystem::QueueCarLeave(char a[])    //便道中的车直接离开
{
    QCarNode *p,*q;
    p = WaitQueue->head->next;
    q = WaitQueue->head;
    if (WaitQueue->head != WaitQueue->rear)
    {
        while (strcmp(p->data->num, a) && p != NULL)
        {
            q = p;
            p = p->next;
        }
        q->next = p->next;
        free(p);
    }
    else
    {
        cout << "便道中无车!" << endl;
    }
}

void CarSystem::ShowInfo()    //查询车位状态
{
    int choice = 0;
    cout << "请输入查看列表:" << endl;
    cout << "---  1.停车场车位状况    ---" << endl;
    cout << "---  2.便道停车位状况    ---" << endl;
    cout << "---  3.返回主菜单        ---" << endl;
    while (choice!=3)
    {
        while (1)
        {
            cin >> choice;
            if (choice >= 1 || choice <= 3) break;
            else cout << "请检查输入!" << endl;
        }
        switch (choice)
        {
        case 1:
            Carstack();
            break;
        case 2:
            Carqueue();
            break;
        case 3:
            return;
            break;
        default:
            break;
        }
    }
}

void CarSystem::Carstack()    //车场车位显示
{
    int i;
    if (CarBase->top>0)
    {
        cout << "停车场车位状态:";
        cout << "\n车位号\t" << "        到达时间    \t" << "车牌号\n";
        for (i = 1; i <= CarBase->top; i++)
        {
            cout << "  " << i << "\t  ";
            cout << CarBase->CarStack[i]->reach.year << "年" << CarBase->CarStack[i]->reach.month << "月" << CarBase->CarStack[i]->reach.day
                << "日" << CarBase->CarStack[i]->reach.hour << "时" << CarBase->CarStack[i]->reach.min << "分";
            cout << "\t  " << CarBase->CarStack[i]->num << endl;
        }
    }
    else cout << "\n车场里没有车";
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/51504bb524e497378398263fe3db3c5f.html