can someone help me? my bool function is compiling but isnt showing up on output.
Design a class called Date. The attributes of a date are three integers that
represent the month, day, and year. Your class definition MUST BE THE FOLLOWING:
class Date
{
private:
int month, day, year;
public:
Date();
Date(int, int, int);
bool setDate(int, int, int);
void getDate(int&, int&, int&);
void printShort();
void printLong();
bool isEqual(Date);
void increment();
void decrement();
};
Description of the functions:
default Sets month to 1, day to 1, year to 2000 (01/01/2000 is default date)
constructor
constructor with (i.e. Date mydate(7, 30, 2007); will set the date to 07/30/2007) Should
m, d, y parameters validate and use default date if bad input.
setDate Set the values of month, day, year. Include validation: do not accept values
for the day greater than 30 or less than 1. Do not accept values for the
month greater than 12 or less than 1. Return a bool value to indicate if data
is valid.
getDate Returns the values of month, day , year (you will need reference parameters)
printShort print the date as mm/dd/yy (i.e. 02/05/03) (note 2 digits for month, day,
year) (you should look up setFill, it can be useful)
printLong print the date as month dd, yyyy (i.e. December 25, 2003)
isEqual tests if two date objects are equal. Returns true or false.
increment adds 1 to the day. Adjust the month and/or year when necessary. (i.e. When
you increment 06/30/2007 you should get 07/01/2007) *
decrement subtracts 1 from the day. Adjust the month and/or year when necessary.
(i.e. When you decrement 1/1/2007 it becomes 12/30/2006. * )
*You can assume all months have 30 days to simplify the algorithm. handle the days for each month correctly
TESTING: Create an appropriate program (driver) to test all the functionality of class. show all the member functions of class work correctly!
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
|
#include<iostream>
using namespace std;
class Date
{
private:
int month, day, year;
public:
Date();
Date(int d, int m, int y)
{
day = d;
month = m;
year= y;
}
bool setDate(int, int, int);
void getDate(int&, int&, int&);
void printShort();
void printLong();
bool isEqual(Date);
void increment();
void decrement();
};
int main()
{
}
bool setDate(int d, int m, int y)
{
cout<<"Enter the day"<<endl;
cin>>d;
cout<<"Enter the month"<<endl;
cin>>m;
cout<<"Enter the year"<<endl;
cin>>y;
if( d<30)
return true;
else
return false;
}
|