The purpose of this code is to try and output a start time, start date, finish time, and finish date for an event calling on header files and another .cpp file. I believe i am on the right track but could really use some help!
Header file.
#ifndef EVENT_H
#define EVENT_H
// Event class declaration.
#include <string>
#include <iostream>
#include <cstring>
using namespace std;
class Event
{
public:
Event(); //Default Constructor
Event(string name, int sday, int smonth, int syear, int fday, int fmonth, int fyear,
int shour, int smin, int fhour, int fmin); //Constructor
Event(Event & Event); //Copy Constructor
~Event(); //Destructor
void Print() const;
Date GetStartDate() const;
Date GetFinishDate() const;
Time GetStartTime() const;
Time GetStartTime() const;
float GetDuration() const;
void SetEventName(const string name);
void SetStartDate(const int day, const int month, const int year);
void SetFinishDate(const int day, const int month, const int year);
void SetStartTime(const int hours, const int mins);
void SetFinishTime(const int hours, const int mins);
private:
string name;
Date startDate;
Date finishDate;
Time startTime;
Time finishTime;
};
#endif /* EVENT_H */
#ifndef TIME_H
#define TIME_H
class Time
{
public:
Time();
Time(int,int,int,int);
Time(const Time&);
void setshour(int);
void setsmin(int);
void setfhour(int);
void setfmin(int);
int getshour();
int getsmin ();
int getfhour();
int getfmin();
void printTime();
private:
int shour;
int smin;
int fmin;
int fhour;
};
#endif /* TIME_H */
// Constants
const int NUM_MONTHS = 12;
const int NAME_SIZE = 10;
// Declaration of the Date class
class Date
{
private:
int smonth; // To hold the month
int fmonth;
int sday; // To hold the day
int fday;
int syear; // To hold the year
int fyear;
// An array of char arrays to hold
// the names of the months
char names[NUM_MONTHS][NAME_SIZE];
// Private member function to assign
// the month names to the names array
void setNames();
// Functions to print the date
void showDate1()const;
};
Main.cpp (havent gotten to work on this part much yet, trying to get the other two parts done first)
#include <cstdlib>
#include "Event.h"
using namespace std;
int main()
{
Event event1;
event1.Print();
return 0;
}
Alternate.cpp
#include <iostream>
#include "Event.h"
using namespace std;
//**********************************
// Overloaded constructor *
// Parameters: mo is the month *
// d is the day *
// y is the year
// s/f are start and finish*
//**********************************
Date::Date(int smo,int fmo, int sd,int fd, int sy, int fy)
{
setsmonth(smo);
setfmonth (fmo);
setsday(sd);
setfday(fd);
setsyear(sy);
setfyear(fy)
setNames();
}
Date::~Date()
{
}
//**********************************
// Member function setNames *
// This function assigns the names *
// of the months to the names *
// array. *
//**********************************
//**********************************
// Member function setMonth *
//**********************************
void Date::setsmonth(int smo)
{
if (smo >= 1 && smo <= 12)
smonth = smo;
else
{
cout << smo << " is not a valid
<< "value for the month.\n";
exit (EXIT_FAILURE);
}
}
void Date::setfmonth(int fmo)
{
if (fmo >= 1 && fmo <= 12)
fmonth = fmo;
else
{
cout << fmo << " is not a valid "
<< "value for the month.\n";
exit (EXIT_FAILURE);
}
}
//**********************************
// Member function setDay *
//**********************************
void Date::setsday(int sd)
{
if (sd >= 1 && sd <= 31)
sday = sd;
else
{
cout << sd << " is not a valid "
<< "value for the start day.\n";
exit(EXIT_FAILURE);
}
}
//**********************************
// Member function setYear *
//**********************************
void Date::setsyear(int sy)
{
syear = sy;
}
//**********************************
// Member function showDate1 *
// Displays the date in the form *
// MM/DD/YY *
// Example: 12/25/06 *
//**********************************