Question
Hello friends, I am currently doing a C++ project that involves what is needed below. Each part has what is needed inside assigned in the
Hello friends, I am currently doing a C++ project that involves what is needed below. Each part has what is needed inside assigned in the commented out sections right above the class. I am completely lost on how to continue and create code that works. I will include my includes .cpp files below the .cpp file I need to fill in. Thank you in advance for your help!!!
#include "./includes/Smalltalk.h" #include"./includes/constants.h" #include "./includes/Watch.h"
Smalltalk::Smalltalk(std::string myNationality,int iPerson=1){ }
//if pWatch !=0 then be sure to delete what it points to Smalltalk::~Smalltalk(void){ }
//cycles through phrases added in populatePhrases. Returns them 1 by 1 starting with the first and ending //with the last and then it starts over //takes the form Nationality iPerson: phrase //for instance the following string comes from an American instance, the 10th iPerson and it is printing AMERICAN_PHRASE_2 //AMERICAN 10:Why yes, I would like to supersize that std::string Smalltalk::saySomething(){
}
//returns the time (if pWatch != 0) in the form of THE_CURRENT_TIME_IS: and then the time //or I_DO_NOT_HAVE_A_WATCH string (if pWatch == 0) std::string Smalltalk::getTime(){ std::string watch = pWatch->getTime();
if(pWatch != 0){ return THE_CURRENT_TIME_IS + watch; } else{ return I_DO_NOT_HAVE_A_WATCH; } }
//if this object has a watch it is taken away, otherwise a NULL pointer is returned //this means return the pointer to the watch so another smalltalker //can use the watch. Set this->pWatch =NULL. This transaction simulates giving up a watch //this is one of the few times when a shallow copy is appropriate Watch* Smalltalk::takeWatch(){
}
//if already have a watch then return false and dont change pWatch pointer //otherwise accept watch (return true) and set this->pWatch=pWatch //this is one of the few times when a shallow copy is appropriate bool Smalltalk::giveWatch(Watch *pWatch){ return false; }
//Abstract Base Class (ABC), implement in derived classes void Smalltalk::populatePhrases(){
}
const std::string nationality; std::vector
Above is all I need to fill in, below is my included .h files
/* * constants.h * * Created on: Nov 5, 2017 * Author: keith */
#ifndef CONSTANTS_H_ #define CONSTANTS_H_ #include
const std::string I_DO_NOT_HAVE_A_WATCH = "I do not have a watch"; const std::string THE_CURRENT_TIME_IS = "The current time is:";
//nationalities const std::string AMERICAN = "AMERICAN"; const std::string AMERICAN_DE = "AMERICAN_DONUT_ENTHUSIEST"; const std::string BRIT = "BRIT";
//american phrases const std::string AMERICAN_PHRASE_1 = "Yall from round here?"; const std::string AMERICAN_PHRASE_2 = "Why yes, I would like to supersize that"; const std::string AMERICAN_PHRASE_3 = "Im off to the beach for a one day va-cay"; const std::string AMERICAN_PHRASE_4 = "The mets are gonna take the pennant this year"; const std::string AMERICAN_PHRASE_5 = "I cant see that happening this year";
//american donut enthusiest phrases const std::string AMERICAN_DE_PHRASE_1 = "Krispy Kreme is the bees knees!"; const std::string AMERICAN_DE_PHRASE_2 = "Dunkin Donuts is a horrendous, disappointing compromise"; const std::string AMERICAN_DE_PHRASE_3 = "...Jelly..donuts..are..an..abomination..."; const std::string AMERICAN_DE_PHRASE_4 = "If \'Hot Donuts Now\' is lit, I\'m stopping"; const std::string AMERICAN_DE_PHRASE_5 = "I\'m thinking a dozen hots, you want anything?"; //british phrases const std::string BRIT_1 = "Those chips gave me the collywobbles"; const std::string BRIT_2 = "Im a bit knackered mate"; const std::string BRIT_3 = "Look at that legless bloke"; const std::string BRIT_4 = "Im off to the big smoke"; const std::string BRIT_5 = "I was serving at her majesties pleasure"; const std::string BRIT_6 = "I got a right good bollicking for skiving off work."; const std::string BRIT_7 = "Its all rubbish!";
#endif /* CONSTANTS_H_ */
Above are all the constants, I have a bunch of .cpp files that populate a vector called listofpeeps with each person constant seen above (this is done specifically in a file called functions.cpp), and these .cpp files are linked to smalltalk as well. Below is my watch.cpp and watch.h that we need to use doing the time seen above.
/* * Watch.cpp * * Created on: Nov 5, 2017 * Author: keith */ #include
Watch::Watch() { }
Watch::~Watch() { }
std::string Watch::getTime() { const int CONVERT_TO_12_HOUR = 12; time_t rawtime; struct tm * timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); std::string curtime = "The time is: " + std::to_string(timeinfo->tm_min) + " minutes after" + std::to_string(timeinfo->tm_hour % CONVERT_TO_12_HOUR); return curtime; }
and below this is the watch.h
/* * Watch.h * * Created on: Nov 5, 2017 * Author: keith */
#ifndef WATCH_H_ #define WATCH_H_ #include
class Watch { public: Watch(); virtual ~Watch(); virtual std::string getTime(); };
#endif /* WATCH_H_ */
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started