Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- enum SIZE {
- S,
- M,
- L,
- };
- class Vehicle {
- public:
- // "S", "M", "L"
- SIZE size;
- int number;
- Vehicle() {
- }
- Vehicle(SIZE s, int n) {
- size = s;
- number = n;
- // &&
- // ||
- if ((number/100000) < 1 || (number / 100000) >= 10) {
- //cout << "registracionniq nomer ne e 6 cifri" << endl;
- }
- }
- };
- class ParkingSpace {
- private:
- SIZE size;
- int number;
- bool taken; // true (1) ; false (0)
- public:
- friend class Parking;
- ParkingSpace() {
- taken = false;
- number = 0;
- }
- ParkingSpace(SIZE s) {
- size = s;
- taken = false;
- number = 0;
- }
- // name, return type, parameters, body
- void operator+(Vehicle v) {
- if (size > v.size) {
- taken = true;
- number = v.number;
- }
- }
- };
- class Parking {
- public:
- vector<ParkingSpace> spaces;
- void totalSpaces() {
- int small = 0;
- int medium = 0;
- int large = 0;
- for (ParkingSpace space : spaces) {
- if (space.size == SIZE::S) small++;
- else if (space.size == SIZE::M) medium++;
- else if (space.size == SIZE::L) large++;
- }
- cout << small << "," << medium << "," << large << endl;
- }
- void freeSpacesBySize(SIZE s) {
- int counter = 0;
- // ||
- // &&
- for (ParkingSpace space : spaces) {
- if (space.size == s && space.taken == false) counter++;
- }
- cout << counter << endl;
- }
- };
- int main() {
- Vehicle v1;
- v1.size = SIZE::M;
- v1.number = 123456;
- Vehicle v2(SIZE::L, 123456);
- vector<int> n = { 2,4,6,8 };
- for (int x : n) {
- cout << x;
- }
- for (int i = 0; i < n.size(); i++) {
- cout << n[i];
- }
- Parking p;
- p.freeSpacesBySize(SIZE::M);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement