Write a NotValidContactInfo class with the following (5): Inherit from the Exception class A constructor that accepts a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a NotValidContactInfo class with the following (5): Inherit from the Exception class A constructor that accepts a

Post by answerhappygod »

Write
a NotValidContactInfo class
with the following (5):
Inherit from
the Exception class
A constructor that accepts a String which is used to call the
Exception class to form an error message that informs the user that
the given String is not a valid contact information (the format is
at your own discretion)
Return to the Scholar class
and do the following (5):
Handle
the NotValidContactInfo exception
in the constructor with three parameters by throwing the exception
at the else portion of the if condition that calls
the isValid method to check if the contactInfo
is correctly formatted (refer to the first part).
Create a Main class with the
following (10):
Create 2 try and catch blocks
In the first try block, create
a Scholar object with the three
parameters: (String, String, int) but the second parameter (the
contactInfo) is not a valid one (refer to the example input for the
isValid String parameter, choose one that is incorrect)
In the first catch block, fill in the
exception NotValidContactInfo with
the name of the exception (at your own discretion) and print the
error message that tells the user that the given String is not
valid contact information.
In the second try block, create
a Scholar object with the three
parameters: (String, String, int) but the second parameter (the
contactInfo) is a valid one (refer to the first example input for
the isValid String parameter)
In the second catch block, fill in the
exception NotValidContactInfo with
the name of the exception (at your own discretion) and print the
error message that tells the user that the given String is not
valid contact information.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply