My teacher gave me a homework assignment a week ago. I have been trying to create two classes one of them is Flight and the other one is Plane.
I have created nearly all of them but I can't go on.:cursing: I'm putting my code here so if any one willing to help me ( tell me how to do it ) I would be greatly thankful. ^^
The commend parts are the ones that I was not able to complete/understand. Some of them are false written but I still put them there so that you get the idea.
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
class Plane
{
public:
Plane( string, int, int );
void display();
//Plane select(); //displays the plane list and let user select one
private:
static const int MAXPLANE = 40;
//Plane planes[MAXPLANE]; //it saves Plane objects
//int plncnt; //counts the number of planes
string type;
int passenger;
int distance;
};
Plane::Plane( string _type, int _passenger, int _distance )
{
type = _type;
passenger = _passenger;
distance = _distance;
}
void Plane::display()
{
cout << "Type : " << type << endl;
cout << "Passenger Number : " << passenger << endl;
cout << "Distance : " << distance << endl;
}
/*
Plane Plane::select()
{
??
}
*/
class Flight
{
public:
Flight( string, string, string, string );
//void setPlane(); //set plane object (call select method of plane)
void setTime(string);
void displayFrom(string);
private:
static const int MAXFLIGHT = 35;
//Flight flights [MAXFLIGHT];// it saves Flight objects
//int flycnt; // counts the number of flights
string flightno;
string from;
string to;
string time;
};
Flight::Flight( string _fligtno, string _from, string _to, string _time )
{
flightno = _fligtno;
from = _from;
to = _to;
time = _time;
}
/*
void Flight::setPlane()
{
??
}
*/
void Flight::setTime(string _time)
{
time = _time;
}
/*
void Flight::displayFrom(string)
{
??
}
*/
int main()
{
Plane p1("Oceanic815",34,567);
p1.display();
system("PAUSE");
return EXIT_SUCCESS;
}


Sign In
Create Account


Back to top









