59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
#include <ctime>
|
|
|
|
using namespace std;
|
|
|
|
void menu() {
|
|
cout << "============================" << endl;
|
|
cout << "=========== MENU ===========" << endl;
|
|
cout << "============================" << endl;
|
|
cout << "1 ... GENERATE WATER INTAKES" << endl;
|
|
cout << "2 ... PRINT WATER INTAKES" << endl;
|
|
cout << "0 ... EXIT" << endl;
|
|
cout << "============================" << endl;
|
|
cout << "Select: ";
|
|
}
|
|
|
|
void fillVector(vector<WaterIntake*> &waterIntakes, const unsigned int size) {
|
|
for (unsigned int i = 0; i < size; i++) {
|
|
waterIntakes.push_back(new WaterIntake(3, 3, 2022, (float)(rand() % 31 + 5)/10.f));
|
|
}
|
|
}
|
|
|
|
void printVector(const vector<WaterIntake*> &waterIntakes) {
|
|
for (unsigned int i = 0; i < waterIntakes.size(); i++)
|
|
cout << waterIntakes[i]->toString() << ((i < waterIntakes.size() - 1) ? ", " : ".") << std::endl;
|
|
}
|
|
|
|
int main() {
|
|
const unsigned int days = 30;
|
|
vector<WaterIntake*> waterIntakes;
|
|
|
|
srand(time(nullptr));
|
|
|
|
bool running = true;
|
|
int selection;
|
|
|
|
do {
|
|
menu();
|
|
cin >> selection;
|
|
switch (selection) {
|
|
case 1:
|
|
fillVector(waterIntakes, days);
|
|
break;
|
|
case 2:
|
|
printVector(waterIntakes);
|
|
break;
|
|
case 0:
|
|
running = false;
|
|
break;
|
|
default:
|
|
cout << "Wrong selection!" << endl;
|
|
break;
|
|
}
|
|
cout << endl;
|
|
} while (running);
|
|
|
|
return 0;
|
|
} |