Write a University class with the following (5): String data type for the name of the university Accessor/mutator for th

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 University class with the following (5): String data type for the name of the university Accessor/mutator for th

Post by answerhappygod »

Write a University class
with the following (5):
String data type for the name of the university
Accessor/mutator for the String data type above
A constructor that accepts a String which sets the name based on
the String parameter
Override the toString() method to return the name (the format is
at your discretion)
Write a Scholar class with
the following (25):
Inherit from
the University class
String data type for contactInfo, int data type for idNum
Override the toString() method to return the name (the format is
at your own discretion)
A constructor that accepts three parameters: a String which sets
the name by using inheritance from
the University class, a String
which sets the contactInfo but goes to a if condition that uses the
method isValid (refer to the next bullet point)
to either set it if it return true, else set it to an empty String
(this is temporary and will be expanded upon the second part), and
an int which sets the idNum.
Create a method called isValid that accepts a
String and returns a boolean which checks if the String is valid
contact information (in the form of a phone number, (123)
456-7890 is valid and returns true if it is valid and false if it
is not. The phone number is considered valid if it contains only
numbers and is the correct length of 14 .
isValid method should be called from the constructor
which checks if the contactInfo is a valid String
Example input for the isValid String parameter:
(123) 456-7890 // returns true - correct length and all
numbers
(a28) 5&9-s896 // returns false - contains letters and
punctuation characters
(235) 583-74 // returns false - too short
(235) 583-74456 // returns false - too long
Accessors/mutators for the contactInfo and idNum
Override the toString() method to return the name, the
contactInfo, and the idNum (the format is at your own
discretion)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply