You will need to develop a system that can track employee information for two Organizations
(such as Google and Microsoft). The Employee information you must track is as follows:
Name
Gender
Job Title
Organization they work for
Birthday
As for the Organization that the Employee works for, you must also track this information:
Organization Name
Number of Employees
The system must be able to properly compare any two employees against each other to determine
if they are the same Employee. This means that if you compared two Employees with the same
Name, Gender, Birthday and Organization, the system should think that they are equal to one
another. If any of these properties are different, then the two Employees are not the same
Employee.
The same rules apply to comparing Organizations to one another. Organizations with the same
Organization name are to be thought of as equal, different names means different organizations.
Use the charts on the next page to create your classes.
Employee
private String name;
private String gender;
private String jobTitle;
private Organization organization;
private String birthDate;
Employee(String theName, String theGender,
String title, Organization org,
String theBirthDate)
<>
String getName()
String getGender()
String getJobTitle()
Organization getOrganization()
String getBirthDate()
String toString()
boolean equals(Employee other)
<>
void changeJobTitle (String newTitle)
void changeName(String newName)
void changeOrganization(Organization org)
Organization
private String organizationName;
private int numEmployees;
Organization(String name, int employees)
<>
String getOrganizationName()
int getNumEmployees()
String toString()
boolean equals(Organization other)
<>
void changeOrganizationName(String newName)
*****NOTE: All constructors and methods should be public. *****
*Note: There is a zip file listed that has a starts for each of the classes that are required. They are
located in the source file and you will also find a test file for the program.
STARTER CODE - EMPLOYEE
public class Employee
{
}
STARTER CODE - ORGANIZATION
/**
* Organization.java
*
* @author - Jane Doe
* @author - Period n
* @author - Id nnnnnnn
*
* @author - I received help from ...
*
*/
public class Organization
{
}
TESTER CODE
/**
* This class tests the Employee and Organization classes.
*/
public class Tester
{
public static void main(String[] args)
{
Employee emp1 = new Employee(\"Sally Brown\", \"Female\", \"Vice President\",
new Organization(\"Google\", 5500), \"11-11-1969\");
System.out.println(emp1);
System.out.println();
System.out.println(\"Name should be Sally Brown and is \" + emp1.getName());
System.out.println(\"Gender should be Female and is \" + emp1.getGender());
System.out.println(\"Job title should be Vice President and is \" + emp1.getJobTitle());
System.out.println(\"Birth date should be 11-11-1969 and is \" + emp1.getBirthDate());
System.out.println(\"Organization should be Google and is \"
+ emp1.getOrganization().getOr.
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
You will need to develop a system that can track employee informatio.pdf
1. You will need to develop a system that can track employee information for two Organizations
(such as Google and Microsoft). The Employee information you must track is as follows:
Name
Gender
Job Title
Organization they work for
Birthday
As for the Organization that the Employee works for, you must also track this information:
Organization Name
Number of Employees
The system must be able to properly compare any two employees against each other to determine
if they are the same Employee. This means that if you compared two Employees with the same
Name, Gender, Birthday and Organization, the system should think that they are equal to one
another. If any of these properties are different, then the two Employees are not the same
Employee.
The same rules apply to comparing Organizations to one another. Organizations with the same
Organization name are to be thought of as equal, different names means different organizations.
Use the charts on the next page to create your classes.
Employee
private String name;
private String gender;
private String jobTitle;
private Organization organization;
private String birthDate;
Employee(String theName, String theGender,
String title, Organization org,
String theBirthDate)
<>
String getName()
String getGender()
String getJobTitle()
Organization getOrganization()
String getBirthDate()
String toString()
boolean equals(Employee other)
2. <>
void changeJobTitle (String newTitle)
void changeName(String newName)
void changeOrganization(Organization org)
Organization
private String organizationName;
private int numEmployees;
Organization(String name, int employees)
<>
String getOrganizationName()
int getNumEmployees()
String toString()
boolean equals(Organization other)
<>
void changeOrganizationName(String newName)
*****NOTE: All constructors and methods should be public. *****
*Note: There is a zip file listed that has a starts for each of the classes that are required. They are
located in the source file and you will also find a test file for the program.
STARTER CODE - EMPLOYEE
public class Employee
{
}
STARTER CODE - ORGANIZATION
/**
* Organization.java
*
* @author - Jane Doe
* @author - Period n
* @author - Id nnnnnnn
*
* @author - I received help from ...
*
*/
public class Organization
{
3. }
TESTER CODE
/**
* This class tests the Employee and Organization classes.
*/
public class Tester
{
public static void main(String[] args)
{
Employee emp1 = new Employee("Sally Brown", "Female", "Vice President",
new Organization("Google", 5500), "11-11-1969");
System.out.println(emp1);
System.out.println();
System.out.println("Name should be Sally Brown and is " + emp1.getName());
System.out.println("Gender should be Female and is " + emp1.getGender());
System.out.println("Job title should be Vice President and is " + emp1.getJobTitle());
System.out.println("Birth date should be 11-11-1969 and is " + emp1.getBirthDate());
System.out.println("Organization should be Google and is "
+ emp1.getOrganization().getOrganizationName());
System.out.println("Number of employees in organization should be 5500 and is "
+ emp1.getOrganization().getNumEmployees());
System.out.println();
Employee emp2 = new Employee("Sally Brown", "Female", "Vice President",
new Organization("Google", 5500), "11-11-1969");
System.out.println(emp2);
System.out.println();
System.out.println("Name should be Sally Brown and is " + emp2.getName());
System.out.println("Gender should be Female and is " + emp2.getGender());
System.out.println("Job title should be Vice President and is " + emp2.getJobTitle());
System.out.println("Birth date should be 11-11-1969 and is " + emp2.getBirthDate());
System.out.println("Organization should be Google and is "
+ emp2.getOrganization().getOrganizationName());
System.out.println("Number of employees in organization should be 5500 and is "
+ emp2.getOrganization().getNumEmployees());
4. System.out.println();
Employee emp3 = new Employee("Charlie Brown", "Male", "President",
new Organization("Microsoft", 15500), "9-15-1965");
System.out.println(emp3);
System.out.println();
System.out.println("Name should be Charlie Brown and is " + emp3.getName());
System.out.println("Gender should be Male and is " + emp3.getGender());
System.out.println("Job title should be President and is " + emp3.getJobTitle());
System.out.println("Birth date should be 9-14-1965 and is " + emp3.getBirthDate());
System.out.println("Organization should be Microsoft and is "
+ emp3.getOrganization().getOrganizationName());
System.out.println("Number of employees in organization should be 15500 and is "
+ emp3.getOrganization().getNumEmployees());
System.out.println();
Employee emp4 = new Employee("Charlie Brown", "Male", "President",
new Organization("Google", 5500), "9-15-1965");
System.out.println(emp4);
System.out.println();
System.out.println("Name should be Charlie Brown and is " + emp4.getName());
System.out.println("Gender should be Male and is " + emp4.getGender());
System.out.println("Job title should be President and is " + emp4.getJobTitle());
System.out.println("Birth date should be 9-14-1965 and is " + emp4.getBirthDate());
System.out.println("Organization should be Google and is "
+ emp4.getOrganization().getOrganizationName());
System.out.println("Number of employees in organization should be 5500 and is "
+ emp4.getOrganization().getNumEmployees());
System.out.println();
System.out.println("emp1.equals(emp2) should be true and is " + emp1.equals(emp2));
System.out.println("emp1.equals(emp3) should be false and is " + emp1.equals(emp3));
System.out.println("emp1.equals(emp4) should be false and is " + emp1.equals(emp4));
System.out.println("emp2.equals(emp3) should be false and is " + emp2.equals(emp3));
System.out.println("emp2.equals(emp4) should be false and is " + emp2.equals(emp4));
System.out.println("emp3.equals(emp4) should be false and is " + emp3.equals(emp4));
7. }
public void changeJobTitle(String newTitle) {
this.jobTitle = newTitle;
}
public void changeName(String newName) {
this.name = newName;
}
public void changeOrganization(Organization org) {
this.organization = org;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((birthDate == null) ? 0 : birthDate.hashCode());
result = prime * result + ((gender == null) ? 0 : gender.hashCode());
result = prime * result
+ ((jobTitle == null) ? 0 : jobTitle.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result
+ ((organization == null) ? 0 : organization.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
8. if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Employee))
return false;
Employee other = (Employee) obj;
if (birthDate == null) {
if (other.birthDate != null)
return false;
} else if (!birthDate.equals(other.birthDate))
return false;
if (gender == null) {
if (other.gender != null)
return false;
} else if (!gender.equals(other.gender))
return false;
if (jobTitle == null) {
if (other.jobTitle != null)
return false;
} else if (!jobTitle.equals(other.jobTitle))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (organization == null) {
if (other.organization != null)
return false;
} else if (!organization.equals(other.organization))
return false;
return true;
}
}
public class Organization {
9. private String organizationName;
private int numEmployees;
/**
* @param organizationName
* @param numEmployees
*/
public Organization(String organizationName, int numEmployees) {
this.organizationName = organizationName;
this.numEmployees = numEmployees;
}
public String getOrganizationName() {
return organizationName;
}
public int getNumEmployees() {
return numEmployees;
}
public void changeOrganizationName(String newName) {
this.organizationName = newName;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + numEmployees;
result = prime
* result
+ ((organizationName == null) ? 0 : organizationName.hashCode());
return result;
}
/*
* (non-Javadoc)
10. *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Organization))
return false;
Organization other = (Organization) obj;
if (numEmployees != other.numEmployees)
return false;
if (organizationName == null) {
if (other.organizationName != null)
return false;
} else if (!organizationName.equals(other.organizationName))
return false;
return true;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Organization [organizationName=" + organizationName
+ ", numEmployees=" + numEmployees + "]";
}
}
public class Tester {
public static void main(String[] args) {
Employee emp1 = new Employee("Sally Brown", "Female", "Vice President",
new Organization("Google", 5500), "11-11-1969");
11. System.out.println(emp1);
System.out.println();
System.out.println("Name should be Sally Brown and is "
+ emp1.getName());
System.out
.println("Gender should be Female and is " + emp1.getGender());
System.out.println("Job title should be Vice President and is "
+ emp1.getJobTitle());
System.out.println("Birth date should be 11-11-1969 and is "
+ emp1.getBirthDate());
System.out.println("Organization should be Google and is "
+ emp1.getOrganization().getOrganizationName());
System.out
.println("Number of employees in organization should be 5500 and is "
+ emp1.getOrganization().getNumEmployees());
System.out.println();
Employee emp2 = new Employee("Sally Brown", "Female", "Vice President",
new Organization("Google", 5500), "11-11-1969");
System.out.println(emp2);
System.out.println();
System.out.println("Name should be Sally Brown and is "
+ emp2.getName());
System.out
.println("Gender should be Female and is " + emp2.getGender());
System.out.println("Job title should be Vice President and is "
+ emp2.getJobTitle());
System.out.println("Birth date should be 11-11-1969 and is "
+ emp2.getBirthDate());
System.out.println("Organization should be Google and is "
+ emp2.getOrganization().getOrganizationName());
System.out
.println("Number of employees in organization should be 5500 and is "
+ emp2.getOrganization().getNumEmployees());
System.out.println();
Employee emp3 = new Employee("Charlie Brown", "Male", "President",
new Organization("Microsoft", 15500), "9-15-1965");
12. System.out.println(emp3);
System.out.println();
System.out.println("Name should be Charlie Brown and is "
+ emp3.getName());
System.out.println("Gender should be Male and is " + emp3.getGender());
System.out.println("Job title should be President and is "
+ emp3.getJobTitle());
System.out.println("Birth date should be 9-14-1965 and is "
+ emp3.getBirthDate());
System.out.println("Organization should be Microsoft and is "
+ emp3.getOrganization().getOrganizationName());
System.out
.println("Number of employees in organization should be 15500 and is "
+ emp3.getOrganization().getNumEmployees());
System.out.println();
Employee emp4 = new Employee("Charlie Brown", "Male", "President",
new Organization("Google", 5500), "9-15-1965");
System.out.println(emp4);
System.out.println();
System.out.println("Name should be Charlie Brown and is "
+ emp4.getName());
System.out.println("Gender should be Male and is " + emp4.getGender());
System.out.println("Job title should be President and is "
+ emp4.getJobTitle());
System.out.println("Birth date should be 9-14-1965 and is "
+ emp4.getBirthDate());
System.out.println("Organization should be Google and is "
+ emp4.getOrganization().getOrganizationName());
System.out
.println("Number of employees in organization should be 5500 and is "
+ emp4.getOrganization().getNumEmployees());
System.out.println();
System.out.println("emp1.equals(emp2) should be true and is "
+ emp1.equals(emp2));
System.out.println("emp1.equals(emp3) should be false and is "
+ emp1.equals(emp3));
13. System.out.println("emp1.equals(emp4) should be false and is "
+ emp1.equals(emp4));
System.out.println("emp2.equals(emp3) should be false and is "
+ emp2.equals(emp3));
System.out.println("emp2.equals(emp4) should be false and is "
+ emp2.equals(emp4));
System.out.println("emp3.equals(emp4) should be false and is "
+ emp3.equals(emp4));
}
}
OUTPUT:
Employee [name=Sally Brown, gender=Female, jobTitle=Vice President,
organization=Organization [organizationName=Google, numEmployees=5500],
birthDate=11-11-1969]
Name should be Sally Brown and is Sally Brown
Gender should be Female and is Female
Job title should be Vice President and is Vice President
Birth date should be 11-11-1969 and is 11-11-1969
Organization should be Google and is Google
Number of employees in organization should be 5500 and is 5500
Employee [name=Sally Brown, gender=Female, jobTitle=Vice President,
organization=Organization [organizationName=Google, numEmployees=5500],
birthDate=11-11-1969]
Name should be Sally Brown and is Sally Brown
Gender should be Female and is Female
Job title should be Vice President and is Vice President
Birth date should be 11-11-1969 and is 11-11-1969
Organization should be Google and is Google
Number of employees in organization should be 5500 and is 5500
Employee [name=Charlie Brown, gender=Male, jobTitle=President, organization=Organization
[organizationName=Microsoft, numEmployees=15500], birthDate=9-15-1965]
Name should be Charlie Brown and is Charlie Brown
Gender should be Male and is Male
Job title should be President and is President
Birth date should be 9-14-1965 and is 9-15-1965
Organization should be Microsoft and is Microsoft
14. Number of employees in organization should be 15500 and is 15500
Employee [name=Charlie Brown, gender=Male, jobTitle=President, organization=Organization
[organizationName=Google, numEmployees=5500], birthDate=9-15-1965]
Name should be Charlie Brown and is Charlie Brown
Gender should be Male and is Male
Job title should be President and is President
Birth date should be 9-14-1965 and is 9-15-1965
Organization should be Google and is Google
Number of employees in organization should be 5500 and is 5500
emp1.equals(emp2) should be true and is true
emp1.equals(emp3) should be false and is false
emp1.equals(emp4) should be false and is false
emp2.equals(emp3) should be false and is false
emp2.equals(emp4) should be false and is false
emp3.equals(emp4) should be false and is false