Question: Each code segment below starts with some comments ( lines that begin with two slashes ) that describe the program. Examine the pseudocode that follows
Each code segment below starts with some comments lines that begin with two slashesthat describe the program. Examine the pseudocode that follows the introductory comments, then find and correct all the bugs
b The Date class contains a month, day, and year, and methods to set and display the values. The month cannot be set to less than or
more than and the day of the month cannot be set to less than
or more than the number of days in that month. The demonstration
program instantiates four Date objects and purposely assigns
invalid values to some of the arguments; the class methods, when
called, will correct the invalid values.
class Date
Declarations
private num month
private num day
private num year
public void setDatenum mo da yr
num HIGHMONTH
num HIGHESTDAYSHIGHMONTH
if mo HIGHMONTH then
month HIGHMONTH
else
if mo then
month
else
month mo
end
end
if da HIGHESTDAYSmonth then
day HIGHESTDAYSmonth
else
if da then
day
else
day da
end
year yr
return
public void showDate
output "Date: month, day, year
return
Classend
start
Declarations
Date birthday, annivsary, graduation, party
birthday.month
birthday.day
birthday.year
anniversary.setDate
graduation.setDate
party.setDate
output "Birthday
birthday.showDate
output "Anniversary
anniversary.showDate
output "Graduation
graduation.showDate
output "Party
party.showDate
stop
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
