Name = Muhammad Waleed Sattar
SAP-ID = 55700
Section = BS SE 2-2
Subject = oop LAB
LAB Task 2:
Health Monitoring System:
Part-1 Code:
#include<iostream>
#include<string>
#include"Task1part2.cpp"
using namespace std;
int main() {
Patient Patient2;
Patient Patient1("Waleed", 19, "Male");
Patient Patient3 = Patient1; // Copy construction
// Print Patient1
cout << "Patient 1:" << endl;
cout << "Name: " << Patient1.getname() << endl;
cout << "Age: " << Patient1.getage() << endl;
cout << "Gender: " << Patient1.getgender() <<
endl<<endl;
// Print Patient3
cout << "Patient 3:" << endl;
cout << "Name: " << Patient3.getname() << endl;
cout << "Age: " << Patient3.getage() << endl;
cout << "Gender: " << Patient3.getgender() <<
endl<<endl;
return 0;
}
Part 2:
#include<iostream>
#include<string>
using namespace std;
class Patient {
private:
string name;
int age;
string gender;
public:
Patient() {
name = "";
age = 0;
gender = "";
cout << "Name = " << name << endl;
cout << "Age = " << age << endl;
cout << "Gender = " << gender << endl <<
endl;
}
Patient(string name, int age, string gender) {
this->name = name;
this->age = age;
this->gender = gender;
}
// Copy constructor
Patient(const Patient &otherPatient) {
name = otherPatient.name;
age = otherPatient.age;
gender = otherPatient.gender;
}
~Patient() {
cout << "Object has been deleted !!" << endl;
}
void setname(string name) {
this->name = name;
}
void setage(int age) {
this->age = age;
}
void setgender(string gender) {
this->gender = gender;
}
string getname() {
return this->name;
}
int getage() {
return this->age;
}
string getgender() {
return this->gender;
}
};
Document Management System:
#include<iostream>
#include<string>
#include"Task2part2.cpp"
using namespace std;
int main(){
Document Documents;
Document Documents1("DLD","Morris Mano",".pdf");
Document Documents3=Documents1;
cout<<"Title of Document 1 is "<<Documents1.gettitle()<<endl;
cout<<"Author of Document 1 is "<<Documents1.getauthor()<<endl;
cout<<"File Format of Document 1 is
"<<Documents1.getfile_format()<<endl<<endl;
cout<<"Title of Document 3 is "<<Documents3.gettitle()<<endl;
cout<<"Author of Document 3 is "<<Documents3.getauthor()<<endl;
cout<<"File Format of Document 3 is
"<<Documents3.getfile_format()<<endl<<endl;
return 0;
}
Part 2:
#include<iostream>
#include<string>
using namespace std;
class Document
{
private:
string title;
string author;
string file_format;
public:
Document()
{
this->title="";
this->author="";
this->file_format="";
cout<<"Title = "<<title<<endl;
cout<<"Author = "<<author<<endl;
cout<<"File Format ="<<file_format<<endl<<endl;
}
Document(string title,string author, string file_format)
{
this->title=title;
this->author=author;
this->file_format=file_format;
}
Document(Document &Docobj)
{
this->title=Docobj.title;
this->author=Docobj.author;
this->file_format=Docobj.file_format;
}
~Document()
{
cout<<"Object has been Deleted "<<endl;
}
void settitle(string title){
this->title=title;
}
void setauthor(string author){
this->author=author;
}
void setfile_format(string file_format){
this->file_format=file_format;
}
string gettitle(){
return this->title;
}
string getauthor(){
return this->author;
}
string getfile_format(){
return this->file_format;
}
};