View Single Post
  #1 (permalink)  
Old 07-24-2007, 08:38 PM
fegiflu fegiflu is offline
Member
 
Join Date: Jul 2007
Posts: 11
fegiflu is on a distinguished road
Help with removing somthing once inputed.
This is my code, but i want to add a Remove function, so once you enter in a number, you can remove it from the Fill list.
the ; is suppose to be ;; and )
Quote:

public class SimpleSearchableList {

private static String[] List = new String[25];
private static int Size; unavailable


public static void main(String[] args)
{
String Cmd;

for(; {
Menu();
System.out.print("Command: ");
Cmd = SimpleIO.inputString();

if(Cmd.equals("Quit"))
break;
else if(Cmd.equals("Fill"))
FillList();
else if(Cmd.equals("Remove"))
RemoveList();
else if(Cmd.equals("Search"))
SearchList();
else if(Cmd.equals("Show"))
ShowList();
}

}



public static void Menu()
{
System.out.println("Choices....................... ...........");
System.out.println("\tFill the list");
System.out.println("\tRemove List");
System.out.println("\tShow the list");
System.out.println("\tSearch the list");
System.out.println("\tQuit");
System.out.println(".............................. ...........");
}


public static void FillList()
{
int Count;

for(Count = 0 ; Count < List.length ; Count++)
{
System.out.print("Enter: ");
List[Count] = SimpleIO.inputString();
if(List[Count].equals("Stop"))
break;
}

Size = Count;
}






public static void SearchList()
{
String KeyValue;
boolean NotFoundFlag;
int K;

System.out.println("Enter Names Below, Stop To Quit");

while(true)
{
System.out.print("Enter: ");
KeyValue = SimpleIO.inputString();
if(KeyValue.equals("Stop"))
break;

NotFoundFlag = true;

for(K = 0 ; K < Size ; K++)
if(List[K].equals(KeyValue)) {
NotFoundFlag = false;
System.out.println(List[K] + " found");
}

if(NotFoundFlag)
System.out.println(KeyValue + " Not Found");
}
}


public static void ShowList()
{
int K;

for(K = 0 ; K < Size ; K++)
System.out.println("List[" + K + "] = " + List[K]);
}
}
Reply With Quote
Sponsored Links