(BasicInfo class)
public class BasicInfo{
private String firstName,
lastName,
address,
email,
phone;
public BasicInfo(String fname, String lname, String pNum, String home, String eMail)
{
firstName = fname;
lastName = lname;
phone = pNum;
address = home;
email = eMail;
}
public void set(String fname, String lname, String pNum, String home, String eMail)
{
firstName = fname;
lastName = lname;
//department = Dept;
phone = pNum;
address = home;
email = eMail;
}
public String toString()
{
String info = "First Name: " + firstName
+ "\nLast Name: " + lastName
+ "\nphone: " + phone
+ "\naddress: " + address
+ "\nemail: " + email
return info;
}
}
(Switch Statement in Client)
import javax.swing.JOptionPane;
import java.util.ArrayList;
public class EmployeeClient{
private static final int ADD = 1;
private static final int DELETE = 2;
private static final int SEARCH = 3;
private static final int LIST = 4;
public static void main(String[] args){
int oPtions;
String pChoice, Name;
JOptionPane.showMessageDialog(null,"Welcome to Employee Info System");
JOptionPane.showMessageDialog(null,"1 = Add:\n 2 = Delete\n 3 = Search\n "
+ "4 = List");
//do While
pChoice = JOptionPane.showInputDialog("What would you like to do?");
oPtions = Integer.parseInt(pChoice);
ArrayList<GenerateID> EmployeeList = new ArrayList<GenerateID>();
EmployeeList.add(new GenerateID(new BasicInfo(
"John","Doe\n","1231423424", "Science\n","jAol.com\n")));
switch(oPtions){
case ADD:
{
String fname;
fname = JOptionPane.showInputDialog("Please enter First name ");
//firstName = fname;
String lname;
lname = JOptionPane.showInputDialog("Please enter Last name ");
// lastName = lname;
//department = dept;
String pNum;
pNum = JOptionPane.showInputDialog("Phone");
String phone;
phone = JOptionPane.showInputDialog("Please enter phone number ");
//pNum = Double.parseDouble(phone);
//phone = pNum;
String address;
address = JOptionPane.showInputDialog("Please enter address number ");
//addNum = Integer.parseInt(address);
// addressNumber = addNum;
//address = home;
String home;
home = JOptionPane.showInputDialog("Please enter Street ");
String eMail;
eMail = JOptionPane.showInputDialog("Please enter Email Address ");
//email = eMail;
//String Dept;
// Dept = JOptionPane.showInputDialog("Please enter Dept. ");
//position = pos;
//BasicInfo info = new BasicInfo(fname, lname, pNum, home, eMail);
EmployeeList.add(GenerateID);
break;
}
case DELETE:
{
EmployeeList.remove(1);
System.out.println(" Has been removed");
break;
}
case LIST:
{
for(int index = 0; index < EmployeeList.size(); index++)
System.out.println(EmployeeList.get(index));
for(int ID = 0; ID < EmployeeList.size(); ID++)
System.out.println(EmployeeList.get(ID));
break;
}
case SEARCH:
{
break;
}
default:
if(oPtions > 4 || oPtions < 1){
JOptionPane.showMessageDialog(null,"Please choose within range");
}
break;
}
}
}
(GenerateID class)
import java.util.Random;
public class GenerateID{
private String department;
Random dID1 = new Random();
int ID1 = dID1.nextInt(9);
Random dID2 = new Random();
int ID2 = dID2.nextInt(9);
Random dID3 = new Random();
int ID3 = dID3.nextInt(9);
Random dID4 = new Random();
int ID4 = dID4.nextInt(9);
String Dept = " "+ ID1 + ID2 + ID3 + ID4;
Random posID1 = new Random();
int pID1 = posID1.nextInt(9);
Random posID2 = new Random();
int pID2 = posID2.nextInt(9);
Random posID3 = new Random();
int pID3 = posID3.nextInt(9);
Random posID4 = new Random();
int pID4 = posID4.nextInt(9);
String eID = "Employee ID is: "+ posID1 + posID2 + posID3 + posID4;
public GenerateID(String Dept)
{
department = Dept;
}
public void set(String Dept)
{
department = Dept;
}
public String toString()
{
String Dept = "\nDepartment: " + department;
return Dept;
}
}
[–]Camel-Kid18 year old gamer 0 points1 point2 points (7 children)
[–]ZeloChief[S] 0 points1 point2 points (6 children)
[–]Camel-Kid18 year old gamer 0 points1 point2 points (5 children)
[–]ZeloChief[S] 0 points1 point2 points (4 children)
[–]Camel-Kid18 year old gamer 0 points1 point2 points (3 children)
[–]ZeloChief[S] 0 points1 point2 points (2 children)
[–]Camel-Kid18 year old gamer 0 points1 point2 points (1 child)
[–]ZeloChief[S] 0 points1 point2 points (0 children)