Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Билеты.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <stdio.h>
- #include <vector>
- using namespace std;
- class Ticket_System
- {
- protected:
- int uid; // уникальный номер
- char* departure; // место отправления
- char* arrival; // место прибытия
- char* departure_time; // время отправления
- char* arrival_time; // время прибытия
- char* type; // класс билета
- int price; // цена
- public:
- Ticket_System(int = 0);
- Ticket_System(int, const char*, const char*, const char*, const char*, const char*, int); //создание билета
- void Show_Ticket(void); // показывает полную информацию о билете
- int get_uid(void);
- char* get_departure(void);
- char* get_arrival(void);
- char* get_departure_time(void);
- char* get_arrival_time(void);
- char* get_type(void);
- int get_price(void);
- };
- Ticket_System::Ticket_System(int a) : uid(0), departure(new char[1]), arrival(new char[1]), departure_time(new char[1]), arrival_time(new char[1]), type(new char[1]), price(0)
- {
- departure = "\0";
- arrival = "\0";
- departure_time = "\0";
- arrival_time = "\0";
- type = "\0";
- }
- Ticket_System::Ticket_System(int a1, const char* s1, const char* s2, const char* s3, const char* s4, const char* s5, int a2) : uid(a1), departure(new char[20]), arrival(new char[20]), departure_time(new char[10]), arrival_time(new char[10]), type(new char[3]), price(a2)
- {
- strcpy_s(departure, strlen(s1) + 1, s1);
- strcpy_s(arrival, strlen(s2) + 1, s2);
- strcpy_s(departure_time, strlen(s3) + 1, s3);
- strcpy_s(arrival_time, strlen(s4) + 1, s4);
- strcpy_s(type, strlen(s5) + 1, s5);
- }
- int Ticket_System::get_uid(void)
- {
- return uid;
- }
- char* Ticket_System::get_departure(void)
- {
- return departure;
- }
- char* Ticket_System::get_arrival(void)
- {
- return arrival;
- }
- char* Ticket_System::get_departure_time(void)
- {
- return departure_time;
- }
- char* Ticket_System::get_arrival_time(void)
- {
- return arrival_time;
- }
- char* Ticket_System::get_type(void)
- {
- return type;
- }
- int Ticket_System::get_price(void)
- {
- return price;
- }
- void Ticket_System::Show_Ticket(void)
- {
- cout << "uid = " << uid << endl;
- cout << "place1 = " << departure << endl;
- cout << "place2 = " << arrival << endl;
- cout << "date1 = " << departure_time << endl;
- cout << "date2 = " << arrival_time << endl;
- cout << "type = " << type << endl;
- cout << "price = " << price << endl;
- }
- class User_account : public Ticket_System {
- protected:
- vector <int> user_ticket_count;
- public:
- int find_new_ticket(vector <Ticket_System>, int, const char*, const char*, const char*, const char*, const char*, int);
- void buy_ticket(int, int);
- void show_ticket_list(vector <Ticket_System> a);
- };
- void User_account::buy_ticket(int, int uid) {
- user_ticket_count.push_back(uid);
- cout << "Thank's for your purchase!" << endl;
- system("pause");
- }
- int User_account::find_new_ticket(vector <Ticket_System> all_tickets, int uid, const char *departure,
- const char * arrival, const char *deparure_time, const char *arrival_time,
- const char *type, int price) {
- for (int i = 0; i < all_tickets.size(); i++) {
- if (all_tickets[i].get_arrival() == arrival and all_tickets[i].get_arrival_time() == arrival_time and
- all_tickets[i].get_departure() == departure and all_tickets[i].get_departure_time() == deparure_time and
- all_tickets[i].get_price() == price and all_tickets[i].get_type() == type) {
- all_tickets[i].Show_Ticket();
- cout << "/n" << endl;
- }
- }
- cout << "End of the list of tickets" << endl;
- return 0;
- }
- void User_account::show_ticket_list(vector <Ticket_System> a) {
- int c = 0;
- for (int i = 0; i < user_ticket_count.size(); i++) {
- if (a[i].get_uid() == user_ticket_count[c]) {
- a[i].Show_Ticket();
- c++;
- }
- }
- }
- int main()
- {
- Ticket_System a[100]; // массив билетов
- Ticket_System obj(1, "Moscow", "SPB", "23.04.2018", "25.04.2018", "bis", 2700);
- a[0] = obj;
- a[0].Show_Ticket();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement