method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a2d5ddbc-722e-4c26-9729-5b57afd6182b
1
private Teleporter getRandomDestination(Teleporter current, List<Teleporter> teleports) { int randomIndex = teleports.indexOf(current); while (randomIndex == teleports.indexOf(current)) randomIndex = (int) (Math.random() * teleports.size()); return teleports.get(randomIndex); }
9fe3a504-6cce-4c24-8bf9-bda26ee31264
3
private void init() { try { Element existing = editor.getXMLElementByString("/MLP_Save/MapZone[@ID='0']/GameObjects/Pony_Objects/Object[@ID='" + id + "']"); Element bluePrintExisting = editor.getXMLElementByString("/MLP_Save/MapZone[@ID='0']/GameObjects/Pony_Objects/Object[@ID='" + blue...
55cfaa07-ead8-4e65-b5f6-5027c717f32e
3
public static String latToPrintable(Double lat) { if (lat == null) { return "N/A"; } String ns = "N"; if (lat < 0) { ns = "S"; lat *= -1; } int hours = (int)lat.doubleValue(); lat -= hours; lat *= 60; String latStr = String.format(Locale.US, "%3.3f", lat); while (latStr.indexOf('.') < 2) { ...
9560dcfc-3767-4fe0-8899-e4d8b26c1c1c
9
@Test public void reTest5() { userInput.add("hi"); userInput.add("my name is meng meng"); userInput.add("can i teach you a recipe"); userInput.add("french fries"); // removableFiles.add("french fries"); userInput.add("france"); removableFiles.add("france"); userInput.add("you need potatoes"); userInpu...
f69f3824-7a5c-485c-9624-590d1ee23924
6
@Override public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { //Check for bad Request if (!request.getDecoderResult().isSuccess()) { HandlerUtil.sendError(ctx, BAD_REQUEST); return; } //Check for correct HTTP Method...
fe000724-b72c-4542-b312-ba667efdb074
8
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { HttpSession session = request.getSession(true); AlumnoBean alumno = ((AlumnoBean) (session.getAttribute("currentSessionUser"))); Curriculum c = new Curriculum(); boolean flag=true; ...
024ad30e-4498-4ad8-938f-141f693bd3bc
0
public static void main(String[] args) { int i = 32768; short s = (short) i; System.out.println("i = " + i + ", s = " + s); // i = 32768, s = -32768 }
dc3ae061-8304-4a50-a3c7-c4a5489f60ff
4
@Override public Class getColumnClass(int col) { try { if (col == 0) { return Class.forName("java.lang.String"); } else if (col == 1) { return Class.forName("javax.swing.ImageIcon"); } else if (col == 2) { return Class.forName("java.lang.String"); } else { return Class.forName("java.lang....
ca4b796a-a033-4e34-b319-bf46b829f7d7
7
public void defendGoal(ObjBall ball) throws UnknownHostException, InterruptedException { //Pos ridBallPoint = new Pos(0,0); //Move to catchable range of ball if (ball.getDistance() > 1.0) { getAction().gotoPoint(mh.getNextBallPoint(ball)); //Thread.sleep(100); } else { if((getMem().side.compareTo(...
7f71feb0-ccfb-4371-985a-a0acea481feb
2
@RequestMapping(value="nuevoProducto", method=RequestMethod.POST) public ModelAndView agregarProducto(@ModelAttribute(value="nombreProducto") String nombreProducto, @ModelAttribute(value="cantidadProducto") Integer cantidadProducto) { Stock stock = Stock.getInstance(); if (!stock.existeProducto(nombreProduct...
575dc25a-14a4-431e-98ec-812b1955c8c0
1
@Override public void destroy() { unlink(); if(parent instanceof TimerPanel){ ((TimerPanel) parent).pack(); } timer.updcallback = null; timer = null; super.destroy(); }
c6c869de-1e1c-421b-acfd-9e9f6f40b1d4
5
public void Animate() { if (!playsong) { level.PlaySound(room, Level.ENDMUSICSOUND); playsong = true; } animationState = 1 - animationState; for (int a = 0; a < 20; a++) { if (a % 2 == animationState) { room.SetMaterial(a, 0, 0); ...
23582e44-5692-4f07-b3e4-c4c6cc88de11
8
public void sendAnnounce(MOB from, String announcement, Session S) { final StringBuffer Message=new StringBuffer(""); if((from!=null)&&(from.playerStats()!=null)&&(from.playerStats().getAnnounceMessage().length()>0)) Message.append(from.playerStats().getAnnounceMessage()+" '"+announcement+"'.^.^N"); else ...
7df7b7a2-4ef3-4a31-81ab-5df2801d6dc0
7
public void visitFrame( final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) { buf.setLength(0); buf.append(ltab); buf.append("FRAME "); switch (type) { case Opcodes.F_NEW: case...
4d07b6e7-e05d-4c9e-af8f-b449cf7baa04
9
public void printSimpleKmd() throws FileNotFoundException, IOException, NoSuchAlgorithmException { if (moduleManager == null) { loadModulesFromKmdFiles(); } MessageDigest digest = MessageDigest.getInstance("MD5"); for (ModuleDefinition module : moduleManager.getModules()) { for (RemoteClas...
2a0aeabb-6dcc-4dbe-aa8b-e3c13ca710c2
6
public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and fe...
c692636f-c2b1-4279-ba5e-c7b7e5a9a3c0
8
void setModelVisibility() { if (frame == null) // necessary for file chooser return; // named objects must be set individually // in the future, we might include here a BITSET of models rather than just a modelIndex BitSet bs = viewer.getVisibleFramesBitSet(); for (int i = JmolConstants.SHAPE_MIN_NAMED_...
10c26980-858a-4ccf-bdbc-4b95aa5ffac7
0
public void setDeviceBinding(String value) { this.deviceBinding = value; }
46efaedc-79e9-4cd6-b64d-518eaa9b45bd
4
public void disconnect() { boolean disconnected = false; synchronized(CONNECTION_LOCK) { if(isConnected) { logger.fine("Disconnecting from " + serverAddress + ":" + serverPort); disconnectQuietly(); disconnected = true; } else if(isAttemptingToConnect) { logger.fine("Cancelling connect requ...
740ffa7a-a126-4b95-b4b5-d2a1f6da2c18
6
public ArrayList<Flight> shortestFlight(String departureAirport, String arrivalAirport) { ArrayList<ArrayList<Flight>> multiHopFlights = getMultiHopFlights( departureAirport, arrivalAirport); ArrayList<Flight> nonStopFlights = getNonStopFlights(departureAirport, arrivalAirport); ArrayList<Flight> resul...
f4ea5363-a402-4a8d-90c9-14dc2b446d9a
0
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { containChoixAnimal = new javax.swing.JPanel(); containAnimal = new javax.swing.JPanel(); ptsScroll = new javax.swing.JScrollPane(); ...
a08c807d-e3fa-45cf-a894-516de9502198
4
private SplayTreeNode zig(SplayTreeNode node) { SplayTreeNode k1 = new SplayTreeNode(node); SplayTreeNode a = new SplayTreeNode(node.left); SplayTreeNode b = new SplayTreeNode(node.right); if (a.isNull()) a.parent = k1; if (b.isNull()) b.parent = k1; ...
0d490540-e5ea-4040-833f-edd4f0afeb56
3
void attackPlaceHorizontallyRight(int position, char[] boardElements, int dimension, int rightPosition) { while (rightPosition > 0) { if (isPossibleToPlaceRight(position, dimension, rightPosition) && isBoardElementEmpty(boardElements[position + rightPosition])) { ...
b5a0c5dd-19b6-4d8b-b976-6848779330dd
2
@Override public void run(ListIterator<Instruction> iter) throws Exception { Instruction i = iter.next(); i.getArgumentSubstitutes(); if(i instanceof ArithmeticInstruction) { ArithmeticInstruction a = (ArithmeticInstruction) i; if(a.isComputable()) { ...
003e02ef-8335-47e8-a0e3-7c4fdf1c9ea3
5
@Override public void initTreeTraversal(){ try { if(memory != null) { memory.rewind(); return; } if(in != null) { in.close(); } in = new BufferedInputStrea...
ebe217aa-2ed2-4542-9da3-a839212ef596
0
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + typeId; return result; }
cb3c117b-471a-4344-88b7-b2f5cc55fd4e
7
@Override public void received(Connection c, Object o) { if (o instanceof Packet) { Packet answer = null; if (o instanceof AuthRequest) { AuthRequest r = (AuthRequest) o; if (getByClientByName(r.nickname) == null) { answer = new Aut...
28e45f88-7aa2-46be-8698-39be2a6e5ba8
1
public void testErrorCount() { DataSet ds = null; try { final TabDelimited testTab = new TabDelimited(); ds = testTab.getDsForTest(); // check that we had no errors assertEquals(0, ds.getErrors().size()); } catch (final Exception ex) { ...
a3d13db8-98a1-493c-ba5e-8bb2b7430eb5
7
public static boolean areEqual(MyStack<String> stack1, MyStack<String> stack2) { /* same object */ if (stack1.equals(stack2)) { return true; } boolean flag = false; MyStack<String> temp = new ArrayStack<String>(); /* compare elements from two stacks */ while (!stack1.isEmpty() && !stack2.isEmpty()...
1918ee2d-7c36-464f-bbf9-c9a0bf0e62d0
7
private List<String> searchForMatches(String string){ List<String> results = new ArrayList<String>(); if(string.length() <= "help".length() && ("help".substring(0,string.length()).equals(string))){ results.add("help"); } for (String string1 : commandCollection.getComm...
89244374-2d0f-4e3a-b629-f1b018d4b59a
0
public static void main(String[] args) { //int NumberOfTimesPacketsAreDeliverd = 0; int NumberOfPackets = 50; //************************* double mean = 4.5;//2.9; double StandardDeviation = 1.5; long SEED = 287848937; //**********************...
a8414e88-960e-419f-8f6c-23be51184f2b
3
public void printCells(Cell[][] cells) { System.out.println("Cell Count: " + cells[0].length); for (int i = 0; i < cells.length; i++) { for (int j = 0; j < cells[0].length; j++) { if (cells[i][j] == null) { System.out.println("Null at " + i + "," + j); ...
b5222f02-f128-49b7-9513-a880cadb9da2
0
public void deregisterBeing(Being b) { beings.remove(b); }
10b128bf-ed22-4efc-95ea-3793bad3db05
6
public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and fe...
65ea628b-b322-4835-b94d-cd2138f91a9c
5
@Override public boolean open() { WidgetChild wc; return MainTabs.ABILITY_BOOK.open() && (this.isOpen() || (wc = Widgets.get(BOOK_WIDGET, component)) != null && wc.visible() && wc.click(true) && new TimedCondition(2000) { @Override public boolean isDone() { return AbilityTabs.this.i...
d7463897-8c91-47a2-9af4-11161427fee2
6
protected boolean checkMethodProxy(String methodName, Object[] params) { if ("toString".equals(methodName) && params.length == 0) { return true; } if ("hashCode".equals(methodName) && params.length == 0) { return true; } if ("equals".equals(methodName) && params.length == 1) { return true; } retu...
21103dc4-2db3-417d-bbe2-8b4e74ef5cb0
1
public void setupDebugFile() throws IOException { if(debug) { cleanLog(); FileWriter write = new FileWriter(System.getProperty("user.dir") + "/" + debugFile + ".txt", true); PrintWriter print_line = new PrintWriter(write); print_line.prin...
0ef78206-d266-4b6f-8fe8-188e7fd78bc8
4
@Override public URI getIdentity() { ContextKey contextKey = getContextKey(); if (contextKey == null && get() == null) { return NSpace.NEPTICAL_SYSTEM_SPACE.getIdentity(); } if (getContextKey() == null) { return get().getLocation().getResourceIdentity(); } try { return new URI(getCont...
d00f8d69-6d95-4b5f-a442-974ac5ff3ec5
8
private static void ArrayMenu (Array<Integer> Array){ System.out.println("\nWhat do you want to do ?"); System.out.println(" 1) Insert"); System.out.println(" 2) Search"); System.out.println(" 3) Delete"); System.out.println(" 4) Print"); System.out.println("Enter your option and hit enter: (from 1 to 4)");...
82428d08-7dbe-429c-8e67-4ce276bd1c39
1
public void clearCounts(int[] counts) { for (int i = 0; i < counts.length; i++) { counts[i] = 0; } }
e277c9af-0a9a-46ad-8c27-f14575286ca8
4
@Override public void save(Administratie admin) throws IOException { if (!isCorrectlyConfigured()) { throw new RuntimeException("Serialization mediator isn't initialized correctly."); } // todo opgave 2 ObjectOutputStream out = null; FileOutputStream stream = nul...
136cb3c4-13d1-4989-bf92-ae9f7f4ae5a9
8
protected boolean canFallFrom(Room fromHere, int direction) { if((fromHere==null)||(direction<0)||(direction>=Directions.NUM_DIRECTIONS())) return false; final Room toHere=fromHere.getRoomInDir(direction); if((toHere==null) ||(fromHere.getExitInDir(direction)==null) ||(!fromHere.getExitInDir(direction).i...
04178b6b-7caa-4c63-823b-a45127bc3be2
1
public String next() throws Exception { if (!tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(reader.readLine().trim()); return next(); } return tokenizer.nextToken(); }
19f65fd9-51a6-4caa-9761-c6d35f4bb7c3
8
public boolean setColumn(int fromX, int fromY, int whichStep) { boolean ret = false; for (int i = fromY; i < 8; i++) { if(getField(fromX,i).isNotVisited()){ setValueOfField(fromX, i, whichStep); } if(!getField(fromX,i).isNotBlocked()){ break; } if(getField(fromX,i).isEndField() == true){ ...
024691aa-cb40-482f-bd4a-abfbbc3f34da
8
public EulerMain() { setTitle("projecteuler.net"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 640, 480); cl = new CardLayout(); cardList = new ArrayList<JPanel>(); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnEuler10 = new JMenu("Euler Problem 1-10")...
f3e59554-1bc3-4704-8f91-9468d3227010
2
public BlockCloudEntity(int width, int elements, Sprite blockSprite) { super(); blocks = new ArrayList<BlockEntity>(elements); int x = 0; int y = 0; for (int el = elements; el >= 0; el--){ blocks.add(new BlockEntity(x, y, blockSprite)); x += blockSprite.ge...
645554ae-092c-4198-ad48-773943a1a953
3
public static boolean errorCheck(String s, int startingParenLoc) { // error checking if (s == null) return true; // null object passed else if (s.length() <= 1) return true; // cant possibly have an open and a close else if (s.charAt(startingParenLoc) != '(') return true; // starting location is off. ...
ae12815c-0c0d-4b9b-a3dd-ffbfcc926170
0
public String getComposition() { return composition; }
7d825783-85c6-4c98-a1c6-5038c45f32a8
1
public static void SendButton() { if (!messageField.getText().equals("")) { chatClient.Send(messageField.getText()); messageField.requestFocus(); } }
91beabb3-b925-4148-97b5-50f82f9a800f
7
@Override public void giveI3MudList(MOB mob) { if((mob==null)||(!i3online())) return; if(mob.isMonster()) return; final StringBuffer buf=new StringBuffer("\n\rI3 Mud List:\n\r"); int col1Width=CMLib.lister().fixColWidth(25, mob); int col2Width=CMLib.lister().fixColWidth(25, mob); List<I3Mud> muds =...
b47c28b6-f9f2-47a2-9679-85ad6c9ac77c
6
private final void setLeaves() { if (daughterNodes.size() > 0) for (Node n : daughterNodes) n.setLeaves(); else { isLeaf = true; for (Point p : leafLocations) if (p.x == (int) x && p.y == (int) y) isLeaf = false; if ...
8be20498-bbb4-4366-b38d-d2ad47cb050d
4
public void saveColumnWidth() { try { //get the widths of any cell that is shown for(int i=0; i < isColumnShow.length ;i++) { if(isColumnShow[i]) { columnWidths[i] = browseTable.getColumn(browseHeader[i]).getWidth(); } } } catch (IllegalArgumentException e) { //fallback values will acti...
86229125-f6c4-400f-a5aa-d27f59627ebf
6
public boolean growPotatoes(Player player, String[] args, int radius) { Block playerCenter = player.getLocation().getBlock(); // Get Centrepoint (Player) int Potatoes = 0; for (int x = -radius; x < radius; x++) { for (int y = -radius; y < radius; y++) { for (int z = -radius; z < radiu...
9c527253-83f8-430d-abc1-09c55f8a20ac
1
@Test //@Req(id=1004) public void testTableLayout() throws Exception { CSTable t = DataIO.table(r, "Olaf"); Assert.assertNotNull(t); Assert.assertEquals(2, t.getColumnCount()); int rows = 0; for (String[] row : t.rows()) { rows++; Assert.assertEqua...
d49aa0dd-ee70-4b0d-9f95-1fa301d2db78
7
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Pessoa other = (Pessoa) obj; if (this.id != other.id) { return false; } if (!...
6f8ff094-aa0a-4b41-8786-fee639167899
0
public void setExtension(String extension) { this.extension.set(extension); }
a36454a8-b9ec-44cb-845c-d431da7c0fb8
8
public static void main(String[] args){ int count = 0; for(int p200 = 0; p200 <= 1; p200++) { for(int p100 = 0; p100 <= 2; p100++) { for(int p50 = 0; p50 <= 4; p50++) { for(int p20 = 0; p20 <= 10; p20++) { for(int p10 = 0; p10 <= 20; p10++) { for(int p5 = 0; p5 <= 40; ...
a21b091c-9f46-4dc0-a39c-b1917cce84f8
5
public void attackEntity(DamageType type, float amount) { if(onAttack(type, amount) && hurtTime <= 0) { life-=amount*(1f/this.getArmorMultiplier()); hurtTime = 20; if(life <= 0.f && onDeath(type, amount)) { alive = false; ...
a7d06cba-4e25-4fce-a271-ec4f4afd4727
0
public PublisherThread(ActiveMQConnectionFactory factory, Vector<MessageAdaptor> messageSource, String topic) { this.factory = factory; this.messageSource = messageSource; this.topic = topic; }
510d4501-0f97-4238-9321-65da401fcbbc
7
public int count(int N, String[] L, String[] R){ StringBuilder sb = new StringBuilder(); for(int i=0; i<L.length; i++) sb.append(L[i]+" "); StringTokenizer stL = new StringTokenizer(sb.toString()); sb = new StringBuilder(); for(int i=0; i<R.length; i++) sb.append(R[i]+" "); ...
c0c9d0e9-1a69-4457-aa48-22d5112c7903
5
public static void loadTiles(final ScrabbleBoard board, final File file) { board.clear(); if (file.exists() && file.getName().contains(".game")) { try (BufferedReader br = new BufferedReader(new FileReader(file))) { String line; while ((line = br.readLine()) !...
53ea99fd-9b2c-4f72-b69d-2416e33aa798
9
private static EntropyEncoder getEncoder(String name, OutputBitStream obs) { switch(name) { case "FPAQ": case "CM": case "PAQ": case "TPAQ": return new BinaryEntropyEncoder(obs, getPredictor(name)); case "HUFFMAN": ...
57607454-1069-494e-a28e-8d4cb9c4e77a
7
public List getSaveList() { ArrayList arraylist = new ArrayList(); File afile[] = savesDirectory.listFiles(); File afile1[] = afile; int i = afile1.length; for (int j = 0; j < i; j++) { File file = afile1[j]; if (!file.isDirectory()) ...
8c2a93e8-25ee-40d8-a7af-3c4c9ad83789
1
public Iterator iterator() { return new Iterator() { int pos = 0; public boolean hasNext() { return pos < count; } public Object next() { return locals[pos++]; } public void remove() { if (pos < count) System.arraycopy(locals, pos, locals, pos - 1, count - pos); count--; ...
bc16ab46-8223-4619-bc6c-4ebe3ffe9c34
7
Object look(DspState vd, InfoMode vm, Object vr){ InfoResidue0 info=(InfoResidue0)vr; LookResidue0 look=new LookResidue0(); int acc=0; int dim; int maxstage=0; look.info=info; look.map=vm.mapping; look.parts=info.partitions; look.fullbooks=vd.fullbooks; look.phrasebook=vd.fullbo...
5de0d163-39ff-4e61-bcf5-350e620bddb8
4
private int compute( String s1, String s2, String op ) { int a = Integer.parseInt(s1); int b = Integer.parseInt(s2); int ret = 0; switch (op) { case "+": ret = a + b; break; case "-": ret = a - b; break; case "*": ret = a * b; break; case "/": ret = a / b; break; default...
cd312ddb-2527-462c-b142-9956e5a3f476
7
private static String decodeCPT(final short id) { switch (id) { case (short)0x0000: return "UCMM"; case (short)0x00A1: return "connection based"; case (short)0x8000: return "sockaddr, orig->tgt."; case (short)0x8001: return "sockaddr, tgt.->orig"; ...
1dc6a881-29a2-4ffa-aca0-e9b7a994eb4a
7
@Override public void mouseExited(MouseEvent e) { if(e.getSource().equals(btnStation) || e.getSource().equals(btnSortCentreEntrance) || e.getSource().equals(btnSortCentreExit) || e.getSource().equals(btnJunctionPoint) || e.getSource().equals(btnConveyor)) { if(!m_currentlyAdding) ...
21225efb-fcd7-4c1f-9936-476448337366
3
public ListNode reverseKGroup(ListNode head, int k) { ListNode newHead = new ListNode(-1); ListNode node = newHead; node.next = head; // 防止 {1} ,2 这种情况 Stack<ListNode> s = new Stack<ListNode>(); while(head != null){ s.push(head); head = head.next; ...
8a1a069c-e6cf-49f8-8dc8-5667485362ef
9
@Test public void test_diffuse_severalDiffusions_unevenResources_shouldNotLoseResources() { int numTrials = 5; for (int trial = 0; trial < numTrials; trial += 1) { // Populate the world evenly with resources. Map<WorldResource, Integer> resourcesAtEachPosition = populateWorldWithRandomButUniformResources(...
b90bcf11-cea6-471e-8e10-7d8af054920b
1
public void printRand(){ int a = 0; while(a < 25){ System.out.println(randlist[a]); a++; } }
0369c317-2ff0-4f94-a76e-49724581c9c1
3
public void setPriceCode(int arg) { switch (arg) { case REGULAR: price = new RegularPrice(); break; case CHILDREN: price = new ChildrenPrice(); break; case NEW_RELEASE: price = new NewReleasePrice...
dcc10e69-2d81-49fa-8d2e-41453813827c
9
public void setValueAt(Object valor, int indiceLinha, int indiceColuna) { //Obtém o objeto em questão, para alteração, de acordo com o índice de linha recebido Parada Parada = linhas.get(indiceLinha); if (indiceColuna == 0){ Parada.setInicio((String)valor...
5c0647b9-9170-4ce3-a05b-1b10c234b8d4
0
public void setTxtCp(JTextField txtCp) { this.txtCp = txtCp; }
8f02e6b0-2d1a-4bae-bcd2-510c094aa9c8
0
@Id @Column(name = "session_id") public String getSessionId() { return sessionId; }
dfb385c7-490b-4f57-b898-2630eac90a85
4
public String[] ReadVulnerabilityData(String TargetPHPFileSelectedComboBox) { String[] VulnerabilityData = null; int count = 0; PreparedStatement ps = null; ResultSet rs = null; // Adapted from http://developers.sun.com/docs/javadb/10.2.2/ref/rrefclob.html try { ...
df572d03-859e-40b6-aa98-7f782769ad0d
6
public void render(float xOffset, float yOffset) { for (Tile[] _t : tiles) { for (Tile t : _t) { if (t != null) { Rectangle rec = null; boolean render = false; if (clippingArea != null) { rec = new Rectangle( (int) (t.getPosition().getX() + xOffset), (int) (t.getPosition()....
5670e055-0e1f-4b70-971c-0b0d4054511f
3
public void keyPressed(KeyEvent evt) { keyCode = evt.getKeyCode(); if (keyCode == KeyEvent.VK_A) { e.teleportEntity( e.findEntityGlobal(1), new Node(100,100) ); } else if (keyCode == KeyEvent.VK_S) { e.teleportEntity( e.findEntityGlobal(1)...
c9f41687-8a26-45c8-b2d5-010e39e639b9
2
public String join(String separator) throws JSONException { int len = this.length(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < len; i += 1) { if (i > 0) { sb.append(separator); } sb.append(JSONObject.valueToString(this.myArrayL...
648b0f53-2cc2-495b-a815-5e326ccc14ae
5
public String execute(JavaService js) { if(Model.getElectionOptions() == null) { return "Cannot count before options has been loaded."; } if (args.length < 2) { return invalidArguments; } long[] votes; switch (args[1]) { // adds the personal votes to the party votes case "sum": votes = cou...
c53b3e0a-101d-4ef9-b716-c049509f5043
9
private boolean doesIntersectInternal(AbstractLineSegment other) { final double d1 = direction(other.getP1(), other.getP2(), this.getP1()); final double d2 = direction(other.getP1(), other.getP2(), this.getP2()); final double d3 = direction(this.getP1(), this.getP2(), other.getP1()); final double d4 = direction...
009aaa00-eadc-47e0-8f80-9123015bafd4
4
public void updateCosts(PathProposal newPath, List<GeoRef> convexHull) { //Check if we destroyed the edge of this point if (mPath.getInsertionIndex() == newPath.getInsertionIndex()) { mPath = null; obtainPath(convexHull); } else { // We haven't destroyed the e...
3c99054e-2c09-4994-ba10-839d02cbdd3e
7
public byte[] readMemory(final Destination dst, final int startAddr, final int bytes) throws KNXTimeoutException, KNXDisconnectException, KNXRemoteException, KNXLinkClosedException, InterruptedException { if (startAddr < 0 || startAddr > 0xFFFF || bytes < 1 || bytes > 63) throw new KNXIllegalArgumentException...
0d6e4ad9-b10b-4be8-8d72-94d13943159a
8
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final UnitOfMeasure other = (UnitOfMeasure) obj; if (this.id != other.id && (this.id ...
4a276d0c-8485-435a-97fb-d6f1b4bfdf5e
8
public static boolean landedOn(UserData one, UserData two) { Box2DPhysics p1 = one.getEntity().getExtends(Box2DPhysics.class); Box2DPhysics p2 = two.getEntity().getExtends(Box2DPhysics.class); if(p1 == null || p2 == null) return false; float z1 = p1.getPosition().z; float z2 = p2.getPosition().z; f...
1af366b1-9ee6-42ab-9099-c25a8ede45a2
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
02f7f06b-2fa0-411f-a88f-cf33625f8fdd
9
@Override public void spring(MOB target) { if((target!=invoker())&&(target.location()!=null)) { final boolean ok=((invoker()!=null)&&(invoker().location()!=null)); if((!ok)||(doesSaveVsTraps(target))) target.location().show(target,null,null,CMMsg.MASK_ALWAYS|CMMsg.MSG_NOISE,L("<S-NAME> foil(s) a trap on...
32c132ea-643a-4a20-a025-e58948d9ddb6
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
701b7438-ab84-4a49-86c9-533380ec52a9
1
private void handleUserIsAwayResponse(String response) { String[] parts = response.split(" ", 3); String reason = parts[2].substring(1); PrivateMessagingListener listener = getPrivateMessagingListener(parts[1]); if (listener != null) listener.userIsAway(reason); }
d14924d5-a49a-4ba4-ba9e-8bdd15665b7d
8
protected boolean handleOnChannelEvents(Type t, IRCEvent e) { // things that happen TO a channel if (Type.KICK_EVENT.equals(t)) { handleKickEvent((KickEvent) e); return true; } if (Type.MODE_EVENT.equals(t)) { handleModeEvent((ModeE...
1c250318-e2f4-4370-b724-075fa5a7e4ad
4
@Override public ValueType returnedType(ValueType... types) throws Exception { // Check the number of argument if (types.length == 1) { // if array if (types[0] == ValueType.NONE) { return ValueType.NONE; } // If numerical if (types[0].isNumeric()) { return ValueType.DOUBLE; } // if ...
eda854c6-391f-47bf-ad3a-f678bef4b5d5
1
public void setFinal(final boolean flag) { int modifiers = classInfo.modifiers(); if (flag) { modifiers |= Modifiers.FINAL; } else { modifiers &= ~Modifiers.FINAL; } classInfo.setModifiers(modifiers); this.setDirty(true); }
e8366498-e949-41d5-ae95-ad82b4e6f2d3
4
public static void movePlayer(Client c) { if (Region.getClipping(c.getX() - 1, c.getY(), c.heightLevel, -1, 0)) { c.getPA().movePlayer(c.absX+1, c.absY, 0); } else if (Region.getClipping(c.getX() + 1, c.getY(), c.heightLevel, 1, 0)) { c.getPA().movePlayer(c.absX-1, c.absY, 0); } else if (Region.getClipping(...
4f80bd0f-1c86-4d98-9b7f-ec0e2209d222
6
@Test /** * This does not test the distribution, but if we belive in the random generators * it tests the "border values" in that all possible values must be generated */ public void testGetRandomQuestion() { int testTries = 30; boolean horseFound = false; boolean houseFound = false; bool...
ceac71db-3875-4253-8c06-5de5cd5c894d
8
private final int method2845(int i, Class348_Sub43 class348_sub43) { try { if (i != 0) anInt8956 = 53; anInt8934++; int i_30_ = (((Class348_Sub43) class348_sub43).anInt7080 - -((((Class348_Sub43) class348_sub43).anInt7072 * ((Class348_Sub43) class348_sub43).anInt7089) >> -19744216...
6a26ffa0-a1d4-43c6-9bc7-c1269605218d
2
public final String getPackageRoot() { StringBuffer buff = new StringBuffer(); JavaFile jf = null; try { jf = fileManager.getFile( this.getCurrentFilename() ); } catch ( IOException e ) { e.printStackTrace(); return null; ...
c360e20b-05e4-4d2b-8ed7-c4cfefa8347a
1
@Override public void move(Direction direction) { Position currentPos = getGrid().getElementPosition(this); getGrid().moveElement(this, direction); Position newPos = getGrid().getElementPosition(this); if (currentPos.equals(newPos)) throw new IllegalArgumentException("The element can't move in the chosen d...
7fe98113-4cd9-47ff-8061-e954d56ffc7a
9
private int startWith(int n, ArrayList<Candy> t0, ArrayList<Candy> t1){ int cnt = 0; int curr = 0; int last = n; while(true){ curr = cnt; int chosen = -1; if(last == 0){ for(int i=0;i<t0.size();i++){ if(x>=t0.get(i).h){ chosen = i; break; } } if(chosen >= 0){ ...
d86a3f92-6eac-4e00-be70-b7de877b307e
7
public void chat(ChatPlayer player, String line, String channel) { ChatChannel chan = ChannelManager.getChannel(PlayerManager.getPlayer(player).channel); if (channel == null || channel.length() <= 0) channel = chan.name; else chan = ChannelManager.getChannel(channel); if (MCNSAChat3.permissions.getUser(p...
e8395fbd-4baf-41f4-a8b5-a29ef0238222
6
public int removeDuplicates(int[] A) { if (A.length == 0) return 0; int n = 0; for (int i = 0; i < A.length; i++) { int num = A[n]; while (i<A.length && A[i]==num){ i++; } if (i<A.length && A[i]!=num){ n = n+1; A[n] = A[i]; } } return n+1; }