-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCarp.java
72 lines (67 loc) · 2.06 KB
/
Carp.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
public class Carp extends Fish {
private String species;
public Carp(){
super();
}
public Carp(double w, double l){
super(w, l);
species = "Carp";
}
public String getSpecies(){
return species;
}
/**
* Catching Carp
*
* size: increments of 0.1
*
* 20% of Carp caught are huge
* 27-33lb 25-33in
*
* 45% they are regular
* 7-27lb 20-25in
*
* 35% they are small
* 3-7lb 13-20in
*
* @param i % of catching different sizes of Carp
* @return returns the Carp with appropriate size and weight
* depending on the percentage or probability(return the Carp caught)
*/
public static Carp carpRiver(int i){
Carp c = new Carp();
if (i > 80){
double weight = Math.round((Math.random()*6 + 27)*10.0)/10.0;
double length = Math.round((Math.random()*8 + 25)*10.0)/10.0;
Carp c1 = new Carp(weight, length);
c = c1;
}
else if (i > 35){
double weight = Math.round((Math.random()*20 + 7)*10.0)/10.0;
double length = Math.round((Math.random()*5 + 20)*10.0)/10.0;
Carp c1 = new Carp(weight, length);
c = c1;
}
else{
double weight = Math.round((Math.random()*4 + 3)*10.0)/10.0;
double length = Math.round((Math.random()*7 + 13)*10.0)/10.0;
Carp c1 = new Carp(weight, length);
c = c1;
}
return c;
}
public String toString(){
String str = "";
double w = super.getWeight();
if (w >= 27){
str = w + "lb & " + super.getLength() + "inch Huge " + species + "!";
}
else if (w >= 7){
str = w + "lb & " + super.getLength() + "inch " + species + "!";
}
else{
str = w + "lb & " + super.getLength() + "inch Small " + species + "!";
}
return str;
}
}