📄 flight.cpp
字号:
#include <iostream>
#include <iomanip>
#include "Flight.h"
using namespace std;
char *Flight::getstart() //返回出发地点
{
return start;
}
char *Flight::getDestination() //返回目的地点
{
return destination;
}
char *Flight::getFlightNumber() //返回航班号
{
return flightNumber;
}
int Flight::getTicketLeft() //返回剩余票量
{
return ticketLeft;
}
void Flight::setStart() //设置出发地点
{
cin>>start;
}
void Flight::setDestination() //设置目的地点
{
cin>>destination;
}
void Flight::setTakeoff() //设置起飞时间
{
cin>>takeoff;
}
void Flight::setDescent() //设置到达时间
{
cin>>descent;
}
void Flight::setFlightNumber() //设置航班号
{
cin>>flightNumber;
}
void Flight::setType() //设置机型
{
cin>>type;
}
void Flight::setPrice() //设置全价
{
cin>>price;
}
void Flight::setSeats() //设置座位总数
{
cin>>seats;
}
void Flight::setTicketLeft(int n) //设置余票量
{
ticketLeft=n;
}
istream & operator >>(istream &in,Flight &flight) //重载"》"
{
cout<<"请输入您要添加的航班信息:"<<endl;
cout<<"出发地点: ";
in>>flight.start;
cout<<"目的地点: ";
in>>flight.destination;
cout<<"起飞时间: "<<endl;
in>>flight.takeoff;
cout<<"到达时间: "<<endl;
in>>flight.descent;
while(flight.takeoff.getHour()>=flight.descent.getHour()||
(flight.takeoff.getHour()==flight.descent.getHour()&&
flight.takeoff.getMinute()>=flight.descent.getMinute()))
{
cout<<"时间输入错误,请重新输入:"<<endl;
cout<<"起飞时间: ";
in>>flight.takeoff;
cout<<"到达时间: ";
in>>flight.descent;
}
cout<<"航班号: ";
in>>flight.flightNumber;
cout<<"机型: ";
in>>flight.type;
cout<<"全价: ";
in>>flight.price;
cout<<"座位总数: ";
in>>flight.seats;
flight.ticketLeft=flight.seats;
return in;
}
ostream & operator <<(ostream &out,Flight &flight) //重载"《"
{
out<<setw(10)<<flight.start<<setw(10)<<flight.destination<<" "<<flight.takeoff<<" "<<flight.descent<<setw(8)<<flight.flightNumber<<setw(6)<<flight.type<<setw(5)<<flight.price<<setw(10)<<flight.seats<<setw(10)<<flight.ticketLeft<<endl;
return out;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -