Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class Kola {
- public:
- // "S", "M", "L"
- // "small", "medium", "large"
- string size;
- int number;
- Kola() {}
- Kola(string s, int n) {
- size = s;
- number = n;
- }
- };
- class ParkingSpace {
- private:
- string size;
- bool taken;
- int number;
- public:
- friend class Parking;
- ParkingSpace() {
- }
- ParkingSpace(string s) {
- size = s;
- taken = false;
- }
- // int/string/void? function1 () {}
- // return type name parameters body
- vector<int> funkci1() {
- return { 0,0,0 };
- }
- void operator+(Kola k) {
- if (size == k.size) {
- taken = true;
- number = k.number;
- }
- }
- };
- class Parking {
- public:
- vector<ParkingSpace*> parkomesta;
- void totalSpaces() {
- auto small = 0;
- int medium = 0;
- int large = 0;
- for (ParkingSpace* space : parkomesta) {
- if (space->size == "S") small++;
- if (space->size == "M") medium++;
- if (space->size == "L") large++;
- }
- cout << small << "," << medium << "," << large << endl;
- }
- void freeSpaceBySize(string s) {
- int counter = 0;
- // &&
- for (ParkingSpace* space : parkomesta) {
- if (s == space->size && space->taken == false) counter++;
- }
- cout << counter << endl;
- }
- vector<ParkingSpace> function2() {
- vector<ParkingSpace> result;
- for (ParkingSpace* space : parkomesta) {
- if (space->taken == false) result.push_back(*space);
- }
- return result;
- }
- };
- int main() {
- Kola k;
- k.size = "S";
- k.number = 123456;
- Kola k2("M", 123456);
- ParkingSpace p1("S");
- ParkingSpace p2("M");
- ParkingSpace p3("L");
- Parking p;
- p.parkomesta = { &p1, &p2, &p3, &p2 };
- p.totalSpaces();
- p.freeSpaceBySize("M");
- p2 + k2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement