Page 1 of 1

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

Posted: Fri May 20, 2022 1:44 pm
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.