-
Notifications
You must be signed in to change notification settings - Fork 0
/
29-08-2016 2nd.java
88 lines (84 loc) · 1.98 KB
/
29-08-2016 2nd.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
class Person{
private String name;
private String address;
Person(String name,String address)
{
this.name=name;
this.address=address;
}
public String getName(){
return "Name: "+name;}
public String getAddress(){
return "Address: "+address;}
public void setAddress(String address){
this.Address=address;
}
public String toString(){
return name+" "+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 String getProgram(){
return "program: "+program;}
public void setProgram(String program){
this.Program=program;}
public int getYear(){
return "Year: "+year;}
public void setYear(){
this.Year=year;}
public int getFee(){
return "Fee: "+fee;}
public void setFee(double fee){
this.Fee=fee;
}
public String toString(){
return name+" "+address+" "+program+" "+year+" "+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 String getSchool(){
return "School: "+school;}
public void setSchool(String school){
this.School=school;}
public double getPay() {
return "Pay: "+pay;}
public void setPay(double pay){
this.Pay=pay;
}
public String toString(){
return name+" "+address+" "+school+" "+pay;
}
}
public class TestPerson {
public static void main(String args[]) {
Person p1=new Person("subhani","1/163b");
System.out.println(p1.getName());
System.out.println(p1.getAddress());
System.out.println(p1.toString());
Student s1=new Student("subhani","1/163b","java",2015,2500);
System.out.println(s1.getProgram());
System.out.println(s1.getYear());
System.out.println(s1.getFee());
System.out.println(s1.toString());
Staff st=new Staff("subhani","1/163b","sve",2200);
System.out.println(st.getSchool());
System.out.println(st.getPay());
System.out.println(st.toString());
}
}