Question

the coding language is java The start of Polymorphism Assignment Outcome: Student will demonstrate the ability...

the coding language is java

The start of Polymorphism Assignment

Outcome:

  • Student will demonstrate the ability to apply polymorphism in a Java program.

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:

  • Follow the rules from the prior assignments.

YOU MAY NOT EVER:

  • Use global variables.
  • Use the word goto.
  • Use the break command outside a case statement.

Homework Answers

Answer #1

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 *******************************************************

Know the answer?
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
Similar Questions
Create a student record management system With JAVA using linked list and queue using Java language...
Create a student record management system With JAVA using linked list and queue using Java language and (oracle or any) database to save files and GUI Java swing to create background The program will have the following properties: A. Register students ( assume each students has ID, first name, last name and middle name) B. Register students with courses ( course no ,course title chr ) C. Able to maintain grade on which course they are registered D. Searches students...
Write a program in Java that: 1. will prompt user with a menu that contains options...
Write a program in Java that: 1. will prompt user with a menu that contains options to: a. Add a To-Do Item to a todo list. A To-Do Item contains: i. An arbitrary reference number (4; 44,004; etc.) ii. A text description of the item ("Pick up dry cleaning", etc.) iii. A priority level (1, 2, 3, 4, or 5) b. View an item in the list (based on its reference number) c. Delete an item from the list (based...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
IN JAVA!! You may be working with a programming language that has arrays, but not nodes....
IN JAVA!! You may be working with a programming language that has arrays, but not nodes. In this case you will need to save your BST in a two dimensional array. In this lab you will write a program to create a BST modelled as a two-dimensional array. The output from your program will be a two-dimensional array.   THEN: practice creating another array-based BST using integers of your choice. Once you have figured out your algorithm you will be able...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*;...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*; import javax.swing.*; public class Clicker extends JFrame implements ActionListener {     int count;     JButton button;     Clicker() {         super("Click Me");         button = new JButton(String.valueOf(count));         add(button);         button.addActionListener(this);         setSize(200,100);         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         setVisible(true);     }     public void actionPerformed(ActionEvent e) {         count++;         button.setText(String.valueOf(count));     }     public static void main(String[] args) { new Clicker(); } } a. add(button);...
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName (a String), numSold (an integer that represents the number of that type of game sold), and priceEach (a double that is the price of each of that type of Game). I only want three instance variables!! The class should have the following methods: A constructor that has two parameter – a String containing the name of the Game and a double containing its price....
I need this before the end of the day please :) In Java 10.13 Lab 10...
I need this before the end of the day please :) In Java 10.13 Lab 10 Lab 10 This program reads times of runners in a race from a file and puts them into an array. It then displays how many people ran the race, it lists all of the times, and if finds the average time and the fastest time. In BlueJ create a project called Lab10 Create a class called Main Delete what is in the class you...
IT 168                                         &nb
IT 168                                                                                          Fall 2020 Program 4 Due Date: October 21 at 11:55 PM Problem: A simulation program is needed to determine if the ISU Quiz Bowl Team should comprise mainly of genius students or regular students. A primary requirement of this program that is different from your earlier assignments is that you are required to create 2 different Java classes in the design of your program. Here are some other design details that may be helpful: Design: The classes should...