Skip to content

Commit 987e487

Browse files
committed
new recipe WhichFish w/@samanthalangit
1 parent ae47807 commit 987e487

3 files changed

Lines changed: 123 additions & 41 deletions

File tree

src/main/java/org/teachingkidsprogramming/recipes/completed/section06modelviewcontroller/OneFishTwoFish.java

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
import java.util.Iterator;
44
import java.util.Scanner;
55

6-
import javax.swing.ImageIcon;
7-
8-
import org.teachingextensions.logo.utils.EventUtils.FancyMessageBox;
9-
106
//*************This Lesson is In Development*****************************//
117
public class OneFishTwoFish
128
{
@@ -15,8 +11,6 @@ public class OneFishTwoFish
1511
public static void main(String[] args)
1612
{
1713
makeAString();
18-
int numberOfFish = FancyMessageBox.askForNumericalInput("How many fishes?", "Are Fishes Like Wishes?");
19-
makeAFishyDecision(numberOfFish);
2014
}
2115
public static void makeAString()
2216
{
@@ -55,39 +49,4 @@ public Iterator<String> iterator()
5549
}
5650
System.out.println("");
5751
}
58-
public static void makeAFishyDecision(int numberOfFish)
59-
{
60-
// Use a switch...case on the number of fish
61-
switch (numberOfFish)
62-
{
63-
// If number of fish is -1
64-
case -1 :
65-
String image = "//Users//lynnlangit//Documents//workspace//TeachingKidsProgramming.Source.Java//src//main//resources//icons//thumb-up.png";
66-
ImageIcon icon = new ImageIcon(image);
67-
// Show a message with the fancy message box this text, this title and this icon...
68-
FancyMessageBox.showMesage("Had a Fish", "Not hungry anymore...", icon);
69-
// End
70-
break;
71-
case 0 :
72-
String image0 = "//Users//lynnlangit//Documents//workspace//TeachingKidsProgramming.Source.Java//src//main//resources//icons//information.png";
73-
ImageIcon icon0 = new ImageIcon(image0);
74-
FancyMessageBox.showMesage("No Fish", "Still hungry", icon0);
75-
break;
76-
case 1 :
77-
String image1 = "//Users//lynnlangit//Documents//workspace//TeachingKidsProgramming.Source.Java//src//main//resources//icons//star.png";
78-
ImageIcon icon1 = new ImageIcon(image1);
79-
FancyMessageBox.showMesage("One Fish", "This one has a little star", icon1);
80-
break;
81-
case 2 :
82-
String image2 = "//Users//lynnlangit//Documents//workspace//TeachingKidsProgramming.Source.Java//src//main//resources//icons//github.png";
83-
ImageIcon icon2 = new ImageIcon(image2);
84-
FancyMessageBox.showMesage("Two Fish", "Funny things are everywhere", icon2);
85-
break;
86-
default :
87-
String image4 = "//Users//lynnlangit//Documents//workspace//TeachingKidsProgramming.Source.Java//src//main//resources//icons//hint.png";
88-
ImageIcon icon4 = new ImageIcon(image4);
89-
FancyMessageBox.showMesage("Vegetaraian meal", "Fish are icky", icon4);
90-
break;
91-
}
92-
}
9352
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.teachingkidsprogramming.section07objects;
2+
3+
//*************This Lesson is In Development*****************************//
4+
public class WhichFish
5+
{
6+
public static void main(String[] args)
7+
{
8+
// UNCOMMENT to create a variable called 'numberOfFish' to hold the result of the question "How many fishes?" -- #INFO
9+
// Use the FancyMessageBox with a title of "Are fishes like wishes?" -- #INFO
10+
// int numberOfFish = FancyMessageBox.askForNumericalInput("How many fishes?", "Are Fishes Like Wishes?"); --#1
11+
// Create recipe makeAFishyDecision using the numberOfFish (recipe below) --#2
12+
//----------recipe for makeAFishyDecision with the numberOfFish---------------------/
13+
// Use a switch...case on the numberOfFish --#3
14+
// When the numberOfFish is -1 --#4
15+
// UNCOMMENT to create a string of this image
16+
// String image = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/thumb-up.png";
17+
// Create a new ImageIcon from your image
18+
// UNCOMMENT to Show a message with the fancy message box this text, this title and this icon...
19+
// FancyMessageBox.showMesage("Had a Fish", "Not hungry anymore...", icon);
20+
// End
21+
// When the numberOfFish is 0 --#4
22+
// UNCOMMENT to create a string of this image
23+
// String image0 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/information.png";
24+
// Create a new ImageIcon from your image
25+
// Show a message with the fancy message box this text, this title and this icon...
26+
// End
27+
// When the numberOfFish is 1 --#5
28+
// UNCOMMENT to create a string of this image
29+
// String image1 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/star.png";
30+
// Create a new ImageIcon from your image
31+
// Show a message with the fancy message box this text, this title and this icon...
32+
// End
33+
// When the numberOfFish is 2 --#6
34+
// UNCOMMENT to create a string of this image
35+
// String image2 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/github.png";
36+
// Create a new ImageIcon from your image
37+
// Show a message with the fancy message box this text, this title and this icon...
38+
// End
39+
// Otherwise --#7
40+
// UNCOMMENT to create a string of this image
41+
// String image4 = "../TeachingKidsProgramming.Source.Java/src/main/resources/icons/hint.png";
42+
// Create a new ImageIcon from your image
43+
// Show a message with the fancy message box this text, this title and this icon...
44+
// End
45+
//--------end of recipe for makeAFishyDecision-------------------------------------/
46+
}
47+
}

0 commit comments

Comments
 (0)