Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // System przydziela automatycznie kod nowego produktu
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <sstream> // std::strningstream
- #include <vector>
- #include <string>
- #include "../../../Bjarne Stroustrup/std_lib_facilities.h"
- using namespace std;
- namespace quantity {
- static const string kilogram = "kg";
- static const string piece = "p";
- }
- class Product {
- public:
- enum class type { vegetable, fruit };
- type kind;
- string name;
- string quantity;
- Product(type k, string n, string q, double c, int pc)
- :kind(k), name(n), cost(c), quantity(q), product_code(pc) {}
- void set_cost(double c) { cost = c; }
- double get_cost() { return cost; }
- int get_product_code() { return product_code; }
- private:
- double cost;
- int const product_code;
- };
- void read_from_file()
- {
- ifstream file("data.txt");
- string file_text;
- if (!file)
- cerr << "Error: Failed to open the input file\n";
- getline(file, file_text);
- }
- stringstream parsing_text()
- {
- stringstream sstream;
- string type, kind, quantity;
- double cost = 0;
- int code = 0;
- sstream >> type >> kind >> quantity >> cost >> code;
- return sstream;
- }
- Product::type check_product_type(string& t)
- {
- if (t == "f")
- return Product::type::fruit;
- else
- return Product::type::vegetable;
- }
- string check_product_quantity(string& k)
- {
- if (k == quantity::kilogram)
- return;
- }
- int main()
- try {
- }
- catch (exception& e) {
- cerr << "exception: " << e.what() << endl;
- }
- catch (...) {
- cerr << "exception\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement