Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //WAGON
- #include <string>
- using namespace std;
- class Wagon {
- int mcapacity;
- double mamortization; //iznos
- public:
- string mnumber;
- double mweight;
- string mtype;
- int mdistdone;
- Wagon();
- Wagon (const Wagon &wagon);
- ~Wagon();
- void FillingPrivate(Wagon &wag);
- int Needed();
- void PrintWagon();
- };
- Wagon::Wagon() {
- mcapacity = 0;
- mamortization = 0;
- mweight = 0;
- mnumber = "0";
- mtype = "not set";
- mdistdone = 0;
- }
- Wagon::Wagon (const Wagon &wagon) {
- mcapacity = wagon.mcapacity;
- mamortization = wagon.mamortization;
- mweight = wagon.mweight;
- mnumber = wagon.mnumber;
- mtype = wagon.mtype;
- mdistdone = wagon.mdistdone;
- }
- Wagon::~Wagon () {}
- void Wagon::FillingPrivate(Wagon &wag) {
- if (wag.mtype == "PASSENGER") {
- cout << "Enter Capacity for wagon (amount of people) > ";
- cin >> mcapacity;
- }
- else {
- cout << "Enter Capacity for wagon (tons of cargo) > ";
- cin >> mcapacity;
- }
- cout << "Enter Amortization for wagon > ";
- cin >> mamortization;
- while (mamortization <= 0 || mamortization > 1) {
- cout << "Incorrect! Enter Amortization for wagon again > ";
- cin >> mamortization;
- }
- return;
- }
- int Wagon::Needed() {
- int n;
- int get;
- n = mdistdone / mamortization;
- get = n - mdistdone;
- return get;
- }
- void Wagon::PrintWagon() {
- cout << "Number: " << mnumber << endl;
- cout << "Type: " << mtype << endl;
- cout << "Capacity: " << mcapacity << endl;
- cout << "Weight: " << mweight << endl;
- cout << "Amortization: " << mamortization << endl;
- cout << "Distance: " << mdistdone << endl;
- return;
- }
- void Filling(Wagon &train) {
- cout << endl << "Filling..." << endl;
- cout << "Enter Number for wagon > ";
- cin >> train.mnumber;
- cout << "Enter Type for wagon ( 1-4 )" << endl;
- cout << "1 - PASSENGER" << endl;
- cout << "2 - CARGO" << endl;
- cout << "3 - MAIL" << endl;
- cout << "4 - TANKER" << endl;
- cout << "Type > ";
- cin >> train.mtype;
- if (train.mtype < "1" || train.mtype > "4") {
- cout << "WRONG TYPE! Enter Type again" << endl;
- cout << "Type > ";
- cin >> train.mtype;
- }
- if (train.mtype == "1") { train.mtype = "PASSENGER"; }
- else if (train.mtype == "2") { train.mtype = "CARGO"; }
- else if (train.mtype == "3") { train.mtype = "MAIL"; }
- else if (train.mtype == "4") { train.mtype = "TANKER"; }
- cout << "Type set to " << train.mtype << endl;
- train.FillingPrivate(train);
- cout << "Enter Weight for wagon > ";
- cin >> train.mweight;
- cout << "Enter Made Distance for wagon > ";
- cin >> train.mdistdone;
- return;
- }
- bool CheckNumber(Wagon &wag, string iden) {
- string getid = wag.mnumber;
- if (getid == iden) { return true; }
- else { return false; }
- }
- int main(void) {
- Wagon w1, w2;
- w1.PrintWagon();
- Filling(w1);
- w2 = Wagon(w1);
- w1.PrintWagon();
- cout << "To end: " << w1.Needed() << endl;
- cout << "Copy of w1 - w2. Printing it" << endl;
- w2.PrintWagon();
- cout << endl;
- cout << CheckNumber(w1, "1") << endl;
- cout << CheckNumber(w1, "2") << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement