Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package uni.fmi.bachelors;
- import java.util.Random;
- public class Fish extends Animal{
- private boolean givesBirth;
- public Fish(String type, boolean givesBirth) {
- super(type);
- this.givesBirth = givesBirth;
- }
- @Override
- public void moveTo(String to) {
- System.out.println("Swimmed to " + to);
- Random random = new Random();
- if(random.nextInt(10) > 3) {
- System.out.println("Saw a hook and ate it!");
- System.out.println("Now is in the frying pan!");
- }
- }
- @Override
- public void eat() {
- System.out.println("Eats worms and stuff");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement