Answered step by step
Verified Expert Solution
Link Copied!

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

 

image

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Using Financial Accounting Information The Alternative to Debits and Credits

Authors: Gary A. Porter, Curtis L. Norton

7th Edition

978-0-538-4527, 0-538-45274-9, 978-1133161646

More Books

Students also viewed these Programming questions

Question

square root x - 1 2 = x + 6

Answered: 1 week ago

Question

5.6 Evaluate methods used to treat phobic disorders.

Answered: 1 week ago