Basically my whole program is comprised of 2 class definitions in header files along with the cpp files for each class..
Now all I have to do is the main function.. but i'm stumped..
Here is what I am supposed to do in main:
Provide data validation to the Date. A valid year is an integer between 1900 and 2015
inclusively. A valid month is an integer between 1 and 12 inclusively. A valid day should be an integer
between 1 and n, where
n = 31 if month is 1, 3, 5, 7, 8, 10, or 12;
n = 30 if month is 4, 6, 9, or 11;
n = 28 if month = 2.
Please share the code you allready have and tell us where your problem is.
We prefer to help you with the coding-problems not to give you the solution (at least not for an easy task like that :b )
I hate to put my whole code up, as my professor might find it, but here it is.
PLEASE DON'T QUOTE THIS
Apointment.cpp :
#include "Appointment.h"
#include <string>
void Appointment::print(){
cout << name << " ";
date.print();
}
void Appointment::setName(string val){
name = val;
}
string Appointment::getName(){
return name;
}
void Appointment::setDate(int y, int m, int d){
date.setDate(y,m,d);
}
Date Appointment::getDate(){
return date;
}
bool Appointment::equalDate(const Appointment obj) const{
return date.equalDate(obj.date);
}
Appointment::Appointment(string name, int y, int m, int d){
setName(name);
setDate(y,m,d);
}
Date.cpp:
#include "Date.h"
Date::Date(int year, int month, int day) {
setDate(year,month,day);
}
void Date::print() const
{
printf_s("%d/%d/%d", month, day, year);
}
void Date::setDate(int y, int m, int d)
{
year = y;
month = m;
day = d;
}
int Date::getYear() const
{
return year;
}
int Date::getMonth() const
{
return month;
}
int Date::getDay() const
{
return day;
}
bool Date::equalDate(const Date obj) const
{
return obj.day == day
&& obj.month == month
&& obj.year == year;
}
class Date
{
public:
void print() const;
void setDate(int y, int m, int d);
int getYear() const;
int getMonth() const;
int getDay() const;
bool equalDate(const Date obj) const;
Date(int y=1900, int m=1, int d=1); //constructor with default
//parameters
private:
int year;
int month;
int day;
};
Appointment.h
#include <iostream>
#include <string>
#include <cstring>
#pragma once
#include "Date.h"
using namespace std;
class Appointment
{
private:
string name;
Date date;
public:
void print();
void setName(string val);
string getName();
void setDate(int y, int m, int d);
Date getDate();
bool equalDate(const Appointment obj) const;
Appointment(string name = "", int y=1900, int m=1, int d=1);