intro/MazeTextExample

From ggc

Jump to: navigation, search

01 package intro;
02 //start auto-imports
03 import java.io.*;
04 import java.util.*;
05 //end auto-imports
06 
07 import wiki.Wiki;
08 
09 /**
10  * All about my application.
11  @author My Name Here
12  */
13 public class MazeTextExample
14 {
15   public static void main(String[] args)
16   {
17 System.out.println("Maze:");
18     Scanner scanner=null;
19     try
20     {
21       scanner=new Scanner(Wiki.getInputStream("Maze2.txt"));
22     }
23     catch(IOException e)
24     {
25       System.out.println("Had problems making scanner: "+e);
26     }
27     int rows=scanner.nextInt();
28     int cols=scanner.nextInt();
29     char[][] maze=new char[rows][cols];
30     for(int r=0; r<rows; r++)
31     {
32       for(int c=0; c<cols; c++)
33       {
34         maze[r][c]=scanner.next().charAt(0);
35       }
36     }
37     for(int r=0; r<rows; r++)
38     {
39       for(int c=0; c<cols; c++)
40       {
41         System.out.print(maze[r][c]+" ");
42       }
43       System.out.println();
44     }
45 
46     //while(scanner.hasNext())
47     //{
48     //  String token=scanner.next();
49     //  System.out.println("Read in: "+token);
50     //}
51   }
52 }


Download/View intro/MazeTextExample.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter