我有這樣的項目做,我不知道是什麼步驟來刺穿鏈表步驟
編寫Java程序存儲在一個鏈表員工信息,程序 應實現以下功能:
- 功能
任務 - 插入一個新員工
添加新員工到鏈接 列表和商店僱員的信息 (ID,姓名,地址,部門, 工資) - 更新員工信息
修改現有員工 信息(改變地址和 工資只)。你應該問 員工ID更新他/她的 信息 - 刪除僱員
從鏈表
程序應該顯示的功能列表中刪除使用 員工ID的職員,請求用戶輸入他/她想要執行的功能號碼 ,然後按照上表中的要求執行該功能。
這是我做過什麼
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Collections;
import java.util.ListIterator;
public class LinkedListEmployee {
//------------start of employee class--------
private class Employee {
private String empNumber;
private String name;
private String department;
private int empTest;
private double salary;
public Employee() {
empNumber = null;
empTest= 0;
name = null;
department = null;
salary = 0.0;
}
}
//------------end of employee class--------
public static void main(String args[]) {
LinkedList<Employee> empTest = new LinkedList<Employee>();
System.out.println("\nMENU\n1.Add Employee\n2.Update");
Scanner in = new Scanner(System.in);
int choice = in.nextInt();
if (choice == 2)
System.out.println("Enter employee’s name");
String nm = in.nextLine();
update(nm, empTest);
}
public static void update(String namePara, LinkedList<Employee> empTest) {
ListIterator<Employee> litr = empTest.listIterator();
Employee tempEmp;
Scanner in = new Scanner(System.in);
while (litr.hasNext()) {
tempEmp=litr.next();
if (tempEmp.name.equals(namePara)) {
System.out.println("Enter new address");
String add = in.nextLine();
System.out.println("Enter new salary");
String sal = in.nextLine();
//tempEmp.Empaddress = add;
tempEmp.salary = Double.parseDouble(sal);
break;
}
}
}
}
這最後的工作是它?或者有更多的步驟去!提到這個問題?
請幫助我知道的步驟
您收到的錯誤是什麼? – McWayWeb
listIterator litr = empTest.listIterator();找不到符號--class listteterator –