[SOLVED] CSI2372- Lab 5

25.99 $

Category:

Description

Rate this product

 

Exercise 1 of 6) Define a class named Money that stores a monetary amount.  The class should have two private integer variables, one to store the number of dollars and another to store the number of cents.   Add accessor and mutator functions to read and set both member variables.   Add another function that returns the monetary amount as a double.  Write a program that tests all of your functions with at least two different Money objects.

 

Exercise 2 of 6) Do the Exercise 1, the definition of a Money class, except create a default constructor that sets the monetary amount to 0 dollars and 0 cents, and create a second constructor with input parameters for the amount of the dollars and cents variables.  Modify your test code to invoke the constructors.

Constructor initialization section:

The implementation of the constructor can have an initialization section:

classname:: classname (list of arguments): a(0), b(1)

{ //empty or implementation }

In the literature, this feature is sometimes called a member initializer list.  The purpose of a member initializer list is to initialize the class data members.   Only constructors may have member initializer lists.

Exercise 3 of 6) Define a class called StartTime with the following attributes and methods

 

char d_hour;  char d_minutes; 

inline void get(char& _hour, char& _minutes) const;  inline void set(char _hour, char _minutes); 

 

inline StartTime(char _hour, char _minutes); 

inline void print() const;  

 

This class will be placed in the starttime.h file.

Header files are a good place to define classes.

 

Exercise 4 of 6) Define the class CourseActivity containing a pointer to a StartTime, a duration in minutes, and a location. These attributes must be private. A public method for changing the start time, a display method, and a full constructor are also required. The signatures of these methods and the type of the attributes are:

StartTime* d_start;  double duration;  std::string location; 

CourseActivity( const StartTime* _start, double _duration, const std::string _location );  void reschedule( StartTime* _newStart );  void print() const;  

 

This class will be placed in the activity.h file.

Define three public subclasses of CourseActivity (in the same cpp file activity.h). These classes are: Lecture, Laboratory and Tutorial. Each of these classes should define a method void print(); and must include a std::string to contain a topic, an assignment, and an exercise. The class definition must be in the activity.h file, while the methods will be defined in activity.cpp

Exercise 5 of 6)  Add the following constructors to the classes defined in exercise 4.

 

Lecture( const StartTime* _start, double _duration, const string location,            const string& _topic ); 

 

Lecture( const CourseActivity& _oActivity, const string& topic );  

 

Laboratory( const StartTime& _start, double _duration, const string location, const string& _assignment ); 

 

 

Tutorial( const StartTime& _start, double _duration, const string location,                const string& _exercise );   

 

 

 

  Exercise 6 of 6) Define a main() function in lab5.cpp. Create three instances of

StartTime for 11:30, 13:00 and 16:00. With these, create a Lecture, a

Laboratory and a Tutorial with a duration of 90 minutes. Then display each of these activities.

Construct two additional Lecture instances from Tutorial and Laboratory with

the constructor Lecture(const CourseActivity & _oActivity, const std::string & topic); Display these five activities.  Then change the time of two conflicting lectures for 19