subject
Computers and Technology, 19.03.2020 16:44 xman839

Your task is to implement the Name class. This class represents a person's name. It has three instance variables representing the first, last and middle name (all are string variables). A character instance variable representing a separator (to be used for printing purposes) is also part of the class. The only valid separators we can have are a comma (,), a dash (-), and a pound symbol (#). In addition a nickname instance variable (string) keeps track of the person's nickname (if any). For this class you need to define a private method called validSeparator that takes a character as a parameter. The method will return true if the character is one of the three valid separators and false otherwise. Make sure you use this method when you need to validate a separator. In addition, the class will keep track of the number of instances created by using a private static field called nameObjsCount. This field is initialized to zero when you declared it. The methods associated with the class are provided below. All the methods are non-static unless specified otherwise. You may want to take a look at the files Driver. java, PublicTests. java and pubTest1.txt as they can help you clarify the signature associated with each method and the expected output format. Default Constructor - Initializes a Name object with "NOFIRSTNAME", "NOMIDDLENAME", "NOLASTNAME" as first name, middle name and last name, respectively. In addition the separator will be the '#' character. Constructor with two parameters - The first parameter is the first name and the second the last name. The middle name will be the empty string and the separator will a comma. Constructors with three parameters - The parameters are the first name, the middle name, and the last name. The separator will be a comma. Constructors with four parameters - The parameters are the first name, the middle name, the last name and the separator. If an invalid separator is provided a comma will be used instead. getFirstname - Get method for first name. getMiddlename - Get method for middle name. getLastname - Get method for last name. setNickname - Set method for nickname. getNickname - Get method for the nickname. If there is no nickname the method returns the empty string. Notice the empty string is not the same as null. setSeparator - Set method for the separator. If the separator parameter is invalid the separator for the Name object will not be changed. getSeparator - Get method for the separator. equals - Two names are considered equal if they have the same first, middle, and last names. The nickname is ignored. toString - Returns a string with the last name, the first name, the middle name (if any), and the nickname in parentheses (if any). compareTo - It will return a negative value if the current object precedes the parameter in alphabetical order, 0 if the current object is equal to the parameter and a positive value otherwise. getNumberOfNameObjects - Static method that returns the number of objects that have been created. normalize - Static method that takes a Name object and a boolean as parameters. The method returns a new Name object where the first name, the last name and the middle name (if any) have been capitalized if the boolean parameter is true. If the boolean parameter is false all the names will be in lowercase. Use the string methods toUpperCase() and toLowerCase() for the normalization. Comma will be the separator for the normalized name object. validSeparator - Private method that takes a character as a parameter and returns true if the parameter is a valid character. You must use this method whenever you need to verify the validity of a separator. If you define but do not use the method you will lose credit (code duplication penalty).

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
What is the main benefit of minimizing the ribbon in word? more options will be accessible through customized keystrokes. more of the document will be viewable without needing to scroll. fewer controls will be accessible to the user by using the mouse. fewer editing options will be available without entering a password.
Answers: 1
question
Computers and Technology, 24.06.2019 02:50
Be sure to answer all parts. synthesize the following compound from benzene. a. b. c. d. e. f. reaction [1] conditions: a b c d e f reaction [1] product: draw structure reaction [2] conditions: a b c d e f reaction [2] product: draw structure reaction [3] conditions: a b c d e f reaction [3] product:
Answers: 3
question
Computers and Technology, 24.06.2019 08:30
Intellectual property rights are exclusive rights that protect both the created and the creation. ipr offers exclusively what benefits to the person or people covered by it
Answers: 3
question
Computers and Technology, 24.06.2019 12:00
Which spreadsheet operation does a look function perform?
Answers: 1
You know the right answer?
Your task is to implement the Name class. This class represents a person's name. It has three instan...
Questions
question
Arts, 06.11.2020 02:00
question
Physics, 06.11.2020 02:00
question
Mathematics, 06.11.2020 02:00
question
Arts, 06.11.2020 02:00
question
Mathematics, 06.11.2020 02:00
Questions on the website: 13722363