Question
Work Schedule Project Write a C++ program to display workers schedule for a company. To accomplish this (1) Write a struct Time with attributes (at
Work Schedule Project
Write a C++ program to display workers schedule for a company. To accomplish this
(1) Write a struct Time with attributes (at least) : hours, minutes and seconds (using military time). Add other functions or attributes you need to get the job done (2) Write a class Schedule with attributes : Day of week, start_time, end_time and activity. Schedule should have at least (a) Display to display the schedule (b) Length to return the duration of the schedule (ie end_time - start_time), (c) ReadSchedule to read schedule from user
(2b) Your program must check that only appropriate numbers are entered for Time in ReadSchedule (default value for hour/minute and second is 0) (2c) Your program should indicate error when end_time
(3) Your program should read list of schedules from a csv file named schedules.csv (a) schedules.csv must contain a schedule per line (day,start-time,end-time,activity) for example Mon,10:30:0,12:15:30,Swimming lesson (the enclosed CSVReader contains a method getCellAsIntArray(':') that returns an array like [hour,min,sec] which you can use to get the time part of the csv) (b) schedules.csv must contain at least two schedules per day of the week (Mon - Sun) (c) YOU MAY NOT DIRECTLY USE MY SCHEDULES.CSV FOR SUBMISSION - YOU MUST PROVIDE YOUR OWN - USING MINE WILL RESULT IN DEDUCTION OF 5 POINTS
(4) Create the struct Time and class Schedule in a file named schedule.h which you must include in main.cpp
(5) Your program must be able to search for schedule given (a) day of the week (not case sensitive, ie entering MON or Mon or mon or mOn should mean the same thing) (b) activity type (not case sensitive) (c) I have included a file called stringutils.h which contains functions for comparing strings which may be of use to you - feel free to use it
(6) Your program should produce EXACTLY the same output as the enclosed program (run sample.exe to see the output). Feel free to customize my Scheduler program provided for version 2 of this project
(7) The project name is SCHEDULER3
(8) Use AssignmentZipper or winrar to package your assignment into one .zip folder
Below is the csvreader2.h file that must be used
and a picture of a sample of the run output.
csvreader2.h file
#ifndef CSVREADER_H #define CSVREADER_H
using namespace std; #include
// trim from left. This is not part of the class, just a utility function inline std::string& ltrim(std::string& s, const char* t = " \t \f\v") { s.erase(0, s.find_first_not_of(t)); return s; }
// trim from right. This is not part of the class, just a utility function inline std::string& rtrim(std::string& s, const char* t = " \t \f\v") { s.erase(s.find_last_not_of(t) + 1); return s; }
// trim from left & right. This is not part of the class, just a utility function inline std::string& trim(std::string& s, const char* t = " \t \f\v") { return ltrim(rtrim(s, t), t); }
////Split a given string using given delimiter. This is not part of the class, just a utility function vector
class CSVReader { public: CSVReader(string filepath,char del=','); vector
//implementation of the functions CSVReader::CSVReader(string filepath,char del) { ColsLength=0; this->del=del; //declare the file ifstream csvfile; csvfile.open(filepath); if(csvfile.good()) { string line; while ( getline(csvfile, line) ){ if (line.find(del) != std::string::npos) //make sure the delimiter is in the line we are reading { Rows.push_back(trim(line)); //set the number of columns if necessary if(ColsLength==0) ColsLength = (split(line,del)).size(); } }//end of while } else cout I had trouble opening the file["
///get an entire row as vector vector
///get content in location (row, col) string CSVReader::getCellAsString(int row, int col) const { vector
///get content in location (row, col) as char char CSVReader::getCellAsChar(int row, int col) const { vector
///get content in location (row, col) as int int CSVReader::getCellAsInt(int row, int col) const { vector
///get content in location (row, col) as vector #endif
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