Здравствуйте, задали написать курсач на тему "Продажа авиабилетов" чтобы отразить возможности ООП, нужно реализовать фабричным методом на С++ Фишка в том, что нужно реализовать классы "Окно создания" и "Окно уничтожения" объекта класса, но я не понимаю как их реализовывать, если у нас и так есть деструкторы в каждой фабрике. Помогите с реализацией
Код:
#include <iostream>
#include <string>
#include <vector>
class Ticket
{
private:
int price;
std::string ticketClass;
bool baggage;
bool availability;
bool food;
public:
void setPrice(int p){
this->price = p;
}
void setTicketClass(std::string cl){
this->ticketClass = cl;
}
void setBaggage(bool b){
this->baggage = b;
}
void setAvailability(bool a){
this->availability = a;
}
void setFood(bool f){
this->food = f;
}
int getPrice(){
return price;
}
std::string getClass(){
return ticketClass;
}
void getBaggage(){
if(baggage){
std::cout<<"baggage included"<<std::endl;
}
else{
std::cout<<"baggage isn't included"<<std::endl;
}
}
void getAvailability(){
if(availability){
std::cout<<"the ticket is available"<<std::endl;
}else {
std::cout<<"the ticket isn't avaliable"<<std::endl;}
}
void getFood(){
if(food){
std::cout<<"food is included"<<std::endl;
}else {
std::cout<<"food isn't included"<<std::endl;}
}
};
class Flight
{
private:
std::vector <Ticket>tickets;
std::string company;
std::string takeoffCity;
std::string landingCity;
std::string flightDate;
int hours;
int minutes;
int flightNumber;
int amountofseats;
public:
void setCompany(std::string c){
this->company = c;
}
void setTakeOffCity(std::string t_city){
this->takeoffCity = t_city;
}
void setLandingCity(std::string l_city){
this->landingCity = l_city;
}
void setFlightDate(std::string d){
this->flightDate = d;
}
void setHours(int h){
this->hours = h;
}
void setMinutes(int m){
this->minutes = m;
}
void setNumber(int n){
this->flightNumber = n;
}
void setAmount(int a){
this->amountofseats = a;
}
void addTicket(Ticket t){
tickets.push_back(t);
}
std::string getCompany(){
return company;
}
std::string getTakeoffCity(){
return takeoffCity;
}
std::string getLandingCity(){
return landingCity;
}
std::string getFlightDate(){
return flightDate;
}
int getAmountOfSeats(){
return amountofseats;
}
int getFlightNumber(){
return flightNumber;
}
void getTime(){
std::cout<<"the plane leaves at "<<hours<<"h "<<minutes<<"min "<<std::endl;
}
~Flight(){}
};
class Airport
{
private:
std::string name;
std::vector <Ticket>tickets;
public:
void setNameAirport(std::string na){
this->name = na;
}
void addTicket(Ticket t){
tickets.push_back(t);
}
std::string getNameAirport(){
return name;
}
~Airport(){}
};
class City
{
private:
std::string name;
std::vector <Airport> airports;
public:
void setNameCity(std::string n){
this->name = n;
}
void addAirport(Airport a){
airports.push_back(a);
}
std::string getNameCity(){
return name;
}
~City(){}
};
class Base
{
private:
std::vector <City>cities;
std::vector <Airport>airports;
public:
void addCity(City c){
cities.push_back(c);
}
void addAirport(Airport a){
airports.push_back(a);
}
};
class CityFactory
{
public:
City* create(){
return new City;
}
~CityFactory(){}
};
class AirportFactory
{
public:
Airport* create(){
return new Airport;
}
~AirportFactory(){}
};
class FlightFactory
{
public:
Flight* create(){
return new Flight();
}
~FlightFactory(){}
};
class CityWindowCreator: public CityFactory, public City
{
private:
int number_a;
public:
CityWindowCreator(int n){
this->number_a = n;
}
};
class CityWindowDestroyer
{
};
int main(){
}
Все что есть пока что
________
Код нужно оформлять по правилам:
тегом [CODE]..[/СODE]
(это кнопочка на панели форматирования с решёточкой #)
Не забывайте об этом!
Модератор.