Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Created customer class, user class and a function to try and save use…
…r data to a local file
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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;} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |