You are on page 1of 4

Long Term Project Outline

8/31 – Create a list of attributes an employee would need to be entered into a database.
9/30 – Build an Employee class with the fields from the list of attributes from the previous
assignment.
11/30 – Build methods used for Employee class (gettor, settor, etc).
1/31 – Build EmployeeList class that will create a database to store your employees.
3/1 – Create methods for EmployeeList class that will allow for searching, sorting, etc.

1. What is their name, how old are they, what is their gender, are they a criminal, how many
years of experience do they have, and most importantly: are they actually a good worker?

100. Good job. I would also suggest maybe what department they work for.

public class Employee


{
private String name;
private int age;
private String gender;
private boolean criminal;
private int experience;
private boolean good;
}

100. Looks great. Remember not all fields have to be private, but most of them are.

public String getName()


{
return name;
}
public void setName(String x)
{
name = x;
}
public int getAge()
{
return age;
}
public void setAge(int x)
{
age = x;
}
public String getGender()
{
return gender;
}
public void setGender(int x)
{
if(x == 0)
gender = "Male";
else if(x == 1)
gender = "Female";
}
public boolean getCriminal()
{
return criminal;
}
public void setCriminal(boolean x)
{
criminal = x;
}
public int getExperience()
{
return experience;
}
public void setExperience(int x)
{
experience = x;
}
public boolean getGood()
{
return good;
}
public void setGood(boolean x)
{
good = x;
}

100. Nice job on the get/set methods.


import java.util.*;
public class EmployeeList
{
public static void main(String[] args) throws Exception
{
Scanner keyboard = new Scanner(System.in);

System.out.println("How many employees would you like to


put in a list?");
int numOfEmployees = keyboard.nextInt();
keyboard.nextLine();
Employee[] employeeList = new Employee[numOfEmployees];

for(int i = 0; i < numOfEmployees; i++)


{
employeeList[i] = new Employee();
}

for(int i = 0; i < numOfEmployees; i++)


{
System.out.println("Enter employee " + (i + 1) + "'s
name >>>");
keyboard.nextLine();
String name = keyboard.nextLine();
employeeList[i].setName(name);

System.out.println("Enter employee " + (i + 1) + "'s


age >>>");
int age = keyboard.nextInt();
employeeList[i].setAge(age);

System.out.println("Enter employee " + (i + 1) + "'s


gender, 0 for male, 1 for female. >>>");
int gender = keyboard.nextInt();
employeeList[i].setGender(gender);

System.out.println("Does employee " + (i + 1) + "


have a criminal record? 0 for no, 1 for yes >>> ");
int criminal = keyboard.nextInt();
employeeList[i].setCriminal(criminal);

System.out.println("How many years of experience does


employee " + (i + 1) + " have? >>> ");
int experience = keyboard.nextInt();
employeeList[i].setExperience(experience);

System.out.println("Lastly, is employee " + (i + 1) "


a good employee? 0 for no, 1 for yes >>> ");
int good = keyboard.nextInt();
employeeList[i].setGood(good);
}
}
}

100. Code looks great, keep it up!

You might also like