-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathSports_Player.java
45 lines (39 loc) · 1.07 KB
/
Sports_Player.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
public class Sports_Player {
public static void main(String[] args) {
Cricket_Player cp = new Cricket_Player("Cricket", 7, "India");
Football_Player fp = new Football_Player("Football", 11, "Brazil");
Hockey_Player hp = new Hockey_Player("Hockey", 60, "India");
cp.Display();
fp.Display();
hp.Display();
}
}
class Player {
String sports;
int jerseynumber;
String country;
void Display() {
System.out.println(this.sports + " " + this.jerseynumber + " " + this.country);
}
}
class Cricket_Player extends Player {
Cricket_Player(String s, int jn, String c) {
this.sports = s;
this.jerseynumber = jn;
this.country = c;
}
}
class Football_Player extends Player {
Football_Player(String s, int jn, String c) {
this.sports = s;
this.jerseynumber = jn;
this.country = c;
}
}
class Hockey_Player extends Player {
Hockey_Player(String s, int jn, String c) {
this.sports = s;
this.jerseynumber = jn;
this.country = c;
}
}