mirror of
				https://github.com/fooflington/wordsearch.git
				synced 2025-10-31 04:38:33 +00:00 
			
		
		
		
	allow output of grid pre-filled
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -16,7 +16,7 @@ OBJS = ${SRCS:.java=.class} | ||||
| all: build wordsearch.jar | ||||
|  | ||||
| run: all | ||||
| 	$(JAVA) uk.org.mafoo.wordsearch.GridFactory 10 10 | ||||
| 	$(JAVA) uk.org.mafoo.wordsearch.GridFactory 30 30 | ||||
|  | ||||
| .java.class: | ||||
| 	$(JAVAC) $(JFLAGS) $< | ||||
|   | ||||
| @@ -17,5 +17,10 @@ Once built, you need to make a "war" file to deploy to your J2EE container (test | ||||
| ``` | ||||
| $ cd war && jar cfv ../wordsearch.war . | ||||
| ``` | ||||
|  | ||||
| Then deploy your war file :-) | ||||
|  | ||||
| Alternatively you can test-run the engine... | ||||
| ``` | ||||
| $ make run <wordlist.txt | ||||
| ``` | ||||
|  | ||||
|   | ||||
| @@ -56,7 +56,7 @@ public class GridFactory { | ||||
| 		while ((s = in.readLine()) != null && s.length() != 0) { | ||||
| 			words.add(s); | ||||
| 		} | ||||
| 		char[][] g = makeGrid(words, Integer.parseInt(args[0]), Integer.parseInt(args[1])); | ||||
| 		char[][] g = makeGrid(words, Integer.parseInt(args[0]), Integer.parseInt(args[1]), false, false); | ||||
| 		dump2d(g); | ||||
| 	} | ||||
|  | ||||
| @@ -155,10 +155,10 @@ public class GridFactory { | ||||
| 	} | ||||
|  | ||||
| 	public static char[][] makeGrid(List<String> words, int height, int width) { | ||||
| 		return makeGrid(words, height, width, false); | ||||
| 		return makeGrid(words, height, width, false, true); | ||||
| 	} | ||||
|  | ||||
| 	public static char[][] makeGrid(List<String> words, int height, int width, boolean simple) { | ||||
| 	public static char[][] makeGrid(List<String> words, int height, int width, boolean simple, boolean fill) { | ||||
| 		char[][] grid = new char[height][width]; | ||||
|  | ||||
| 		// Place words at random? | ||||
| @@ -181,11 +181,13 @@ public class GridFactory { | ||||
| 		} | ||||
|  | ||||
| 		// Fill rest of grid | ||||
| 		for (int y=0; y<height; y++) { | ||||
| 			for (int x=0; x<width; x++) { | ||||
| 				if (grid[y][x] == Character.UNASSIGNED)  | ||||
| 					// grid[y][x] = '_'; | ||||
| 					grid[y][x] = getRandomChar(); | ||||
| 		if(fill) { | ||||
| 			for (int y=0; y<height; y++) { | ||||
| 				for (int x=0; x<width; x++) { | ||||
| 					if (grid[y][x] == Character.UNASSIGNED)  | ||||
| 						// grid[y][x] = '_'; | ||||
| 						grid[y][x] = getRandomChar(); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| @@ -240,4 +242,4 @@ public class GridFactory { | ||||
| 			System.out.println(""); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user