0% found this document useful (0 votes)
6 views7 pages

Assignment2 OOP

The document contains C++ code for an Object Oriented Programming assignment at Bahria University Islamabad. It defines classes for Patient, Doctor, Appointment, and MedicalRecord, each with attributes and methods for setting and getting values, as well as displaying information. The main function demonstrates the creation of instances of these classes and displays their information.

Uploaded by

Asheer Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Assignment2 OOP

The document contains C++ code for an Object Oriented Programming assignment at Bahria University Islamabad. It defines classes for Patient, Doctor, Appointment, and MedicalRecord, each with attributes and methods for setting and getting values, as well as displaying information. The main function demonstrates the creation of instances of these classes and displays their information.

Uploaded by

Asheer Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

BAHRIA UNIVERSITY ISLAMABAD

H-11 Campus

Assignment 2
COURSE: Object Oriented Programming
NAME: Muhammad Asheer Ali
ENROLMENT: 09-134242-007
Patient.h
#ifndef PATIENT_H

#define PATIENT_H

#include <iostream>

using namespace std;

class Patient {

private:

string name;

int id;

int age;

string disease;

string admissionDate;

public:

Patient() : id(0), age(0), name(""), disease(""), admissionDate("") {}

Patient(int i, string n, int a, string d, string ad)

: id(i), name(n), age(a), disease(d), admissionDate(ad) {}

void setId(int i) { id = i; }

void setName(string n) { name = n; }

void setAge(int a) { age = a; }

void setDisease(string d) { disease = d; }

void setAdmissionDate(string ad) { admissionDate = ad; }

int getId() const { return id; }

string getName() const { return name; }

int getAge() const { return age; }

string getDisease() const { return disease; }

string getAdmissionDate() const { return admissionDate; }

void displayPatientInfo() const;

};

#endif
Patient.cpp
#include "Patient.h"

void Patient::displayPatientInfo() const {

cout << "\n--- Patient Information ---\n";

cout << "ID: " << id << "\n";

cout << "Name: " << name << "\n";

cout << "Age: " << age << "\n";

cout << "Disease: " << disease << "\n";

cout << "Admission Date: " << admissionDate << "\n";

Doctor.h
#ifndef DOCTOR_H

#define DOCTOR_H

#include <iostream>

using namespace std;

class Doctor {

private:

string name;

int id;

string specialization;

public:

Doctor() : id(0), name(""), specialization("") {}

Doctor(int i, string n, string s)

: id(i), name(n), specialization(s) {}

void setId(int i) { id = i; }

void setName(string n) { name = n; }

void setSpecialization(string s) { specialization = s; }

int getId() const { return id; }


string getName() const { return name; }

string getSpecialization() const { return specialization; }

void displayDoctorInfo() const;

};

#endif

Doctor.cpp
#include "Doctor.h"

void Doctor::displayDoctorInfo() const {

cout << "\n--- Doctor Information ---\n";

cout << "ID: " << id << "\n";

cout << "Name: " << name << "\n";

cout << "Specialization: " << specialization << "\n";

Appointment.h
#ifndef APPOINTMENT_H

#define APPOINTMENT_H

#include <iostream>

using namespace std;

class Appointment {

private:

int appointmentID;

int patientID;

int doctorID;

string date;

public:

Appointment() : appointmentID(0), patientID(0), doctorID(0), date("") {}

Appointment(int aID, int pID, int dID, string d)


: appointmentID(aID), patientID(pID), doctorID(dID), date(d) {}

void setAppointmentID(int aID) { appointmentID = aID; }

void setPatientID(int pID) { patientID = pID; }

void setDoctorID(int dID) { doctorID = dID; }

void setDate(string d) { date = d; }

int getAppointmentID() const { return appointmentID; }

int getPatientID() const { return patientID; }

int getDoctorID() const { return doctorID; }

string getDate() const { return date; }

void displayAppointmentInfo() const;

};

Appointment.cpp
#include "Appointment.h"

void Appointment::displayAppointmentInfo() const {

cout << "\n--- Appointment Information ---\n";

cout << "Appointment ID: " << appointmentID << "\n";

cout << "Patient ID: " << patientID << "\n";

cout << "Doctor ID: " << doctorID << "\n";

cout << "Date: " << date << "\n";

MedicalRecord.h
#ifndef MEDICALRECORD_H

#define MEDICALRECORD_H

#include <iostream>

using namespace std;

class MedicalRecord {

private:
int recordID;

int patientID;

string details;

public:

MedicalRecord() : recordID(0), patientID(0), details("") {}

MedicalRecord(int rID, int pID, string d)

: recordID(rID), patientID(pID), details(d) {}

void setRecordID(int rID) { recordID = rID; }

void setPatientID(int pID) { patientID = pID; }

void setDetails(string d) { details = d; }

int getRecordID() const { return recordID; }

int getPatientID() const { return patientID; }

string getDetails() const { return details; }

void displayMedicalRecord() const;

};

#endif

MedicalRecord.cpp
#include "MedicalRecord.h"

void MedicalRecord::displayMedicalRecord() const {

cout << "\n--- Medical Record ---\n";

cout << "Record ID: " << recordID << "\n";

cout << "Patient ID: " << patientID << "\n";

cout << "Details: " << details << "\n";

Main.cpp
#include <iostream>

#include "Patient.h"
#include "Doctor.h"

#include "Appointment.h"

#include "MedicalRecord.h"

using namespace std;

int main() {

Patient p1(1, "Ali", 30, "Flu", "18-03-2025");

Doctor d1(101, "Dr. Ahmed", "Cardiology");

Appointment a1(501, 1, 101, "20-03-2025");

MedicalRecord m1(601, 1, "Patient recovered from flu.");

p1.displayPatientInfo();

d1.displayDoctorInfo();

a1.displayAppointmentInfo();

m1.displayMedicalRecord();

return 0;

You might also like