Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include "Gang.h"
- using namespace std;
- Boss::Boss() {
- }
- void Boss::init() {
- cout << "Podaj nazwe Bossa";
- cin >> nameBoss;
- }
- void Boss::show() {
- cout << "Nazwa Bossa : " << nameBoss << endl;
- }
- Boss::~Boss() {
- }
- Gang::Gang()
- {
- }
- Gang::~Gang() {
- for (int i = 0; i < sizeBoss; i++) {
- ptrBoss[i].~Boss();
- }
- delete[]ptrBoss;
- }
- void Gang::init() {
- cout << "podaj nazwe grupy : ";
- cin >> name_gang;
- cout << "podaj date zalozenia organizacji : ";
- string yr;
- cin >> yr;
- while (!atoi(yr.c_str()) && yr != "0") {
- cout << "podany rok nie jest liczba " << endl;
- cin >> yr;
- }
- year = atoi(yr.c_str());
- cout << "Podaj liczbe Bossow" << endl;
- cin >> sizeBoss;
- ptrBoss = new Boss[sizeBoss];
- for (int i = 0; i < sizeBoss; i++) {
- ptrBoss[i].init();
- }
- }
- void Gang::show() {
- if (this != nullptr) {
- cout << "Nazwa organizacji : " << name_gang << endl;
- for (int i = 0; i < sizeBoss; i++) {
- ptrBoss[i].show();
- }
- cout << "Rok zalozenia : " << year << endl;
- }
- }
- Gang & Gang :: operator=(const Gang & g) {
- name_gang = g.name_gang;
- year = g.year;
- sizeBoss = g.sizeBoss;
- ptrBoss = new Boss[sizeBoss];
- for (int i = 0; i < sizeBoss; i++) {
- ptrBoss[i] = g.ptrBoss[i];
- }
- return *this;
- }
Add Comment
Please, Sign In to add comment