Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topics: Separate compilation, class composition, vectors Write a program that manages a schedule of classes for a college. The program will include four classes: DigitalTime,

Topics: Separate compilation, class composition, vectors

Write a program that manages a schedule of classes for a college.

The program will include four classes: DigitalTime, TimeInterval, DaysOfWeek, and Course. The header files for DigitalTime and TimeInterval are provided. Note A description of the DaysOfWeek and Course classes are provided below. 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.

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)

*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 is Overlap 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

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.

clear Delete all courses from the current schedule.

export 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 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

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. 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:

Headers:

1- dtime.h

https://onedrive.live.com/redir?resid=766E6FC39721FBBB!713170&authkey=!AGe2P8d-FlMmWrY&ithint=file%2ch

2- timelnterval.h

https://onedrive.live.com/redir?resid=766E6FC39721FBBB!713169&authkey=!ALMhsPPDBYk5f-Q&ithint=file%2ch

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions