Skip to main content

::: vuaskari.com ::: CS402 solution 4 assignment

//Hinna
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Schedule
{
public:
enum Place
{
Lahore =0 ,
Karachi,
Islamabad,
Peshawar,
Quetta
};
private:
bool trip;
string departureDate;
string returnDate;
Place destination; //(Going to)
Place origin; //(Leaving from)
int flightNo;
int depatureTime; //only hour (not full time like 12:56)
int arrivalTime;

public:
Schedule() //default constructor
{
trip = false;
departureDate = "";
returnDate = "";
destination = Lahore;
origin = Lahore;
flightNo = 0;
depatureTime = 0;
arrivalTime = 0;
};

~Schedule() //destructor
{
cout<<"Destructor ..."<<endl;
};

//get/set properties
bool getTrip() {return trip;};
string getDepartureDate(){return departureDate;};
string getReturnDate(){return returnDate;};
Place getDestination(){return destination;};
Place getOrigin(){return origin;};
int getFlightNo(){return flightNo;};
int getDepatureTime(){return depatureTime;};
int getArrivalTime(){return arrivalTime;};

void setTrip(bool val) {trip = val;};
void setDepartureDate(string date){departureDate = date;};
void setReturnDate(string date){returnDate = date;};
void setDestination(Place val){destination = val;};
void setOrigin(Place val){origin = val;};
void setFlightNo(int val){flightNo = val;};
void setDepatureTime(int aTime){depatureTime = aTime;};
void setArrivalTime(int aTime){arrivalTime = aTime;};

// method for get input
void getInputData()
{
int i;

cout<<"\n======================================="<<endl;
cout<<"Enter flight information :"<<endl;
cout<<"Trip type (0: Oneway Trip | 1: Round Trip): ";
cin>>trip;

cout<<"Date of departure: ";
cin>>departureDate;


returnDate = "";
if(trip)//round trip
{
cout<<"Date of return: ";
cin>>returnDate;
}

do
{
cout<<"Destination (0: Lahore, 1: Karachi, 2: Islamabad, 3: Peshawar, 4: Quetta): ";
cin>>i;
}
while (i<0 || i >4);
destination = Place(i);
do
{
cout<<"Origin (0: Lahore, 1: Karachi, 2: Islamabad, 3: Peshawar, 4: Quetta): ";
cin>>i;
}
while (i<0 || i >4);
origin = Place(i);

/* initialize random seed: */
srand ( time(NULL) );
flightNo = rand() % 201;

depatureTime = rand() % 24;
arrivalTime = rand() % 24;
if(abs(arrivalTime-depatureTime)<2) arrivalTime = (arrivalTime + 2)%24;
};

// method for write to disk
void writeData()
{
static char *places[] = {
"Lahore", "Karachi", "Islamabad", "Peshawar", "Quetta"
};

ofstream myfile ("schedule.txt");
if (myfile.is_open())
{
myfile << "Flight No: "<<flightNo<<endl;
myfile << "Origin: "<<places[origin]<<endl;
myfile << "Destination: "<<places[destination]<<endl;
myfile << "Date of Departure: "<<departureDate<<endl;
if(trip)
{
myfile << "Date of Return: "<<returnDate<<endl;
}
else
{
myfile << "Date of Return: N/A"<<endl;
}
myfile << "Departure Time: "<<depatureTime<<":00"<<endl;
myfile << "Arrival Time: "<<arrivalTime<<":00"<<endl;
myfile.close();
}
else cout << "Unable to open file";
};
};

int main()
{
Schedule *mysdl = new Schedule();
mysdl->getInputData();
mysdl->writeData();

system("pause");
return 0;
}
dont copy past..............

--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en

Comments

Popular posts from this blog

[vu-students] Urdu Love Letters ............ ahahahahahhahahah

  The One & Only .......... IRFAN. Italy. http://groups.yahoo.com/group/p_se_poetry   -- You received this message because you are subscribed to the Google Groups "VU Students" group. To post to this group, send email to vu-students@googlegroups.com To unsubscribe from this group, send email to vu-students+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/vu-students?hl=en_PK?hl=en

Re: ::: vuaskari.com ::: Fwd: Cancer treatment- Shocking news.

plz send me the soloution of Assignment MGT-603 and MKT-624 plzzzzzzzzz today last day i need urgent 2011/4/23 ∂υα ωαqαя < dua4566@gmail.com > ---------- Forwarded message ---------- From: Virtual Brain < mc090400181@gmail.com > Date: Sat, Apr 23, 2011 at 10:30 AM Subject: Cancer treatment- Shocking news. AS  one of my friend tell me all this PLEASE FORWARD THIS MAIL.  Dear All, One of my cousin got   lung cancer   few months back. That was really shocking to all his family members. Cancer diagnosed was of stage three. Immediately treatment was started from Pakistan most of the art hospital for cancer i.e. Shoukat Khanum Hospital in Lahore. But there were little chances to reverse the disease as it's already reached to stage 3. Than one day somebody told us about a person in Distt Nowshera who is treating cancer by herbs. We went there and he gave us some   herbal medicines   for ten days. It was really amazing when we saw an improvement in the condition of my...

Updating our Google Account inactivity policy

Every day Google works hard to keep you and your private information safe and secure by preventing unauthorized access to your Google Account with our built-in security protections. And keeping you safe means having strong privacy practices across our products that minimize how long we store your personal files and any data associated with them. We want to protect your private information and prevent any unauthorized access to your account even if you're no longer using our services. Therefore, we are updating the inactivity period for a Google Account to two years across all our products and services. This change starts rolling out today and will apply to any Google Account that's been inactive, meaning it has not been signed into or used within a two-year period. An inactive account and any content in it will be eligible for deletion from December 1, 2023. What this means for you: These changes do not impact you unless you h...