-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrinter.cpp
More file actions
74 lines (59 loc) · 1.49 KB
/
Printer.cpp
File metadata and controls
74 lines (59 loc) · 1.49 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<iostream>
#include<queue>
class Job{
private:
int JobNumber;
std::string name;
int pageNumber;
public:
static int JobCount;
public:
Job(std::string U,int P):JobNumber(++JobCount),name(U),pageNumber(P){}
friend std::ostream& operator<<(std::ostream&os ,const Job& J)
{
os<<"id: "<<J.JobNumber<<", name; "<<J.name<<", the number of Page: "<<J.pageNumber<<std::endl;
return os;
}
};
int Job::JobCount=0;
template<size_t N>
class Printer{
std::queue<Job>currnetPrint;
public:
bool addPrint(const Job& Jobs){
if(currnetPrint.size()==N){
std::cout<<"Woakload is full"<<Jobs<<std::endl;
return false;
}
std::cout<<"add Print:"<<Jobs<<std::endl;
currnetPrint.push(Jobs);
return true;
}
void PrintStart()
{
while(not currnetPrint.empty())
{
std::cout<<"is press"<<currnetPrint.front()<<std::endl;
currnetPrint.pop();
}
}
};
int main()
{
Printer<5> Printer;
Job j1("Lee",10);
Job j2("kim",3);
Job j3("park",14);
Job j4("oh",2);
Job j5("choi",6);
Job j6("Lee",8);
Printer.addPrint(j1);
Printer.addPrint(j2);
Printer.addPrint(j3);
Printer.addPrint(j4);
Printer.addPrint(j5);
Printer.addPrint(j6);
Printer.PrintStart();
Printer.addPrint(j6);
Printer.PrintStart();
}