Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <vector>
- class photo
- {
- public:
- double sz;
- string id;
- photo()
- {
- cout << "sz" << endl;
- cin >> sz;
- cout << "id" << endl;
- cin >> id;
- cout << endl;
- }
- void print_id() {
- cout << id << endl;
- }
- void print_size() {
- cout << sz << endl;
- }
- };
- class camera {
- public:
- string model;
- double internal_size;
- double external_size = 0;
- vector <photo> photoset;
- camera(double size1, string model1)
- {
- internal_size = size1;
- model = model1;
- }
- void insert_sd(double size1) {
- external_size = size1;
- }
- void take_pic(vector <photo> photos)
- {
- for (int i = 0; i < photos.size(); i++) {
- if (photos[i].sz < internal_size) {
- photoset.resize((photoset.size() + 1), photos[i]);
- internal_size -= photos[i].sz;
- cout << "Saving photo" << photos[i].id << " to internal sd" << endl;
- }
- else if (photos[i].sz < external_size) {
- photoset.resize((photoset.size() + 1), photos[i]);
- external_size -= photos[i].sz;
- cout << "Saving photo" << photos[i].id << " to external sd" << endl;
- }
- else cout << "Not enough space to store photo" << photos[i].id << endl;
- }
- }
- void print_info() {
- cout << "Info about free space" << endl;
- cout << "Int mem " << internal_size << endl << "Ext mem " << external_size << endl;
- }
- };
- void main() {
- double int_size;
- double ext_size = 0;
- string MODEL;
- cout << "Enter int mem size and model" << endl;
- cin >> int_size;
- cout << endl;
- cin >> MODEL;
- camera cam{ int_size, MODEL };
- cout << endl;
- cout << "Enter sd card mem size" << endl;
- cin >> ext_size;
- cam.insert_sd(ext_size);
- int count = 0;
- int flag;
- vector <photo> photos;
- cout << "Take photo? 1-yes 0-no" << endl;
- cin >> flag;
- while (flag != 0)
- {
- photos.resize(count + 1);
- //cin >> photos[count].id;
- //cout << endl;
- //cin >> photos[count].sz;
- cout << endl;
- count++;
- cout << "Take another photo? 1-yes 0-no" << endl;
- cin >> flag;
- cout << endl;
- }
- cout << photos.size();
- cout << endl;
- cam.take_pic(photos);
- cam.print_info();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement