|
| 1 | +package org.teachingkidsprogramming.recipes.completed.section07objects; |
| 2 | + |
| 3 | +import javax.swing.ImageIcon; |
| 4 | + |
| 5 | +import org.teachingextensions.logo.utils.EventUtils.FancyMessageBox; |
| 6 | + |
| 7 | +//*************This Lesson is In Development*****************************// |
| 8 | +public class WhichFish |
| 9 | +{ |
| 10 | + public static void main(String[] args) |
| 11 | + { |
| 12 | + // Uncomment to create a variable called 'numberOfFish' to hold the result of the question "How many fishes?" |
| 13 | + // Use the FancyMessageBox with a title of "Are fishes like wishes?" |
| 14 | + int numberOfFish = FancyMessageBox.askForNumericalInput("How many fishes?", "Are Fishes Like Wishes?"); |
| 15 | + // create recipe makeAFishyDecision using the numberOfFish (recipe below) |
| 16 | + makeAFishyDecision(numberOfFish); |
| 17 | + } |
| 18 | + // recipe for makeAFishyDecision with the numberOfFish |
| 19 | + public static void makeAFishyDecision(int numberOfFish) |
| 20 | + { |
| 21 | + // Use a switch...case on the numberOfFish |
| 22 | + switch (numberOfFish) |
| 23 | + { |
| 24 | + // When the numberOfFish is -1 |
| 25 | + case -1 : |
| 26 | + // Uncomment to create a string of this image |
| 27 | + String image = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/thumb-up.png"; |
| 28 | + // Create a new ImageIcon from your image |
| 29 | + ImageIcon icon = new ImageIcon(image); |
| 30 | + // Show a message with the fancy message box this text, this title and this icon... |
| 31 | + FancyMessageBox.showMesage("Had a Fish", "Not hungry anymore...", icon); |
| 32 | + // End |
| 33 | + break; |
| 34 | + // When the numberOfFish is 0 |
| 35 | + case 0 : |
| 36 | + // Uncomment to create a string of this image |
| 37 | + String image0 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/information.png"; |
| 38 | + // Create a new ImageIcon from your image |
| 39 | + ImageIcon icon0 = new ImageIcon(image0); |
| 40 | + // Show a message with the fancy message box this text, this title and this icon... |
| 41 | + FancyMessageBox.showMesage("No Fish", "Still hungry", icon0); |
| 42 | + // End |
| 43 | + break; |
| 44 | + // When the numberOfFish is 1 |
| 45 | + case 1 : |
| 46 | + // Uncomment to create a string of this image |
| 47 | + String image1 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/star.png"; |
| 48 | + // Create a new ImageIcon from your image |
| 49 | + ImageIcon icon1 = new ImageIcon(image1); |
| 50 | + // Show a message with the fancy message box this text, this title and this icon... |
| 51 | + FancyMessageBox.showMesage("One Fish", "This one has a little star", icon1); |
| 52 | + // End |
| 53 | + break; |
| 54 | + // When the numberOfFish is 0 |
| 55 | + case 2 : |
| 56 | + // Uncomment to create a string of this image |
| 57 | + String image2 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/github.png"; |
| 58 | + // Create a new ImageIcon from your image |
| 59 | + ImageIcon icon2 = new ImageIcon(image2); |
| 60 | + // Show a message with the fancy message box this text, this title and this icon... |
| 61 | + FancyMessageBox.showMesage("Two Fish", "Funny things are everywhere", icon2); |
| 62 | + // End |
| 63 | + break; |
| 64 | + // Otherwise |
| 65 | + default : |
| 66 | + // Uncomment to create a string of this image |
| 67 | + String image4 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/hint.png"; |
| 68 | + // Create a new ImageIcon from your image |
| 69 | + ImageIcon icon4 = new ImageIcon(image4); |
| 70 | + // Show a message with the fancy message box this text, this title and this icon... |
| 71 | + FancyMessageBox.showMesage("Vegetaraian meal", "Fish are icky", icon4); |
| 72 | + // End |
| 73 | + break; |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments