From 8d7b976f5e1da0f0a6e9482113010b2cb8d21103 Mon Sep 17 00:00:00 2001 From: Mazin Date: Mon, 25 Feb 2019 02:22:51 +0000 Subject: [PATCH] Created customer class, user class and a function to try and save user data to a local file --- customer.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ user.h | 38 +++++++++++++++++++++++++++++++++++++ write.h | 15 +++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 customer.h create mode 100644 user.h create mode 100644 write.h diff --git a/customer.h b/customer.h new file mode 100644 index 0000000..5adcaa3 --- /dev/null +++ b/customer.h @@ -0,0 +1,55 @@ +#include +#include + +std::string randomname(); + +std::vector 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; +} + diff --git a/user.h b/user.h new file mode 100644 index 0000000..7be30b6 --- /dev/null +++ b/user.h @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +/*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;} +}; + diff --git a/write.h b/write.h new file mode 100644 index 0000000..178a89d --- /dev/null +++ b/write.h @@ -0,0 +1,15 @@ +#include +#include +#include +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; +} \ No newline at end of file