-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpassageway.cpp
57 lines (51 loc) · 1.33 KB
/
passageway.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
56
57
#include"parking.h"
#include<iostream>
#include<iterator>
using std::cout;
using std::endl;
void Passageway::enterWay(Car* car)
{
passageway.push_back(car);
extern QLabel* l3;
l3->setText(QString::number(passageway.size()));
}
void Passageway::leaveWay()
{
passageway.pop_front();
extern QLabel* l3;
l3->setText(QString::number(passageway.size()));
}
Car* Passageway::getFront() const
{
return *(passageway.begin());
}
int Passageway::countCar() const
{
return passageway.size();
}
bool Passageway::findCar(const string& id, bool print) const
{
extern QString state;
for (deque<Car*>::const_iterator i = passageway.begin(); i != passageway.end(); i++)
if ((*i)->getNumber() == id)
{
if (print)
state="便道";
//cout << "Car " << id << " is in the passageway" << endl;
return true;
}
return false;
}
void Passageway::show(QTextBrowser* text) const
{
if (passageway.size() == 0)
return;
//cout << "(empty)" << endl;
else
{
for (deque<Car*>::const_iterator i = passageway.begin(); i != passageway.end(); i++)
text->append(QString::fromStdString((*i)->getNumber()));
//cout << (*i)->getNumber() << endl;
//cout << "(" << passageway.size() << " car(s))" << endl;
}
}