Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the attached document. Complete the Name class and the Name class\' UML. I

ID: 3572903 • Letter: U

Question

Using the attached document. Complete the Name class and the Name class' UML. I have purposely left off parts of the code in the Name class. Even some of the parts that I did in class. You are to identify the missing code and put it in. You are to correct the code to our class standard pseudocode. Check each method for completeness. When you are finished, you should be able to take the sample terminal "Input and Output" display from the first page and follow the program on the second page through to completion.

/**

* Author Larry Shannon

* This program tests the Name Class

* Build a Name object and have it ask the user to enter their name.

* Inform the user what they entered.

* Build another Name object (clone) using the names from the first

* Name object. Check to see if the new clone Name object is equal (has the

* same name) as the first Name object.

* If the clone Name object and the first

* Name object are not equal

* -> Tell the user that the cloning failed. If they

* are equal

* -> Tell the user that they are the same and need to be different

* so they can be told apart. Change the name of the cloned named object to

* all upper case. Check to see if the name change worked If it worked

* -> Tell the user that you changed the name to all upper case

* so you could tell them apart.

* If it did not work

* -> tell the user it did not work.

* Ask the user to enter a new name that they wish to have their name changed to.

* Use a new Name object to collect the new name from the user.

* Tell the user that you are going to change their name from their old name to
* the new name.

* Change the name. Display the new name

*/

SAMPLE TERMINAL DISPLAY OF PROGRAM RUNNING

Please enter First Name.

Tommy

Please enter Middle Name.

Lee

Please enter Last Name.

Jones

You entered:

Tommy Lee Jones

You have just been cloned and your clone now has your name.

Your name: Tommy Lee Jones

Your clone's name: Tommy Lee Jones

You might want to differentiate yourself from your clone by using all uppercase for the clone's name.

Your name: Tommy Lee Jones

Your clone's name: TOMMY LEE JONES

That is better! Now I can tell you apart.

You should now enter a new name for yourself and I will change your name.

Please enter First Name.

Jerry

Please enter Middle Name.

Lee

Please enter Last Name.

Lewis

You entered:

Jerry Lee Lewis

I will now change your name from: Tommy Lee Jones-Moore to Jerry Lee Lewis

Your name is now:
Jerry Lee Lewis

START

DECLARE Name myName = NEW Name()

DISPLAY "You entered: "

DISPLAY myName.getFullName()

DECLARE Name cloneName = NEW Name(myName.getFirstName(), myName.getMiddleName(), myName.getLastName())

IF myName.equals(cloneName) THEN

DISPLAY "You have just been cloned and your clone now has your name."

DISPLAY "Your name: " + myName.getFirstName() + “ “ + myName.getMiddleName() + “ “ + myName.getLastName()

DISPLAY "Your clone's name: " + cloneName.getFullName()

DISPLAY "You might want to differentiate yourself from your clone " + "by using all uppercase for the clone's name. "

cloneName.toUpperCase();

IF myName.equals(cloneName) THEN

    DISPLAY "That did not work they are still equal!"

ELSE

    DISPLAY "Your name: " + myName.getFullName()

    DISPLAY "Your clone's name: " + cloneName.getFullName()

    DISPLAY "That is better! Now I can tell you apart."

ENDIF

ELSE

DISPLAY "You failed to clone yourself!"

ENDIF

DISPLAY "You should now enter a new name for yourself and I will change your name."

Name: newName()

DISPLAY "You entered: "

DISPLAY newName.getFullName()

DISPLAY "I will now change your name from: " + myName.getFullName() + " to " + newName.getFullName()

myName.changeNameTo(newName);

IF (myName.equals(newName) THEN

DISPLAY "Your name is now: "

DISPLAY myName.getFullName()

ELSE

DISPLAY ”Your name did not change.”

ENDIF

STOP

class Name

   private String firstName = “Tommy”

   private String middleName = “Lee”

   private String lastName = “Jones”

   public Name()

      DISPLAY "Enter your first name."

       GET firstName

      DISPLAY "Enter your middle name."

       GET middleName

      DISPLAY "Enter your last name."

       GET lastName

   END

  

   public Name(String firstName2, String middleName2, String lastName2)

       firstName = firstName2;

       middleName = middleName2;

   END

   public boolean equals(Name paraName)

       IF firstName is equal to paraName.firstName THEN

          IF middleName is equal to paraName.middleName THEN

             

          ELSE

              RETURN false

          ENDIF

       ELSE

          RETURN false

       ENDIF

   END

  

   //returns the middle name as a string

   public String getMiddleName()

       RETURN middleName

   END

   public String getFirstName()

       RETURN firstName

   END

  

   //returns the full name as a string

   public String getFullName()

       RETURN getFirstName() + " " + getMiddleName()

   END

   //converts all parts of the name to upper case

   public void toUpperCase()

       Convert firstName to upper case

   END

Name class UML

Name

private STRING firstName = “Lamda”

private STRING middleName = “Lee”

private STRING lastName = “Lima”

methods

public Name()

public Name(STRING, STRING, STRING)

public equals(Name):boolean or boolean equals(Name)

public getLastName():String

public equals(Name):Boolean

public changeNameTo(Name):void

Name

private STRING firstName = “Lamda”

private STRING middleName = “Lee”

private STRING lastName = “Lima”

methods

public Name()

public Name(STRING, STRING, STRING)

public equals(Name):boolean or boolean equals(Name)

public getLastName():String

public equals(Name):Boolean

public changeNameTo(Name):void

Explanation / Answer

HI, Please find my implementation.

############## Name.java ############

import java.util.Scanner;

public class Name {

   private String firstName;

   private String middleName;

   private String lastName;

  

   private static Scanner sc = new Scanner(System.in);

  

   public Name(){

      

       System.out.print("Enter your first name: ");

       firstName = sc.next();

       System.out.print("Enter your middle name: ");

       middleName = sc.next();

       System.out.print("Enter your last name: ");

       lastName = sc.next();

   }

   public Name(String first, String middle, String last){

       firstName = first;

       lastName = last;

       middleName = middle;

   }

   public boolean equals(Name other){

       if(firstName.equalsIgnoreCase(other.firstName) &&

               lastName.equalsIgnoreCase(other.lastName) &&

               middleName.equalsIgnoreCase(other.middleName))

           return true;

       return false;

   }

   public String getLastName(){;

       return lastName;

   }

  

   public String getMiddleName(){

       return middleName;

   }

  

   public String getFirstName(){

       return firstName;

   }

  

   public String getFullName(){

       return getFirstName()+" "+getMiddleName()+" "+getLastName();

   }

  

   public void toUpperCase(){

       firstName = firstName.toUpperCase();

   }

   public void changeNameTo(Name other){

       firstName = other.firstName;

       middleName = other.middleName;

       lastName = other.middleName;

   }

}

################### TestName.java ###################

public class TestName {

  

   public static void main(String[] args) {

      

       Name name = new Name();

      

       System.out.println("First name: "+name.getFirstName());

       System.out.println("Full name: "+name.getFullName());

      

       name.toUpperCase();

      

       System.out.println("Full name: "+name.getFullName());

      

       Name name1 = new Name("Alex", "Bob", "M");

       System.out.println(name1.getFullName());

      

       System.out.println("name == name1 ? "+name.equals(name1));

   }

}

/*

Sample run:

Enter your first name: Pravesh

Enter your middle name: Kumar

Enter your last name: Mehta

First name: Pravesh

Full name: Pravesh Kumar Mehta

Full name: PRAVESH Kumar Mehta

Alex Bob M

name == name1 ? false

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote