id
stringlengths
36
36
text
stringlengths
1
1.25M
eeaa5506-0c86-411b-9ae2-ad05e2340ee5
public Controller (Game game, Screen screen) { g = game; this.screen = screen; // Initialize the random number generator random = new Random(); // Set up the refresh timer. refreshTimer = new Timer(FRAME_INTERVAL, this); transitionCount = 0; asteroids = 161; score = 0; bulletIndex = 0; ...
0a147461-9694-407a-8091-606f77c54b47
private void splashScreen () { // Clear the screen and display the legend screen.clear(); screen.setLegend("Love you!!"); // Place four asteroids near the corners of the screen. placeAsteroids(); createStars(75); // Make sure there's no ship ship = null; }
9cd33daf-7d4e-4b26-aa49-a5ecdff23ecf
private void initialScreen () { // Clear the screen screen.clear(); // Place four asteroids placeAsteroids(); // Place the ship placeShip(); // Reset statistics g.setLives(lives); // Start listening to events. In case we're already listening, take // care to avoid listening twice....
1cdc24d7-abd1-461b-8cb3-b930e8b25ce2
private void finalScreen () { screen.setLegend(GAME_OVER); asteroids = 161; round2 = false; round3 = false; round4 = false; gameWon = false; screen.removeCollisionListener(this); screen.removeKeyListener(this); }
89c4ecfe-8dbd-4156-a4cd-0410636c0d87
public void createDebris(double x, double y, int type) { if (type == 0) { for (int i = 0; i < 5; i++) { Debris d = new Debris(3, x, y); screen.addParticipant(d); new CountdownTimer(this, d, 2000); } } if (type == 1) { for (int i = 0; i < 3; i++) { Debris d = new Debris(1, x, y); scree...
a63acef5-fd58-4ade-9ba8-b589a55cb359
public void createStars (int amount) { double r= random.nextDouble()*Math.PI*2; for (int i = 0; i < amount; i++) { Participant a = new Star(random.nextDouble()*SIZE, random.nextDouble()*SIZE); a.setVelocity(.3 + random.nextDouble()* .2, r); screen.addParticipant(a); } }
b12e575b-4aa7-4f99-9b22-fd2108c2ab91
private void placeAsteroids () { //if initial large asteroid speed is 3, for round 2 is 4, and round 3 and 4 it is 5 int speed = 3; if (asteroids < 134) speed = 4; if (asteroids < 99) speed = 5; Participant a = new Asteroid(0, 2, EDGE_OFFSET, EDGE_OFFSET); a.setVelocity(speed, random.nextDouble()*2...
acb78aee-9cd3-4fbe-94ed-1d5006f4cce0
private void placeShip () { if (ship == null) { ship = new Ship(); } ship.setPosition(SIZE/2, SIZE/2); ship.setRotation(-Math.PI/2); ship.setVelocity(0, 0); screen.addParticipant(ship); }
e2bf63d7-8be0-4564-acd3-fe1c86f72643
@Override public void collidedWith(Participant p1, Participant p2) { if (p1 instanceof Asteroid && p2 instanceof Ship) { asteroidCollision((Asteroid)p1); shipCollision((Ship)p2); } else if (p1 instanceof Ship && p2 instanceof Asteroid) { asteroidCollision((Asteroid)p2); shipCollision((Ship)p1); } ...
b9863a81-3443-4c2d-a72b-44553cb8c379
private void asteroidCollision (Asteroid a) { // The asteroid disappears screen.removeParticipant(a); createDebris(a.getX(), a.getY(), 0); asteroids--; if (a.getSize() == 2) score += 20; if (a.getSize() == 1) score+= 50; if (a.getSize() == 0) score+=100; g.setScore(score); // Create ...
275dd27b-d997-4f42-901d-90eab0af85c1
private void shipCollision (Ship s) { // Remove the ship from the screen and null it out screen.removeParticipant(s); createDebris(ship.getX(), ship.getY(), 1); ship = null; // Display a legend and make it disappear in one second screen.setLegend("Ouch!"); new CountdownTimer(this, null, 1000); // ...
38fb8b92-c0a9-4570-846c-32ec41c55b95
private void bulletCollision (Bullet b) { screen.removeParticipant(b); }
e59a37c2-14fe-4e3d-9170-a8d27f8d6ee3
@Override public void actionPerformed(ActionEvent e) { // The start button has been pressed. Stop whatever we're doing // and bring up the initial screen if (e.getSource() instanceof JButton) { transitionCount++; asteroids = 161; score = 0; g.setScore(score); lives = 3; initialScreen(); ...
fc1888f2-cdf4-4b6e-9f1b-7e550f4668a2
public int getTransitionCount () { return transitionCount; }
42ffcec0-d265-4c8d-9f4f-087712f478fe
public void performTransition () { // Record that a transition was made. That way, any other pending // transitions will be ignored. transitionCount++; // If there are no lives left, the game is over. Show // the final screen. if (lives == 0) { finalScreen(); } // The ship must have been d...
f39b35e5-8f10-44e4-b185-0d60f2f31e24
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_LEFT) leftPressed = true; if (e.getKeyCode() == KeyEvent.VK_RIGHT) rightPressed = true; if (e.getKeyCode() == KeyEvent.VK_UP) upPressed = true; if (e.getKeyCode() == KeyEvent.VK_SPACE) spacePressed = true; //ra...
579910d7-b0be-45a9-92c1-115ce47da453
@Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_LEFT) leftPressed = false; if (e.getKeyCode() == KeyEvent.VK_RIGHT) rightPressed = false; if (e.getKeyCode() == KeyEvent.VK_UP) upPressed = false; if (e.getKeyCode() == KeyEvent.VK_SPACE) { spacePressed = false; ...
d21eadb4-4bb1-4e50-b783-4ebf03f04211
@Override public void keyTyped(KeyEvent e) { }
988cfac7-2987-4e79-9702-5e350b7ae1b1
@Override public void timeExpired(Participant p) { if (p == null) screen.setLegend(""); if (p instanceof Ship) { bulletLimiter = false; } if (p instanceof Bullet) { screen.removeParticipant(p); bulletIndex--; } if (p instanceof Star) { //p.on(); } if (p instanceof Debris) { screen.rem...
805b3c28-e353-4d0f-97b9-73a87d075372
public int getScore () { return score; }
e16aaf16-798c-425e-a4b9-d3a867cc1e7f
public int getLives () { return lives; }
166edf59-6837-4c31-9515-be6ed9ffcda2
public Bullet (double x, double y, double radians) { Ellipse2D.Double e = new Ellipse2D.Double(0, 0, 1, 1); setPosition(x,y); setVelocity(20, radians); outline = e; }
4fde314d-f99e-4c97-8e2c-b0da977d6d26
@Override Shape getOutline() { return outline; }
43c1eba2-ae78-4fd6-bee0-06eb7b55aa42
public Asteroid (int variety, int size, double x, double y) { this.size = size; setPosition(x, y); outline = createAsteroid(variety, size); }
3aa7574c-b461-4f1b-b23f-2599825d1c07
protected Shape getOutline () { return outline; }
a25dea6e-9b9a-4444-88c9-92116bc73b65
private Shape createAsteroid (int variety, int size) { // This will contain the outline Path2D.Double poly = new Path2D.Double(); // Fill out according to variety if (variety == 0) { poly.moveTo(0, -30); poly.lineTo(28, -15); poly.lineTo(20, 20); poly.lineTo(4, 8); poly.lineTo(-1, 30); p...
bf097162-9ec5-463d-a977-d90ac96cb4a1
public int getSize () { return size; }
b875d212-b57e-4276-8723-6ac41539f2f5
public TimeRange(int minTime, int maxTime) { this.minTime = minTime; this.maxTime = maxTime; }
b20cb64c-caed-4aca-9833-112713609233
public static TimeRange fromString(String timeString) { String[] times = timeString.split("\\-"); if (times.length != 2) return null; int minTime = parseTime(times[0]); if (minTime == -1) return null; int maxTime = parseTime(times[1]); if (maxTime == -1 || maxTime < minTime) return null; ...
991b3261-9c98-4b5d-93a4-8fa0708e0096
private static int parseTime(String timeString) { String[] parts = timeString.split(":"); if (parts.length != 2) return -1; int time = 0; try { time = Integer.parseInt(parts[0].trim()) * 10000; if (time < 0 || time > 24000) return -1; } catch (Exception e) { return -1; } try ...
d5f99f06-0008-4355-9161-1afff6823b56
public int getMinTime() { return this.minTime; }
50dde012-c7d9-4e87-a168-6113f702d048
public int getMaxTime() { return this.maxTime; }
100e8329-47ce-4c77-8d36-d6aa6405f2b2
public static void copy(InputStream in, File file) { try { OutputStream out = new FileOutputStream(file); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); in.close(); } catch (Exception e) { e.printStackTrace(); }...
3133e01f-171c-4b5c-84a3-008f84002729
@Override public void onLoad() { instance = this; log = Logger.getLogger("Minecraft"); this.recipes = new RecipeHandler(); info("Loading Alchemist version " + getDescription().getVersion()); }
ce99e524-5a8a-4874-b502-29ad13c49a16
@Override public void onEnable() { createConfig(); loadConfig(); info("Enabled Alchemist!"); }
1860608a-9b8e-4ad3-a448-da1ab91cf268
@Override public void onDisable() { info("Disabled Alchemist!"); }
c006eb3d-7ce3-466b-9d9e-b028b524ab32
private void createConfig() { File configFile = new File(getDataFolder(), "config.yml"); if (!configFile.exists()) { configFile.getParentFile().mkdirs(); FileUtils.copy(Alchemist.getInstance().getResource("config.yml"), configFile); Alchemist.info("'config.yml' didn't exist. Created it."); } }
0669a550-3796-48fe-af51-5da4e2f19923
private void loadConfig() { FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml")); ConfigurationSection limits = config.getConfigurationSection("limits"); if (limits == null) { this.explosionsAllowed = true; } else { this.explosionsAllowed = limits....
897c5184-c82a-4d88-bf8d-f07cae5f871d
public static Alchemist getInstance() { return instance; }
ddfcaacc-4a00-4b60-9ecb-b74474fb1fd5
public static void info(String message) { log.info("[Alchemist]" + message); }
18b53b6b-ad41-4947-89b7-061b7360e98e
public static void warning(String message) { log.warning("[Alchemist]" + message); }
d385a069-0b63-4b7e-844e-5ed26ace470e
public static void severe(String message) { log.severe("[Alchemist]" + message); }
4e4f97f2-9000-4704-8df1-49b51c49682f
public RecipeResult(String name, float weight, float success, float luckInfluence, List<ItemStack> items, float ingredientsPreserveChance, Fill fill, float explosionChance, List<TimeRange> times, List<Integer> lunarCycles, Boolean raining) { this.name = name; this.weight = weight; this.success = success; this....
678f7c74-fd6a-4006-99e3-46ae910e8652
public static RecipeResult fromConfig(ConfigurationSection config) { if (config == null) { Alchemist.warning("Invalid recipe result (Missing or invalid .YML)."); return null; } String name = config.getName(); float weight = (float)config.getDouble("weight", 1); float success = (float)config.getDou...
0bbfb4ae-78fa-4b79-9a90-db07773f208b
public RecipeHandler() { this.recipes = new ArrayList<Recipe>(); }
53b0ae8d-675d-43ae-9b2c-e2516bb21548
public boolean loadRecipes() { File recipesDirectory = new File(Alchemist.getInstance().getDataFolder(), "/Recipes/"); if (!recipesDirectory.exists() && !recipesDirectory.mkdirs()) { Alchemist.severe("Failed to read recipes directory. (1)"); return false; } String[] fileNames = recipesDirectory.lis...
767da893-5868-4d0a-a67c-9d117632a133
public void loadRecipes(File file) { FileConfiguration config = YamlConfiguration.loadConfiguration(file); for (String key : config.getKeys(false)) { if (config.isConfigurationSection(key)) { Recipe recipe = Recipe.fromConfig(config.getConfigurationSection(key)); if (recipe != null) { this...
32a1e979-a6cd-48bb-8d19-d07ba169440b
public void unloadRecipes() { for (Recipe recipe : this.recipes) { recipe.unload(); } this.recipes.clear(); }
e8eee546-15d5-4eaa-b04c-7facb0b1c6da
public Recipe(String name, List<Biome> biomes, float tolerance, Map<String, RecipeResult> results, List<RecipeStep> steps) { this.name = name; if (biomes == null) this.biomes = new ArrayList<Biome>(allBiomes); else this.biomes = new ArrayList<Biome>(biomes); this.tolerance = tolerance; this.results = r...
d29ca9d6-d0d7-4752-97c5-7e1ed83f9df4
public static Recipe fromConfig(ConfigurationSection config) { if (config == null) { Alchemist.warning("Invalid recipe (Missing or invalid .YML)."); return null; } String name = config.getName(); return null; }
9a794bb4-5008-4fad-b7f5-5b7b41b4721e
void unload() { }
b956748d-8b57-49e2-97ca-7a9591361231
@XmlElement(name = "locale") public String getLocale() { return locale; }
bdbe7ac7-2283-4c50-8f74-8e9c579a6c54
public void setLocale(String locale) { this.locale = locale; }
d6e56be7-518e-4dac-8f8c-7df7079ca8c9
@XmlElement(name = "program") public String getProgram() { return program; }
6a89ff30-0df4-44a1-b0dd-2e0b18b0faba
public void setProgram(String program) { this.program = program; }
a9b83405-b633-44b1-953e-9ee41d134fd1
public void process(Exchange exchange) throws Exception { exchange.getOut().setBody(exchange.getProperty("originalRequest")); }
7c707cc8-8f6e-4088-a19a-9aa3fc7f42d5
public ApplicationProperties() {}
861909e3-7d2c-4e7a-824a-547b081f14e9
public ApplicationProperties(String name) { org.slf4j.MDC.put("app.name",name); }
46747fc6-9f86-4783-8707-7e0e6dfac7d1
private Error(String errorCode, String description) { this.errorCode = errorCode; this.description = description; }
d9100dae-3135-4047-9212-49e6fd48b27b
public String getErrorCode() { return errorCode; }
7d1b86f7-830d-423d-8892-1f4723e07b8c
public void setErrorCode(String errorCode) { this.errorCode = errorCode; }
946c7318-e766-41ce-b6aa-69495a46ffd0
public String getDescription() { return description; }
90d16b99-4f31-4c89-a6bf-d55b2a732fcb
public void setDescription(String description) { this.description = description; }
503d357b-5a29-4c38-a0a0-80a3dc78ec1e
public void process(Exchange exchange) throws Exception { exchange.setProperty("originalRequest", exchange.getIn().getBody()); }
a0c0460c-1c81-4591-8759-5c6cbbb6e517
public void process(Exchange exchange) throws Exception { LOG.info(LOG_MESSAGE_DEFAULT); SOAPMessage message = (SOAPMessage) exchange.getIn().getBody(List.class).get(0); SOAPBody body = message.getSOAPBody(); Node firstLevelChild = null; Node secondLevelChild = null; for(in...
b62d4a1d-6971-4dd6-b51e-6e127884daf2
public void process(Exchange exchange) throws Exception { LOG.info(LOG_MESSAGE_DEFAULT); LOG.info(exchange.getIn().getBody(String.class)); StringBuilder xmlResponse = new StringBuilder(); xmlResponse.append(LABEL_LESS_THAN); xmlResponse.append(LABEL_ERROR); xmlResponse.append(LABEL_GREATER_THAN); Exceptio...
0e5fccbb-8964-442b-8b15-920a937eef45
private SOAPMessage generateSoap(String errorCodeXml, XmlResponder responder) throws Exception { StringBuilder response = new StringBuilder(); response.append(responder.OPEN_LABEL); response.append(responder.getNamespacePrefix()); response.append(responder.COLON); response.append(responder.getMainContainer())...
fb526809-144e-4fa7-833a-babd5c582def
public void setMissingBrmsResponder(XmlResponder missingBrmsResponder) { errorMap.put(Error.MISSING_BRMS.getErrorCode(), missingBrmsResponder); }
e7546c1f-5216-4980-a556-bc5dcff7aba6
public void setBadConfigResponder(XmlResponder badConfigResponder) { errorMap.put(Error.BAD_CONFIG.getErrorCode(), badConfigResponder); }
236a25ca-bb8e-4fb0-ac7f-107bd7902e20
public void setBadRequestResponder(XmlResponder badRequestResponder) { errorMap.put(Error.BAD_REQUEST.getErrorCode(), badRequestResponder); }
34d74550-b6c5-4c2a-b5fe-e422ba179704
public void setTimeOutResponder(XmlResponder timeOutResponder) { errorMap.put(Error.TIMEOUT.getErrorCode(), timeOutResponder); }
33eb1e0c-8c8d-4915-8c3a-b1e88c2bc194
public void setUnknowResponder(XmlResponder unknowResponder) { errorMap.put(Error.UNKNOW.getErrorCode(), unknowResponder); }
7cbf358a-4044-4180-88bd-c16a89f3f967
public SOAPMessage processSOAP(Exchange exchange) throws SOAPException, JAXBException, ParserConfigurationException, UnsupportedEncodingException, SAXException, IOException { LOG.info(LOG_MESSAGE_DEFUALT); StringBuilder response = new StringBuilder(); response.append(OPEN_LABEL); response.append(namespacePrefix...
19337395-1348-4f1f-a5a0-58503e3fa156
public String getNamespace() { return namespace; }
bd066d13-c31f-44ef-97d0-0fe081579ef3
public void setNamespace(String namespace) { this.namespace = namespace; }
2bbc4074-ea53-4f74-8bc5-db1139a20836
public String getNamespacePrefix() { return namespacePrefix; }
ae9ad37f-8391-4faa-a3cf-2976e0d6930c
public void setNamespacePrefix(String namespacePrefix) { this.namespacePrefix = namespacePrefix; }
578178e6-88d6-4183-8973-cf6a2fe3e681
public String getMainContainer() { return mainContainer; }
b10a11b7-446f-471c-a99e-85f9e909f543
public void setMainContainer(String mainContainer) { this.mainContainer = mainContainer; }
23a38e29-498a-4343-b48c-c89810b4366e
public String getFirstChildContainer() { return firstChildContainer; }
3dd82f5f-1ffa-439f-ad25-01144daf1fe6
public void setFirstChildContainer(String firstChildContainer) { this.firstChildContainer = firstChildContainer; }
973c2204-40c8-4641-bef4-6b1909b4de0f
public SOAPMessage invoke(SOAPMessage message) { // Requests should not come here as the Camel route will // intercept the call before this is invoked. throw new UnsupportedOperationException("Placeholder method"); }
bb4dea87-3ebf-42e6-9009-d1b21a58afb8
public EnvironmentProperties getEnvironment() { return environment; }
e95b8bac-6dc5-4152-b680-77b7143d4a0b
public void setEnvironment(EnvironmentProperties environment) { this.environment = environment; }
fcc62e44-64ea-4725-8d94-61ff7fbc7cb6
public KnowledgeBase getKnowledgeBase(String knowledgePackage) throws Exception { String guvnorUrl = knowledgeBaseBuilder.getGuvnorUrl(environment.getIp() , environment.getPort(), knowledgePackage); return this.knowledgeBaseBuilder.getKnowledgeBase(environment.getKnowledgeAgentName(), guvnorUrl, environment.getBasi...
ac594885-1619-48be-b97a-79f3ed900762
public KnowledgeBaseBuilder getKnowledgeBaseBuilder() { return knowledgeBaseBuilder; }
f2f1c768-9fc1-4037-9f66-59a87bd1dae3
public void setKnowledgeBaseBuilder(KnowledgeBaseBuilder knowledgeBaseBuilder) { this.knowledgeBaseBuilder = knowledgeBaseBuilder; }
be026138-b43e-4f5c-ab67-36b07399ba81
public String getGuvnorUrl(String ip, String port, String knowledgePackage){ return PROTOCOL + ip + COLON + port + PATH + knowledgePackage + VERSION; }
a7dd77d0-5954-4961-9e3d-a2c202895b20
public KnowledgeBase getKnowledgeBase(String knowledgeAgentName, String guvnorUrl, String basicAutenticationStatus, String userName, String password) throws Exception { KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(knowledgeAgentName); URL url = new URL(guvnorUrl); UrlResource urlResource = new ...
d81c4142-d500-4612-adbb-f4f75c599583
public String executeAllRules(Exchange exchange) throws DroolsException, BrmsException { LOG.info(LOG_MESSAGE); StringBuilder xmlResponse = new StringBuilder(); try { Request request = exchange.getIn().getBody(Request.class); xmlResponse.append(XML_HEADER); xmlResponse.append(ERROR_CODE_HEADER); xmlRe...
81ad149c-22ff-4620-926e-32f48929c750
public EnvironmentProperties(String propertiesFile) { Properties properties = new Properties(); InputStream inputStream = null; try { inputStream = new FileInputStream(propertiesFile); properties.load(inputStream); this.ip = properties.getProperty(IP); this.port = properties.getProperty(PORT); this...
82e00cd1-3e08-41a2-9df3-0967345f71a7
public String getIp() { return ip; }
bed8b6d5-884b-4214-9d87-2ee114b22380
public void setIp(String ip) { this.ip = ip; }
7c90eab0-0872-42c2-9fb1-bd72046f4a38
public String getPort() { return port; }
ce62a3fd-3c5f-4de3-aec7-9ffc1c050c75
public void setPort(String port) { this.port = port; }
29854f2b-cf98-4fa9-b78c-968c3d75291d
public String getUserName() { return userName; }
c26a9b34-2cb2-4eaa-b30e-ca6312517521
public void setUserName(String userName) { this.userName = userName; }
b575ff48-c3d7-4669-944f-e404b3859b86
public String getPassword() { return password; }
44fc5573-7346-47f4-b6d4-00af083f4f55
public void setPassword(String password) { this.password = password; }
10660321-4713-4ce8-b92d-a32bd952f03c
public String getBasicAutenticationStatus() { return basicAutenticationStatus; }