You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/org/teachingkidsprogramming/recipes/completed/section06modelviewcontroller/OneFishTwoFish.java
+29-6Lines changed: 29 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@
10
10
//*************This Lesson is In Development*****************************//
11
11
publicclassOneFishTwoFish
12
12
{
13
+
// Create a Scanner to make a string
13
14
privatestaticScannerscanner;
14
15
publicstaticvoidmain(String[] args)
15
16
{
@@ -20,22 +21,32 @@ public static void main(String[] args)
20
21
publicstaticvoidmakeAString()
21
22
{
22
23
finalStringinput = "1 fish 2 fish red fish blue fish,black fish,blue fish,old fish,new fish ";
24
+
// Use your scanner with your input
23
25
scanner = newScanner(input);
24
26
System.err.println("\nWe have: " + input + '\n');
27
+
// Now, tell a story with a new Scanner instance
25
28
tellAStory(input);
26
29
}
27
30
privatestaticvoidtellAStory(finalStringinput)
28
31
{
32
+
// Use 'fish' as the base text w/your scanner [story]
29
33
Scanners = scanner.useDelimiter("\\s*fish\\s*");
34
+
// Get the next number to use in your scanner [story]
30
35
System.out.println("So: " + s.nextInt() + " and " + s.nextInt());
36
+
// Get the next value to use in your scanner [story]
0 commit comments