Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me;
- import java.util.Random;
- /**
- * This class represents a piece of fruit, it can be eaten
- */
- public abstract class Fruit {
- /**
- * This function eats the fruit... no more fruit.
- * @return whether it was eaten successfully.
- */
- abstract boolean eat();
- /**
- * This function throws out the fruit as it's mouldy.
- * @return
- */
- abstract boolean throwOut();
- /**
- * Pre-programmed, hard coded logic to determine if a fruit is mouldy.
- * @return true if mouldy, false otherwise.
- */
- public boolean isMouldy() {
- return new Random().nextBoolean();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement