-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate.cpp
75 lines (72 loc) · 1.4 KB
/
date.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**********************
* Luke Brown *
* Section 003 *
* Lab 8 *
* 10-11-16 *
**********************/
#include <iostream>
#include "date.h"
using namespace std;
Date::Date() //default constructor
{//this constructor inits everything to 0
setDay(0);
setMonth(0);
setYear(0);
}
Date::Date(int d, int m, int y) //expected constructor
{
setDay(d);
setMonth(m);
setYear(y);
}
int Date::getDay(){
return day;
}
int Date::getMonth(){
return month;
}
int Date::getYear(){
return year;
}
//Set methods
void Date::setDay(int d){
//validates user input
if (d > 31 || d <= 0)
{
//printHelp(1);
} else {
day = d;
}
}
void Date::setMonth(int m) {
if (m > 12 || m < 1)
{
//printHelp(2);
} else {
month = m;
}
}
void Date::setYear(int y){
year = y;
}
//print methods
void Date::printDate(){
//print date
cout << getMonth() << "/" << getDay() << "/" << getYear() << "\n";
}
/*
void printCurrentDate(){
cout << "The second date is: " << getMonth() << "/" << getDay() << "/" << getYear() << "\n";
}
void printHelp(int i){
switch(i)
{
case 1 : cout << "Plese enter a valid month day (1-31)\n";
break;
case 2 : cout << "Please enter a valid Gregorian month number (1-12)\n";
break;
default : cout << "Please enter constructor args in DD/MM/YYYY format\n";
}
}
*/