I have been up for 24+ hrs, and am failing to see where I'm getting these junk numbers from?
I know it's staring me right in the face, I just can't see it for the life of me!!
Keep in mind this code is ugly and may make your eyes bleed, I just have a very sloppy style at the moment.
// Week4Lab_RyanRodgers.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class Time
{
public:
Time(int hour, int minute); //constructor w/ parameters
Time(); //default constructor
void setTime(int hour, int minute);
void getTime(int&, int&);
void printTime();
private:
int hr, min; //declare hour & min
};
class Date
{
public:
Date(int month, int day, int year);
Date();
void getDate(int&mm, int&dd, int&yy);
void setDate(int month = 0, int day = 0, int year = 0);
void printDate();
private:
int month;
int day;
int year;
};
class Event
{
public:
void setEventData(string eventName, int hour, int minute, int month, int day, int year);
void printEventData();
Event (string eventName = "", int hour = 0, int minute = 0, int month = 0, int day = 0, int year = 1900); //constructor
private:
string eventName;
Date eventDate; //date object
Time eventTime; //event object composed of time object
};
Time::Time() { int hour = 0,minute = 0; }
Time::Time(int hour, int minute) { hour = hr; minute = min; }
void Time::getTime(int &hour, int &minute){ hr = hour; min = minute; }
void Time::setTime(int hour, int minute){ hour = hr; minute = min; }
void Time::printTime()
{
int hr, min;
getTime (hr, min);
if(hr<10) cout << "0";
cout << hr << " : ";
if(min<10) cout << "0";
cout << min;
}
Date::Date(){month = day = 1; year = 1900;}
Date::Date(int m, int d, int y):month(m), day(d), year(y){ };
void Date::getDate(int&mm, int&dd, int&yy){mm = month; dd = day; yy = year;}
void Date::setDate(int mm, int dd, int yy){month = mm; day = dd; year = yy;}
void Date::printDate()
{
int mm, dd, yy;
getDate(mm, dd, yy);
if(mm<10) cout << "0";
cout << mm << "/";
if(dd<10) cout << "0";
cout << dd << "/";
if(yy<100) cout << "20";
cout << year;
}
Event::Event(string name, int hour, int minute, int month, int day, int year):eventTime(hour,minute), eventDate(month, day, year)
{
eventName = name;
}
void Event::setEventData(string name, int hr, int min, int mm, int dd, int yy)
{
string eventName = name;
eventTime.setTime(hr, min);
eventDate.setDate(mm, dd, yy);
}
void Event::printEventData()
{
cout << eventName << " occurs ";
eventDate.printDate();
cout << " at ";
eventTime.printTime();
}
int main()
{
Event myEvent("My 100th Birthday", 4,19,7,21,74);
myEvent.setEventData("My 100th Birthday", 4,19,7,21,74);
myEvent.printEventData();
cout << "\n" << endl;
return 0;
}
Everything comes out great except the time. It's like, 1241872 : 2045197120