-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRare.java
More file actions
24 lines (23 loc) · 997 Bytes
/
Copy pathRare.java
File metadata and controls
24 lines (23 loc) · 997 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
/*
Derived class of Uncommon and thus an extension of all other fish types
The most rare type of fish with the most methods to fight back
*/
import java.util.Random;
public class Rare extends Uncommon{
public Rare(String rarity, String name, double size, int value, int strength) {
super(rarity, name, size, value, strength);
}
// calculates if the player's rod breaks or not while fishing
public int calculateBreak(int durability){
Random gen = new Random();
int breakChance = gen.nextInt(10);
if (breakChance/10 * strength > durability){ //if the rod's durability stat isn't high enough break the rod
System.out.println("Oh snap! Your line...snapped.");
return 1; //the rod breaks in main
}
else{ //the rod was durable enough not to break
System.out.println("Woah the fish almost snapped your line there, be careful!");
return 0;//the rod does not break in main
}
}
}