QuestionQuestion

Your program will include four classes: DigitalTime, TimeInterval, DaysOfWeek, and Course. You will need to implement all four classes, and write the header file for DaysOfWeek and Course. Finally, you will write a main program that uses a vector of Course objects to implement the application described below. You will submit a tar file (or zip file) containing the 4 header files and the 5 source files.

The Course class
The Course class represents a single course entry in a schedule of classes. Its member variables should include:
• A course code (a string of alpha-numeric characters such as COMPSCI337)
• A section, which is a string of 3 numeric characters
• The days of the week the course meets (such as MW, TR, MWF, etc.). This is a DaysOfWeek object
• The time the course meets (such as 09:30-10:45 or 17:00-19:50). This is a TimeInterval object
• The instructor, a string of alphabetic characters which uniquely identifies an instructor

Besides the normal set/get member which you will need to implement for the Course class, and any constructors yo wish to use, you will also need to implement 2 additional member functions:
• An isOverlap member function, which takes a second course object. If the 2 courses have the same instructor and overlapping times, the isOverlap member function returns true. Times a and b overlap if the start of a is less than or equal to the end time of b and the end time of a is greater than or equal to the start time of b. Otherwise, it returns false.
• An isMatch member function, which takes a second course object. If the 2 courses have the same course code and section, the isMatch member function returns true. Otherwise, it returns false.
Use isOverlap to overload the && operator. Use isMatch to overload the == operator.

The DaysOfWeek class
Logically, a DaysOfWeek object is a six element Boolean array. Each of the days of the week, except for Sunday, is represented by a letter code: M=Monday, T=Tuesday, W=Wednesday, R=Thursday, F=Friday, S=Saturday. Each day is either present(on), or absent (off). It is possible to have a DaysOfWeek object with no days present, and such an object is produced by the default constructor for the class.
• In addition, you should implement a constructor and a set function that takes a string and, for each day of the week, sets that day to be present if its code letter (in upper or lower case) appears in the input string, and absent otherwise.
• The get member function returns a string of code letters for each day present in the object, all uppercase, in chronological order (i.e. MTWRFS).
• The input member function takes an istream object, removes the first whitespace delimited token, and sets the object using this token as input.
• The output member function takes an ostream object, and sends the results of get to that ostream.
• The isEqual member function returns true for if the host object and DaysOfWeek argument have identical present days, false otherwise.
• The isOverlap function member function returns true for if the host object and DaysOfWeek argument have at least one common present day, false otherwise. Note that this means that 2 DaysOfWeeks objects with no present days do not overlap (online courses).
• Finally, you should overload the &&, ==, and != operators as non-member functions using isOverlap for && and isEqual to implement == and !=.

Functional Requirements
Your program will be driven by a command line prompt. The valid commands are add, clear, import, export, remove, and validate. Command parameters are denoted by < >.
add <days> <start time> <end time> <course code> <section> <instructor
If any of the inputs are not valid, the program responds with an error message. If an course with the same course code and section already exists an error is displayed. Otherwise the course is added to the schedule.

For example:
add MW 09:30 10:45 COMPSCI337 401 ROCK

The letter O is used to denote an empty set of days of the week. For example, add O 00:00 00:00 COMPSCI140 901 ROCK

This would be useful for online courses, which have no set meeting time.

clear
Delete all courses from the current schedule.

export <file name>
Save the contents of the schedule vector to an output file only if the schedule can be validated. If the schedule is not valid, error messages are displayed describing the problem(s) (see validate below). If the given file name is invalid (file exists, bad path, no permissions, etc.) an error message is displayed. Otherwise, the file is created and filled with the courses from the schedule in the schedule file format (SFF) described below.

For example:
export class.txt
import <file name>
Read the contents of the given file assuming it is a valid SFF If a line of the input file contains an invalid SFF course entry, and error message displays the line number and contents of the line and identifies which field triggered the error, then file processing continues with the next line. If a course with the same course code and section already exists an error message is displayed and file processing continues with the next line. Otherwise the course is added to the schedule and processing continues with the next line. The SFF file format is described below.

For example:
import class.txt
remove <course code> <section>

Deletes the given course from the schedule. If the course does not exist, an error message is displayed and no changes are made to the schedule.

For example:
remove COMPSCI337 401

validate
Check the current schedule to determine whether any instructor is teaching 2 courses at the same time. If there are course overlaps, each should be noted with a separate error message.

quit
End the program.
SFF Format
An SFF file contains a course entry on each line. Each course entry is of the form:
<days> <start time> <end time> <course code> <section> <instructor>

For example:
MW 09:30 10:45 COMPSCI337 401 ROCK
The letter O is used to denote an empty set of days of the week. For example,

O 00:00 00:00 COMPSCI140 901 ROCK

This would be useful for online courses, which have no set meeting time.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

include "DigitalTime.h"

/**
* constructor
*/
DigitalTime::DigitalTime() {
    hour = 0;
    minute = 0;
    good = true;
}

/**
* constructor
* @param time
*/
DigitalTime::DigitalTime(string time) {
    good = setDigitalTime(time);
}

/**
* copy constructor
* @param o
*/
DigitalTime::DigitalTime(const DigitalTime& o) {
    hour = o.hour;
    minute = o.minute;
    good = o.good;
}

/**
* destructor
*/
DigitalTime::~DigitalTime() {
}

/**
* add zero to number to create suitable string for outputing
* @param num
* @return the format 09 or 12
*/
string DigitalTime::addZero(int num) {
    stringstream ss;

    if (num > 9) {
       ss << num;
    } else {
       ss << "0" << num;
    }

    return ss.str();
}

/**
*
* @return string expression of object
*/
string DigitalTime::getDigitalTime() {
    return addZero(hour) + ":" + addZero(minute);
}

/**
* parse and setup the object
* @param time
* @return
*/
bool DigitalTime::setDigitalTime(string time) {
    hour = 0;
    minute = 0;
    good = false;
    // bad input
    if (time.length() != 5) {
       return good;
    }
    // input should follow this format 00:14
    for (int i = 0; i < 2; i++) {
       if (isdigit(time[i]) == false
                || isdigit(time[i + 3]) == false ) {
            return good;
       }
    }
    // the middle character has to be ':'
    if (time[2] != ':') {
       return good;
    }
    // split the time string
    string h = time.substr(0, 2);
    string m = time.substr(3);
    hour = atoi(h.c_str());
    minute = atoi(m.c_str());
   
    // test the correctness of hour and minute
    if (hour >= 24 || minute >= 60) {
       good = false;
    } else {
       good = true;
    }
    return good;
}...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$50.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats