SlideShare a Scribd company logo
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().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");
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));
}
}
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)
Solution
public class Employee {
private String name;
private String gender;
private String jobTitle;
private Organization organization;
private String birthDate;
/**
* @param name
* @param gender
* @param jobTitle
* @param organization
* @param birthDate
*/
public Employee(String name, String gender, String jobTitle,
Organization organization, String birthDate) {
this.name = name;
this.gender = gender;
this.jobTitle = jobTitle;
this.organization = organization;
this.birthDate = birthDate;
}
public String getName() {
return name;
}
public String getGender() {
return gender;
}
public String getJobTitle() {
return jobTitle;
}
public Organization getOrganization() {
return organization;
}
public String getBirthDate() {
return birthDate;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Employee [name=" + name + ", gender=" + gender + ", jobTitle="
+ jobTitle + ", organization=" + organization + ", birthDate="
+ birthDate + "]";
}
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) {
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 {
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)
*
* @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");
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");
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));
}
}
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
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

More Related Content

Similar to You will need to develop a system that can track employee informatio.pdf

Basic Object Oriented Concepts
Basic Object Oriented ConceptsBasic Object Oriented Concepts
Basic Object Oriented Concepts
Scott Lee
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdf
nipuns1983
 
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfNot sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
wasemanivytreenrco51
 
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docxCSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
faithxdunce63732
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
alliedscorporation
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
DEEPAKSONI562
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
arihantgiftgallery
 
In your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdfIn your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdf
arihanthtextiles
 
Overview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfOverview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdf
info961251
 
Java Question---------------------------FacebookApp(Main).jav.pdf
Java Question---------------------------FacebookApp(Main).jav.pdfJava Question---------------------------FacebookApp(Main).jav.pdf
Java Question---------------------------FacebookApp(Main).jav.pdf
ambersushil
 
Cis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry universityCis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry university
lhkslkdh89009
 
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdfThis is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
jillisacebi75827
 
Rd
RdRd
JavaAssignment6
JavaAssignment6JavaAssignment6
JavaAssignment6
Art Saucedo
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
Scalac
 
Grails queries
Grails   queriesGrails   queries
Grails queries
Husain Dalal
 
Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
arishmarketing21
 
Cis 407 i lab 4 of 7
Cis 407 i lab 4 of 7Cis 407 i lab 4 of 7
Cis 407 i lab 4 of 7
helpido9
 
package employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdfpackage employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdf
sharnapiyush773
 
1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf
aniljain719651
 

Similar to You will need to develop a system that can track employee informatio.pdf (20)

Basic Object Oriented Concepts
Basic Object Oriented ConceptsBasic Object Oriented Concepts
Basic Object Oriented Concepts
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdf
 
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdfNot sure why my program wont run.Programmer S.Villegas helper N.pdf
Not sure why my program wont run.Programmer S.Villegas helper N.pdf
 
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docxCSE 110 - Lab 6 What this Lab Is About  Working wi.docx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
 
So Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdfSo Far I have these two classes but I need help with my persontest c.pdf
So Far I have these two classes but I need help with my persontest c.pdf
 
In your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdfIn your Person classAdd a constant field to store the current yea.pdf
In your Person classAdd a constant field to store the current yea.pdf
 
Overview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdfOverview You are tasked with writing a program called Social Security.pdf
Overview You are tasked with writing a program called Social Security.pdf
 
Java Question---------------------------FacebookApp(Main).jav.pdf
Java Question---------------------------FacebookApp(Main).jav.pdfJava Question---------------------------FacebookApp(Main).jav.pdf
Java Question---------------------------FacebookApp(Main).jav.pdf
 
Cis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry universityCis407 a ilab 4 web application development devry university
Cis407 a ilab 4 web application development devry university
 
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdfThis is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
This is the official tutorial from Oracle.httpdocs.oracle.comj.pdf
 
Rd
RdRd
Rd
 
JavaAssignment6
JavaAssignment6JavaAssignment6
JavaAssignment6
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
 
Grails queries
Grails   queriesGrails   queries
Grails queries
 
Refer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdfRefer to my progress on this assignment belowIn this problem you w.pdf
Refer to my progress on this assignment belowIn this problem you w.pdf
 
Cis 407 i lab 4 of 7
Cis 407 i lab 4 of 7Cis 407 i lab 4 of 7
Cis 407 i lab 4 of 7
 
package employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdfpackage employeeType.employee;public class Employee {    private.pdf
package employeeType.employee;public class Employee {    private.pdf
 
1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf
 

More from jeetumordhani

• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
jeetumordhani
 
You heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdfYou heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdf
jeetumordhani
 
write at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdfwrite at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdf
jeetumordhani
 
Why have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdfWhy have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdf
jeetumordhani
 
Who writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdfWho writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdf
jeetumordhani
 
Which of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdfWhich of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdf
jeetumordhani
 
Which of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdfWhich of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdf
jeetumordhani
 
Which of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdfWhich of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdf
jeetumordhani
 
What tissue type has polarity and is avascular What tissue.pdf
What tissue type has polarity and is avascular  What tissue.pdfWhat tissue type has polarity and is avascular  What tissue.pdf
What tissue type has polarity and is avascular What tissue.pdf
jeetumordhani
 
What organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdfWhat organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdf
jeetumordhani
 
What is meant by modular software and why is it important How can t.pdf
What is meant by modular software and why is it important  How can t.pdfWhat is meant by modular software and why is it important  How can t.pdf
What is meant by modular software and why is it important How can t.pdf
jeetumordhani
 
What are the two major steps in biological classification What .pdf
What are the two major steps in biological classification  What .pdfWhat are the two major steps in biological classification  What .pdf
What are the two major steps in biological classification What .pdf
jeetumordhani
 
Tissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdfTissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdf
jeetumordhani
 
The members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdfThe members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdf
jeetumordhani
 
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdfNetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
jeetumordhani
 
Please help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdfPlease help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdf
jeetumordhani
 
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdfNumerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
jeetumordhani
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdf
jeetumordhani
 
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdfJava AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
jeetumordhani
 
Irreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdfIrreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdf
jeetumordhani
 

More from jeetumordhani (20)

• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
 
You heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdfYou heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdf
 
write at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdfwrite at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdf
 
Why have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdfWhy have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdf
 
Who writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdfWho writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdf
 
Which of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdfWhich of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdf
 
Which of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdfWhich of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdf
 
Which of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdfWhich of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdf
 
What tissue type has polarity and is avascular What tissue.pdf
What tissue type has polarity and is avascular  What tissue.pdfWhat tissue type has polarity and is avascular  What tissue.pdf
What tissue type has polarity and is avascular What tissue.pdf
 
What organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdfWhat organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdf
 
What is meant by modular software and why is it important How can t.pdf
What is meant by modular software and why is it important  How can t.pdfWhat is meant by modular software and why is it important  How can t.pdf
What is meant by modular software and why is it important How can t.pdf
 
What are the two major steps in biological classification What .pdf
What are the two major steps in biological classification  What .pdfWhat are the two major steps in biological classification  What .pdf
What are the two major steps in biological classification What .pdf
 
Tissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdfTissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdf
 
The members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdfThe members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdf
 
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdfNetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
 
Please help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdfPlease help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdf
 
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdfNumerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
 
My question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdfMy question is pretty simple, I just want to know how to call my ope.pdf
My question is pretty simple, I just want to know how to call my ope.pdf
 
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdfJava AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
 
Irreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdfIrreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdf
 

Recently uploaded

S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 

Recently uploaded (20)

S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 

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));
  • 5. } } 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) Solution public class Employee { private String name; private String gender; private String jobTitle; private Organization organization; private String birthDate; /** * @param name * @param gender * @param jobTitle
  • 6. * @param organization * @param birthDate */ public Employee(String name, String gender, String jobTitle, Organization organization, String birthDate) { this.name = name; this.gender = gender; this.jobTitle = jobTitle; this.organization = organization; this.birthDate = birthDate; } public String getName() { return name; } public String getGender() { return gender; } public String getJobTitle() { return jobTitle; } public Organization getOrganization() { return organization; } public String getBirthDate() { return birthDate; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return "Employee [name=" + name + ", gender=" + gender + ", jobTitle=" + jobTitle + ", organization=" + organization + ", birthDate=" + birthDate + "]";
  • 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