-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicket.cpp
More file actions
73 lines (62 loc) · 1.86 KB
/
Ticket.cpp
File metadata and controls
73 lines (62 loc) · 1.86 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
//
// Ticket.cpp
// Final Project
//
// Created by Ainur Aman on 2021. 04. 19..
//
#include <stdio.h>
#include "Ticket.h"
#include <fstream>
#include "airplane.h"
Ticket:: Ticket(){ //Default constructor of Ticket class
ticketid=0;
fnum=0;
name="";
surname="";
passportID="";
dateofbirth="";
phonenumber="";
email="";
}
Ticket:: Ticket(const Ticket& theOther){ //CopyConstructor of Ticket class
ticketid=theOther.ticketid;
fnum=theOther.fnum;
name=theOther.name;
surname=theOther.surname;
passportID=theOther.passportID;
dateofbirth=theOther.dateofbirth;
phonenumber=theOther.phonenumber;
email=theOther.email;
}
Ticket& Ticket:: operator = ( Ticket &theOther){ //operator overloading to assign one ticket to another easily
Ticket t(theOther);
return t;
}
std::istream& operator >> (istream& is, Ticket& t) //operator overloading to get ticket info easily
{
t.ticketid=0;
t.fnum=0;
cout << "\t\t\t\tPlease enter your personal information to make a reservation" << endl;
cout << "\t\t\t\tName: ";
is >> t.name;
cout << "\t\t\t\tSurname: ";
is >> t.surname;
cout << "\t\t\t\tPassport ID: ";
is >> t.passportID;
cout << "\t\t\t\tDate of birth: ";
is >> t.dateofbirth;
cout << "\t\t\t\tPhone number: ";
is >> t.phonenumber;
cout << "\t\t\t\tEmail: ";
is >> t.email;
cout<<endl;
return is;
}
std::ostream& operator<<(ostream& os, Ticket& t){ //operator overloading to print ticket info easily
if(t.ticketid==0 && t.fnum==0){
os<<" "<<t.name<<" "<<t.surname <<" "<<t.passportID <<" "<<t.dateofbirth <<" "<<t.phonenumber <<" "<<t.email <<" "<<endl;
}else{
os<<" "<<t.ticketid <<" "<<t.fnum <<" "<<t.name<<" "<<t.surname <<" "<<t.passportID <<" "<<t.dateofbirth <<" "<<t.phonenumber <<" "<<t.email <<" "<<endl;
}
return os;
}