Java
//Java Program
abstract class Employee{
private String name;
public Employee(String name) {
this.name=name;
}
public String toString() {
return name;
}
abstract public double getpayment();
}
class SalaryEmployee extends Employee{
private double salary;
public SalaryEmployee(String name,double salary)
{
super(name);
this.salary = salary;
}
@Override
public double getpayment() {
return salary/24;
}
public String toString() {
return super.toString()+"
salary:$"+salary;
}
}
class CommissionEmployee extends Employee{
private double commissionRate;
private double totalSales;
public CommissionEmployee(String name,double
rate,double sales) {
super(name);
commissionRate=rate;
totalSales = sales;
}
@Override
public double getpayment() {
return
commissionRate*totalSales;
}
public String toString() {
return super.toString()+"
commission:%"+commissionRate+"@ "+totalSales+" sales ";
}
}
class HourlyEmployee extends Employee{
private double hourlyRate;
private double hoursWorked;
public HourlyEmployee(String name,double rate,double
hours) {
super(name);
hourlyRate=rate;
hoursWorked = hours;
}
@Override
public double getpayment() {
return
hourlyRate*hoursWorked;
}
public String toString() {
return super.toString()+" hourly:$
"+hourlyRate+" @"+hoursWorked+" hours";
}
}
public class TestEmployee {
public static void main(String args[]) {
Employee e[] = new
Employee[3];
e[0] =new SalaryEmployee("Meg
Manager",50000);
e[1] =new CommissionEmployee("Sal
Salesman",.15,3400);
e[2] =new HourlyEmployee("Timmy
Temp",10.50,25);
for(Employee worker:e) {
System.out.println(worker);
System.out.printf("Paycheck : $%.02f\n",worker.getpayment());
}
}
}
//sample output
Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEm...
java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings. Create another class HourlyEmployee that inherits from the abstract Employee class. HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings. Create another class HourlyEmployee that inherits from the abstract Employee class. HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...
Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications: HourlyPlusCommissionEmployee earns money based on 2 separate calculations: commissions are calculated by the CommissionEmployee base class hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the details of SalariedEmployee. Use this as...
In the processLineOfData method, write the code to handle case "H" of the switch statement such that: • An HourlyEmployee object is created using the firstName, lastName, rate, and hours local variables. Notice that rate and hours need to be converted from String to double. You may use parseDouble method of the Double class as follows: Double.parseDouble(rate) Call the parsePaychecks method in this class passing the Hourly Employee object created in the previous step and the checks variable. Call the...
Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has ▪ a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use “unknown” to initialize all private attributes. ▪ a constructor with parameters for each of the attributes ▪ getter and setter methods for each of the private attributes ▪ a method getFullName() that returns the last name, followed by a...
Problem 5: Monster Factory (10 points) (Game Dev) Create a Monster class that maintains a count of all monsters instantiated and includes a static method that generates a new random monster object. In software engineering, a method that generates new instances of classes based on configuration information is called the Factory pattern. UML Class Diagram: Monster - name: String - health: int - strength: int - xp: int + spawn(type:String): Monster + constructor (name: String, health: int, strength: int, xp:...
please write in Java and include the two classes Design a class named Fan (Fan.java) to represent a fan. The class contains: An int field named speed that specifies the speed of the fan. A boolean field named fanStatus that specifies whether the fan is on (default false). A double field named radius that specifies the radius of the fan (default 5). A string field named color that specifies the color of the fan (default blue). A no-arg (default) constructor...
In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...