Advertisement
Daniel_leinaD

Untitled

Nov 30th, 2022
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include <vector>
  4.  
  5. class photo
  6. {
  7. public:
  8.     double sz;
  9.     string id;
  10.  
  11.     photo()
  12.     {
  13.         cout << "sz" << endl;
  14.         cin >> sz;
  15.         cout << "id" << endl;
  16.         cin >> id;
  17.         cout << endl;
  18.     }
  19.  
  20.     void print_id() {
  21.         cout << id << endl;
  22.     }
  23.     void print_size() {
  24.         cout << sz << endl;
  25.     }
  26. };
  27.  
  28. class camera {
  29. public:
  30.     string model;
  31.     double internal_size;
  32.     double external_size = 0;
  33.     vector <photo> photoset;
  34.  
  35.     camera(double size1, string model1)
  36.     {
  37.         internal_size = size1;
  38.         model = model1;
  39.     }
  40.  
  41.     void insert_sd(double size1) {
  42.         external_size = size1;
  43.     }
  44.  
  45.     void take_pic(vector <photo> photos)
  46.     {
  47.         for (int i = 0; i < photos.size(); i++) {
  48.  
  49.             if (photos[i].sz < internal_size) {
  50.                 photoset.resize((photoset.size() + 1), photos[i]);
  51.                 internal_size -= photos[i].sz;
  52.                 cout << "Saving photo" << photos[i].id << " to internal sd" << endl;
  53.             }
  54.             else if (photos[i].sz < external_size) {
  55.                 photoset.resize((photoset.size() + 1), photos[i]);
  56.                 external_size -= photos[i].sz;
  57.                 cout << "Saving photo" << photos[i].id << " to external sd" << endl;
  58.             }
  59.             else cout << "Not enough space to store photo" << photos[i].id << endl;
  60.         }
  61.     }
  62.  
  63.     void print_info() {
  64.         cout << "Info about free space" << endl;
  65.         cout << "Int mem " << internal_size << endl << "Ext mem " << external_size << endl;
  66.  
  67.     }
  68. };
  69.  
  70. void main() {
  71.  
  72.     double int_size;
  73.     double ext_size = 0;
  74.     string MODEL;
  75.     cout << "Enter int mem size and model" << endl;
  76.     cin >> int_size;
  77.     cout << endl;
  78.     cin >> MODEL;
  79.     camera cam{ int_size, MODEL };
  80.     cout << endl;
  81.  
  82.     cout << "Enter sd card mem size" << endl;
  83.     cin >> ext_size;
  84.     cam.insert_sd(ext_size);
  85.  
  86.     int count = 0;
  87.     int flag;
  88.     vector <photo> photos;
  89.     cout << "Take photo? 1-yes 0-no" << endl;
  90.     cin >> flag;
  91.     while (flag != 0)
  92.     {
  93.         photos.resize(count + 1);
  94.         //cin >> photos[count].id;
  95.         //cout << endl;
  96.         //cin >> photos[count].sz;
  97.         cout << endl;
  98.         count++;
  99.         cout << "Take another photo? 1-yes 0-no" << endl;
  100.         cin >> flag;
  101.         cout << endl;
  102.     }
  103.     cout << photos.size();
  104.     cout << endl;
  105.     cam.take_pic(photos);
  106.  
  107.     cam.print_info();
  108.  
  109.  
  110.     system("pause");
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement