Question

In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a...

In this lab you will work with abstract classes/interfaces. (Java Program)

You will be implementing a basic employee schema within a company. The Employee class will be an abstract class that will contain methods applicable to all employees. You will then create 2 classes called SoftwareEngineer and ProductManager. Both are different employee types based on occupation. You will create an interface called Developer which will consist of specific methods that apply to only Developers (e.g. SoftwareEngineer class will implement this, we will assume all of them in this company are developers only).

Extend both the SoftwareEngineer and ProductManager class from the Employee class.

NOTE: When creating your classes be sure to use all of the proper security measures to prevent direct access by the user (e.g. Select the right access modifier)

1. Create a abstract class called Employee, inside here include the following abstract methods:

a. void conductWork() – accepts no parameters

2. Create a interface called Developer, inside here include the following methods:

a. public void createComponent()

b. public void createAPI()

c. public void performTesting()

3. Create a class called SoftwareEngineer and include the following variables/methods:

a. Variables: Format is variableName : dataType

i. Salary: double

ii. Name: String

iii. Age: int

iv. startDate : String

v. gradeLevel: char (a letter from A – E)

b. 2 constructors:

i. Empty constructor that simply prints “New software engineer added”

ii. Parameterized constructor – accept all of the data above and initialize the values and then prints “New software engineer added with grade level: “ and print the grade level passed in.

c. Implement the 3 methods from the interface, they will only print the following:

i. createComponent() – “Build component…”

ii. createAPI() – “Creating API architecture and implementation…”

iii. performTesting() – “Testing created modules…”

d. Implement setter/getter methods for all of the data fields

e. Implement the abstract method conductWork() – this will print “I am coding…”

4. Create a class called ProductManager and include the following variables/methods:

a. Variables:

i. employees: int

b. 2 constructors:

i. Empty constructor that simply prints “New software engineer added”

ii. Parameterized constructor – accept the int as an input and initialize the employees variable

c. Implement setter/getter for the variable

d. Implement abstract method conductWork() – this will print “Managing upcoming product release…”

Your main method will be empty, you won’t be running any code just writing the class definitions.

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

PROGRAM CODE


// Employee class
abstract class Employee {

// All abstract methods required
abstract void conductWork();
}

// Developer Interface

interface Developer {

public void createComponent();
public void createAPI();
public void performTesting();
}

// SoftwareEngineer class

class SoftwareEngineer extends Employee implements Developer{

// Member variables

private double Salary;
private String Name;
private int Age;
private String startDate;
private char gradeLevel;

// 2 Constructors

public SoftwareEngineer() {

System.out.println("New software engineer added");
}

// A constructor which initializes all of the above fields

public SoftwareEngineer(double salary, String name, int age, String startDate, char gradeLevel) {
Salary = salary;
Name = name;
Age = age;
this.startDate = startDate;
this.gradeLevel = gradeLevel;

System.out.println("New software engineer added with grade level: " + gradeLevel);
}

@Override
public void createComponent() {
System.out.println("Build component...");
}

@Override
public void createAPI() {
System.out.println("Creating API architecture and implementation...");
}

@Override
public void performTesting() {
System.out.println("Testing created modules...");
}

@Override
void conductWork() {
System.out.println("I am coding...");
}

// Implementing setters and getters

public double getSalary() {
return Salary;
}

public void setSalary(double salary) {
Salary = salary;
}

public String getName() {
return Name;
}

public void setName(String name) {
Name = name;
}

public int getAge() {
return Age;
}

public void setAge(int age) {
Age = age;
}

public String getStartDate() {
return startDate;
}

public void setStartDate(String startDate) {
this.startDate = startDate;
}

public char getGradeLevel() {
return gradeLevel;
}

public void setGradeLevel(char gradeLevel) {
this.gradeLevel = gradeLevel;
}
}

// ProductManager Class

class ProductManager extends Employee {

private int employees;

// Constructors

public ProductManager() {
System.out.println("New product manager added");
}

public ProductManager(int employees) {
this.employees = employees;
}

// Setters and getters

public int getEmployees() {
return employees;
}

public void setEmployees(int employees) {
this.employees = employees;
}

@Override
void conductWork() {
System.out.println("Managing upcoming product release...");
}
}

// Test class which contain main method

public class Test {

// As it is said main method will be empty

public static void main(String[] args) {
  
}
}

SAMPLE OUTPUT

Test X C:\Program Files\Java\jdk1.8.0_111\bin\java.exe Process finished with exit code 0

-----------------------------------------------------------------------------------------


COMMENT DOWN FOR ANY QUESTIONS...........
HIT A THUMBS UP IF YOU DO LIKE IT!!!

Add a comment
Know the answer?
Add Answer to:
In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a...
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
  • JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class...

    JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare (); } The prepare method will...

  • Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named...

    Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type(does not mention the data type of the variable coffeeType), price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public...

  • JAVA Problem:  Coffee do not use ArrayList or Case Design and implement a program that manages coffees....

    JAVA Problem:  Coffee do not use ArrayList or Case Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare ();...

  • A Java Program Purpose:         Work with Abstract classes. Purpose:         Abstract classes are import because they ensure...

    A Java Program Purpose:         Work with Abstract classes. Purpose:         Abstract classes are import because they ensure than any children which inherit from it must implement certain methods. This is done to enforce consistency across many different classes. Problem:        Implement a class called Student. This class needs to be abstract and should contain a String for the name, and a String for the major (and they should be private). The class must have a constructor to set the name and major....

  • Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will...

    Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...

  • Abstract classes and Interfaces problems 10. Explain one similarity and one difference between abstract classes and...

    Abstract classes and Interfaces problems 10. Explain one similarity and one difference between abstract classes and interfaces. 11. Consider the following declarations. public interface Shape{ int someFunction(Shape other); //other functions not shown } public class Square implements Shape {/*implementation not shown*/} Which of the following function headings of someFunction must be added to the declaration of the Square class such that it will satisfy the Shape interface? public int someFunction (Shape other) public int someFunction (Square other) public boolean someFunction(Object...

  • JAVA CODING: (14 points) Abstract Class exercise You are given two abstract classes with no abstract...

    JAVA CODING: (14 points) Abstract Class exercise You are given two abstract classes with no abstract method in the NoGo.java file. The purpose of this exercise is to get familiar with abstract class and its object creation 4. Follow the steps below: (be sure common on each to score points) 1) 2) 3 points) Create a subclass Go1 with Nogo1 as its super class and create Go1() constructor 3) (2 points) Now inside the NoGo class create an instance of...

  • Abstract Classes and Interfaces Java This particular assignment is doing research and programming. I want you to do a research report of the following: Ways that abstract classes promotes software re...

    Abstract Classes and Interfaces Java This particular assignment is doing research and programming. I want you to do a research report of the following: Ways that abstract classes promotes software reusability, decreases time programming, and helps reduce the number of errors in software. Research the using abstract classes and interfaces. I would like for you to be creative and come up with your own example of abstract classes and interfaces in Java by writing your own abstract class and interface,...

  • Abstract classes and Interfaces problems 10. Explain one similarity and one difference between ab...

    Abstract classes and Interfaces problems 10. Explain one similarity and one difference between abstract classes and interfaces. 11. Consider the following declarations. public interface Shape{ int someFunction(Shape other); //other functions not shown } public class Square implements Shape {/*implementation not shown*/} Which of the following function headings of someFunction must be added to the declaration of the Square class such that it will satisfy the Shape interface? public int someFunction (Shape other) public int someFunction (Square other) public boolean someFunction(Object...

  • In Java Create an interface called Amount that includes a method called setPrice (). Create an a...

    In Java Create an interface called Amount that includes a method called setPrice (). Create an abstract class named Book that inherits from the interface Amount. Include a String field for the book’s title and a double field for the book’s Price . Within the class, include a constructor that requires the book title and add two getter methods — one that returns the title and one that returns the price. Include an abstract method named setPrice (). Create a...

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
ADVERTISEMENT