Skip to content

Commit 9da9a16

Browse files
Initial Commit
1 parent 3917a72 commit 9da9a16

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

FATANSWERKEY/src/Employee.java

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
*
3+
*/
4+
import java.util.*;
5+
/**
6+
* @author M.NAVEEN
7+
* RANDOM CODER'S
8+
* Tech/Project Lead Android Club
9+
*/
10+
public class Employee
11+
{
12+
private String name;
13+
private int id;
14+
public Employee(String name, int id)
15+
{
16+
17+
this.name = name;
18+
this.id = id;
19+
}
20+
21+
public String getName() {
22+
return name;
23+
}
24+
25+
public int getId() {
26+
return id;
27+
}
28+
29+
public String toString()
30+
{
31+
return "Name :"+name+"\nId :"+id;
32+
}
33+
public static void main(String ...strings)
34+
{
35+
Employee e1;
36+
PartTimeEmployee pe=new PartTimeEmployee("NAVEEN",5,10.0d);
37+
pe.calulateSalary(5);//number of hours
38+
e1=pe;
39+
System.out.println(e1);
40+
41+
FullTimeEmployee fe=new FullTimeEmployee("praveen",6,60d);
42+
fe.calulateSalary(5); //number of Days
43+
e1=fe;
44+
System.out.println(e1);
45+
}
46+
47+
}
48+
49+
class PartTimeEmployee extends Employee
50+
{
51+
private double salary,hourlyRate;
52+
53+
public PartTimeEmployee(String name, int id, double hourlyRate) {
54+
super(name, id);
55+
this.hourlyRate = hourlyRate;
56+
}
57+
public double calulateSalary(int numberofHours)
58+
{
59+
salary=numberofHours*hourlyRate;
60+
return salary;
61+
}
62+
public String toString()
63+
{
64+
return "Name :"+super.getName()+"\nId :"+super.getId()+"\nHourly Rate :"+hourlyRate+"\nsalary :"+salary+"\n";
65+
}
66+
}
67+
68+
69+
class FullTimeEmployee extends Employee
70+
{
71+
72+
73+
private double salary,weeklyPayRate;
74+
75+
public FullTimeEmployee(String name, int id, double weeklyPayRate) {
76+
super(name, id);
77+
78+
this.weeklyPayRate = weeklyPayRate;
79+
}
80+
81+
public double calulateSalary(int numberofDays)
82+
{
83+
salary=numberofDays*weeklyPayRate;
84+
return salary;
85+
}
86+
public String toString()
87+
{
88+
return "Name :"+super.getName()+"\nId :"+super.getId()+"\nWeekly Pay Rate :"+weeklyPayRate+"\nsalary :"+salary+"\n";
89+
}
90+
91+
}

0 commit comments

Comments
 (0)