Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here is my loadData function in my Scheduler class: void Scheduler::LoadData ( const std::string& filename ) { std::ifstream inputFile ( filename ) ; if (
Here is my loadData function in my Scheduler class: void Scheduler::LoadDataconst std::string& filename
std::ifstream inputFilefilename;
if inputFile.isopen
std::cerr "Error opening file: filename std::endl;
return;
std::string line;
while std::getlineinputFile line
std::stringstream ssline;
std::string type;
std::getliness type, ;
if type G type H
std::string groomerFirstName, groomerLastName, groomerPhone;
std::string ownerFirstName, ownerLastName, ownerPhone;
std::string petName, petType;
double groomingPrice, haircutPrice;
std::string date, time;
Read strings with delimiter
std::getliness groomerFirstName, ;
std::getliness groomerLastName, ;
std::getliness groomerPhone, ;
std::getliness ownerFirstName, ;
std::getliness ownerLastName, ;
std::getliness ownerPhone, ;
std::getliness petName, ;
std::getliness petType, ;
ss groomingPrice;
if type H
ssignore; Ignore the comma
ss haircutPrice;
std::getliness date, ;
std::getliness time, ;
Assuming DateTime has SetDate and SetTime functions
DateTime dateTime;
dateTime.SetDatedate; Make sure SetDate handles the ddmmyyyy format
dateTime.SetTimetime; Assuming SetTime handles the hh:mm ampm format
if type G
std::sharedptr groomingAppointment std::makeshared
PersongroomerFirstName groomerLastName, groomerPhone
PetownerFirstName ownerLastName, ownerPhone, petName, petType
dateTime.GetDate Use the GetDate function to retrieve the formatted date
dateTime.GetTime Use the GetTime function to retrieve the formatted time
groomingPrice;
appointmentspushbackgroomingAppointment;
else if type H
std::sharedptr haircutAppointment std::makeshared
PersongroomerFirstName groomerLastName, groomerPhone
PetownerFirstName ownerLastName, ownerPhone, petName, petType
dateTime.GetDate Use the GetDate function to retrieve the formatted date
dateTime.GetTime Use the GetTime function to retrieve the formatted time
groomingPrice,
haircutPrice;
appointmentspushbackhaircutAppointment;
inputFile.close; Here is my SetDate function in the DateTime class: void DateTime::SetDateconst std::string& date
std::istringstream dateStreamdate;
char delimiter;
Try parsing with as delimiter
dateStream day delimiter month delimiter year;
If parsing fails, reset the stream position and try parsing with as delimiter
if dateStreamfail
dateStream.clear;
dateStream.seekg;
Try parsing with as delimiter
dateStream day delimiter month delimiter year;
If parsing still fails, reset the stream position and try parsing with as delimiter
if dateStreamfail
dateStream.clear;
dateStream.seekg;
Try parsing with as delimiter
dateStream day delimiter month delimiter year;
std::cerr "Parsed date: month month day day year year std::endl;
My issue is when I run the program the date gets printed as instead of the actual date. Can anyone see why? Is it a parsing issue? Thanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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