Hello. I took a picture of the area that I am having trouble with please help. A
ID: 3591337 • Letter: H
Question
Hello. I took a picture of the area that I am having trouble with please help. And if you could bold any changes, so that I can learn for next time. :) Thank you
class EmployeeClassName {
//get and return firstName, lastName, and employeeNumber
private String firstName;
private String lastName;
private int employeeNumber;
public String getFirstName()
{
return firstName;
}
public String getLastName()
{
return lastName;
}
public int getEmployeeNumber()
{
return employeeNumber;
}
public EmployeeClassName (String fn, String ln, int en)
{
firstName = fn;
lastName = ln;
employeeNumber = en;
}
}
//address class
class Address{ // better to use Class names starting with Capital letter
String street;
String city;
String state;
String zipcode;
// get and return street
public String getStreet() {
return street;
}
public String getCity() {
return city;
}
public String getState() {
return state;
}
public String getZipcode() {
return zipcode;
}
// constructor of class
public Address(String st, String c, String sta, String zip) {
street = st;
city = c;
state = sta;
zipcode = zip;
}
}
// date class
class Date{ // better to use Class names starting with Capital letter
int month;
int day;
int year;
// get and return month
public int getMonth() {
return month;
}
public int getDay() {
return day;
}
public int getYear() {
return year;
}
}
// if you want to use the classes(EmployeeClassName, Address, Date) you have to extend those classes
class Employee extends EmployeeClassName, Address, Date, {
public void main (String args []) {
Employee( String fn, String ln, String st, String c, String sta, String zip, int month, int day, int year, String en, String as )
{
SalariedEmployee employee1 = new SalariedEmployee("Suzie", "Palmer", 135 Pheasant, Argyle, TX, 76226, 01, 17, 2010, 12005, 126000);
System.out.println(employee1.getFirstName() + " " + employee1.getLastName() + " " + employee1.getStreet() + " " + employee1.getCity() + " " + employee1.getState() + " " + employee1.getZipcode() + " " + employee1.getMonth() + "/" + employee1.getDay() + "/" + employee1.getYear() + employee1.getEmployeeNumber() + " " +employee1.annualSalary());
}
}
class SalariedEmployee extends EmployeeClassName, Address, Date {
double annualSalary;
SalariedEmployee(String fn, String ln, String st, String c, String sta, String zip, int month, int day, int year, int en, double as);
{
super(fn, ln, st, c, sta, zip, month, day, year, en);
annualSalary = as;
}
}
//these are my two classes
class HourlyEmployee extends Employee {
double hourlyPayRate;
double hoursWorked;
double earnings;
HourlyEmployee(String fn, String ln, int en,String street, String city, String state, String zipcode, int month, int day, int year, double hpr, double hw, double e)
{
super(fn, ln, street, city, state, zipcode, month, day, year, en);
hourlyPayRate = hpr;
hoursWorked = hw;
earnings = e;
}
double getEarnings (){
if (hoursWorked >40 ){
earnings = hourlyPayRate * 1.5 * hoursWorked;
}
else{
earnings = hourlyPayRate * hoursWorked;
}
return earnings;
}
118 119 0120 121 0122 123 124 125 126 127 128 129 130 131 132 // if you want to use the classes (EmployeeClassName, Address, Date) you have to extend those classes class Employee extends EmployeeClassName Address, Date. 5 public void main (String args EmployeeC String fn, String ln, String st, String c, String sta, String zip, int month, int day, int year, String en, String as) SalariedEmployee employee1 new SalariedEmployee("Suzie", "PaLmer", 135 Pheasant, Arayle, TX, 76226, 01, 17, 2010, 12005, 126000); System.out.println employee1.getFirstNameOemployeel.getLastNameO "t"employee1.getStreetO "employee1.getityOemploy 134 0135 136 3137 138 0139 class SalariedEmployee extends EmployeeClassName. Address, Date double annual Salary 140e B141 2142 143 144 145 146 147 148 149 //these are my two classes class HourlyEmployee extends Employee t double hourlyPavRate:Explanation / Answer
In Java multiple inheritance is not possible which means a class can extend only one class and but cannot extend more than one class. But here you are extending more than one class with the statements in one line 120 and line 135. That is the main reason why you program getting errors please check that and fix that by extending only one class you need then it will solve the problem.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.