There are quite a few files for this lab assignment Zip them

There are quite a few files for this lab assignment. Zip them up and submit a zip file. makefile Time.h Time.cpp Date.h Date.cpp Calendar.cpp (this is the driver program) Practice using Eclipse Practice using Linux Use a makefile Use C++, not C Programs must compile. Programs that have syntax errors receive a grade of zero. Programs must have header comments, inline comments, consistent spacing, and consistent indentation (no less than3 spaces per indent and no more than 5 spaces per indent) C++: The only exception is variables that are used Programs must declare ALL variables at the top of the function. control a for loop. to int main void // all variable declarations first // then executable statements Programs cannot have any \"magic numbers\" in the executable statements. be declared as symbolic constants or as variables with initial values. All numeric literals other than 0 or 1 must * Creating a symbolic constant (pg 222 in the text) #include #define SIZE 10 Declaring a constant using \"const void checkHour (int x) const int HOUR LIMIT 12 // executable statements begin here if (x

Solution

In this program, you need to create time and date libraries in order to build a final calendar program. Don\'t get confused and go step by step:

1. Create time header file Time.h

2. Create date header file Date.h

3. Create the final calendar program by including these two header files

I\'ll show you how to create the header file for Time and make you understand the concept of how we create header files and work with them. Header files are a combination of 2 files: a .h and a .cpp file with same name. In this case, we will create 2 files: 1. Time.h and 2. Time.cpp.:

1. Create header file Time.h:

This file contains the class declaration. This includes declaration of data members as well as member functions. Please note that this file only contains declarations. All the definitions are included in .cpp file for this class.

Time.h code:

#define Time
class Time{
public:
int hour;
int minute;
int second;
Time();
Time(int,int,int);
void mutateHour(int);
void mutateMinute(int);
void mutateSecond(int);
int accessHour();
int accessMinute();
int accessSecond();
};

2. Create the file Time.cpp

As mentioned above, this file will contain the definitions of constructors and member functions of the class mentioned in the .h file.

Time.cpp code:

#include \"Time.h\"
#define MAX_HOUR 23
#define MAX_MINUTE 59
#define MAX_SECOND 59
Time::Time(){
    hour = 0;
    minute = 0;
    second = 0;
}

Time::Time(int h, int m, int s){
    if(h<=MAX_HOUR)
    hour = h;
    else
    hour = 0;
    if(m<=MAX_MINUTE)
    minute = m;
    else
    minute = 0;
    if(s<=MAX_SECOND)
    second = s;
    else
    second = 0;
}
void Time::mutateHour(int h){
    if(h<=MAX_HOUR)
    hour = h;
    else
    hour = 0;
}
void Time::mutateMinute(int m){
    if(m<=MAX_MINUTE)
    minute = m;
    else
    minute = 0;
}
void Time::mutateSecond(int s){
    if(s<=MAX_SECOND)
    second = s;
    else
    second = 0;
}
int Time::accessHour(){
    return hour;
}
int Time::accessMinute(){
    return minute;
}
int Time::accessSecond(){
    return second;
}

Now when you create the calender program, you simple have to include this header file at the top of the file with other includes as follows:

#include <iostream.h>

#include \"Time.h\"

And you will be able to use the Time class as any other class, as if you have declared and defined it in this calender.cpp only.

Use this information to make Date.h yourself and you will be able to understand how this works.

 There are quite a few files for this lab assignment. Zip them up and submit a zip file. makefile Time.h Time.cpp Date.h Date.cpp Calendar.cpp (this is the driv
 There are quite a few files for this lab assignment. Zip them up and submit a zip file. makefile Time.h Time.cpp Date.h Date.cpp Calendar.cpp (this is the driv

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site