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:
- // small medium large
- string razmer;
- int number;
- Kola() {
- }
- };
- class Parkomqsto {
- private:
- string razmer;
- int number;
- bool zaeto; // true, false
- friend class Parking;
- public:
- Parkomqsto() {}
- Parkomqsto(string r) {
- razmer = r;
- zaeto = false;
- }
- void operator+(Kola k) {
- if (razmer == k.razmer) {
- zaeto = true;
- number = k.number;
- }
- }
- // return type name () {}
- };
- class Parking {
- public:
- vector<Parkomqsto> mesta;
- void obshtiMestaPoRazmeri() {
- int small = 0;
- int medium = 0;
- int large = 0;
- // S S M L M
- for (Parkomqsto p : mesta) {
- if (p.razmer == "S") {
- small++;
- }
- else if (p.razmer == "M") {
- medium++;
- }
- else if (p.razmer == "L") {
- large++;
- }
- }
- cout << small << "," << medium << "," << large << endl;
- }
- void svobodniMesta(string s) {
- int counter = 0;
- for (Parkomqsto p : mesta) {
- if (p.razmer == s && p.zaeto == false) {
- counter++;
- }
- }
- cout << counter << endl;
- }
- };
- int main() {
- Kola k;
- k.razmer = "S";
- Kola k2;
- k2.razmer = "M";
- Kola k3;
- k3.razmer = "L";
- Parkomqsto p1("S");
- Parkomqsto p2("S");
- Parkomqsto p3("M");
- Parking p;
- p.mesta = {p1, p2, p3};
- p2 + k;
- p.obshtiMestaPoRazmeri();
- p.svobodniMesta("S");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement