-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathInterfaceUse.java
More file actions
72 lines (63 loc) · 1.25 KB
/
InterfaceUse.java
File metadata and controls
72 lines (63 loc) · 1.25 KB
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
/*
* What to Do
* Interface is 100% Abstract
*/
interface ISuperPower{
void bonusPoints();
}
// abstract interface IPlayer
interface IPlayer{
int MAX_SPEED = 100; // public static int final MAX_SPEED = 100;
int MIN_SPEED = 1;
int AVERAGE_SPEED = 50;
int DEFAULT_SPEED = 10;
int FULL_JUMP =90;
int AVERAGE_JUMP = 50;
void jump(); //public abstract void jump();
int run(); // public abstract int run();
}
class BlackPlayerImpl implements IPlayer,ISuperPower{
@Override
public void jump() {
// TODO Auto-generated method stub
}
@Override
public int run() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void bonusPoints() {
// TODO Auto-generated method stub
}
}
// How to do
class WhitePlayerImpl implements IPlayer{
int jumpStart;
int runStart;
WhitePlayerImpl(int jumpStart, int runStart){
this.jumpStart = jumpStart;
this.runStart = runStart;
}
@Override
public void jump(){
if(jumpStart<FULL_JUMP){
jumpStart++;
}
}
@Override
public int run(){
if(runStart<AVERAGE_SPEED){
runStart++;
}
return runStart;
}
}
public class InterfaceUse {
public static void main(String[] args) {
// TODO Auto-generated method stub
WhitePlayerImpl w = new WhitePlayerImpl(10, 2);
w.jump();
w.run();
}
}