Free Response Questions: Consider the following detailed inheritance hierarchy diagram Person instance variables private String myFirstName private String myLastName private String myEmailAddress methods public String getFirstName( ) public String getLastName( ) public String getEmailAddress( ) public abstract int compareTo(Person p); Student | class variables int lastIdAssigned // initially set to 20050 instance variables private int myStudentId private double myGpa private double myNumberOfCredits methods public void addCourse(int credits, double grade) public int getStudentId( ) |public double getGpa( ) (a) The Person constructor has two String parameters, a first name and a last name. The constructor initializes the e-mail address to the first letter of the first name followed by the first five letters of the last name followed by @jc.com. If the last name has fewer than five letters, the e-mail address will be the first letter of the first name followed by the entire last name followed by @jc.com. Examples: Name Email Address JSmith@jc.com Jane Smith John Morris JMorriejc.com MKey@jc.com Mary Key
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Consider the following detailed inheritance hierarchy diagram:
(ATTACHED IN IMAGE)
The person constructor has two string parameters, a first name, and the last name. The constructor initializes the e-mail address to the first letter of the first name followed by the first five letters of the last name followed by @jc.com. If the last name has fewer than five letters, the e-mail address will be the first letter of the first name followed by the entire late name followed by @jc.com
Implement the person constructor:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps