Hi guys. I am hoping for a little help with this. I am pretty new to programming and just can't seem to get things right yet. Here is my code. It returns like 40 errors. Way messed up eh?
#include <iostream>
#include <string>
using namespace std;
class Date
{
public:
Date(); //default constructor
Date(int month, int day, int year); //constructor with parameters
void setMonth(int);
void setDay(int);
void setYear(int);
int getMonth();
int getDay();
int getYear();
void printDate();
private:
int month;
int day;
int year;
};
class Time
{
public:
Time(); //constructor
Time(int, int); //constructor with parameters
void setHour(int);
void setMinute(int);
int getHour();
int getMinute();
void printTime();
private:
int hr;
int min;
};
class Event
{
public:
Event(); //constructor
Event(string, int, int, int, int, int); //constructor with parameters
string getName();
void printName();
void printDate();
void printTime();
private:
string EventName;
Time EventTime;
Date EventDate;
};
Date::Date()
{
month = 03;
day = 17;
year = 2011;
}
Date::Date(int mm, int dd, int yyyy)
{
month = mm;
day = dd;
year = yyyy;
}
void Date::setMonth(int mm)
{
if(03 <= mm && mm <= 12)
mm = month;
else
month = 03;
}
void Date::setDay(int dd)
{
if(17 <= dd && dd <= 31)
dd = day;
else
day = 17;
}
void Date::setYear(int yyyy)
{
if(0 <= yyyy && yyyy <= 2020)
yyyy = year;
else
year = 2011;
}
int Date::getMonth()
{
return month;
}
int Date::getDay()
{
return day;
}
int Date::getYear()
{
return year;
}
int Date::printDate()
{
cout << getMonth() << "/" << getDay() << "/" << getYear();
};
Time::Time() //default constructor sets the hour and minute
{
hour = 0;
minute = 0;
}
Time::Time (int hr, int min)
{
hr = hour;
min = minute;
}
void Time::setHour (int hr)
{
if(0 <= hr && hr < 24)
hr = hour;
else
hour = 0;
}
void Time::setMinute(int min)
{
if(0 <= min && min < 60)
min = minute;
else
minute = 0;
}
int Time::getHour()
{
return hour;
}
int Time::getMinute()
{
return minute;
}
Time::printTime()
{
cout << getHour() << ":" << getMinute();
}
Event::Event()
{
}
Event::Event(string eName, int eHour, int eMinute, int eMonth, int eDay, int eYear)
{
eventTime.setHour(eHour);
eventTime.setMinute(eMinute);
eventDate.setMonth(eMonth);
eventDate.setDay(eDay);
eventDate.setYear(eYear);
}
string Event::getName()
{
return eventName;
}
void Event::printName()
{
cout << eventName;
}
void Event::printDate()
{
cout << eventDate.getMonth() << "/" << eventDate.getDay() << "/" << eventDate.getYear();
}
void Event::printTime()
{
cout << eventTime.getHour() << ":" << eventTime.getMinute();
}
int main()
{
Event eventOne ("Saint Patricks Day", 06, 00, 03, 17, 2011);
Event eventTwo ("The Fourth of July", 08, 00, 07, 04, 2011);
cout << eventOne.printName() << " occurs on " << eventOne.printDate() << "at" << eventOne.printTime() << "." << endl;
cout << eventTwo.printName() << " occurs on " << eventTwo.printDate() << "at" << eventTwo.printTime() << "." << endl;
cout << endl;
return 0;
}
Any help on this would be greatly appreciated.