fork download
  1. package gen;
  2.  
  3. import java.awt.Point;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.util.ArrayList;
  7. import java.util.Random;
  8. import java.util.concurrent.LinkedBlockingQueue;
  9.  
  10. import main.Main;
  11. import world.Chunk;
  12. import world.Village;
  13. import world.Villager;
  14.  
  15. public class ChunkLoader implements Runnable{
  16. private LinkedBlockingQueue<Point> toLoad = new LinkedBlockingQueue<Point>();
  17. private Thread loadingThread;
  18. //TODO !!!!!!!!!!!!!!!!!!!
  19. //TODO fill in this class!
  20. private final File saveFile;
  21. public ChunkLoader(String saveFileName) throws FileNotFoundException
  22. {
  23. this.saveFile = new File(saveFileName);
  24. }
  25. public ChunkLoader(File saveFile)
  26. {
  27. this.saveFile = saveFile;
  28. }
  29.  
  30. public synchronized void beginLoading()
  31. {
  32. loadingThread = new Thread(this, "Chunk Loading Thread");
  33. loadingThread.start();
  34. }
  35.  
  36. @Override
  37. public void run() {
  38. while (true)
  39. {
  40. try {
  41. Point p = toLoad.take();
  42. Main.getLoadedWorld().addChunk(load(p));
  43. } catch (InterruptedException e) {
  44. e.printStackTrace();
  45. }
  46. }
  47. }
  48.  
  49. private Chunk load(Point p)
  50. {
  51. return generate(p);
  52. }
  53. private Chunk generate(Point p)
  54. {
  55. Chunk c = new Chunk((new Random()).nextInt(Chunk.NUM_BIOMES-1), 0, p);
  56. if (p.x == 0 && p.y == 0)
  57. {
  58. ArrayList<Villager> population = new ArrayList<Villager>();
  59. population.add(new Villager());
  60. population.add(new Villager());
  61. population.add(new Villager());
  62. population.add(new Villager());
  63. population.add(new Villager());
  64. population.add(new Villager());
  65. population.add(new Villager());
  66. population.add(new Villager());
  67. population.add(new Villager());
  68. population.add(new Villager());
  69. population.add(new Villager());
  70. Village village = new Village(population, 0, 0);
  71. c.addVillage(village);
  72. }
  73. return c;
  74. }
  75.  
  76. public void queueLoad(Point p)
  77. {
  78. try {
  79. toLoad.put(p);
  80. } catch (InterruptedException e) {
  81. e.printStackTrace();
  82. }
  83. }
  84. }
  85.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:15: error: class ChunkLoader is public, should be declared in a file named ChunkLoader.java
public class ChunkLoader implements Runnable{
       ^
Main.java:10: error: package main does not exist
import main.Main;
           ^
Main.java:11: error: package world does not exist
import world.Chunk;
            ^
Main.java:12: error: package world does not exist
import world.Village;
            ^
Main.java:13: error: package world does not exist
import world.Villager;
            ^
Main.java:49: error: cannot find symbol
	private Chunk load(Point p)
	        ^
  symbol:   class Chunk
  location: class ChunkLoader
Main.java:53: error: cannot find symbol
	private Chunk generate(Point p)
	        ^
  symbol:   class Chunk
  location: class ChunkLoader
Main.java:42: error: cannot find symbol
				Main.getLoadedWorld().addChunk(load(p));
				^
  symbol:   variable Main
  location: class ChunkLoader
Main.java:55: error: cannot find symbol
		Chunk c = new Chunk((new Random()).nextInt(Chunk.NUM_BIOMES-1), 0, p);
		^
  symbol:   class Chunk
  location: class ChunkLoader
Main.java:55: error: cannot find symbol
		Chunk c = new Chunk((new Random()).nextInt(Chunk.NUM_BIOMES-1), 0, p);
		              ^
  symbol:   class Chunk
  location: class ChunkLoader
Main.java:58: error: cannot find symbol
			ArrayList<Villager> population = new ArrayList<Villager>();
			          ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:58: error: cannot find symbol
			ArrayList<Villager> population = new ArrayList<Villager>();
			                                               ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:59: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:60: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:61: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:62: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:63: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:64: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:65: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:66: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:67: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:68: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:69: error: cannot find symbol
			population.add(new Villager());
			                   ^
  symbol:   class Villager
  location: class ChunkLoader
Main.java:70: error: cannot find symbol
			Village village = new Village(population, 0, 0);
			^
  symbol:   class Village
  location: class ChunkLoader
Main.java:70: error: cannot find symbol
			Village village = new Village(population, 0, 0);
			                      ^
  symbol:   class Village
  location: class ChunkLoader
25 errors
stdout
Standard output is empty