新学习Java,用Vector写了个通讯录,但是编译的时候总是出错,求指点,感激不尽!
import java.io.*;
import java.util.Vector;
import java.util.Scanner;
public class tongxunlu1 {
//主方法
public static void main (String[] args){
SimpleMember tongxunList=new SimpleMember();
int choice;
showSelection();
choice=GetInput.getInput();
while(choice!=0){
switch(choice){
case 1:
tongxunList.printAllMember();
break;
case 2:
tongxunList.InputMember();
break;
case 3:
tongxunList.searchMember();
break;
case 4:
tongxunList.dMember();
break;
case 5:
tongxunList.chMember();
break;
default:System.out.println("Invalid selection");
}
System.out.println("\n");
showSelection();
choice=GetInput.getInput();
}
}
//输入主界面
public static void showSelection () {
System.out.println("**********************");
System.out.println(" 1.显示所有的通讯人");
System.out.println(" 2.添加新的通讯人");
System.out.println(" 3.查找通讯人");
System.out.println(" 4.删除通讯人");
System.out.println(" 5.修改通讯人");
System.out.println(" 0.退出");
System.out.println("**********************");
}
}
//输入选择项
class GetInput{
public static int getInput() {
System.out.println("请输入:");
Scanner scanner=new Scanner(System.in);
int str=scanner.nextInt();
return str;
}
}
class SimpleMember {
public Vector memberList=new Vector();
public Vector member=new Vector();
//输入
String InputSth(String Sth1,String Sth2) {
String str;
Scanner scanner=new Scanner(System.in);
System.out.println("请输入需要"+Sth1+"的人的"+Sth2);
str=scanner.next();
return str;
}
//打印链表中的所有成员
void printAllMember(){
int memberNum;
memberNum=memberList.size();
System.out.println("该通讯录中共有"+"memberNum"+"个条目");
System.out.println(memberList);
}
//向链表中添加成员
void InputMember(){
String strInput;
member.removeAllElement();
strInput=InputSth("添加","名字");
member.addElement(strInput);
strInput=InputSth("添加","年龄");
member.addElement(strInput);
strInput=InputSth("添加","国家");
member.addElement(strInput);
memberList.addElement(member);
System.out.print("刚刚输入的信息是:"+member);
}
//查找成员
void searchMember(){
String strSearch;
int i;
strSearch=InputSth("查找","名字");
for(i=0;i<memberList.size();i++){
if(memberList.elementAt(i).contains(strSearch))
System.out.println(memberList.elementAt(i));
else
System.out.println("该通讯录中无"+strSearch+"的记录");
}
}
//删除成员
void dMember() {
String strDel;
int i;
strDel=InputSth("删除","名字");
for(i=0;i<memberList.size();i++){
if(memberList.elementAt(i).contains(strDel)){