tickets.cpp
#include <iostream>
using namespace std;
//Party class
class Party{
public:
char p_code;
string addr;
string p_no;
};
//Person class with attributes
class Person{
public:
string dob;
string fname;
string lname;
};
//Passenger class , inherited Person and party class
properties
class Passenger : public Person, public Party{
int ticket_no;
string ffn="N/A";
int ticket_price;
int flight_no;
int seat_loc;
string flight_date;
char status='H';
public:
void purchar_ticket();
void change_seat();
void cancel_ticket();
void print();
};
//purchase ticket functions
void Passenger ::purchar_ticket(){
//get input from user and store
cout<<"\nEnter the Party code 'P' =person, 'O' =
organization:";
cin>> p_code;
//if party code is O
if(p_code== 'O'){
cout<<"\nEnter the organization address: ";
cin>> addr;
cout <<"\nEnter the phone number: ";
cin>> p_no;
}
//if party code is P
if(p_code=='P'){
cout<<"\nEnter your date of birth: ";
cin>>dob;
cout<<"\nEnter your First name: ";
cin>>fname;
cout<<"\nEnter your last name: ";
cin>>lname;
}
//get other details
cout<<"\nEnter the flight number: ";
cin>>flight_no;
cout<<"\nEnter your flight date : ";
cin>>flight_date;
cout<<"\nEnter the seat location: ";
cin>>seat_loc;
// set the other values
ticket_no=1001;
status='T';
ticket_price =10000;
cout<<"\n\n Ticket has been booked successfully!!!\n\n";
//print the ticket:
print();
}
//change seat function
void Passenger ::change_seat(){
//get the new seat number from user
cout << "\n Enter the seat number";
cin>>seat_loc;
cout<<"\n\n Seat number has been changed successfully
!!!\n\n";
print();
}
//cancel ticket function
void Passenger ::cancel_ticket(){
status= 'C';
cout<<"\n\n Ticket has been canceled
successfully!!!\n\n";
print();
}
//print the ticket
void Passenger ::print(){
if(p_code=='P'){
cout<<"\n\n\nTicket_no FirstName LastName FrequentFlyerNo
Ticket Price FlightNo SeatLocation FlightDate Status\n\n";
cout<<ticket_no<<" "<<fname<<"
"<<lname<<" "<<ffn<<"
"<<ticket_price<<" "<<flight_no<<"
"<<seat_loc<<" "<<flight_date<<"
"<<status;
}
if(p_code=='O'){
cout<<"\n\n\nTicket_no Address PhoneNo FrequentFlyerNo Ticket
Price FlightNo SeatLocation FlightDate Status\n\n";
cout<<ticket_no<<" "<<addr<<"
"<<p_no<<" "<<ffn<<"
"<<ticket_price<<" "<<flight_no<<"
"<<seat_loc<<" "<<flight_date<<"
"<<status;
}
}
int main()
{
char s_ch,c_ch;
Passenger p;
cout<<"\nPurchase Ticket:\n";
p.purchar_ticket();
cout<<"\n\n Do you want to change the seat location ('y' for
Yes or 'n' for No): ";
cin>>s_ch;
if(s_ch=='y'){
p.change_seat();
}
cout<<"\n\n Do you want to cancel the ticket ('y' for Yes or
'n' for No): ";
cin>>c_ch;
if(c_ch=='y'){
p.cancel_ticket();
}
return 0;
}
output:
//for any clarification or modification ofc ode please do comments.
Consider the Passenger data structure we discussed during the last class. Instead of using "struct", we...
C++ project we need to create a class for Book and Warehouse
using Book.h and Warehouse.h header files given. Then make a main
program using Book and Warehouse to read data from book.dat and
have functions to list and find book by isbn
Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...
Assignment Requirements
I have also attached a Class Diagram that describes the
hierarchy of the inheritance and interface behaviors . The link to
the PDF of the diagram is below
MotorVehical.pdf
Minimize File Preview
User Define Object Assignment:
Create a Intellij Project. The
Intellij project will contain three user defined
classes. The project will test two of the User Define Classes by
using the invoking each of their methods and printing the
results.
You are required to create three UML...
code in java please:)
Part I Various public transporation can be described as follows: A PublicTransportation class with the following: ticket price (double type) and mumber of stops (int type). A CityBus is a PublicTransportation that in addition has the following: an route number (long type), an begin operation year (int type), a line name (String type), and driver(smame (String type) -A Tram is a CityBus that in addition has the following: maximum speed (int type), which indicates the maximum...