I can not invoke the findPerson method. It should work because I have done this in the past.
I did a debug and got this error.
<terminated>Emp loyeeData (1) [Java Application]
<disconnected>a rrayproject.Emp loyeeData at localhost:1253
<terminated, exit value: 0>C:\Program Files\EasyEclip se Desktop Java 1.2.1\jre\bin\j avaw.exe (May 9, 2007 2:04:22 PM)
I have attached my whole project and if someone can help me that would be great..
Thanks a bunch
nomad
I did a debug and got this error.
<terminated>Emp loyeeData (1) [Java Application]
<disconnected>a rrayproject.Emp loyeeData at localhost:1253
<terminated, exit value: 0>C:\Program Files\EasyEclip se Desktop Java 1.2.1\jre\bin\j avaw.exe (May 9, 2007 2:04:22 PM)
I have attached my whole project and if someone can help me that would be great..
Code:
class PersonClass {
private String empid;
private String lname;
private String fname;
private String street;
private String city;
private String state;
private String zip;
private double payrate;
private int yearsworked;
public PersonClass(String id) {
empid = id;
}
public PersonClass(String id, String ln, String fn, String st, String ct, String se, String zp, double pr, int yw) {
empid = id;
lname = ln;
fname = fn;
street = st;
city = ct;
state = se;
zip = zp;
payrate = pr;
yearsworked = yw;
}
// accessors
public String getID() {return empid;}
public String getFname() {return fname;}
public String getLname() {return lname;}
public String getStree() {return street;}
public String getCity() {return city;}
public String getState() {return state;}
public String getZip() {return zip;}
public double getPayrate() {return payrate;}
public int getYearsworked() {return yearsworked;}
}
public class EmployeeData {
static ArrayList<PersonClass> arlist;
static Scanner kbd;
public static PersonClass makePerson() {
PersonClass temp = null;
// prompt for data
String id;
String ln;
String fn;
String st;
String se;
String ct;
String zp;
double pr;
int years;
System.out.print("Enter ID Number ==>");
id = kbd.next();
System.out.print("Enter Last Name ==>");
ln = kbd.next();
System.out.print("Enter First Name ==>");
fn = kbd.next();
System.out.print("Enter the address==>");
st = kbd.next();
System.out.print("Enter City ==>");
ct = kbd.next();
System.out.print("Enter State ==>");
se = kbd.next();
System.out.print("Enter Zip ==>");
zp = kbd.next();
System.out.print("Enter payrate as double ==>");
pr = kbd.nextDouble();
System.out.print("Enter years worked ==>");
years = kbd.nextInt();
// make an object
temp = new PersonClass(id, ln,fn,st,ct,se, zp, pr,years);
return temp;
}
public void displayMatch() {
String id_flag = "";
Scanner kbd = new Scanner(System.in);
System.out.println("Enter your info please ie: AB1234: ");
id_flag = kbd.next();
boolean notfound = true;
for (PersonClass e : arlist) {
String emp = e.getID();
if (emp.equals(id_flag)) {
System.out.println("Hello" + ("e.lname"));
notfound = false;
}
}
if (notfound == true) {
System.out.println("Error - Employee not found");
// back to menu?
}
}//close findperson
public static void main(String[] args) {
EmployeeData emp = new EmployeeData();
// make array list object
arlist = new ArrayList<PersonClass>();
// make a scanner
kbd = new Scanner(System.in);
int choice;
System.out.println("Make a Section: ");
System.out.println("1. Enter Employees ");
System.out.println("2. Find Employees ");
System.out.println("3. Exit this Program ");
System.out.print("\nPlease press Enter afer each response");
System.out.println("Enter your chose please: ");
choice = kbd.nextInt();
kbd.nextLine();
if (choice == 1) { // if 1 is select go to makePerson
// create people until select stop
boolean endData = false;
while (!endData) {
PersonClass temp = makePerson();
arlist.add(temp);
System.out.println("Add More employees (Y/N)-->");
String ans = kbd.next();
if (ans.equalsIgnoreCase("N")) {
endData = true;
}
}//close while loop
if (choice == 2) { // if 2 is select go to find
emp.displayMatch();
}// close the choice==2
if (choice == 3) {
System.out.printf("Good bye");
}// close the choice == 3
// print out all elements of array list
for (PersonClass idx : arlist) {
System.out.printf("Employee Id is %n", idx.getID());
System.out.printf("Name is %s - %s%n", idx.getFname(),idx.getLname());
System.out.printf("Street is %s%n", idx.getStree());
System.out.printf("City is %s%n", idx.getCity());
System.out.printf("State is %s%n", idx.getState());
System.out.printf("Zip Code is %s%n", idx.getZip());
System.out.printf("Payrate is %8.2f%n", idx.getPayrate());
System.out.printf("Years worked are %d\n", idx.getYearsworked());
System.out.println("--------------------");
}
}
}
}
Thanks a bunch
nomad
Comment