Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Add the following methods to your Name class: a. A method that accepts no parameters and returns the length of the name, i.e., the
Add the following methods to your Name class: a. A method that accepts no parameters and returns the length of the name, i.e., the sum of the lengths of the three parts of the name. b. A method that accepts no parameters and returns a String consisting of the three initials IN UPPERCASE. c. A method that accepts an integer n and returns the nth character in the full three part name. d. A method that accepts no parameters and returns a String consisting of the last name followed by a comma followed by the first name followed by the middle name. Remember to put spaces between the names. e. A method that accepts a String and returns true if the String is equal to the first name (use the equals method in the String class!). This is not quite the proper way to define an equals() method, as we will learn later. f. A method that accepts a Name object and returns true if the three parts of the name object are the same as the three parts of "this" Name object. 4. Create a class called Name Driver which contains a main method. Inside the main method, instantiate a Name object using your name and test your methods to make sure they work. Does it work for all names? private String firstName; /** *Middle name. */ private String middleName; /** * Last name */ private String lastName; //Constructor /** * @param args */ public Name (String firstname, String middlename, String lastname) { firstName = firstname; middleName = middlename; last Name lastname; } //getters //get First Name public String getFirstName () { return firstName; } //get middle name public String getMiddleName() { return middleName; } //get last name public String getLastName() { return lastName; } //setters public void setFirstNmae (String firstname) { this.firstName = firstname; } public void setMiddleNmae (String middlename) { this.middleName = middlename; } public void setLastName (String lastname) { this.lastName = lastname; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started