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, 22.06.2019 20:00
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
Answers: 1
question
Computers and Technology, 24.06.2019 00:40
What is the error in the following pseudocode? module main() call raisetopower(2, 1.5) end module module raisetopower(real value, integer power) declare real result set result = value^power display result end module
Answers: 1
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
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
Questions on the website: 13722367