Monday, January 16, 2012

Re: [ vuZs.net ] cs201 ki assignment main koi to help kr da aj last date hai

//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;
}


On Mon, Jan 16, 2012 at 5:57 PM, mc110203934 Saira Anjum <mc110203934@vu.edu.pk> wrote:


--
--
Please visit www.vuzs.net For Current & Old Papers, Quizzes, Assignments and study material.

To post a new message on this group, send email to vuZs@googlegroups.com

Message Posting Rules: http://vuzs.net/faq/4795-vuzs-google-groups-basic-rules-for-posting-messages.html
--
To unsubscribe from this group, send email to vuZs+unsubscribe@googlegroups.com
--
To join this group Send blank email to vuZs+subscribe@googlegroups.com
or visit
http://groups.google.com/group/vuZs/subscribe

--
--
Please visit www.vuzs.net For Current & Old Papers, Quizzes, Assignments and study material.
 
To post a new message on this group, send email to vuZs@googlegroups.com
 
Message Posting Rules: http://vuzs.net/faq/4795-vuzs-google-groups-basic-rules-for-posting-messages.html
--
To unsubscribe from this group, send email to vuZs+unsubscribe@googlegroups.com
--
To join this group Send blank email to vuZs+subscribe@googlegroups.com
or visit
http://groups.google.com/group/vuZs/subscribe

No comments:

Post a Comment