method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
93c1ff5b-9b54-4bdd-aca2-11ee65c7691b
5
public int getSecondOrderClassification(GraphPoint p) { List<GraphPoint> neighbourhood = new ArrayList<GraphPoint>(); for(GraphPoint neighbour: p.getEdges()) { if(neighbour.getClassification() == p.getClassification()) { for(GraphPoint edge: neighbour.getEdges()) { if(edge != neighbour && !nei...
e78e6588-1bc7-4d21-8b93-d3f4ccb4a232
3
private static void test_onesCount(TestCase t) { // Print the name of the function to the log pw.printf("\nTesting %s:\n", t.name); // Run each test for this test case int score = 0; for (int i = 0; i < t.tests.length; i += 2) { int bits = (Integer) t.tests[i]; int exp = (Integer) t.tests[i + 1]; t...
93cac647-d329-4f3a-9b20-2c0fe8c44bcd
8
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initPageRender() { try { Element root = configXml.getDocumentElement(); NodeList nodeList = root.getElementsByTagName("pageRender"); if (nodeList.getLength() == 0) {// 如果没有配置则默认是freemarker渲染 RenderFactory.setPageRender(new FreemarkerRender()); ...
60e6bc95-b710-4763-8c1e-9664beb5e6a7
0
public static Pet randomPet() { return creator.randomPet(); }
83f99e35-ac84-429a-befc-9c99daed1ffd
1
public void activePlayerEndTurn(){ int lastIndexOfActivePlayer = getPlayerNumber(getActivePlayer()); lastIndexOfActivePlayer++; if (lastIndexOfActivePlayer >= players.size()){ lastIndexOfActivePlayer = 0; } setActivePlayer(players.get(lastIndexOfActivePlayer)); getActivePlayer().incrementTurnsWithThree(...
99759d21-6990-4c2c-9b0b-ad57b37f396f
9
public void handleKeyStroke(KeyEvent evt) { switch (evt.getKeyCode()) { case KeyEvent.VK_SPACE: if (!inGame) { this.startSnake(); } break; case KeyEvent.VK_UP: snake.setCurrentDirection(Direction.UPARROW)...
58dcd90c-6923-41d8-9011-8b1c198f065a
2
public static void closeStatement(Statement stmt) { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { throw new RuntimeException(e.getSQLState() + "\nCaused by\n" + e.getCause(), e); } } }
f1ac298f-81c0-462a-883b-18d96758d077
7
public static long findMaxPrime(long value){ //long bigValue = value; //save the factor which have try long factor = 1; //save the max factor long lastFactor = 1; //remove the only one even factor if(value%2==0){ lastFactor=2; factor = 2; value = value/2; whil...
e9daa74f-9eb0-454a-8ce1-c4e44bd5c085
4
private static String LetterOrNumber(String string) { final String works = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; String finals = ""; boolean change = true; for (char c : string.toCharArray()) { for (char x : works.toCharArray()) { if (x == c) { change = false; break;...
e0ae8861-428d-48ab-b5a0-f59bf1ee4038
1
public boolean canHaveAsCreditLimit(BigInteger creditLimit) { return (creditLimit != null) && (creditLimit.compareTo(BigInteger.ZERO) <= 0); }
a13b73fd-d75e-43fa-af7c-60a18589455d
0
public int hashCode() { return super.hashCode() ^ myUnprocessedInput.hashCode() ^ myOutput.hashCode(); }
2c64a3ea-92b6-419c-8f7b-54d1fa41c811
6
public long[] next() { if (!hasNext()) { throw new NoSuchElementException(); } // save current long current[] = new long[numberOfLevels]; for (int i = 0; i < numberOfLevels; i += 1) { current[i] = axisWithoutMeaning[i]; ...
e8fa7d90-8775-4e2b-bd56-08dbb0bba3b0
7
private void processScreenBlt(RdpPacket_Localised data, ScreenBltOrder screenblt, int present, boolean delta) { if ((present & 0x01) != 0) screenblt.setX(setCoordinate(data, screenblt.getX(), delta)); if ((present & 0x02) != 0) screenblt.setY(setCoordinate(data, scree...
0bfb4635-36d9-4584-812f-4da666dad0c1
6
@EventHandler public void IronGolemMiningFatigue(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getIronGolemConfig().getDouble("Ir...
3b4a4c82-c057-4e6f-913a-1b468b31121a
7
public void mainMenu() { System.out.println("Welcome grand overlord, What is your bidding?"); System.out.println("1:Print monthly sales"); System.out.println("2:Change Status"); System.out.println("3:Make Replenishment Order"); System.out.println("4:Delete Unneeded Sales"); System.out.println("5:Change Pri...
2f7e79bb-6f8b-44fe-b789-d25f2b652601
8
private static Node add(Node node, Argument left, Argument right) { if (left.getType() == String.class || right.getType() == String.class || left.getType() == Character.class || right.getType() == Character.class) { String ls = left.asString(); String rs = right.asString(); return new StringArgument(no...
c4ebd529-adc1-4965-bba1-c86c75e818b0
5
public ShopConfigurationPanel() { super(); setLayout(new BorderLayout()); contents = new ShopData(); PropertySet ps = new PropertySet(); final FileProperty fpShopBackground = new FileProperty( "Shop background image (160 \u00d7 120)", null); final FileProperty fpShopButtonImage = new FileProperty( ...
a1a9b90b-72f8-41c0-a8d1-054f297a41b0
7
public void setEmass(String emass) { // 精密質量設定 this.emass = emass; // 精密質量からソート用精密質量設定 if (!emass.equals("") && emass.length() != 0) { this.sortEmass = Float.parseFloat(emass); } // 精密質量から表示用精密質量設定 StringBuffer dispEmass = new StringBuffer(); if (!emass.equals("") && emass.length() != 0) { ...
0bd5d12d-cd35-45ca-8b25-391224bf0c6b
1
public static void UnloadWorld(String name, Boolean save) { if (Core.getPlugin().getServer().getWorld(name) != null) { Core.getPlugin().getServer().unloadWorld(name, save); } }
b59698c0-cfc5-4e72-827b-82634360691c
6
private void animate(Entity entity, int delta) { combinedDelta += delta; if(previousDir != dir){ if(previousDir == Direction.RIGHT && dir == Direction.LEFT || previousDir == Direction.LEFT && dir == Direction.RIGHT){ entity.flip(); previousDir = dir; } } if(combinedDelta > 140){ nextFrame(...
a6de6977-c7b4-4e6e-ac69-ef1be7e80419
9
public Query setParamsToQuery(Query query) { if (params != null) { for (int i = 0; i < params.size(); i++) { if (types.get(i) == null) { query.setParameter(params.get(i), values.get(i)); } else { query.setParameter(params.get(i), values.get(i), types.get(i)); } } } ...
965089df-77a7-4f4f-9b47-feb3355c9d46
8
public void checkCollisionWithWeapons() { for (int i = 0; i < weaponList.size(); i++) { for (int j = 0; j < boardSpawn.getEnemies().size(); j++) { if (weaponList.get(i).getShape().intersects(boardSpawn.getEnemies().get(j).getShape())) { if (weaponList.get(i) instanceof Star) { weaponList.remove(i); ...
869cd0be-4855-4834-b4fc-e96095888a78
9
static void checkMethodDesc(final String desc) { if (desc == null || desc.length() == 0) { throw new IllegalArgumentException( "Invalid method descriptor (must not be null or empty)"); } if (desc.charAt(0) != '(' || desc.length() < 3) { throw new Illeg...
b93acc84-0140-4153-9609-905b6310176b
8
private Command parse(String userInput) { if (userInput == null) { return null; } StringTokenizer tokenizer = new StringTokenizer(userInput); if (tokenizer.countTokens() == 0) { return null; } CommandName commandName = null; String userName = null; float amount = 0; int userInputTokenNo = 1; ...
f552bc6c-9b0d-48eb-bcd9-7d9dff0db22e
9
@Override public Node parse(Token token) throws IOException { AttrNode node = null; if (ExpressionParser.START.contains(token.type())) { node = new AttrNode(startLine()); token = tokenizer().peek(); Token var = tokenizer().current(); if (ATTR.contains(token.type())) { boolean first = true; whil...
56c3414a-f844-4c00-99ca-196863ba504f
7
@SuppressWarnings("deprecation") private boolean setAirIfAllowed(World world, int x, int y, int z, boolean dungeonGen) { if(canSetAir(world, x, y, z, dungeonGen)) { setBlock(world, x, y, z, 0); int id = getBlock(world, x, y+1, z); if(id == Material.SNOW.getId() || id == Material.YELLOW_FLOWER.getId...
2fe0d4ad-420f-4c68-a149-3e86c8d55d47
7
public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); // Make sure we are responding to the right event. if (propertyName.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { File selection = (File)e.getNewValue(); String name; ...
f8d3e14c-7ba4-4903-97af-b16359edb0b8
1
private static void method501(char arg0[]) { char ac1[] = arg0.clone(); char ac2[] = { '(', 'a', ')' }; Censor.method509(null, ac1, ac2); char ac3[] = arg0.clone(); char ac4[] = { 'd', 'o', 't' }; Censor.method509(null, ac3, ac4); for (int i = Censor.aCharArrayArray623.length - 1; i >= 0; i--) { Censor...
01262c61-0d63-4d26-8485-c6c7085c3f8c
7
@Override public void paint(Graphics2D g) { if (drawAll && StateHandler.instance.getCurrentState() == State.PLAYING) { for (int i = 0; i < rectangles.size(); i++) { g.setColor(ColorUtils.getAlpha(BOX_COLOR, 150)); g.fillRoundRect(rectangles.get(i).x, rectangles.get(i).y, rectangles.get(i).width, rec...
9e1ec15b-99cf-414e-aad9-6f1163804481
0
public void registerStopWatchListener(StopWatchListener listener) { this.listener = listener; }
8582ead8-367b-499c-8130-bd5aeb4cf4b3
6
public static void main(String[] args) throws NumberFormatException, IOException{ BufferedReader strin; boolean choice = true; int gameNum = 0; int win = 0; int lose = 0; while (choice){ Random random = new Random(); int n = rando...
e5eeffc5-395b-46d1-bd6d-6ff00ec24ac6
0
public synchronized void addUnsearchList(String url){ this.unsearchSitesList.add(url); }
4aba884b-f602-4810-b074-dc17f3b4128e
8
@Override public FSMNode<EventType> nodeToTransitTo(StateMachineEvent<EventType> event) throws InvalidEventException { if (aspects != null && !aspects.onTransitionStart(event)) return null; try { FSMNode<EventType> target = delegate.nodeToTransitTo(event); if (tar...
a237818b-7dca-4c54-855c-988f3a78af6b
0
public OnlineSearch(Settings settings) { SEARCH_JUMPLENGTH = settings.getSearchJumpLength(); SEARCH_SENTENCELENGTH = settings.getCompareSentenceLength(); MAX_URLS = settings.getSearchNumLinks(); URL = settings.getSearchURL(); URL_ARGS = settings.getSearchURLArgs(); URL_ARG_AUTH = settings.getSearchAuthArg(...
ab40bdee-f0ce-44b4-9838-1506f4422067
3
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) { pressed = true; } if (pressed && e.getKeyCode() == KeyEvent.VK_V) { adaptee.pasteClipboard(); } }
ca5e2760-1003-4ce1-93b0-04e37c84e4e7
3
public void writeExternalWithoutImages(ObjectOutput paramObjectOutput) throws IOException { paramObjectOutput.writeObject(this.location); paramObjectOutput.writeObject(this.LastPosition); paramObjectOutput.writeObject(this.LastCell); boolean[][] arrayOfBoolean = new boolean[this.shape.length][this.sha...
05b1b8f5-f0fd-46e2-b58f-0bb78a132728
4
public static int getGreatestProdDownColumns(int[][] arr, int maxDigits, int columns, int rows) { int sum = 0; for(int i = 0; i < rows; i++) { int prod = 0; while((prod) < (columns-(maxDigits-1))) { int tmpProd = 1; int curr = prod; for(int it = 0; it < maxDigits; it++) { tmpProd = tmpProd * ...
95fd2eb7-f81a-4126-acf5-f028cb9dc398
7
public Symbol debug_parse() throws java.lang.Exception { /* the current action code */ int act; /* the Symbol/stack element returned by a reduce */ Symbol lhs_sym = null; /* information about production being reduced with */ short handle_size, lhs_sym_num; /* set up ...
cd11d85c-442d-4cb0-918d-a20dd840c086
4
@Override public void scoreRound(boolean won, int score) { if (TRAIN_score && old_score != null){ //Final target value is the final score old_score.output = score / max_points; //old_score.output = won ? 1 : 0; train_data.add(old_score); //Train the network //Give higher learning rate to more rece...
e9731f9d-f21e-4996-9339-b581b1659e82
8
@Override public void deserialize(Buffer buf) { super.deserialize(buf); maxPods = buf.readShort(); if (maxPods < 0) throw new RuntimeException("Forbidden value on maxPods = " + maxPods + ", it doesn't respect the following condition : maxPods < 0"); prospecting = buf.read...
7b7170de-f7b4-44b2-ad28-1220d373a39a
4
private static void compare(List<String> urlsOrFiles, String[] testSetIdArr) throws Exception { List<TestResultData> testNgResultData = parseTestNgResultFromFilesOrUrls(urlsOrFiles); List<String> testNgTests = (List<String>) CollectionUtils .collect(testNgResultDa...
4bffe9a5-08a9-4071-877b-a3319a41f5cf
9
public SetupHeader(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException { if (source.getLong(48) != HEADER) { throw new VorbisFormatException("The setup header has an illegal leading."); } // read code books int codeBookCount = ...
b54d9033-8043-4ecf-b34b-b6001c27888f
0
private void listen() { ListenThread thread = new ListenThread(); thread.start(); }
f3e0bab2-c106-497a-8bc5-b9c11955dfc4
9
private void cleaningText() { int latinCount = 0, nonLatinCount = 0; for(int i = 0; i < text.length(); ++i) { char c = text.charAt(i); if (c <= 'z' && c >= 'A') { ++latinCount; } else if (c >= '\u0300' && UnicodeBlock.of(c) != UnicodeBlock.LATIN_EXTEND...
efe7764e-a6e9-41e2-9e53-15ad4e9d992f
7
private void solve() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); skill = new int[n]; gender = new char[n]; out = new boolean[n]; prev = new int[n]; next = new int[n]; prev[0] = 0; next[0] = 1; prev[n-1] = n...
ddee6cce-a57f-4e9e-bf79-f9723516bada
2
public int compareTo(FolderWatcherQueue t1) { { if (date.before(t1.getDate())) { return -1; } if (date.after(t1.getDate())) { return 1; } return 0; } }
11be2bb3-813e-4839-8828-688b9b3d58fb
7
public void establishInitialConnection() throws FileNotFoundException , IOException{ String line_in_file, full_html = ""; FileReader html_file = new FileReader("page.html"); //FileWriter temp = new FileWriter("tmp.abc") BufferedReader html_file_br = new BufferedReader(html_file); while( (line_in_file=html_f...
52958a0b-bba4-4e88-99f1-10d836d2062b
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); addActionListener(this); Outliner.documents.addTreeSelectionListener(this); setEnabled(false); }
9aa5c156-9870-43b0-9797-0a46dcc4cce8
9
public static int getItemBurnTime(ItemStack par1ItemStack) { if (par1ItemStack == null) { return 0; } else { int var1 = par1ItemStack.getItem().shiftedIndex; if (var1 < 256 && Block.blocksList[var1].blockMaterial == Material.wood) return 30...
12b60b2b-28a4-45c3-8971-0f17030b1b8d
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PacketEntry other = (PacketEntry) obj; if (underlyingPacket == null) { if (other.underlyingPacket != null) return false; } e...
e7b22b79-8f0a-4e5a-933d-5f6b0b3ab20f
1
protected Class<? extends AnnotatedElement> getAnnotatedElementType() { return this.annotatedElementType; }
a7a9b8ab-787d-4c6b-a10d-628a380439be
8
private final void enableDeviceSpecificEvents (boolean b) { enableMotorVelocityChangeEvents (b && motorVelocityChangeListeners.size () > 0); enableCurrentChangeEvents (b && currentChangeListeners.size () > 0); enableCurrentUpdateEvents (b && currentUpdateListeners.size () > 0); enableInputChangeEvents (b && in...
cd550d45-f9cc-4449-b39a-cfa18737f43a
6
@Override public void paintComponent(Graphics g) { Object map = Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); //$NON-NLS-1$ if (map != null) { ((Graphics2D) g).addRenderingHints((Map<?, ?>) map); } Rectangle clip = this.getVisibleRect(); // line numbering is alway...
6095d91a-c385-4ad5-a554-779e1d113ec2
8
public void nettavisen(URL uri, String url) { try { HttpURLConnection web = (HttpURLConnection) uri.openConnection(); web.setRequestMethod("GET"); web.connect(); int code = web.getResponseCode(); if (code == HttpURLConnection.HTTP_OK) { BufferedReader in = new BufferedReader(new InputStreamReader...
514625fa-38fa-4afc-894a-03aac8e6fd68
1
public void restoreScreen() { Window window = device.getFullScreenWindow(); if(window != null) { window.dispose(); } device.setFullScreenWindow(null); }
5ae247e1-5bfe-4141-aef7-8d4f91d754b1
2
public static Node followXpath (Node start, String Xpath) throws DOMException { StringTokenizer tokenizer = new StringTokenizer(Xpath, "/"); if (tokenizer.countTokens() == 0) { String invalidXpath = Xpath + " is an invalid Xpath!"; throw new DOMException(DOMException.SYNTAX_ERR,...
94df1f84-94b4-481c-b193-190e1226ad4b
9
public void run() { Vector<Long> historyBytes = new Vector<Long>(); int maxSize = 20; while (true) { long timeInit = System.currentTimeMillis(); if (!copier.getPause()){ historyBytes.add(0,copier.readAndInitBytesCounter()); if (historyBytes.size() > maxSize) historyBytes.removeElementAt(h...
cb3bb6ab-72a1-45a0-b140-286305c63bea
7
public Item(String name, String catagoryStr, String type) throws SalesTaxApplicationException { super(); if (name != null && name.length() > 0) { this.name = name; } else { throw new SalesTaxApplicationException("No item name specified !"); } if (catagoryStr.equals("FOOD")) this.catagory = Catagory...
f1811197-d586-4f97-a23f-3ded28f86ae4
8
public void initControllers() throws SlickException { if (controllersInited) { return; } controllersInited = true; try { Controllers.create(); int count = Controllers.getControllerCount(); for (int i = 0; i < count; i++) { Controller controller = Controllers.getController(i); if ((co...
36e83298-d5bc-43cf-a800-d02243840920
7
public static boolean isSupport(ABObject o2, ABObject o1) { if (o2.x == o1.x && o2.y == o1.y && o2.width == o1.width && o2.height == o1.height) return false; int ex_o1 = o1.x + o1.width; int ex_o2 = o2.x + o2.width; int ey_o2 = o2.y + o2.height; if ((Math.abs(ey_o2 - o1.y) < gap) && !(o2.x - ex_o...
5a7f7a33-80e0-4901-9d26-dbb97ce253d0
4
public static Input readInput(File file) throws InputException { if ((file != null) && (file.canRead())) { try { Input input = readInputFromFile(file); verifyInput(input); return input; } catch (InputException exception) { throw exception; } catch (IOException e) { throw new Inp...
a3f185f7-6588-4f41-a8d7-5123d708b82b
9
public synchronized int getNextIndex() { int i, count = dataListModel.getSize(); if (nextIndex == -1) { switch(playMode) { case 1: break; //不改变 case 3: curIndex = (int)(Math.random()*count); break; //任意的 default: curIndex = (curIndex + 1 == count) ? 0 : curIndex + 1; break; } } else { cur...
0c268a77-b08d-4e92-8a07-39d3500dfa24
0
public final URL getDownloadUrl() { return downloadUrl; }
fac559d1-f9ca-4e6f-8f1c-1dc96ba0fb79
7
@SuppressWarnings("unchecked") <T> T convertInternal(Object value, Type type) throws JSONException { if (type instanceof TypeReference<?>) { type = ((TypeReference<?>)type).getType(); } Class<?> cls = ClassUtil.getRawType(type); T result = null; try { enter('$', null); result = (T)p...
072e366e-5d75-4d6f-a8d5-7fc1cb0ef6aa
3
@Override public BufferedImage generate() { BufferedImage completePic = new BufferedImage(xSize, ySize, BufferedImage.TYPE_INT_RGB); // initialises to false completedPixels = new boolean[xSize][ySize]; for (int i = 0; i < xSize; i++) { for (int j = 0; j < ySize; j++) { // spots() may have got here f...
36cb6998-9143-43e3-bf1c-51a630ca0c59
7
public boolean eventGeneratable(String eventName) { if (eventName.equals("configuration") && m_Filter != null) { return true; } // can't generate the named even if we are not receiving it as an // input! if (!m_listenees.containsKey(eventName)) { return false; } Object ...
465cd67b-d7fe-4886-ae36-34b90c1f73dd
5
public void renderSprites(Bitmap bm) { boolean visible = true; TreeSet<Sprite> sortedSprites = new TreeSet<Sprite>(spriteComparator); for (Sprite s : entities) { if (visible) sortedSprites.add(s); } for (Sprite s : particles) { if (visible) sortedSprites.add(s); } sortedSprites.addAll(mapSprites); ...
b3ad4b37-43ed-4622-ae84-db52df982083
0
public Scene(Ticker ticker, GameWorld gameWorld) { buffer = new FrameBuffer(1024, 768, FrameBuffer.SAMPLINGMODE_NORMAL); buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE); buffer.enableRenderer(IRenderer.RENDERER_OPENGL); this.gameWorld = gameWorld; camera = new Camer...
45202917-0007-48aa-919a-2d2c8b353cdf
1
public static List<TreeWorker> getsavedTrees() { if(savedTreeWorker==null)savedTreeWorker=new ArrayList<TreeWorker>(); return savedTreeWorker; }
bd658153-6b5b-4258-90e7-966b38b24364
4
void bounce(Dimension size) { if ((position.x <= 0 & xOffset < 0) || (position.x >= size.width & xOffset > 0)) { xOffset *= -1; } if ((position.y <= 0 & yOffset < 0) || (position.y >= size.height & yOffset > 0)) { yOffset *= -1; } }
cfc88b55-b464-42f3-9799-62ef83f0f48f
3
public static void main(String[] args) throws InterruptedException { JFrame view = initWindow(); Supervisor.registerFrame(view); Stats constStatsInit = new HashMapStats(); constStatsInit.put(new Stat(StatType.C_CREATURE_CLASS, 1.0)); constStatsInit.put(new Stat(StatType.C_ATTAC...
f3eb7fa8-4bb6-47ed-8696-482ed875c6d9
7
public static int colisamax_f77 (int n, double x[][], int incx, int begin, int j) { double xmax; int isamax,i,ix; if (n < 1) { isamax = 0; } else if (n == 1) { isamax = 1; } else if (incx == 1) { isamax = 1; ix...
b94e5d11-9a95-411f-9547-d60ebfc4b96c
9
public void disconnectFromURL() { connected=false; try { if(out!=null) { out.write(new byte[]{(byte)255,(byte)253,18}); //iac, iacdo, logout out.flush(); } } catch(final Exception e) { } try { if((in!=null)&&(in[0]!=null)) in[0].close(); } catch(final Exception e) { } try ...
09413c88-d1a6-4b6e-b9d5-25d6fae218d1
5
private void moveBodyAndSetSprites() { Vector2D currentBodyPos = new Vector2D(lastHeadPos.x(), lastHeadPos.y()); Vector2D lastBodyPos = new Vector2D(0, 0); for(int i = 1; i < snake.size(); i++) { lastBodyPos.setCoords(bodyPartPos.get(i).x(), bodyPartPos.get(i).y()); bodyPartPos.get(i).setCoord...
389a045c-8540-444b-8d0e-3504feb87526
2
@Override public boolean isOpen() { return inputStream != null && outputStream != null && serialPort != null; }
f732d0f8-51f1-4922-9ad2-ec2879f1edec
5
@Override public List<Role> findRoleAll() { List<Role> list = new ArrayList<Role>(); Connection cn = null; PreparedStatement ps = null; ResultSet rs = null; try { cn = ConnectionHelper.getConnection(); ps = cn.prepareStatement(QTPL_SELECT_ALL); ...
ea4a0516-d5e2-4198-82f6-b1dea58d474e
1
private void preencheTabela(List<Venda> lista){ this.modelo = new DefaultTableModel(); modelo.addColumn("Id"); modelo.addColumn("Cliente"); modelo.addColumn("Usuario"); modelo.addColumn("Horario"); modelo.addColumn("Forma de Pagamento"); modelo.addColumn("Valor To...
5ea16e1f-c76d-4cfe-82d0-a33a758db4ad
6
public void actualizar(float tpf, float speed) { time += tpf / speed; if (time > 1f && state == 0){ flash.emitAllParticles(); spark.emitAllParticles(); smoketrail.emitAllParticles(); debris.emitAllParticles(); shockwave.emitAllParticles(); ...
eddd16ea-4507-486f-abea-1f96530c2890
0
public void update() { moveCamera(); movePlayer(); }
242f1796-cb1f-43aa-8c85-61535eee0a50
8
@Test public void testConcurrency1() { final int clientThreadCount = 5; final int machineId = 1; int total = 0; int count = 0; for (int i = 0; i < mServerCount; i++) { try { mDhtClientArray[i].purge(); } catch (RemoteException e) { ...
c3d5ddb0-e9a2-4965-a742-f3a96254bee1
4
public Boolean getValid() { boolean test = false; if (test || m_test) { System.out.println("Loader :: loadAll() BEGIN"); } if (test || m_test) { System.out.println("Loader :: loadAll() END"); } return m_allValid; }
89186080-f0c1-4b01-adee-b25640603342
9
public static boolean parseAccessTokenAndOpenId(String responseData, OAuthV2 oAuth) { if (!QStrOperate.hasValue(responseData)) { return false; } oAuth.setMsg(responseData); String[] tokenArray = responseData.split("&"); log.info("parseToken response=>> tokenArray.le...
0875aa14-0c62-42a4-bc86-edd303e30c9f
8
public PixImage boxBlur(int numIterations) { // Replace the following line with your solution. PixImage blur = new PixImage(this.pixWidth, this.pixHeight); if(numIterations < 1){ return this; } else{ for(int x = 0; x<blur.pixWidth; x++){ for(int y = 0; y<blur.pixHeight;y++...
651dd551-34f3-40dd-b3ad-9c37d371b8f9
7
public void moveRow(int start, int end, int to) { if (start < 0) { String message = "Start index must be positive: " + start; throw new IllegalArgumentException( message ); } if (end > getRowCount() - 1) { String message = "End index must be less than total rows: " + end; throw new IllegalArgume...
246ca3c4-3a68-4104-b37c-0110e0a0e79a
4
public void basicSetMeteo(Meteo myMeteo) { if (this.meteo != myMeteo) { if (myMeteo != null) { if (this.meteo != myMeteo) { Meteo oldmeteo = this.meteo; this.meteo = myMeteo; if (oldmeteo != null) oldmeteo.removeWorkout(this); } } } }
4244d4a2-bb12-4d77-9b53-450c496dfcb5
7
private void fillDocumentPositions(BooleanQuery boolQuery) throws IOException, XMLStreamException{ for(BooleanImpl clause: boolQuery.getBooleanClauses()) { if (clause instanceof BooleanClause) clause.getDocPositionST().addAll((this.getDocumentPositions((BooleanClause)clause))); if (clause instanceof Phr...
02f2968b-238a-4efb-aef7-76b7f7116f3b
8
public void begin() { int numberOfCases = Integer.parseInt(readLine( 100 )); readLine( 100 ); // blank line for( int cases = 0 ; cases < numberOfCases; cases++ ){ Map<String,String> registers = new HashMap<String,String>(10); for( int inx = 0 ; inx < 10 ; inx++ ){ registers...
887318e3-7228-48c6-a408-60666ef149f4
0
@Override public int getWidth() { return width; }
405ff6f3-7678-4828-b8fb-61bd5216b18c
0
public String getVis_matricule() { return vis_matricule; }
5da93c7b-80c1-40cf-a537-c40964f79429
6
public boolean getBoolean(int index) throws JSONException { Object object = this.get(index); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object) .equalsIgnoreCase("false"))) { return false; } else if (object.equal...
cab71b87-2f45-45fe-8fd5-ca7a65b9f840
4
public boolean frogIsOnLog(Rectangle log){ boolean collision = log.contains(leftHalf) || log.contains(rightHalf) || log.contains(backHalf) || log.contains(frontHalf); if(collision){ return true; }else{ return false; } }
78449eb4-f7aa-41e7-aaa3-648eff8dbd9a
7
protected void addColumnHeaders(Worksheet worksheet) { List<String[]> rawColumnHeadersList = worksheet.getRowsByRegex("^Druh kriminality.*"); Helper.isTrue(rawColumnHeadersList.size()==1,"Nemozno urcit na ktorom riadku su nazvy stlpcov"); String[] rawColumnHeaders = rawColumnHeadersList.get(0); List<String> col...
dc892c0a-59cd-48ff-a6b9-864834e673d4
8
@Override public void setLock(String resource, String transaction, LockType requestType) { if (requestType != LockType.READ && requestType != LockType.WRITE) { System.err .println("error: site.ImpLockManager.setLock\n invalid coming request " ...
3a4b7850-931a-4ac2-a233-1ad57f62bb63
5
public Bipartite(Graph<?> g) { this.marked = new ListOrderedMap<>(); this.color = new ListOrderedMap<>(); this.isBipartite = true; for (Object x : g.getAllVertices()) { this.marked.put(x, false); this.color.put(x, false); } for (Object x : g.ge...
5448a8d8-06fc-4727-a9fa-0126f3e70e2a
7
public void actionPerformed(ActionEvent e) { // get the button that was pressed JButton b = (JButton)e.getSource(); // fire appropriate event if (b.getText().equals("Normal Setup")) { // set up for normal simulation fireSimulationEvent(SimulationEvent.NORMAL_SETUP_EVENT); } el...
8b25abcc-4d46-4beb-9928-ca92a3cf0a04
1
@Override public void mark(int boardPosition, Cell[] cellBoard, int rows, int columns) throws IllegalMark { //Find the column. int boardPositionColumn = boardPosition % columns; if (boardPositionColumn > 0){ //It's not the first column. int oneLe...
24de4020-f3f5-4e2a-b6ce-e268889390b7
7
private static int checkAck(InputStream in) throws IOException { int b = in.read(); // b may be 0 for success, // 1 for error, // 2 for fatal error, // -1 if (b == 0) return b; if (b == -1) return b; if (b == 1 || b == 2) { StringBuffer sb = new StringBuffer(); int c; do { c = in.rea...
9b15429a-573c-486e-a1d4-fb30d6f35446
5
public void draw() { // draw board drawBoard(); // draw pieces double x = 0; double y = 0; for (int i = 1; i <= model.getPoints().size(); i++) { drawPoint(i); } // draw rails // player 2 on top, player 1 on bottom x = WIDTH/2; y = HEIGHT/2; StdDraw.setPenColor(StdDraw.WHITE); StdDraw.text(...
0c349c07-1d89-4f14-98f9-a4568efdb637
5
public boolean boundingBoxContains( double x, double y, double z ) { return x >= x0 && x <= x1 && y >= y0 && y <= y1 && z >= z0 && z <= z1; }
71daed16-295c-4cbd-ac12-9ce5baf8f866
6
@EventHandler public void PigZombieNightVision(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getPigZombieConfig().getDouble("PigZ...