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

CPP

The document defines several C++ classes that model different entities in a postal service system: 1. Address, Customer, Invoice, Order, Payment classes store and retrieve address, customer, order and payment details. 2. Clerk, AccountOfficer, Postman classes inherit from PostalWorker and store employee IDs. 3. PostOffice calculates parcel prices based on weight and service type. 4. Mail, BouncedMail classes represent mail entities with IDs and type.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

CPP

The document defines several C++ classes that model different entities in a postal service system: 1. Address, Customer, Invoice, Order, Payment classes store and retrieve address, customer, order and payment details. 2. Clerk, AccountOfficer, Postman classes inherit from PostalWorker and store employee IDs. 3. PostOffice calculates parcel prices based on weight and service type. 4. Mail, BouncedMail classes represent mail entities with IDs and type.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

#include <iostream>

using namespace std;

// Address class
class Address
{
protected:
string sender_address;
string recipient_address;

public:
Address()
{
sender_address='\0';
recipient_address='\0';
}
Address(string sender_address, string recipient_address)
{
this->sender_address=sender_address;
this->recipient_address=recipient_address;
}
string getsender_address()
{
return sender_address;
}
void setsender_address(string sender_address)
{
this->sender_address=sender_address;
}
string getrecipient_address()
{
return recipient_address;
}
void setrecipient_address(string recipient_address)
{
this->recipient_address=recipient_address;
}

void showAddressDetails()
{
cout<<"\nSender Address: ";
cout<<this->sender_address;
cout<<"\nRecipient Address: ";
cout<<this->recipient_address<<endl;
}
};

// Customer class
class Customer: public Address
{
protected:
int trackID;
string name;
string contact_number;
public:
Customer()
{
trackID=0;
name='\0';
contact_number='\0';
}
Customer(int trackID, string name, string contact_number,string sa,string ra)
: Address(sa,ra)
{
this->trackID=trackID;
this->name=name;
this->contact_number=contact_number;
}
int gettrackID()
{
return trackID;
}
void settrackID(int trackID)
{
this->trackID=trackID;
}
string getname()
{
return name;
}
void setname(string name)
{
this->name=name;
}
string getcontact_number()
{
return contact_number;
}
void setcontact_number(string contact_number)
{
this->contact_number=contact_number;
}
void showCustomerDetails()
{
cout<<"CUSTOMER DETAILS\n\n";
showAddressDetails();
cout<<"Tracking ID: ";
cout<<this->trackID;
cout<<"\nName: "<<this->name;
cout<<"\nContact Number: "<<this->contact_number;
}
};

// Invoice class
class Invoice
{
protected:
int orderID;

public:
Invoice()
{
orderID=0;

}
Invoice(int orderID)
{
this->orderID=orderID;
}
int getorderID()
{
return orderID;
}
void setorderID(int orderID)
{
this->orderID=orderID;
}

void PrintInvoice()
{
cout<<"\nTracking ID: "<<this->orderID;
}
};

//OrderClass

class Order
{
protected:
string s;
Customer c;
Invoice i;
public:

Order()
{
s='\0';
}

Order(string ordername,Customer cus,Invoice in)


{
s = ordername;
c = cus;
i = in;
}

void display_Order()
{
cout<<"----------------Order Details----------------\n\n";
cout<<s<<endl;
i.PrintInvoice();
c.showCustomerDetails();
}

};

class PostalWorker
{
protected:
string name;
int age;

public:
PostalWorker()
{
name = '\0';
age = 0;
}

PostalWorker(string pw_name,int pw_age)


{
name = pw_name;
age = pw_age;
}

void Display_PostalWorker()
{
cout<<"\nName: "<<name<<endl;
cout<<"Age: "<<age<<endl;
}
};
class Clerk : public PostalWorker
{
protected:
int clerk_id;

public:
Clerk()
{
clerk_id = 0;
}

Clerk(string n,int a,int c_id) : PostalWorker(n,a)


{
clerk_id = c_id;
}

void Display_Clerk()
{
Display_PostalWorker();
cout<<"Position: Clerk\n";
cout<<"Clerk ID: "<<clerk_id<<endl;
}
};

class AccountOfficer : public PostalWorker


{
protected:
int ao_id;

public:
AccountOfficer()
{
ao_id = 0;
}

AccountOfficer(string n,int a,int acco_id) : PostalWorker(n,a)


{
ao_id = acco_id;
}

void Display_AccountOfficer()
{
Display_PostalWorker();
cout<<"Position: Account-Officer\n";
cout<<"Account-Officer ID: "<<ao_id<<endl;
}
};

class Postman : public PostalWorker


{
protected:
int p_id;

public:
Postman()
{
p_id = 0;
}

Postman(string n,int a,int po_id) : PostalWorker(n,a)


{
p_id = po_id;
}

void Display_Postman()
{
Display_PostalWorker();
cout<<"Position: Postman\n";
cout<<"Postman ID: "<<p_id<<endl;
}
};

class Payment
{
protected:
int amount;
AccountOfficer ao;

public:
Payment()
{
amount = 0;
}

Payment(int am,AccountOfficer a_o)


{
amount = am;
ao = a_o;
}

void DisplayPay()
{
ao.Display_AccountOfficer();
cout<<"Payment: "<<amount<<endl;
}

};

class PostOffice
{
protected:
int weight;
float price;
public:
PostOffice()
{
weight=0;
price=75; //keeping it to 75 because of the registration fee
}
PostOffice(int weight, int price)
{
this->weight=weight;
this->price=price;
}
void ParcelPrice()
{
cout<<"\nWhich service you want to use LMS or General";
cout<<"\nFor UMS press 1 and General 2";
int type;
cin>>type;
if(type==1)
{
int i;
cout<<"\nFor UMS Local press 1";
cout<<"\nFor UMS city to city press 2";
cin>>i;
if(i==1)
{
cout<<"\nMenu for UMS Local";
cout<<"\nEnter Weight: ";
cin>>weight;
if(weight<=250)
{
price = price + 51;
}
else if(weight<=500)
{
price = price + 64;
}
else if(weight>1000)
{
int w=weight%500;
price=64+w*26;
}
else
{
cout<<"\nInvalid Weight entered";
}
}

else if(i==2)
{
cout<<"\nMenu for UMS City to City";
cout<<"\nEnter Weight: ";
cin>>weight;
if(weight<=250)
{
price = price + 86;
}
else if(weight<=500)
{
price = price + 132;
}
else if(weight>1000)
{
int w=weight%500;
price=132+w*43;
}
}
}

else if(type==2)
{
cout<<"\nGeneral Menu";
cout<<"\nEnter Weight";
cin>>weight;
if(weight<=1)
{
price = price + 100;
}
else if(weight>1 && weight<3)
{
price = price + 175;
}
else if(weight>3 && weight<5)
{
price = price + 250;
}
else if(weight>5 && weight<10)
{
price = price + 375;
}
else if(weight>10 && weight<15)
{
price = price + 500;
}
else if(weight>15 && weight<20)
{
price = price + 625;
}
else if(weight>20 && weight<25)
{
price = price + 750;
}
else if(weight>25 && weight<30)
{
price = price + 875;
}

}
else
{
cout<<"\n Invalid option entered";
}
}

};

class Mail
{
protected:
int mail_id;
public:
Mail()
{
mail_id = 0;
}

Mail(int m_id)
{
mail_id = m_id;
}

void DisplayMail()
{
cout<<"Mail ID: "<<mail_id<<endl;
}
};

class Bounced_Mail : public Mail


{
protected:
string type;
public:
Bounced_Mail()
{
type = "Bounced Mail";
}

Bounced_Mail(int id,string t) : Mail(id)


{
type = t;
}

void DisplayBouncedMail()
{
DisplayMail();
cout<<type<<endl;
}

};

class Returned_Mail : public Mail


{
protected:
string type;
public:
Returned_Mail()
{
type = "Returned Mail";
}

Returned_Mail(int id,string t) : Mail(id)


{
type = t;
}

void DisplayReturnedMail()
{
DisplayMail();
cout<<type<<endl;
}

};

class MailServices
{
protected:
int weight;
Mail m;

public:
MailServises()
{
weight=0;
}

MailServices(int w,Mail mail)


{
weight = w;
m = mail;

void DisplayMailServices()
{
m.DisplayMail();
cout<<"Weight: "<<weight<<endl;

}
};

class UMS : public MailServices


{

public:
float price = 75;

UMS(int w, Mail m) : MailServices(w,m){}

void ums()
{
cout<<"\nFor UMS press 1 \n";

int type;
cout<<"Enter: ";
cin>>type;
if(type==1)
{
int i;
cout<<"\nFor UMS Local press 1";
cout<<"\nFor UMS city to city press 2\n";
cout<<"Enter: ";
cin>>i;
if(i==1)
{
cout<<"\nMenu for UMS Local";
if(weight<=250)
{
price = price + 51;
}
else if(weight<=500)
{
price = price + 64;
}
else if(weight>1000)
{
int w=weight%500;
price=64+w*26;
}
else
{
cout<<"\nInvalid Weight entered";
}

cout<<"Total Price: "<<price<<endl;


}

else if(i==2)
{
cout<<"\nMenu for UMS City to City";
if(weight<=250)
{
price = price + 86;
}
else if(weight<=500)
{
price = price + 132;
}
else if(weight>1000)
{
int w=weight%500;
price=132+w*43;
}

cout<<"Total Price: "<<price<<endl;


}

}
};

class RMS : public MailServices


{
public:
float price = 75;
RMS(int w,Mail m) : MailServices(w,m){}
void rms()
{
cout<<"\nFor RMS press 2 \n";

int type;
cout<<"Enter: ";
cin>>type;
if(type==2)
{
if(weight<=1)
{
price = price + 100;
}
else if(weight>1 && weight<3)
{
price = price + 175;
}
else if(weight>3 && weight<5)
{
price = price + 250;
}
else if(weight>5 && weight<10)
{
price = price + 375;
}
else if(weight>10 && weight<15)
{
price = price + 500;
}
else if(weight>15 && weight<20)
{
price = price + 625;
}
else if(weight>20 && weight<25)
{
price = price + 750;
}
else if(weight>25 && weight<30)
{
price = price + 875;
}
cout<<"Total Price: "<<price<<endl;

}
};

class GPO
{
protected:
string city_name;
int postal_code;

public:
GPO()
{
city_name='\0';
postal_code=0;
}
GPO(string city, int code)
{
city_name=city;
postal_code=code;
}
void showDetails()
{
cout<<"City Name: "<<city_name;
cout<<"Postal Code"<<postal_code;
}
};

int main()
{

int t_id;
string n;
string cn;
string sa;
string ra;
string name;
int age;
int weight;
int mailid;
int it;
int id;
int id2;
int q=1;
int nn=1;
int oo=1;

char choice , choice1 ;


int x=0;

system("color 03");
system("cls");

cout<<"\n\n\n\n\n\t\t_______________________________________________________________
_____________________\n";
cout<<"\t\t| ===============>> WELCOME <<================
|\n";
cout<<"\t\t| TO
|\n";
cout<<"\t\t|
---------------------------------------------------------------------- |\n";
cout<<"\t\t| PAKISTAN POST OFFICE
|\n";

cout<<"\t\t|________________________________________________________________________
__________|\n";
cout<<"\t\t|
|\n";
cout<<"\t\t|
|\n";
cout<<"\t\t| MADE BY : SHAHMEER ALI MIRZA 19I-0860
|\n";

cout<<"\t\t|________________________________________________________________________
__________|\n\n\n\n\n\n\n";
system("pause");

while(q==1){

system("color 0A"); //Change Color


system("cls");
cout<<"\n\n\n\n\n\n\n\n\t\t\t====================== MAIN MENU
====================\n\t\t" ;
cout<<"\t\t\t\t\n\t\t\t==>> A. REGISTER CUSTOMERS.\n\t" ;
cout<<"\t\t==>> B. HEAD OF EMPLOYEE LOGIN.\t\t" ;
cout<<"\n\t\t\t==>> C. FETCH DAILY REPORT.\t\t" ;
cout<<"\n\t\t\t==>> D. SORTING.\t\t" ;
cout<<"\n\t\t\t==>> E. EXIT.\t\t" ;

cout<<"\n\n\t\t\t======================================================\n\t\t" ;
cout<<"\n\n ==>> Enter your choice : " ;
cin>>choice;

switch ( choice )
{
case 'A':

while(nn==1)
{
system("cls"); //REGISTER CUSTOMERS

cout<<"\n\n\n\n\n\t\t_______________________________________________________________
_____________________\n";
cout<<"\t\t| REGISTER CUSTOMERS MENU
|\n";

cout<<"\t\t|________________________________________________________________________
__________|\n";
cout<<"\t\t| ==>> 1. ADD YOUR DATA"<<"
|\n";
cout<<"\t\t| ==>> 2. USE URGENT MAIL SERVICE "<<"
|\n";
cout<<"\t\t| ==>> 3. USE REGULAR MAIL SERVICE"<<"
|\n";
cout<<"\t\t| ==>> 4. MAIN MENU"<<"
|\n";
cout<<"\t\t| ==>> 5. EXIT"<<"
|\n";

cout<<"\t\t|________________________________________________________________________
__________|\n\n";
cout<<"\n\n ==>> Enter your choice : " ;
cin>>choice1;

switch(choice1)
{
case '1':
{
system("cls");

cout<<"Enter your name: ";


cin>>n;
cout<<"Enter tracking ID: ";
cin>>t_id;
cout<<"Enter Contact Number: ";
cin>>cn;
cout<<"Enter Sender Address: ";
cin>>sa;
cout<<"Enter Recipient Address: ";
cin>>ra;

Customer c(t_id,n,cn,sa,ra);

cout<<"\n\nDATA SUCCESSFULLY ADDED \n\n";


system("pause");

system("cls");
c.showCustomerDetails();
system("pause");

break;
}

case '2':
{
system("cls");

cout<<"Enter Mail ID: ";


cin>>mailid;

Mail m(mailid);

cout<<"Enter weight of parcel (in grams) : ";


cin>> weight;

UMS u(weight,m);
u.ums();
system("pause");
break;

case '3':
{
system("cls");

cout<<"Enter Mail ID: ";


cin>>mailid;

Mail m(mailid);

cout<<"Enter weight of parcel (in kg) : ";


cin>> weight;

RMS r(weight,m);
r.rms();
system("pause");
break;

case '4': //Back to Main Men


{
system("cls");
nn=0;
break;
}

case '5': //Exit Program


{

exit(1);
system("pause");

}
}
break;
}

case 'B':
{
while(oo==1)
{
system("cls"); //HEAD OF EMPLOYEE LOGIN

cout<<"\n\n\n\n\n\t\t_______________________________________________________________
_____________________\n";
cout<<"\t\t| HEAD OF EMPLOYEE MENU
|\n";

cout<<"\t\t|________________________________________________________________________
__________|\n";
cout<<"\t\t| ==>> 1. ADD DATA"<<"
|\n";
cout<<"\t\t| ==>> 2. DELETE DATA "<<"
|\n";
cout<<"\t\t| ==>> 3. MAIN MENU"<<"
|\n";
cout<<"\t\t| ==>> 4. EXIT"<<"
|\n";

cout<<"\t\t|________________________________________________________________________
__________|\n\n";
cout<<"\n\n ==>> Enter your choice : " ;
cin>>choice1;

switch(choice1)
{
case '1':
system("cls");

cout<<"press 1 if Employee is Account Officer.\n";


cout<<"press 2 if Employee is Clerk.\n";
cout<<"press 3 if Employee is Postman.\n";
cout<<"Enter your choice: ";
cin>>it;

if(it==1)
{
system("cls");
cout<<"Enter Name: ";
cin>>name;
cout<<"Enter Age: ";
cin>>age;
cout<<"Enter ID: ";
cin>>id2;

AccountOfficer acco(name,age,id2);

cout<<"\n\nDATA SUCCESSFULLY ADDED \n\n";


system("pause");

system("cls");
acco.Display_AccountOfficer();
system("pause");
break;

else if(it==2)
{
system("cls");
cout<<"Enter Name: ";
cin>>name;
cout<<"Enter Age: ";
cin>>age;
cout<<"Enter ID: ";
cin>>id;

Clerk clerk(name,age,id);

cout<<"\n\nDATA SUCCESSFULLY ADDED \n\n";


system("pause");
system("cls");
clerk.Display_Clerk();
system("pause");
break;
}

else if(it==3)
{
system("cls");
cout<<"Enter Name: ";
cin>>name;
cout<<"Enter Age: ";
cin>>age;
cout<<"Enter ID: ";
cin>>id;

Postman post(name,age,id);

cout<<"\n\nDATA SUCCESSFULLY ADDED \n\n";


system("pause");

system("cls");
post.Display_Postman();
system("pause");
break;

case '2':
{
system("cls");

cout<<"press 1 if Employee is Account Officer.\n";


cout<<"press 2 if Employee is Clerk.\n";
cout<<"press 3 if Employee is Postman.\n";
cout<<"Enter your choice: ";
cin>>it;

if(it==1)
{
system("cls");
cout<<"Enter ID: ";
cin>>id;

cout<<"\n\nDATA SUCCESSFULLY DELETED\n\n";


system("pause");
break;
}
else if(it==2)
{
system("cls");
cout<<"Enter ID: ";
cin>>id;

cout<<"\n\nDATA SUCCESSFULLY DELETED\n\n";


system("pause");
break;
}

else if(it==3)
{ system("cls");

cout<<"Enter ID: ";


cin>>id;

cout<<"\n\nDATA SUCCESSFULLY DELETED\n\n";


system("pause");
break;
}

}
case '3': //Back to Main Men
system("cls");
oo=0;
break;
case '4': //Exit Program
exit(1);
system("pause");

}
}
break;
}

case 'C':
{
system("cls");
Invoice i(19442);
Customer cust(194,"Shahmeer Ali","033350302942","Islamabad","Karachi");
Order o("First Order",cust,i);

o.display_Order();
cout<<"\n\n";
system("pause");
break;

case 'D':
{
exit(1);
system("pause");
}

case 'E': //Exit Program


exit(1);
system("pause");

You might also like