-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathball.java
More file actions
38 lines (30 loc) · 711 Bytes
/
ball.java
File metadata and controls
38 lines (30 loc) · 711 Bytes
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
import java.lang.Math;
import java.util.ArrayList;
public abstract class Ball {
protected String name ;
protected int number ;
public Ball (String name) {
this.name = name ;
}
public Ball(String name , int numRandom) {
this.name = name ;
this.number = (int)(Math.random()*numRandom) + 1 ;
}
public String getName() {
return name ;
}
public int getNumber() {
return number ;
}
public boolean isCatch(int num) {
if(this.number == num ) {
return true ;
}
else {
return false ;
}
}
public String toString() {
return name ;
}
}