I forgot to add the pseudo code and the output errors I am sorry about that.
Pseudo Code
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
leapday (date)
if date.day is 29 and date.month is 2 and leapyear(date.year)
leapday = true
else
leapday = false
endif
end leapday
maxday (month, year)
if leapyear(year) and month is 2
maxday is assigned 29
return;
endif
switch on month
case 2
maxday is assigned 28
return;
case 1, 3, 5, 7, 8, 10, 12
maxday is assigned 31
return;
case 4, 6, 9, 11
maxday is assigned 30
return;
end switch
end maxday
addDay (forward)
if forward is true
if today.day is less than maxday (today.month, today.year)
increment today.day
else
today.day is assigned to 1
increment today.month
if today.month is greater than 12
today.month is assigned to 1
increment today.year
endif
endif
else
if today.day is greater than 1
decrement day.today
addDay is assigned today
else
decrement today.month
if today.month equals 0
today.month is assigned 12
decrement today.year
endif
today.day is assigned maxday (today.month, today.year)
endif
end if
end addDay
addYears (int years)
if years is 0
return
endif
if today is leapday and (today + years) is not leapday
today.day is assigned 28
endif
today.year is assigned today.year + years
end addYears
addMonths (months)
if months is 0
return
endif
deltayears = months / 12
deltamonths = months mod 12
if months is greater than 0
if today.month + deltamonths is greater than 12
increment deltayears
newmonth is assigned (today.month + deltamonths) - 12
else
newmonth = today.month + deltamonths
endif
else //months is negative
if today.month + deltamonths is less than 1
decrement deltayears
newmonth is assigned today.month + deltamonths + 12
else
newmonth = today.month + deltamonths
endif
endif
if today.day is greater than maxday(newmonth, today.year + deltayears)
today.day is assigned maxday
endif
today.year is assigned to today.year + deltayears
today.month is assigned newmonth
end addMonths
addDays (days)
if days is 0
return
endif
if days is less than 0
for count from -1 to days decrementing
addDay(today, false)
end for
else
for count from 1 to days
addDay(today, true)
end for
endif
end addDays
|
now the errors
[output]date.cpp
date.cpp(40) : warning C4996: 'localtime': This function or variable may be
fe. Consider using localtime_s instead. To disable deprecation, use _CRT_SEC
NO_WARNINGS. See online help for details.
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\time.
112) : see declaration of 'localtime'
date.cpp(123) : error C2446: '==' : no conversion from 'int' to 'int (__cdec
(int,int)'
Conversion from integral type to pointer type requires reinterpret_c
C-style cast or function-style cast
date.cpp(123) : error C2040: '==' : 'int (__cdecl *)(int,int)' differs in le
of indirection from 'int'
date.cpp(123) : warning C4553: '==' : operator has no effect; did you intend
?
date.cpp(124) : error C2561: 'Date::maxDay' : function must return a value
c:\code\cpp\assigment 9\start_files\date.h(25) : see declaration of
e::maxDay'
date.cpp(126) : error C2061: syntax error : identifier 'month'
date.cpp(128) : error C2046: illegal case
date.cpp(130) : error C2659: '=' : function as left operand
date.cpp(131) : error C2043: illegal break
date.cpp(133) : error C2046: illegal case
date.cpp(135) : error C2659: '=' : function as left operand
date.cpp(135) : error C2143: syntax error : missing ';' before ':'
date.cpp(135) : error C2143: syntax error : missing ';' before ':'
date.cpp(147) : error C2061: syntax error : identifier 'forward'
date.cpp(149) : error C2061: syntax error : identifier 'today'
date.cpp(151) : error C2065: 'today' : undeclared identifier
date.cpp(151) : error C2228: left of '._month' must have class/struct/union
type is ''unknown-type''
date.cpp(153) : error C2061: syntax error : identifier 'today'
date.cpp(155) : error C2065: 'today' : undeclared identifier
date.cpp(155) : error C2228: left of '._month' must have class/struct/union
type is ''unknown-type''
date.cpp(156) : error C2065: 'today' : undeclared identifier
date.cpp(156) : error C2228: left of '._year' must have class/struct/union
type is ''unknown-type''
date.cpp(159) : error C2181: illegal else without matching if
date.cpp(161) : error C2065: 'today' : undeclared identifier
date.cpp(161) : error C2228: left of '._day' must have class/struct/union
type is ''unknown-type''
date.cpp(163) : error C2065: 'today' : undeclared identifier
date.cpp(163) : error C2228: left of '._day' must have class/struct/union
type is ''unknown-type''
date.cpp(164) : error C2065: '_today' : undeclared identifier
date.cpp(168) : error C2065: 'today' : undeclared identifier
date.cpp(168) : error C2228: left of '._month' must have class/struct/union
type is ''unknown-type''
date.cpp(170) : error C2065: 'today' : undeclared identifier
date.cpp(170) : error C2228: left of '._month' must have class/struct/union
type is ''unknown-type''
date.cpp(170) : error C2143: syntax error : missing ')' before ';'
date.cpp(170) : error C2059: syntax error : ')'
date.cpp(171) : warning C4390: ';' : empty controlled statement found; is th
he intent?
date.cpp(172) : error C2065: 'today' : undeclared identifier
date.cpp(172) : error C2228: left of '._month' must have class/struct/union
type is ''unknown-type''
date.cpp(173) : error C2065: 'toda' : undeclared identifier
date.cpp(174) : error C2228: left of '._year' must have class/struct/union
type is ''unknown-type''
date.cpp(174) : error C2143: syntax error : missing ';' before '}'
date.cpp(175) : error C2065: 'today' : undeclared identifier
date.cpp(175) : error C2228: left of '._day' must have class/struct/union
type is ''unknown-type''
date.cpp(175) : error C2065: 'today' : undeclared identifier
date.cpp(175) : error C2228: left of '._month' must have class/struct/union
type is ''unknown-type''
date.cpp(175) : error C2065: 'today' : undeclared identifier
date.cpp(175) : error C2228: left of '._year' must have class/struct/union
type is ''unknown-type''
date.cpp(176) : error C2143: syntax error : missing ';' before '}'
date.cpp(184) : error C2065: 'date' : undeclared identifier
date.cpp(184) : error C2228: left of '.day' must have class/struct/union
type is ''unknown-type''
date.cpp(184) : error C2065: 'date' : undeclared identifier
date.cpp(184) : error C2228: left of '.month' must have class/struct/union
type is ''unknown-type''
date.cpp(184) : error C2146: syntax error : missing ')' before identifier 'i
date.cpp(184) : error C2065: 'is' : undeclared identifier
date.cpp(184) : error C2143: syntax error : missing ';' before 'constant'
date.cpp(184) : error C2065: 'date' : undeclared identifier
date.cpp(184) : error C2228: left of '.year' must have class/struct/union
type is ''unknown-type''
date.cpp(184) : error C2059: syntax error : ')'
date.cpp(185) : error C2143: syntax error : missing ';' before '{'
date.cpp(184) : error C3861: 'leapyear': identifier not found
date.cpp(186) : error C2065: 'leapday' : undeclared identifier
date.cpp(188) : error C2181: illegal else without matching if
date.cpp(190) : error C2065: 'leapday' : undeclared identifier
date.cpp(203) : error C2065: 'today' : undeclared identifier
date.cpp(203) : error C2065: 'leapday' : undeclared identifier
date.cpp(203) : error C2065: 'today' : undeclared identifier
date.cpp(203) : error C2065: 'leaday' : undeclared identifier