0% found this document useful (0 votes)
18 views

Oop Assignment

This C++ program models an airline management system using object-oriented principles. It defines classes to represent transactions, customers, crew members, ticket reservations, and payments. These classes are used to create objects that store sample data and demonstrate calling methods like adding, updating, and calculating. The main function brings together these classes and objects to represent the overall airline management system.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Oop Assignment

This C++ program models an airline management system using object-oriented principles. It defines classes to represent transactions, customers, crew members, ticket reservations, and payments. These classes are used to create objects that store sample data and demonstrate calling methods like adding, updating, and calculating. The main function brings together these classes and objects to represent the overall airline management system.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name:Abdullah Nasir ACS223050

Assignment no 4:

Code:
#include <iostream>
#include <string>

using namespace std;

class Transaction {
private:
int id;

public:
string details;
string listOfDishes;

int getId() const {


return id;
}

void setId(int value) {


id = value;
}

void add() {

void update() {

}
};

class Customer {
public:
string address;
string reservation;
string details;

virtual void add() {

virtual void update() {

}
};

class Crew {
private:
int id;
string name;

public:
string age;
string contactNumber;
string userName;
string password;

int getId() const {


return id;
}

void setId(int value) {


id = value;
}

string getName() const {


return name;
}

void setName(const string& value) {


name = value;
}

virtual void add() {

virtual void update() {

}
};

class AirlineTicketReservation {
public:
int id;
string number;
string price;

void calculate() {

void update() {

}
};

class Payment {
public:
int id;
int amount;
int date;

void calculate() {

}
};
class AirlineManagementSystem : public Transaction, public Customer, public Crew, public AirlineTicketReservation,
public Payment {

};

int main() {
AirlineManagementSystem ams;
ams.Transaction::setId(1);
ams.Transaction::details = "Airline Management System";
ams.Transaction::listOfDishes = "Dish1, Dish2";
ams.Transaction::add();
ams.Transaction::update();

cout << "Transaction ID: " << ams.Transaction::getId() << endl;


cout << "Transaction Details: " << ams.Transaction::details << endl;
cout << "List of Dishes: " << ams.Transaction::listOfDishes << endl;

Customer customer;
customer.address = "Islamabad";
customer.reservation = "Flight007";
customer.details = "Customer details";
customer.add();
customer.update();

cout << "Customer Address: " << customer.address << endl;


cout << "Reservation: " << customer.reservation << endl;
cout << "Customer Details: " << customer.details << endl;

Crew crew;
crew.setId(1);
crew.setName("Abdullah Nasir");
crew.age = "20";
crew.contactNumber = "03368325614";
crew.userName = "Abdb614";
crew.password = "Flight614";
crew.add();
crew.update();

cout << "Crew ID: " << crew.getId() << endl;


cout << "Crew Name: " << crew.getName() << endl;
cout << "Crew Age: " << crew.age << endl;
cout << "Contact Number: " << crew.contactNumber << endl;
cout << "Username: " << crew.userName << endl;
cout << "Password: " << crew.password << endl;

AirlineTicketReservation reservation;
reservation.id = 1;
reservation.number = "gk007";
reservation.price = "70000";
reservation.calculate();
reservation.update();

cout << "Reservation ID: " << reservation.id << endl;


cout << "Reservation Number: " << reservation.number << endl;
cout << "Reservation Price: " << reservation.price << endl;

Payment payment;
payment.id = 1;
payment.amount = 5000;
payment.date = 20230609;
payment.calculate();

cout << "Payment ID: " << payment.id << endl;


cout << "Payment Amount: " << payment.amount << endl;
cout << "Payment Date: " << payment.date << endl;

return 0;
}

Output:

Explanation:
This program represents an Airline Management System using object-oriented programming in
C++. It consists of several classes that represent different components of the airline
management system.

1. The `Transaction` class represents a transaction and has an ID, details, and a list of
dishes. It provides methods to get and set the ID and empty methods for adding and
updating the transaction.
2. The `Customer` class represents a customer and has attributes such as address,
reservation, and details. It includes virtual methods for adding and updating the
customer, which can be overridden by derived classes.

3. The `Crew` class represents a crew member and includes attributes like ID, name, age,
contact number, username, and password. It provides methods to get and set the ID
and name, as well as empty virtual methods for adding and updating the crew member.

4. The `AirlineTicketReservation` class represents a ticket reservation and has attributes


such as ID, reservation number, and price. It includes methods for calculating and
updating the reservation.

5. The `Payment` class represents a payment and includes attributes like ID, amount, and
date. It provides a method to calculate the payment.

6. The `AirlineManagementSystem` class inherits from all the aforementioned classes. It


serves as a combined representation of the entire airline management system.

7. In the `main()` function, objects of the `AirlineManagementSystem`, `Customer`,


`Crew`, `AirlineTicketReservation`, and `Payment` classes are created. The objects'
attributes are set, and methods are called to perform actions such as adding, updating,
and calculating. Finally, the information of these objects is printed using `cout`
statements.

Overall, this program demonstrates the concept of OOP, inheritance, and the use of classes to
represent different aspects of an airline management system in C++.

You might also like