subject

Solve the following questions.
after write a method for each question, you need to write a class 'testnameclass' in a separate file, which includes a main method. in your main method, create two object of class name type and test each method you defined in the name class.

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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Lisa’s company, abc ltd., lost its biggest client and is now facing a financial crunch. most of her colleagues have resigned, but lisa decides to stay with the company and assist the management in overcoming the financial situation. which quality is lisa demonstrating? a. self-management b. cooperativeness c. responsibility d. loyalty
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
Which type of file can be used to import data into a spreadsheet?
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
In the context of the box model, what is the difference between a margin and a padding? a. a padding lies outside a box border, while a margin lies inside it. b. a padding lies inside a box border, while a margin lies outside it. c. a padding can be adjusted independently, while a margin depends on the size of its box. d. a padding depends on the size of its box, while a margin can be adjusted independently.
Answers: 3
You know the right answer?
Solve the following questions.
after write a method for each question, you need to write a cl...
Questions
question
Mathematics, 30.08.2019 07:00
question
Mathematics, 30.08.2019 07:00
question
Chemistry, 30.08.2019 07:00