Question: Define a class called Name that represents a person's name. The class should have three (private) fields, firstName and lastName (both Strings) and middlelnitial (char).
Define a class called Name that represents a person's name. The class should have three (private) fields, firstName and lastName (both Strings) and middlelnitial (char). Add the below methods to your class. will need to create a client file (NameClient) to test your class' methods. Recall that strings are contained within double quotes," ", and char are contained within single quotes, "you'll need this for when creating a new Name object. public Name(String firstName, char middlelnitial, String lastName) /constructor to create new Name object with given first, mi and last names public void setName(String newFirst, char newinitial, String newlast) //mutator that sets new values for first, mi, and last names. public String getFirst0 //accessor method to return this Name object's firstName. public String getLast0 //accessor method to return this Name object's lastName. . . public char getinitialo //accessor method to return this Name object's middlelnitial. public String toString //accessor method to return String of this Name object's field in form "John R. Toutonghi" public String reverseName): //accessor method to return String of Name object's fields in the reverse order, i.e. in form "Toutonghi, John R." * public boolean equals(Name otherName //accessor method to return true if this Name object equals otherName object (false otherwise)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
