Question

Urgent help needed with Java program! Create necessary classes and a Java application that support the...

Urgent help needed with Java program!

Create necessary classes and a Java application that support the following: Use the Employee class as the base class:

Employee class, which holds following information:

  • Employee First Name
  • Employee Last Name
  • Employee Phone Number
  • Employee Address
  • Employee id
  • Employee Title
  • Employee salary
  • Create an application that uses the Employee class
    • Constructors –Getters and setters
      • A minimum of 3 constructors including default constructor
    • equals() method
    • Helper methods
    • toString() method

Use Inheritance to create the following additional classes

  • Create Secretary class that holds following additional attributes:
    • Office Location (i.e. SCC104)
    • Status (i.e. Retired, Active, Assigned,)
  • Create a Supervisor class with the following additional attributes
    • Secretary (Instance of Secretary)
    • Department Name
    • Number of Employees assigned
  • Create
    • Constructors –
      • A minimum of 3 constructors including default constructor
    • Getters
    • Setters
    • Helper methods
    • toString() method
    • equals() method
  • Create an array of employees which contains
    • Employee (3)
    • Secretary (4)
    • Supervisor (4)

Provide necessary GUI that supports;

- Display Employee Information
- Search for an Employee
- Add Employee
- Edit Employee Information

0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Employee {

private String firstName, lastName, phoneNumber, address, title;

private int id;

private double salary;

public Employee() {

firstName = "";

lastName = "";

phoneNumber = "";

address = "";

title = "";

id = 1;

salary = 0.0;

}

public Employee(String firstName, String lastName, String phoneNumber, String address, String title,

double salary) {

id = 0;

this.firstName = firstName;

this.lastName = lastName;

this.phoneNumber = phoneNumber;

this.address = address;

this.title = title;

this.salary = salary;

}

public Employee(String firstName, String lastName, String phoneNumber, String address, String title, int id,

double salary) {

this.firstName = firstName;

this.lastName = lastName;

this.phoneNumber = phoneNumber;

this.address = address;

this.title = title;

this.id = id;

this.salary = salary;

}

public String getFirstName() {

return firstName;

}

public void setFirstName(String firstName) {

this.firstName = firstName;

}

public String getLastName() {

return lastName;

}

public void setLastName(String lastName) {

this.lastName = lastName;

}

public String getPhoneNumber() {

return phoneNumber;

}

public void setPhoneNumber(String phoneNumber) {

this.phoneNumber = phoneNumber;

}

public String getAddress() {

return address;

}

public void setAddress(String address) {

this.address = address;

}

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public double getSalary() {

return salary;

}

public void setSalary(double salary) {

this.salary = salary;

}

@Override

public int hashCode() {

final int prime = 31;

int result = 1;

result = prime * result + ((address == null) ? 0 : address.hashCode());

result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());

result = prime * result + id;

result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());

result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());

long temp;

temp = Double.doubleToLongBits(salary);

result = prime * result + (int) (temp ^ (temp >>> 32));

result = prime * result + ((title == null) ? 0 : title.hashCode());

return result;

}

@Override

public boolean equals(Object obj) {

if (this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

Employee other = (Employee) obj;

if (address == null) {

if (other.address != null)

return false;

} else if (!address.equals(other.address))

return false;

if (firstName == null) {

if (other.firstName != null)

return false;

} else if (!firstName.equals(other.firstName))

return false;

if (id != other.id)

return false;

if (lastName == null) {

if (other.lastName != null)

return false;

} else if (!lastName.equals(other.lastName))

return false;

if (phoneNumber == null) {

if (other.phoneNumber != null)

return false;

} else if (!phoneNumber.equals(other.phoneNumber))

return false;

if (Double.doubleToLongBits(salary) != Double.doubleToLongBits(other.salary))

return false;

if (title == null) {

if (other.title != null)

return false;

} else if (!title.equals(other.title))

return false;

return true;

}

@Override

public String toString() {

return "Employee [firstName=" + firstName + ", lastName=" + lastName + ", phoneNumber=" + phoneNumber

+ ", address=" + address + ", title=" + title + ", id=" + id + ", salary=" + salary + "]";

}

}

NOTE: As per Chegg policy, I am allowed to answer specific number of coding question (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
Urgent help needed with Java program! Create necessary classes and a Java application that support the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT