1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#include <iostream>
#include <string>
#include "Player.h"
#include <fstream>
#include <time.h>
#include <cstdlib>
/*
int x = 800;
int *pointer = &x;
cout << *pointer << endl;
*/
using namespace std;
void Load(string &PN, int &M, int &XP, int &L)
{
ifstream File_In;
File_In.open("WMSF.txt");
getline(File_In, PN);
File_In >> M;
File_In >> XP;
File_In >> L;
}
void Save(string &PN, int &M, int &XP, int &L)
{
ofstream File_Out;
File_Out.open("WMSF.txt");
File_Out << PN << endl;
File_Out << M << endl;
File_Out << XP << endl;
File_Out << L << endl;
}
void stats(string &PN, int &M, int &XP, int &L)
{
cout << "Your Stats\n" << endl;
cout << "Name: " << PN << endl;
cout << "Money $" << M << endl;
cout << "Experience: " << XP << endl;
cout << "Level: " << L << endl;
}
void Game(string &PN, int &M, int &XP, int &L)
{
int choice = 0;
int choice2 = 0;
int r;
srand(time(0));
r = rand() % 15;
cout << "MENU\n" << endl;
cout << "1) Ship products" << endl;
cout << "2) Stats" << endl;
cin >> choice;
if(choice == 1)
{
cout << "where are you shipping to" << endl;
cout << "1) Chicago" << endl;
cout << "2) Los Angeles" << endl;
cout << "3) Tokyo" << endl;
cin >> choice2;
switch(choice2)
{
case 1:
cout << "Delivering to chicago" << endl;
}
}
if(choice == 2)
{
stats(PN, M, XP, L);
}
}
int main()
{
int choice = 0;
int money = 0;
int xp = 0;
int level = 1;
int distance = 0;
string Player_Name;
cout << "Warehouse Manager\n" << endl;
cout << "1) New Game" << endl;
cout << "2) Load Game" << endl;
cin >> choice;
cin.ignore(200, '\n');
if(choice == 1)
{
cout << "Welcome, what is your name?" << endl;
getline(cin, Player_Name);
cout << "\nOk " << Player_Name << " Lets get some info before we start\n" << endl;
cout << money << endl;
money += 300;
Save(Player_Name, money, xp, level);
Game(Player_Name, money, xp, level);
}
if(choice == 2)
{
Load(Player_Name, money, xp, level);
Game(Player_Name, money, xp, level);
}
}
|