the coding language is java
The start of Polymorphism Assignment
Outcome:
Program Specifications:
Design the following program:
A person has a name, and age.
An Employee is a person.
An Employee has a company and position.
A SoftwareEngineer is an employee and a person.
A SoftwareEngineer has a rank (Junior, Middle, and Senior)
A SoftwareEngineer either C programmer, Jave programmer or both.
A Manager is an Employee and a person.
A Manager has a specialty.
A Manager specialty is either CEO, Division, or Sales.
An Intern is an employee and a person.
An Intern has duty.
A Security is an employee and a person.
A Security has a position (to guard).
An administrator is an employee and a person.
An Administrator has a type HR, recruiter, Secretary, and Legal.
All Employee type objects have a method named doThis();
SoftwareEngineer -> doThis() displays I program web application.
Manager -> doThis() displays I mange sales.
Intern -> doThis() displays I test application.
administrator -> doThis() displays I do the payroll.
Security -> doThis() displays I guard the main entrance.
... in general, all employee have a doThis() method that displays something.
Main()
Create the classes Person, Employee, SoftwareEngineer
Create the classes Manager, Intern, Security, administrator
Create the doThis() method in each class
In main create the follow reference variables:
SoftwareEngineer Hank (create this reference variable)
Manager Terry (create this reference variable)
Intern Mario (create this reference variable)
administrator Paula (create this reference variable)
Security Danilo (create this reference variable)
administrator Barry (create this reference variable)
SoftwareEngineer Peyton (create this reference variable)
Security Wayne (create this reference variable)
Manager Phil (create this reference variable)
SoftwareEngineer Carlos (create this reference variable)
And then...
Call each Employee doThis method (one at a time) passing each player.
Call the toString methods for each Employee object.
You are to turn in a UML, and CODE.
Submission Requirements:
YOU MAY NOT EVER:
Person.java
public class Person {
private String name;
private int age;
public Person()
{
this.name = "";
this.age = 0;
}
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString()
{
return("Name: " + getName() + ", Age: " + getAge() + "
years");
}
}
Employee.java
public abstract class Employee extends Person {
private String company, position;
public Employee()
{
super();
this.company = this.position = "";
}
public Employee(String name, int age, String company, String
position) {
super(name, age);
this.company = company;
this.position = position;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
@Override
public String toString()
{
return(super.toString() + ", Company: " + getCompany() + ",
Position: " + getPosition());
}
public abstract void doThis();
}
SoftwareEngineer.java
public class SoftwareEngineer extends Employee {
private String rank, type;
public SoftwareEngineer()
{
this.rank = "Junior";
this.type = "Both C and Java programmer";
}
public SoftwareEngineer(String name, int age, String company,
String position, String rank, String type) {
super(name, age, company, position);
this.rank = rank;
this.type = type;
}
public String getRank() {
return rank;
}
public void setRank(String rank) {
this.rank = rank;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString()
{
return(super.toString() + ", Rank: " + getRank() + ", Type: " +
getType());
}
@Override
public void doThis() {
System.out.println("I program web application.");
}
}
Manager.java
public class Manager extends Employee {
private String speciality;
public Manager()
{
super();
this.speciality = "Sales";
}
public Manager(String name, int age, String company, String
position, String speciality) {
super(name, age, company, position);
this.speciality = speciality;
}
public String getSpeciality() {
return speciality;
}
public void setSpeciality(String speciality) {
this.speciality = speciality;
}
@Override
public String toString()
{
return(super.toString() + ", Speciality: " +
getSpeciality());
}
@Override
public void doThis() {
System.out.println("I mange sales.");
}
}
Intern.java
public class Intern extends Employee {
private String duty;
public Intern()
{
super();
this.duty = "";
}
public Intern(String name, int age, String company, String
position, String duty) {
super(name, age, company, position);
this.duty = duty;
}
public String getDuty() {
return duty;
}
public void setDuty(String duty) {
this.duty = duty;
}
@Override
public String toString()
{
return(super.toString() + ", Duty: " + getDuty());
}
@Override
public void doThis() {
System.out.println("I test application.");
}
}
Security.java
public class Security extends Employee {
private String positionToGuard;
public Security()
{
super();
this.positionToGuard = "";
}
public Security(String name, int age, String company, String
position, String positionToGuard) {
super(name, age, company, position);
this.positionToGuard = positionToGuard;
}
public String getPositionToGuard() {
return positionToGuard;
}
public void setPositionToGuard(String positionToGuard) {
this.positionToGuard = positionToGuard;
}
@Override
public String toString()
{
return(super.toString() + ", Position to guard: " +
getPositionToGuard());
}
@Override
public void doThis() {
System.out.println("I guard the main entrance.");
}
}
Administrator.java
public class Administrator extends Employee {
private String type;
public Administrator()
{
super();
this.type = "HR";
}
public Administrator(String name, int age, String company,
String position, String type) {
super(name, age, company, position);
this.type = type;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString()
{
return(super.toString() + ", Type: " + getType());
}
@Override
public void doThis() {
System.out.println("I do the payroll.");
}
}
Main.java (Main class)
public class Main {
public static void main(String[] args) {
SoftwareEngineer Hank = new SoftwareEngineer("Hank", 34, "ABC
Company", "Programmer", "Middle", "Java Programmer");
Manager Terry = new Manager("Terry", 44, "DEF Company", "Asst.
Senior Manager", "Sales");
Intern Mario = new Intern("Mario", 22, "EFG Company", "Associate C
Intern", "Check the import libraries");
Administrator Paula = new Administrator("Paula", 52, "IJK Company",
"Senior Administrator", "Secretary");
Security Danilo = new Security("Danilo", 35, "ProGuard Corp",
"Security In Charge", "Main Office");
Administrator Barry = new Administrator("Barry", 39, "IJK Company",
"Asst. Administrator", "Recruiter");
SoftwareEngineer Peyton = new SoftwareEngineer("Peyton", 36, "ABC
Company", "Senior Developer", "Senior", "Both C and Java
Programmer");
Security Wayne = new Security("Wayne", 31, "ProGuard Corp", "Asst.
Security In Charge", "Main Entrance");
Manager Phil = new Manager("Phil", 52, "DEF Company", "Asst.
Manager", "Division");
SoftwareEngineer Carlos = new SoftwareEngineer("Carlos", 48, "ABC
Company", "Senior Programmer", "Senior", "C Programmer");
System.out.println("Calling doThis() method for all employee
objects..");
Hank.doThis();
Terry.doThis();
Mario.doThis();
Paula.doThis();
Danilo.doThis();
Barry.doThis();
Peyton.doThis();
Wayne.doThis();
Phil.doThis();
Carlos.doThis();
System.out.println("\nCalling toString() method for all employee
objects..");
System.out.println(Hank);
System.out.println(Terry);
System.out.println(Mario);
System.out.println(Paula);
System.out.println(Danilo);
System.out.println(Barry);
System.out.println(Peyton);
System.out.println(Wayne);
System.out.println(Phil);
System.out.println(Carlos);
}
}
********************************************************* SCREENSHOT *******************************************************
Get Answers For Free
Most questions answered within 1 hours.