-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab7Task2.java
108 lines (108 loc) · 1.95 KB
/
Lab7Task2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
class Person
{
private String name;
private String address;
Person(String name,String address)
{
this.name=name;
this.address=address;
}
public void setAddress(String address)
{
this.address=address;
}
public String getName()
{
return name;
}
public String getAddress()
{
return address;
}
public String toString()
{
return "Person[name="+name+",address="+address+"]";
}
}
class Student extends Person
{
private String program;
private int year;
private double fee;
Student(String name,String address,String program,int year,double fee)
{
super(name,address);
this.program=program;
this.year=year;
this.fee=fee;
}
public void setProgram(String program)
{
this.program=program;
}
public String getProgram()
{
return program;
}
public void setYear(int year)
{
this.year=year;
}
public int getYear()
{
return year;
}
public void setFee(double fee)
{
this.fee=fee;
}
public double getFee()
{
return fee;
}
public String toString()
{
return "Student["+super.toString()+",program="+program+",year="+year+",fee="+fee+"]";
}
}
class Staff extends Person
{
private String school;
private double pay;
Staff(String name,String address,String school,double pay)
{
super(name,address);
this.school=school;
this.pay=pay;
}
public void setSchool(String school)
{
this.school=school;
}
public String getSchool()
{
return school;
}
public void setPay(double pay)
{
this.pay=pay;
}
public double getPay()
{
return pay;
}
public String toString()
{
return "staff["+super.toString()+",school="+school+",pay="+pay+"]";
}
}
class Lab7Task2
{
public static void main(String[] args)
{
Student std=new Student("abdul jabbar","MUET hostel","BE",2021,1600);
Staff st=new Staff("abdul jabbar","MUET hostel","Govt: School kamber",0.0);
System.out.println(std);
System.out.println(st);
}
}