java改错
/** To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tongxunlu;
import java.util.*;
public class Tongxunlu {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
System.out.println(" "+"/***通讯录管理***\\");
Yuangong sm = new Yuangong();
//有错
sm.addYuangong();
sm.listAllYuangong();
s1:while(true){
s2:while(true){
System.out.println("/***管理菜单***\\");
System.out.println("1、增加员工");
System.out.println("2、查找员工");
System.out.println("3、修改员工信息");
System.out.println("4、删除员工");
System.out.print("Now 请选择:");
int choose = in.nextInt();
String YN;
String Number;
switch(choose){
case 1:
System.out.print("请输入要添加员工的个数:");
int add = in.nextInt();
//有错
sm.addYuangong2(add);
sm.listAllYuangong();
System.out.print("是否继续管理员工 Y/N:");
YN = in.next();
for(int i =1;i<=add;i++)
{
if(YN.equals("Y") || YN.equals("y"))
{
System.out.print("请输入该员工的工号:");
Number = in.next();
//有错
sm.searchYuangong(Number);
System.out.print("是否继续管理员工 Y/N:");
YN = in.next();
}
}
/*
if(YN.equals("Y") || YN.equals("y")){
break s2;
}
break s1;
case 3:
System.out.print("请输入该员工的工号:");
Number = in.next();
sm.amendYuangong(Number);
System.out.print("是否继续管理员工 Y/N:");
YN = in.next();
if(YN.equals("Y") || YN.equals("y")){
break s2;
}
break s1;
case 4:
System.out.print("请输入该员工的工号:");
Number = in.next();
sm.removeYuangong(Number);
System.out.print("是否继续管理员工 Y/N:");
YN = in.next();
*/
if(YN.equals("Y") || YN.equals("y")){
break s2;
}
break s1;
default:
System.out.println("选择错误,请重新选择!");
}
}
}
System.out.println("程序已退出!");
}
}
//有错
class Tongxunlu{
Random r = new Random();
private Scanner in = new Scanner(System.in);
private Vector<Yuangong> v = new Vector<Yuangong>();
//随机生成员工名字
public String randomName(){
StringBuffer buffer1 = new StringBuffer("普惹二热个饿破范围而非个法品可就得发不好风格和客厅有 罚你你同意你发个你看他 ");
StringBuffer randomname = new StringBuffer();
int len = buffer1.length();
for(int i = 0; i < 3; i++){
randomname.append(buffer1.charAt(r.nextInt(len)));
}
return randomname.toString();
}
Yuangong yuangong[] = new Yuangong[5];
public void addYuangong(){
for(int i = 0; i < yuangong.length; i++){
yuangong[i] = new Yuangong();
yuangong[i].setNumber("KY08_"+String.valueOf("0000".toString()+(i+1)));
yuangong[i].setName(randomName());
yuangong[i].setScore(200+r.nextInt(500));
v.add(yuangong[i]);
}
}
Yuangong yuangong2[];
public void addYuangong2(int add){
for(int i = 0; i < add; i++){
yuangong[i] = new yuangong();
System.out.println("请输入第" + " " + (i + 1) + " " + "员工的信息");
System.out.print("工号:");
student[i].setNumber(in.next());
System.out.print("姓名:");
student[i].setName(in.next());
System.out.print("分数:");
student[i].setScore(in.nextDouble());
v.add(yuangong[i]);
}
}
public void listAllYuangong(){
if(v.size() == 0){
System.out.println("没有任何员工信息!");
return;
}
System.out.println("编号"+"\t"+"工号"+"\t"+"\t"+"姓名"+"\t"+"分数");
for(int i = 0; i < v.size(); i++){
Yuangong stu = (Yuangong)v.get(i);
System.out.println((i+1)+"\t"+stu.getNumber()+"\t"+stu.getName()+"\t"+stu.getScore());
}
}
public void searchYuangong(String Number){
for(int i = 0; i < v.size(); i++){
Yuangong stu = (Yuangong)v.get(i);
if(Number.equals(stu.getNumber())){
System.out.println("编号"+"\t"+"工号"+"\t"+"\t"+"姓名"+"\t"+"分数");
System.out.println((i+1)+"\t"+stu.getNumber()+"\t"+stu.getName()+"\t"+stu.getScore());
break;
}
}
System.out.println("你所查找的员工不存在!");
}
public void amendStudent(String Number){
for(int i = 0; i < v.size(); i++){
Student stu = (Student)v.get(i);
if(Number.equals(stu.getNumber())){
System.out.print("请重新设置该员工的工号:");
stu.setNumber(in.next());
System.out.print("请重新设置该员工的姓名:");
stu.setName(in.next());
System.out.print("请重新设置该员工的成绩:");
stu.setScore(in.nextDouble());
System.out.println("修改后该员工的信息为:");
System.out.println("编号"+"\t"+"工号"+"\t"+"\t"+"姓名"+"\t"+"分数");
System.out.println((i+1)+"\t"+stu.getNumber()+"\t"+stu.getName()+"\t"+stu.getScore());
return ;
}
}
System.out.println("该员工不存在!");
}
public void removeYuangong(String Number){
for(int i = 0; i < v.size(); i++){
Yuangong stu = (Yuangong)v.get(i);
if(Number.equals(stu.getNumber())){
v.remove(i);
System.out.println("删除成功!");
System.out.print("是否打印现有与员工信息 Y/N:");
String YN = in.next();
if(YN.equals("Y") || YN.equals("y")){
listAllYuangong();
}
return ;
}
}
System.out.println("该员工不存在!");
}
}
class Yuangong{
private String name;
private String number;
private double score;
public void setName(String Name){
name = Name;
}
public String getName(){
return name;
}
public void setNumber(String Number){
number = Number;
}
public String getNumber(){
return number;
}
public void setScore(double Score){
score = Score;
}
public double getScore(){
return score;
}
}
追问:怎么做啊!帮我改改好吗?