Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ciapong
- #ifndef TRAIN_H
- #define TRAIN_H
- #include "Locomotive.h"
- #include "Train_car.h"
- #include "Driver.h"
- #include <iostream>
- class Train {
- private:
- std::string m_name;
- int m_amount_train_car;
- Train_car* m_train_car_array;
- Locomotive m_locomotive;
- Driver m_driver;
- static int s_amount_of_objects;
- public:
- Train();
- Train(const std::string& name, const Locomotive& locomotive);
- Train(const int& amount_train_car, const Locomotive& locomotive);
- Train(const std::string& name, const int& amount_train_car, const Locomotive& locomotive);
- Train(const Train& train);
- std::string getName() const;
- Train_car* getTrainCar() const;
- Train_car getTrainCar(const int& key) const;
- Locomotive getLocomotive() const;
- Driver getDriver() const;
- void setName(const std::string& name);
- void setTrainCar(const Train_car& train_car, const int& key);
- void setLocomotive(const Locomotive& locomotive);
- void setDriver(const Driver& driver);
- Train operator+(const Train& train);
- Train operator=(const Train& train);
- Train operator[](const Train& train);
- bool operator==(const Train& train);
- // operator konwersji
- static int getAmountOfObjects();
- ~Train();
- };
- #endif TRAIN_H
- #include "Train.h"
- int Train::s_amount_of_objects = 0;
- Train::Train() {
- m_name = "";
- m_amount_train_car = 0;
- m_train_car_array = nullptr;
- m_locomotive = Locomotive();
- m_driver = Driver();
- s_amount_of_objects++;
- }
- Train::Train(const std::string& name, const Locomotive& locomotive) {
- m_name = name;
- m_amount_train_car = 0;
- m_train_car_array = nullptr;
- m_locomotive = locomotive;
- m_driver = Driver();
- s_amount_of_objects++;
- }
- Train::Train(const int& amount_train_car, const Locomotive& locomotive) {
- m_name = "";
- m_amount_train_car = amount_train_car;
- m_train_car_array = new Train_car[m_amount_train_car];
- m_locomotive = locomotive;
- m_driver = Driver();
- s_amount_of_objects++;
- }
- Train::Train(const std::string& name, const int& amount_train_car, const Locomotive & locomotive) {
- m_name = name;
- m_amount_train_car = amount_train_car;
- m_train_car_array = new Train_car[m_amount_train_car];
- m_locomotive = locomotive;
- m_driver = Driver();
- s_amount_of_objects++;
- }
- Train::Train(const Train& train) {
- m_name = train.m_name;
- m_amount_train_car = train.m_amount_train_car;
- m_train_car_array = new Train_car[m_amount_train_car];
- for (int i = 0; i < m_amount_train_car; i++)
- m_train_car_array[i] = train.m_train_car_array[i];
- m_locomotive = train.m_locomotive;
- m_driver = train.m_driver;
- s_amount_of_objects++;
- }
- std::string Train::getName() const {
- return m_name;
- }
- Train_car* Train::getTrainCar() const {
- return m_train_car_array;
- }
- Train_car Train::getTrainCar(const int& key) const {
- return m_train_car_array[key];
- }
- Locomotive Train::getLocomotive() const {
- return m_locomotive;
- }
- Driver Train::getDriver() const {
- return m_driver;
- }
- void Train::setName(const std::string& name) {
- m_name = name;
- }
- void Train::setTrainCar(const Train_car& train_car, const int& key) {
- m_train_car_array[key] = train_car;
- }
- void Train::setLocomotive(const Locomotive& locomotive) {
- m_locomotive = m_locomotive;
- }
- void Train::setDriver(const Driver& driver) {
- m_driver = driver;
- }
- int Train::getAmountOfObjects() {
- return s_amount_of_objects;
- }
- Train::~Train() {
- delete[] m_train_car_array;
- }
- //klasa maszynista
- #ifndef DRIVER_H
- #define DRIVER_H
- #include <iostream>
- class Driver {
- private:
- std::string m_name;
- int m_age;
- int m_experience;
- double salary;
- };
- #endif DRIVER_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement