Linked List and Cases?

Sky_Lancer

New member
Could someone help me out. I am trying to make a Link List where my options are 1) I myself input/add a node, 2) delete a node 3)Input new data, 4) Remove the Data, and Finally 5) Display the data/ list. Here is my code:
import java.util.Scanner;
import java.util.*;

public class LinkedList{
public static void main(String[] args){

int num;
int x;

Scanner num=new Scanner(System.in);
LinkedList link=new LinkedList();

link.add("A");
link.add("B");
link.add("C");
link.add("D");
link.add("E");

System.out.println("The contents are: " + link);

do{
System.out.print("Enter your choice: ");
System.out.println("\n1. Add Node \n2. Delete Node \n3.Add Data \n4. Remove Data \n5. Display List");

num = keyboard.nextInt();

switch(num){

case 1:
AddNode(x);
break;

case 2:
DeleteNode(x);
break;

case 3:
AddData(x);
break;

case 4:
RemoveData(x);

case 5:
System.out.println ("This is now your new Content: " + link);
}
}
while (num != 5);
}

public static void addNode(int x){
int a;
a = link.add(new Integer (10));
System.out.println("The new contents are: " + link);
}

public static void addData(int x){
int b;
b = link.add("1"); link.add("2"); link.add("3"); link.add("4"); link.add("5");
System.out.println("The new contents are: " + link);
}

public static void RemoveData(int x){
int c;
c =
System.out.println("The new contents are: " + link);
}
}

It's incomplete so bare with me.
 
Back
Top