Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Solve the following questions. If you can, please seperate each question so I know which answer belongs to each question. Please dont just put

Please Solve the following questions. If you can, please seperate each question so I know which answer belongs to each question. Please dont just put all the anser into one code since it makes it difficult to see which part of the code answers which part.

1. Create a class called Name that represents a person's name. The class should have fields representing the person's first name, last name, and middle initial. (Your class should contain only fields for now.)

2. Add two new methods to the Name class: public String getNormalOrder ( ) Returns the person's name in normal order, with the first name followed by the middle initial and last name. For example, if the first name is "John", the middle initial is "Q" and the last name is "Public", returns "John Q. Public". public String getReverseOrder ( ) Returns the person's name in reverse order, with the last name preceding the first name and middle initial. For example, if the first name is "John", the middle initial is "Q", and the last name is "Public", returns "Public, John Q.".

3. Write a toString method for the Name class that returns a String such as "John Q. Public". 4. Add a constructor to the Name class that accepts a first name, middle initial, and last name as parameters and initializes the Name object's state with those values.

5. Encapsulate the Name class. Make its fields private and add appropriate accessor methods to the class.

6. Add methods called setFirstName, setMiddleInitial, and setLastName to your Name class. Give the parameters the same names as your fields, and use the this keyword in your solution

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago