Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The checkDate method should check to see if the date is valid. A valid date should be in the form: mm/dd/yyyyy with mm, dd, and

image text in transcribed
The checkDate method should check to see if the date is valid. A valid date should be in the form: mm/dd/yyyyy with mm, dd, and yyyy being a digit. DO NOT worry about the numbers being realistic (1 through 12 for month, 1 through 31 for days, etc.). Just check to make sure there are digits, two slashes and 10 characters in total. - In class, I mentioned we can check user inputs before setting attribute values. Let's do this for the date attribute: Edit your setDate method by calling the checkDate method first before setting the instance variable, date. If the date is not valid, you should print out, "Date not valid" and then use System.exit (0); to make the program exit. Else, if the date is valid, set the date as you already did. - We can take this a step further and call our setDate method in the constructor body to assign the instance variable for date for us. This will make also make it so our date is being checked. How do you think

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions