Oop Assignment
Oop Assignment
Assignment no 4:
Code:
#include <iostream>
#include <string>
class Transaction {
private:
int id;
public:
string details;
string listOfDishes;
void add() {
void update() {
}
};
class Customer {
public:
string address;
string reservation;
string details;
}
};
class Crew {
private:
int id;
string name;
public:
string age;
string contactNumber;
string userName;
string password;
}
};
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();
Customer customer;
customer.address = "Islamabad";
customer.reservation = "Flight007";
customer.details = "Customer details";
customer.add();
customer.update();
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();
AirlineTicketReservation reservation;
reservation.id = 1;
reservation.number = "gk007";
reservation.price = "70000";
reservation.calculate();
reservation.update();
Payment payment;
payment.id = 1;
payment.amount = 5000;
payment.date = 20230609;
payment.calculate();
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.
5. The `Payment` class represents a payment and includes attributes like ID, amount, and
date. It provides a method to calculate the payment.
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++.