Skip to content
Permalink
Browse files
Created customer class, user class and a function to try and save use…
…r data to a local file
  • Loading branch information
Mazin committed Feb 25, 2019
1 parent 39dfe62 commit 8d7b976f5e1da0f0a6e9482113010b2cb8d21103
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
@@ -0,0 +1,55 @@
#include <string>
#include <vector>

std::string randomname();

std::vector<std::string> namelist = {
"Virgen Terrell",
"Irene Etchison",
"Tommie Nish",
"Marhta Guglielmo",
"Tomoko Hodak",
"Buena Canova",
"Maragret Oconnell",
"Silva Anstett",
"Lance Koonce",
"Alia Rosel",
"Joesph Weideman",
"Judy Washer",
"Benjamin Rose",
"Sabine Brant",
"Terri Scurlock",
"Shenita Astudillo",
"Sherwood Madill",
"Harriette Niemeyer",
"Maxima Zulauf",
"Marylee Ramthun",
};


class customer
{

private:
std::string name ;
std::string order ;


public:
int createcustomer(){
name = randomname();
// order =
return 0;
}

};



std::string randomname(){
int i ;
i = rand();
std::string name = namelist[i];
return name;
}

38 user.h
@@ -0,0 +1,38 @@
#include <vector>
#include <iostream>
#include <fstream>
#include <string>

/*User class is a class that represents the player and will contain info
marking progress, name and current settings for the game.
*/

class user{

private:
char* name;
char* lang;
char* term;
float timeplayed;
float money;

public:
//Creates user, can be used to check if user was previously created.
user(){
const char* name = std::getenv("USER");
const char* lang = std::getenv("LANGUAGE");
const char* term = std::getenv("TERM");
float timeplayed = 0.0 ;
float money = 0.0;
};

~user(){
std::cout << "User object has been destroyed" << std::endl ;
}

char* getName() {return name;}
char* getLang() {return lang;}
char* getTerm() {return term;}
float gettimePlayed() {return timeplayed;}
};

15 write.h
@@ -0,0 +1,15 @@
#include <fstream>
#include <string>
#include <iostream>
using namespace std ;

int savetoFile(string input, string filename)
{
ofstream file;
file.open(filename);
if (! file){
cout << "Error opening file for output"<< endl ;
return -1 ;}
file << input ;
return 0;
}

0 comments on commit 8d7b976

Please sign in to comment.