Master of Methods
1. Ask your Mom for $20, but only if her mood is good.
boolean isInAGoodMood(String parentName) {}
int askForMoney(int amount) {}
2. Write the Pencil class so that this code works.
new Pencil().sharpen();
3. Find out if any of these people like the same ice cream as you.
class Friend {
String getFavoriteIceCream(){}
}
Friend ella = new Friend();
Friend jimmy = new Friend();
Friend pedro = new Friend();
4. Use the magic power to cast a spell.
class MagicPower() {
void castSpell(String spell){}
}
5. Use this method to cheat on your Math test by printing the answers to the first 10 questions.
String getAnswer(String subject, int questionNumber) {}
6. Use a key to open the door to the dungeon.
class Key {
Key(String roomName){}
}
class Door {
boolean openDoor(Key key) {}
}
7. Buy candy for your friend.
class Friend { {
Friend(String name){
this.name = name;
}
Candy getFavoriteCandy(){}
}
class CandyShop {
void buy(Candy candy) {}
}