Need some help with a remove function
Design and code a program that will maintain a list of product names. Use a String type to represent the product name and an array of strings to implement the list. Your program must implement the following methods:
Add a product to the list
Remove a product from the list
Display then entire list
Find out if a particular product is on the list.
You need to create a command command loop with a menu() function. The program must continue asking for input until the user stops.
This is the assignment and this is what I have so far. I need some help writing the remove function.
Thanks
/*
* Title:SimpleSearchableList.java
* Description: this example will show a reasonably efficient and
* simple algorithm for rearranging the value in an array
* in ascending order.
*/
public class SimpleSearchableList {
private static String[] List = new String[25]; //These variables (field variables)
private static int Size; //are common to the entire class, but unavailable
//except to the methods of the class...
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("Search"))
SearchList();
else if(Cmd.equals("Show"))
ShowList();
else if(Cmd.equals("Remove"))
Remove();
}
}
//Tells you what you can do...
public static void Menu()
{
System.out.println("Choices..................................");
System.out.println("\tFill to Enter Product");
System.out.println("\tShow to Show Products");
System.out.println("\tSearch to Search for Product");
System.out.println("\tRemove a Product");
System.out.println("\tQuit");
System.out.println(".........................................");
}
//This method will allow the user to fill an array with values...
public static void FillList()
{
int Count;
System.out.println("Type Stop to Stop");
for(Count = 0 ; Count < List.length ; Count++)
{
System.out.print("Enter Product: ");
List[Count] = SimpleIO.inputString();
if(List[Count].equals("Stop"))
break;
}
Size = Count;
}
//This method will rearrange the values in the array so that
// go from smallest to largest (ascending) order...
public static void SearchList()
{
String KeyValue;
boolean NotFoundFlag;
int Z;
System.out.println("Enter Product Names Below, Stop To Quit");
while(true)
{
System.out.print("Enter: ");
KeyValue = SimpleIO.inputString();
if(KeyValue.equals("Stop")) //Note the use of a method for testing
break;// for equality...
NotFoundFlag = true; //We'll assume the negative
for(Z = 0 ; Z < Size ; Z++)
if(List[Z].equals(KeyValue)) {
NotFoundFlag = false; //If we fine the name, we'll reset the flag
System.out.println(List[Z] + " was found");
}
if(NotFoundFlag)
System.out.println(KeyValue + " was not found");
}
}
//This method will display the contents of the array...
public static void ShowList()
{
int Z;
for(Z = 0 ; Z < Size ; Z++)
System.out.println("Product " + (Z+1) + " = " + List[Z]);
}
public static void Remove()
{
}
}

