HELP WITH C++

hello there, i have complete the code and it looks pretty good, the only problem I am having is time..if you can please guide me what i did wrong.
thanks



#include <iostream>
#include <string>


using namespace std;

//Time Class Definition

class Time
{
public:
void setTime(int hr, int min);
void getTime(int&hr, int&min);
void printTime();
Time(int hr, int min);
Time();

private:
int hour;
int minute;
};

// Date Class Definition

class Date
{
public:
void setDate(int = 1, int = 1, int = 2000);
void getDate(int&m, int&d, int&y);
void printDate();
Date(int month, int day, int year);
Date();

private:
int month;
int day;
int year;
};


//Event Class Definition

class Event
{
public:
void setEventData(string EventName, int hour, int minute, int month, int day, int year);
void printEventData();
Event(string eventName = "Generic Event", int hour = 0, int minute = 0, int month = 1, int day = 1, int year = 2000);

private:
string eventName;
Time eventTime;
Date eventDate;
};

void Event::setEventData(string name, int hr, int min, int mon, int day, int yr)
{
eventName = name;
eventTime.setTime(hr, min);

eventDate.setDate(mon, day, yr);
}

void Event::printEventData()
{
cout << eventName << " occurs ";
eventDate.printDate();
cout << " at ";
eventTime.printTime();
}


Event::Event(string name, int hour, int minute, int month, int day, int year)
:eventTime(hour, minute), eventDate(month, day, year)

{
eventName = name;
}




int main()
{
Event event("New Year's Day",0,1,1,1,2008);
event.printEventData();
cout << endl;
event.setEventData("Valentine's Day",12,15,2,14,2010);
event.printEventData();
cout << endl;

return 0;

}
Last edited on
closed account (DSLq5Di1)
I gather this is what you wanted..

1
2
3
4
5
6
7
8
9
void Time::printTime()
{
    // int hr, min;
    // getTime (hr, min);
    if (hour < 10) cout << "0";
    cout << hour << ":";
    if (minute < 10) cout << "0";
    cout << minute;
}
Thanks sloppy, so it seems like that problem was that I had hours @ 20.
Topic archived. No new replies allowed.