Hi there,

I am trying to build a program that allows the users to add details about themselves. These details are their names such as, title, firstname and surname. In the program I am using a switch statement and gaining input via the scanner of the output box.

I want the program to be able to add data to the linkedlist at any point in the LinkedList and search for a specific piece of data and show the results that match it.

Would you recommend using the setters for the variables in my java class to use in case 1 of my switch after each scan.next so that it sets the variable and then adds it to where the user wants it to go?

Below is the java class code:
package ass3work;
 * @author Jacob
public class Node1
{ //Start of class
    //Defining variables that we are going to be using for our program
    private String title;
    private String firstName;
    private String surname;
    /***Building the constructor for my Node1 name program***\
     * The Getters and Setters
     * @param title This is the title of the user that is inputting data into the program.
     * @param firstName This is the first name of the user that is inputting data into the program.
     * @param surname This is the surname of the user that is inputting data into the program.
     * As a side note methods for my program will be below this in the java class file.
   public Node1(String title, String firstName, String surname)
       this.title = title;
       this.firstName = firstName;
       this.surname = surname;
   //The code below is how you group the variables above into one and make it \n
   //easier to use in the toString function. This puts the names into order and makes \n
   //it so that they are all on one line in the output box.
   public String getNode1() {
       return title + " " + firstName + " " + surname;
   //The code below is what we use to display all the variables above in one line \n
   //of the program. This is the toString function and it is used to make a list \n
   //easier to read.
   public String toString() {
       return "["+getNode1()+"]";
   //Building the Getter and Setter for the title variable in my program.
   public String getTitle() {
       return this.title;
   public void setTitle(String t) {
       this.title = t;
   //Building the Getter and Setter for the firstName variable in my program.
   public String getFirstName() {
       return this.firstName;
   public void setFirstName(String fn) {
       this.firstName = fn;
   //Building the Getter and Setter for the surname variable in my program.
   public String getSurname() {
       return this.surname;
   public void setSurname(String sn) {
       this.surname = sn;
} //End of class

Below is the code for my main program.
package ass3work;
import java.util.Scanner;
import java.util.LinkedList;
 * @author Jacob
public class Ass3Work
{ //Start of class
     * @param args the command line arguments
    public static void main(String[] args)
    { //Start of method
        //Declaring an instance of a linked list of Node1 classes
        LinkedList <Node1>list = new LinkedList <Node1>();
        //Declaring the scanner class so that I can get user input from user\n
        //And also keep a track of where people are in the program.
        Scanner scan = new Scanner(System.in);
        list.add(new Node1("Mr","Jacob","Fellows"));
        list.add(new Node1("Mrs","Wilma","Doo"));
        list.add(new Node1("Miss","Daphney","Doo"));
            //Declaring the names of my cases and what the user will type in to\n
            //Select on of these choices. Then once they have done that they will\n
            //need to follow up what happens in the case so that they understand\n
            //what to do.
            System.out.println("Name Listing Program\n"
                    + "1.Add\n"
                    + "2.Show\n"
                    + "3.Find\n"
                    + "4.Size\n"
                    + "5.Clear\n"
                    + "6.Exit\n");
            //This is the while loop fnction that we se so that we can have the\n
            //ability to go through the menu above.
            while(true) {
            //Declaring a integer variable for my switch so that I can gain input\n
            //from the user so that it chooses the one part of my program that they\n
            //chose instead of all the rest of them all at once.
            int Choice = scan.nextInt();
            switch (Choice) { //Start of my switch and cases.
                //Below is case 1 which is the add function which will allow me to add data to my list of names.
                case 1:
                    //This is how you enter your title, firstname and surname into the program.
                    System.out.print("Please enter your title. E.g. Mr, Mrs, Miss, Ms.: ");
                    System.out.print("Please enter your first name: ");
                    System.out.print("Please enter your surname: ");
                    System.out.print("Please enter the position where you would like to save your details (First or Last): ");
                case 2:
                    //This case displays the details that is in my list and puts them all in one line.
                    System.out.println("This is the list of names in my program: " + list);
                case 3:
                    //This case is going to be the search case and will ask the users what surname they want to search for and then display \n
                    //all the details that match the surname.
                    System.out.println("Please enter the surname your after: ");
                case 4:
                    //This is the case that will tell you how big the list is that has active details in it.
                    int size;
                    size = list.size();
                    System.out.println("The size of the list of names is: " + size);
                case 5:
                    //This clears the list of all elements in the program and will allow\n
                    //the user the ability to enter in more details.
                    System.out.print("The list is now empty and ready to accept new details");
                case 6:
                    //This is the case so that yo can exit ot of the program when you\n
                    //have finished with it.
                    System.out.println("Are you sure you want to exit the program(Yes(0) or No): ");
                    //Need an if function here so that I can act upon the users input.
                default :
                    //This is the default section of a switch statement which allows\n
                    //you to make sure the user knows that they have entered in the wrong details.
                    System.out.println("Wrong entry \n");
            } //End of my switch and cases.
            } //End of the while loop function.
    } //End of method
} //End of class

Thanks for the help and I appreciate all the great programmers out there.

P.S Still kinda newbie / java rookie.