-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab3.cpp
128 lines (114 loc) · 2.56 KB
/
lab3.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// Created by amir_poudel on 1/12/2022.
//
//Problem: Development of ticket booking module for a day of typical Cinema hall.
#include "iostream"
#include "fstream"
using namespace std;
//creating Node for linked list
template<typename T>
class Node{
public:
T ticketType;
T phoneNumber;
T arrivalTime;
Node<T>* next;
Node(T ticketType,T phoneNumber,T arrivalTime){
this->ticketType=ticketType;
this->phoneNumber=phoneNumber;
this->arrivalTime=arrivalTime;
this->next=NULL;
}
};
//creating Queue
template<typename T>
class Queue{
int size;
Node<T>*head;
Node<T>*tail;
public:
Queue(){
head=NULL;
tail=NULL;
size=0;
}
int getSize(){
return size;
}
void enqueue(T ticketType,T phoneNumber,T arrivalTime){
Node<T>*node=new Node(ticketType,phoneNumber,arrivalTime);
if(head==NULL){
head=node;
tail=node;
} else{
tail->next=node;//inserting at tail
tail=tail->next;
}
size++;
}
bool isEmpty(){
return size==0;
}
T front(){
return head->data;
}
void dequeue(){
if(!isEmpty()){
Node<T>*tempHead=head;
head=head->next;
tempHead=NULL;
delete tempHead;
}else{
cout<<"Queue is Empty";
}
}
};
//class for store customer data;
class Customer{
private:
string ticketType;
long phoneNumber;
long arrivalTime;
public:
//constructor for adding data in customer
Customer(string ticketType,long phoneNumber,long arrivalTime){
this->ticketType=ticketType;
this->phoneNumber=phoneNumber;
this->arrivalTime=arrivalTime;
}
void showTicket(){
cout<<ticketType;
}
void showPhoneNumber(){
cout<<phoneNumber;
}
void showArrivalTime(){
cout<<arrivalTime;
}
void setTicketType(string ticketType){
this->ticketType=ticketType;
}
void setPhoneNumber(long phoneNumber){
this->phoneNumber=phoneNumber;
}
void setArrivalTime(long arrivalTime){
this->arrivalTime=arrivalTime;
}
};
int main(){
fstream file;
file.open("../Lab/ticketData.txt",ios::in);
if(file.is_open()){
string data;
long phoneNumber,arrivalTime;
string ticketType;
getline(file,data,',');
getline(file,ticketType,',');
cout<<data;
cout<<endl<<ticketType;
} else{
cout<<"file is not open";
}
file.close();
return 0;
}