-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenterdialog.cpp
55 lines (51 loc) · 1.2 KB
/
enterdialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "enterdialog.h"
#include "ui_enterdialog.h"
#include "parking.h"
#include <QDebug>
enterDialog::enterDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::enterDialog)
{
ui->setupUi(this);
}
enterDialog::~enterDialog()
{
delete ui;
}
void enterDialog::on_buttonBox_2_accepted()
{
extern string id;
extern Car* carList[1000];
extern System sys;
extern int size, i, currentTime;
extern QString msg;
id=(ui->idInput->text()).toStdString();
currentTime=ui->timeInput->value();
msg="";
bool flag = false;
for (i = 0; i < size; i++)
{
if (carList[i]->getNumber() == id)
{
flag = true;
break;
}
}
if (flag)
sys.enterParking(*carList[i], currentTime);
else
{
carList[size] = new Car(id);
sys.enterParking(*carList[size], currentTime);
//cout<<"new "<<carList[size]->getNumber()<<endl;
size++;
}
((MainWindow*)(this->parentWidget()))->updateMessage(msg);
this->close();
}
void enterDialog::on_buttonBox_2_rejected()
{
this->close();
}