Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <sstream>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- //Escape add
- float random(float x);
- //Global
- //Inventory
- int potInv = 0, oilInv = 0;
- int qty = 0; //quantity
- int inv = 0;
- //User
- float balance = 1000;
- //Trade Goods Prices, in order: Sweden, Poland
- //Escape-add;
- float x;
- float randomnum = random(x);
- float potPrice[2] = { 90, 157.5 };
- float oilPrice[2] = { 400, 300 };
- float price;
- float priceArrays[100];
- //Country Mem
- string country = "None"; //Starting
- string place[2] = { "Sweden", "Poland" };
- int land; //index
- //Country Inv (Default inv)
- //surplus 200%;
- //well-met 100%;
- //high 75%; med 50%; low 25%;
- int potInvSwede = 150, potInvPol = 50; //well 100
- int oilInvSwede = 25, oilInvPol = 75; //well 50
- int inv_Country = 0;
- //Goods
- string tradeGoods[2] = { "Pottery ", "Oil " };
- int goodNo;
- int goodType;
- //int remember strings
- int mem = 0; //inv
- int mem2 = 0; //notes
- int mem3 = 0; //buy/sell
- //End of Global
- //Escape add
- void random(void);
- //What do I do first?
- void loc(void);
- //User's Inventory
- void check(void);
- //Trade
- void trade(void);
- //Buy function
- void buy(void);
- //traded
- void traded(void);
- //Quantity function
- void quantity(void);
- //lack function
- void lack(void);
- //Sell function
- void sell(void);
- //Goods function
- void goods(void);
- //Notes function
- void notes(void);
- //Balance function
- void balance_balance(void);
- //todo
- void todo(void);
- void todo2(void);
- //Country Inventory
- void countryInv(void);
- void determineCountry(void);
- main(){
- loc();
- }
- //loc function
- void loc(void){
- country = "None";
- string input;
- int x = 0;
- mem = 0;
- mem2 = 0;
- cout << endl;
- cout << endl;
- cout << "Balance: " << balance;
- cout << endl;
- cout << "What do you want to do?";
- cout << endl;
- cout << "[1] Trade";
- cout << endl;
- cout << "[2] Check Inventory";
- cout << endl;
- do {
- cout << "Enter Input: ";
- cin >> input;
- stringstream(input) >> x;
- switch (x)
- {
- case 1:
- trade();
- break;
- case 2:
- check();
- break;
- default:
- cout << "That's an invalid option. Please try again.";
- }
- cout << endl;
- } while (input != "1" || input != "2");
- }
- //check function
- void check(void){
- cout << endl;
- cout << "You currently have:";
- cout << endl;
- cout << potInv << " Pottery";
- cout << endl;
- cout << oilInv << " Oil";
- cout << endl;
- cout << " ...in your inventory.";
- cout << endl;
- system("pause");
- switch (mem){
- case 0:
- loc();
- break;
- case 1:
- trade();
- break;
- case 2:
- buy();
- break;
- case 3:
- sell();
- break;
- case 4:
- todo2();
- break;
- }
- }
- //trade function
- void trade(void){
- mem = 1;
- string input;
- country = "None";
- mem2 = 1;
- int x;
- cout << endl;
- cout << "Country List: ";
- cout << endl;
- cout << "[1] " << "Sweden";
- cout << endl;
- cout << "[2] " << "Poland";
- cout << endl;
- cout << "[3] " << "Check inventory";
- cout << endl;
- cout << "[4] " << "Check notes";
- cout << endl;
- cout << "[5] " << "Return";
- cout << endl;
- do {
- cout << "Enter Input: ";
- cin >> input;
- stringstream(input) >> x;
- switch (x){
- case 1:
- land = 0;
- todo();
- break;
- case 2:
- land = 1;
- todo();
- break;
- case 3:
- check();
- break;
- case 4:
- notes();
- break;
- case 5:
- loc();
- break;
- default:
- cout << "That's an invalid option. Please try again.";
- cout << endl;
- break;
- }
- cout << endl;
- } while (input != "1" || input != "2" || input != "3" || input != "4" || input != "5");
- }
- //goods function
- void goods(void){
- cout << setprecision(2) << fixed;
- cout << endl;
- random();
- cout << "[3] " << "Check inventory";
- cout << endl;
- cout << "[4] " << "Check notes";
- cout << endl;
- cout << "[5] " << "Return";
- cout << endl;
- }
- //buy function
- void buy(void){
- string input;
- int x;
- mem = 2;
- mem2 = 2;
- mem3 = 0;
- if (land == 0){
- cout << endl;
- cout << "You are trading with Sweden . . . ";
- cout << endl;
- }
- else if (land == 1){
- cout << endl;
- cout << "You are trading with Poland . . . ";
- cout << endl;
- }
- country = "None";
- balance_balance();
- goods();
- cout << "What do you want to buy? ";
- cout << endl;
- cout << "Options: ";
- cin >> input;
- stringstream(input) >> x;
- switch (x){
- case 1:
- goodType = 0;
- determineCountry();
- inv = potInv;
- price = priceArrays[goodType];
- quantity();
- if (balance < qty *price){
- lack();
- break;
- }
- else if (balance >= qty *price){
- traded();
- break;
- }
- case 2:
- goodType = 1;
- determineCountry();
- inv = oilInv;
- price = priceArrays[goodType];
- quantity();
- if (balance < qty *price){
- lack();
- break;
- }
- else if (balance >= qty *price){
- traded();
- break;
- }
- case 3:
- check();
- break;
- case 4:
- notes();
- break;
- case 5:
- trade();
- break;
- default:
- buy();
- cout << endl;
- }
- }
- //traded function
- void traded(void){
- cout << setprecision(2) << fixed;
- if (mem3 == 0){
- balance -= qty * price;
- balance_balance();
- cout << endl;
- cout << "You bought " << tradeGoods[goodType] << " for " << qty * price << ".";
- cout << endl;
- if (goodType==0) potInv+=qty;
- else if (goodType==1) oilInv+=qty;
- system("pause");
- loc();
- }
- else if (mem3 == 1){
- balance += qty * price;
- balance_balance();
- cout << endl;
- cout << "You sold " << tradeGoods[goodType] << " for " << qty * price << ".";
- cout << endl;
- if (goodType==0) potInv-=qty;
- else if (goodType==1) oilInv-=qty;
- cout << endl;
- system("pause");
- loc();
- }
- }
- //quantity function
- void quantity(void){
- mem = 4;
- balance_balance();
- if (mem3 == 0){
- cout << "How many " << tradeGoods[goodType] << " do you want to buy? ";
- cin >> qty;
- countryInv();
- }
- else if (mem3 == 1){
- cout << "How many " << tradeGoods[goodType] << " do you want to sell? ";
- cin >> qty;
- countryInv();
- }
- else quantity();
- }
- //lacking function
- void lack(void){
- if (mem3 == 0){
- cout << endl;
- cout << "You have insufficient balance . . . ";
- cout << endl;
- system("pause");
- buy();
- }
- else if (mem3 == 1){
- cout << endl;
- cout << "You don't have " << qty << " of " << tradeGoods[goodType];
- cout << endl;
- system("pause");
- sell();
- }
- }
- //sell function
- void sell(void){
- string input;
- int x;
- mem = 3;
- mem2 = 3;
- mem3 = 1;
- country = "None";
- balance_balance();
- goods();
- cout << "What do you want to sell? ";
- cout << endl;
- cout << "Options: ";
- cin >> input;
- stringstream(input) >> x;
- switch (x){
- case 1:
- goodType = 0;
- inv = potInv;
- price = priceArrays[goodType];
- quantity();
- if (inv >= qty){
- traded();
- break;
- }
- else if (inv < qty){
- lack();
- break;
- }
- case 2:
- goodType = 1;
- inv = oilInv;
- price = priceArrays[goodType];
- quantity();
- if (inv < qty){
- lack();
- break;
- }
- else if (inv >= qty){
- traded();
- break;
- }
- case 3:
- check();
- break;
- case 4:
- notes();
- break;
- case 5:
- trade();
- break;
- default:
- sell();
- }
- }
- //notes function
- void notes(void){
- if (country == "Sweden"){
- cout << endl;
- cout << "Sweden's exports and imports are well-met . . . ";
- cout << endl;
- //For checking . . .
- cout << "Sweden's Inventory . . . ";
- cout << endl;
- cout << "Pottery: " << potInvSwede;
- cout << endl;
- cout << "Oil: " << oilInvSwede;
- cout << endl;
- }
- else if (country == "Poland"){
- cout << endl;
- cout << "Poland Information . . . ";
- cout << endl;
- cout << "Exports: Placeholder";
- cout << endl;
- cout << "Imports: Placeholder";
- cout << endl;
- // Checking . . .
- cout << "Poland's Inventory . . . ";
- cout << endl;
- cout << "Pottery: " << potInvPol;
- cout << endl;
- cout << "Oil: " << oilInvPol;
- cout << endl;
- }
- else if (country == "None"){
- cout << "Input country notes: ";
- cin >> country;
- notes();
- }
- else{
- cout << "Input country notes: ";
- cin >> country;
- notes();
- }
- system("pause");
- if (mem2 == 1) trade();
- else if (mem2 == 2) buy();
- else if (mem2 == 3) sell();
- else if (mem2 == 4) quantity();
- else if (mem2 == 5) todo2();
- }
- //balance function
- void balance_balance(void){
- cout << endl;
- cout << setprecision(2) << fixed;
- cout << "Balance: " << balance;
- cout << endl;
- }
- //todo function
- void todo(void){
- if (land == 0){
- cout << endl;
- cout << "You are now trading with Sweden . . . ";
- cout << endl;
- todo2();
- }
- else if (land == 1){
- cout << endl;
- cout << "You are now trading with Poland . . . ";
- cout << endl;
- todo2();
- }
- }
- //todo2 function
- void todo2(void){
- int x;
- country = "None";
- mem = 4;
- mem2 = 5;
- cout << endl;
- cout << "[1] Buy";
- cout << endl;
- cout << "[2] Sell";
- cout << endl;
- cout << "[3] Check inventory";
- cout << endl;
- cout << "[4] Check notes";
- cout << endl;
- cout << "[5] Return";
- cout << endl;
- string input;
- cout << "Options: ";
- cin >> input;
- stringstream(input) >> x;
- switch (x){
- case 1:
- buy();
- break;
- case 2:
- sell();
- break;
- case 3:
- check();
- break;
- case 4:
- notes();
- break;
- case 5:
- trade();
- break;
- default:
- todo();
- }
- }
- //country inventory
- void countryInv(void){
- if (land==0){
- //Buy
- //Buying pot
- if (goodType==0 && mem3==0){
- if (qty>potInvSwede){
- cout << "Sweden does not have " << qty << " pottery.";
- quantity();
- }
- else potInvSwede -= qty;
- }
- //Buying oil
- else if (goodType==1 && mem3==0){
- if (qty>oilInvSwede){
- cout << "Sweden does not have " << qty << " oil.";
- quantity();
- }
- else oilInvSwede -= qty;
- }
- //Sell
- //Selling pot
- if (goodType==0 && mem3==1){
- potInvSwede += qty;
- }
- //Selling oil
- else if (goodType==1 && mem3==1){
- oilInvSwede += qty;
- }
- }
- else if (land==1){
- //Buy
- if (goodType==0 && mem3==0){
- if (qty>potInvPol){
- cout << "Poland does not have " << qty << " pottery.";
- quantity();
- }
- else potInvPol -= qty;
- }
- else if (goodType==1 && mem3==0){
- if (qty>potInvPol){
- cout << "Poland does not have " << qty << " oil.";
- quantity();
- }
- oilInvPol -= qty;
- }
- //Sell
- else if (goodType==0 && mem3==1){
- potInvPol += qty;
- }
- else if (goodType==1 && mem3==1){
- oilInvPol += qty;
- }
- }
- }
- //random function
- void random(void){
- goodType = 0;
- for (int i = 1; i <= 2; i++){
- if (goodType == 0){
- if (land == 0){
- inv_Country = potInvSwede;
- }
- else if (land == 1){
- inv_Country = potInvPol;
- }
- if (inv_Country >= 76 && inv_Country >= 100){
- price = potPrice[land] + randomnum * 1;
- }
- else if (inv_Country >= 51 && inv_Country >= 75){
- price = potPrice[land] * 1.25 + randomnum;
- }
- else if (inv_Country >= 26 && inv_Country >= 50){
- price = potPrice[land] * 1.50 + randomnum;
- }
- else if (inv_Country > 25){
- price = oilPrice[land] * 2 + randomnum;
- }
- else if (inv_Country < 100){
- price = potPrice[land] * 0.5 + randomnum;
- }
- priceArrays[0] = price;
- }
- else if (goodType == 1){
- if (land == 0){
- inv_Country = oilInvSwede;
- }
- else if (land == 1){
- inv_Country = oilInvPol;
- }
- if (inv_Country >= 38 && inv_Country >= 50){
- price = oilPrice[land] + randomnum;
- }
- else if (inv_Country >= 26 && inv_Country >= 37){
- price = oilPrice[land] * 1.25 + randomnum;
- }
- else if (inv_Country >= 13 && inv_Country >= 25){
- price = oilPrice[land] * 1.50 + randomnum;
- }
- else if (inv_Country >12){
- price = oilPrice[land] * 2 + randomnum;
- }
- else if (inv_Country < 50){
- price = oilPrice[land] * 0.75 + randomnum;
- }
- priceArrays[1] = price;
- }
- cout << "[" << i << "] " << tradeGoods[goodType] << price;
- cout << endl;
- goodType++;
- }
- }
- float random(float x){
- srand(time(0));
- x = rand() % 20 + (-20);
- return x;
- }
- //inv country function
- void determineCountry(void){
- if (land == 0){
- if (goodType == 0) inv_Country = potInvSwede;
- else if (goodType == 1) inv_Country = oilInvSwede;
- }
- else if (land == 1){
- if (goodType == 0) inv_Country = potInvPol;
- else if (goodType == 1) inv_Country = oilInvPol;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement