method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
c3b2663f-05cf-414d-ba83-2eb39fe1b9fb
3
public void restore(List<mxCellState> snapshot) { mxGraph graph = graphComponent.getGraph(); Iterator<mxCellState> it = snapshot.iterator(); while (it.hasNext()) { mxCellState state = it.next(); mxCellState orig = graph.getView().getState(state.getCell()); if (orig != null && orig != state) { ...
b730c9e5-3317-4b77-8506-73fac2de08be
8
public int compare(String o1, String o2) { String s1 = (String)o1; String s2 = (String)o2; int thisMarker = 0; int thatMarker = 0; int s1Length = s1.length(); int s2Length = s2.length(); while (thisMarker < s1Length && thatMarker < s2Length) { ...
8f2b2c47-0802-4ee4-b248-facabf707001
0
public MultiLineToolTipUI() { super(); }
27c72600-ec96-467f-a4dd-dd49265f9feb
3
private void populateEntity() { enemys = new ArrayList<Enemy>(); entities = new ArrayList<EntitySpecial>(); Slugger s; Crawler s2; Blocker s3; Point[] points = new Point[] { new Point(50, 200), new Point(1260, 140), new Point(2175, 200), new Point(2300, 200) }; Point[] points2 = new Point[] { new Point(63...
52f197cb-67e0-4e78-949e-8bad41f70739
2
public int getUnreadedMessage(){ int num=0; String requete = "select count(*) from message where `Read`=0 AND `Reciever`='Admin'"; try { Statement statement = MyConnection.getInstance() .createStatement(); ResultSet resultat...
bb6756f0-87b5-4b39-8b86-70c1267908bf
3
public void jouerUnePartie(){ while(!joueur1.perdu() && !joueur2.perdu()){ jouerUnTour(); } if(joueur1.perdu()){ System.out.println("\n" + joueur2.getNom() + " a gagne"); } else{ System.out.println("\n" + joueur1.getNom() + " a gagne"); ...
f98e777a-0cf2-44bd-8ffc-106340a6256d
5
@Override public boolean execute(final String sender, final String message, final IRCChannel channel) { final Player[] players = Bukkit.getServer().getOnlinePlayers(); final Vector<String> messages = new Vector<String>(); StringBuilder sb = new StringBuilder(); final int ...
f1832fa7-ef38-410c-bf6b-59f6f84cc03c
8
public String d2s(final double d) { if (Double.isNaN(d)) return nan; if (Double.isInfinite(d)) return (d < 0) ? ("-"+inf) : ("+"+inf); final long dr = Math.round(d); if (dr == d) return String.valueOf(dr); final double da = (d < 0) ? -d : d; if (da < limit) return "0"; String ds = nan; if (d...
9e714218-a52c-42a1-96fc-b4978278e581
2
private void addSprite(TileMap map, Sprite hostSprite, int tileX, int tileY) { if (hostSprite != null) { //set planet total power if planet //if the sprite is an instance of Planet, we are going to use the TileMap //function to create random planets ...
5eeb5d6f-dc67-4729-9074-1252cb8bed4e
8
private int getKingAxisVal(int loc) { switch(loc) { case 0: case 7: return -4; case 1: case 6: return -2; case 2: case 5: return 2; case 3: case 4: return 4; default: return 0; } }
ec4e5f6a-4d03-430c-9cc6-0468abac2df5
3
public static FloatingPoint getFloatingPoint(float fValue) { FloatingPoint floatingPoint = new FloatingPoint(); String original = String.valueOf(fValue); int dot = original.indexOf("."); int value = 0; int fraction = 0; int devide = 1; if (dot == -1) { value = Integer.parseInt(original); } else { ...
8690a10a-ad83-4a91-a254-dd728740b8be
9
private void respondToMapSelection(RambleOn game, int mouseX, int mouseY) { //GET THE MAP FOR THE CURRENT REGION BufferedImage img = dataManager.getCurrentMap(); //EXTRACT THE COLOR OF THE PIXEL AT THE x,y CORDINATES OF THE MOUSE CLICK int rgb = img.getRGB(mouseX, mouseY); Color ...
9df65086-ebae-42a9-8b57-6da104fb2743
8
void showColorForPixel(int x, int y) { if (x >= 0 && x < imageData.width && y >= 0 && y < imageData.height) { int pixel = imageData.getPixel(x, y); RGB rgb = imageData.palette.getRGB(pixel); boolean hasAlpha = false; int alphaValue = 0; if (imageData.alphaData != null && imageData.alphaData.length > 0)...
75839c84-838e-4ebc-8091-be9a9162277c
6
public static Repairs getNextRepairFor(Actor client, float priorityMod) { final World world = client.world() ; final Batch <Venue> toRepair = new Batch <Venue> () ; world.presences.sampleFromKeys( client, world, 10, toRepair, "damaged", Venue.class ) ; final Choice choice = new Choice(client) ...
421c8971-da3b-4342-85ef-90170aca88a7
6
@EventHandler public void CaveSpiderWither(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.getCaveSpiderConfig().getDouble("CaveSpi...
c9be7af1-08c8-47d6-ae9f-165c0fb1e264
8
private String executeCmd(Cmds cmd, String message, String author) { if(feeds.isEmpty()) return "No channels available"; switch(cmd) { case LIST: { String msg = ""; for(Feed f : feeds) msg += f.getName() + " "; ...
ba951238-7507-4a8e-a671-148af7fc74d6
2
public MoveAction(Movement movement, Grid grid) { if (movement == null) throw new IllegalArgumentException("The given movement is invalid!"); if (grid == null) throw new IllegalArgumentException("The given grid is invalid!"); this.grid = grid; this.movement = movement; }
cbbb8cc0-4609-40e4-8815-ac094b08f94c
9
public boolean valid(Vertice current) { Line l = Line.defineByPoints(current, new Point(current.getX().add(BigDecimal.ONE), current.getY())); LinkedList<Point> valid = new LinkedList<Point>(); for (Segment s : this) { Point p = l.intersects(s.getLine()); if (p != null && p.getX().compareT...
44d0750b-83bc-418d-9e0b-c0b440258d96
5
@Override public boolean save(float[][] quad, int size, String outputFile) { ByteBuffer buffer = ByteBuffer.allocate(4 * size * size + 4); buffer.putInt(size); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { buffer.putFloat(quad[i][j]); ...
d77ad77f-599f-41c1-a29a-abd16810b3b3
9
@Override public void parseXML(Document doc) { Element el = doc.getDocumentElement(); if (el.getNodeName().compareTo("INDI") != 0) { return; } NodeList nodes = el.getChildNodes(); for (int i = 0 ; i < nodes.getLength() ; i++) { Node n = nodes.item(i); if (n instanceof Element...
3cf97d6d-a0f5-48e1-bbcc-b6de03e74443
2
public ArrayList<PalavraChave> listar(String condicao) throws Exception { String sql = "SELECT * FROM palavrachave " + condicao; ArrayList<PalavraChave> listaPalavraChave = new ArrayList<PalavraChave>(); try { PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql); ResultSet rs ...
ba0c1734-d591-4a3d-a6e7-880b4373256a
4
@Override public void processFailureOfSnake(Player player, GameController controller) { if (player == null) { Player playerTwo = controller.getPlayerTwo(); Player playerOne = controller.getPlayerOne(); applyPenaltyToPlayer(playerOne); applyPenaltyToPlayer(playerTwo); if (playerOne.getLifesLeft()...
b0297c0f-67cd-4a50-a97b-b6fd171ec4e6
5
@Override protected void doAction(int option) { switch (option) { case 1: updateTitle(); break; case 2: updateArtist(); break; case 3: updateDuration(); break; ...
c54fe8c6-137d-444b-ad27-2876a73ec690
7
public OpdrachtVierTweeTwee() { // aantal iteraties per gebruiker final int MAX = 600; // maak aantal threads (gebruikers) aan for (int t = 0; t < 2; t++) { Thread thread = new Thread() { public void run() { // definieer de variabele voor ...
d188fdfa-9f20-4564-807a-881ba9f72ca8
5
public NpcDefinition method161() { int j = -1; if (varbitId != -1) { VarBit varBit = VarBit.cache[varbitId]; int configId = varBit.configId; int shift = varBit.anInt649; int amountBits = varBit.anInt650; int j1 = Client.anIntArray1232[amountBits - shift]; j = client.configStates[configId] >> shift...
06054a28-f61a-4af9-9dca-de3ae70776a2
9
public void bucketHelper(Color c) { Point p = q.pop(); Color curColor = colorArr[p.x][p.y]; if (curColor.equals(c)) { return; } addDelta(p.x, p.y, c); colorArr[p.x][p.y] = c; if (p.x > 0 && curColor.equals(colorArr[p.x - 1][p.y])) { q.push...
928fb551-06f8-4db2-9fa9-80804a0f75a4
8
private static String[] parseArgumentOptions(String variant) { //Will be converted to an array and returned at the end List<String> options = new ArrayList<String>(); //This is one of the options that is added to the options list when it is completed. StringBuilder wordInTheMaking = new StringBuilder(); ...
6e67b768-3824-4694-a759-17fa6f4b2dbd
1
static void loadJdbcDriver() { try { Class.forName("org.sqlite.JDBC"); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
8851eb2f-6ba9-4933-9e04-1be0671dfff6
4
public Node34(Node23 node, Key key, Value value) throws DuplicateKeyException { int cmp1 = key.compareTo(node.key1); int cmp2 = key.compareTo(node.key2); if (cmp1 < 0) { this.key1 = key; this.value1 = value; this.key2 = node.key1; this.value2 = node.value1; this.key3 = node.key2; t...
c7eb634d-8fe7-48c7-861d-59554012bd3b
7
public MediaWiki endUserGroupModification(final MediaWiki.UserGroupsToken userRightsToken, final Collection<String> add, final Collection<String> remove, final String reason) throws IOException, MediaWiki.MediaWikiException { final Map<String, String> getParams = paramValuesToMap("action", "userrights", "format", "xm...
95f67974-1a16-40a2-bc7c-39ca931309d9
4
public void printMatrix() { int m=this.matrix.length; int n=this.matrix[0].length; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { if(this.matrix[i][j]!=null) { System.out.print("["+i+"]["+j+"]"+this.matrix[i][j]); if(j==n-1) { System.out.println("\n"); } ...
cca084d2-2d88-4132-9b9b-6faf047c5723
5
public boolean resolve(String domain) { if (domain == null || domain.isEmpty()) return false; try { addr = Address.getByName(domain); logger.info("Start querying DNS."); Lookup lookUpAgent = new Lookup(domain, Type.ANY); // Print the DNS server used by dnsjava resolvers = ResolverConfig.getCurr...
8aa5649a-0d94-44d3-baa3-67411eda723d
2
private void initMatrixb() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { matrixb[i][j] = false; } } }
6564212c-b8fa-4867-8ad9-cb348989792b
0
public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub }
1e7ca35f-7fe1-4625-9efd-deccd1d79cbf
8
public List<String> wordBreak(String s, Set<String> dict) { List<String> ret = new ArrayList<String>(); if (s == null || s.length() == 0) { return ret; } int n = s.length(); //because check the subString of String word, position 0 must be true boolean[] dp ...
1d792c94-c08a-4a82-bffa-7ecf6d514493
3
private boolean one_byte_size_ready () { int size = tmpbuf [0]; if (size < 0) size = (0xff) & size; // Message size must not exceed the maximum allowed size. if (maxmsgsize >= 0) if (size > maxmsgsize) { decoding_error (); ...
f21be671-7a3e-4a4d-b142-bc05199a641e
4
public ArrayList<Flight> morningDepartingFlights(String departureAirport) { ArrayList<Flight> morningFlights = new ArrayList<Flight>(); for (int i = 0; i < flights.size(); i++) { if (flights.get(i).getDepartureAirport().equals(departureAirport) && Integer.valueOf(flights.get(i).getDepartureTime()) >= 0 ...
c043af8e-e230-455a-a96e-0ad33640c496
3
@Override public void render() { if(world != null) { world.render(); } /*ray = new Edge(new Vector(light.x, light.y), world.getRayEnd(light, new Vector(world.offsetX + Mouse.getX(), world.offsetY + height - Mouse.getY()), world.sizeX * Tile.SIZE, world.sizeY * Tile.SIZE)); intersection = world.getRayInterse...
104ecadd-700e-4620-808c-c12499f95c88
2
@Override void write(DataOutput dataoutput) { try { dataoutput.writeInt(this.data.length); for (int i = 0; i < this.data.length; ++i) { dataoutput.writeInt(this.data[i]); } } catch (IOException e) { throw new NBTWriteException(e); ...
4e2ab502-d999-4b4e-8244-dc0438eb5b1b
8
private Set<ICard> createSet(Set<ICard> allCards, Set<IConstraint> constraints, boolean randomize){ Set<ICard> goodCards = new HashSet<ICard>(); int size = allCards.size(); int tryCount=0,rand=size; int[] alreadyCheckedCards = new int[size*size*size*2]; ICard[] allCardsArray = new ICard[size*size]; allCa...
f1717f7a-fc5f-44b3-b5a8-bc4fc59d2e77
7
@Override public void init(ServletConfig config) throws ServletException { super.init(config); String memcacheClass = config.getInitParameter("memcache.provider.class"); if (memcacheClass == null) { memCache = new LocalMemCache(); log("Initialized memory cache provid...
60815cd4-9ac0-48a8-a42b-bd30a127ffa1
4
@SuppressWarnings("serial") public DataTable(final Object[][] data, Object[] head) { super(new DefaultTableModel(data, head) { public Class<?> getColumnClass(int column) { if (data.length > 0 && column < getRowCount() && getValueAt(0, column) != null) return getValueAt(0, column).getClass(); re...
74d6485d-162c-48e4-8312-129ab3b98bee
6
public void obliviousSend(int sendTo, BigInteger M_0, BigInteger M_1) { System.out.println("Oblivious Transfer"); // Hard coded messages M_0 and M_1 BigInteger[] M = new BigInteger[2]; M[0] = M_0; M[1] = M_1; if (betray) { M[1] = M[0]; } // Hard coded ElGamal BigInteger p_A ...
12e557a5-30d2-475d-aa98-40fe19781820
9
@Override public int castingQuality(MOB mob, Physical target) { if(mob!=null) { if(!helpfulAbilityFound(mob)) return Ability.QUALITY_INDIFFERENT; final Room R=mob.location(); if(R!=null) { if(((R.domainType()&Room.INDOORS)>0)) return Ability.QUALITY_INDIFFERENT; if((R.domainType()==Ro...
6b6cd071-0217-4c6e-bf6b-8610ff57c157
3
private void doAction(Action actionToDo) { try { if (!objectTron.isFinished()) objectTron.activePlayerDoAction(actionToDo); } catch (InvalidActionException e) { System.out.println(objectTron.getActivePlayer().getPosition().toString());; showError(e.getClass().getSimpleName() , e.getMessage()); } ...
41aad81a-9517-4b84-ba17-3ba4838cfd1c
0
public static void main(String[] args) { System.out.println(Utils.getWebRoot()); }
33f54583-0257-49b3-96a3-2bc4107c4fd7
5
private boolean isDualFeasible(double[][] A, double[] c) { double[] y = dual(); // check that y >= 0 for (int i = 0; i < y.length; i++) { if (y[i] < 0.0) { StdOut.println("y[" + i + "] = " + y[i] + " is negative"); return false; } ...
01945481-5354-4aef-9b3f-af2b75e07578
9
public int compare(Integer i, Integer j) { String cs = mText; for (int m = i, n = j, k = 0; k < mMaxSuffixLength; ++m, ++n, ++k) { if (m == cs.length() || cs.charAt(m) == SEPARATOR) { if (n == cs.length() || cs.charAt(n) == SEPARATOR) r...
03e41929-edfe-412b-a927-c2907835699d
8
public void sendBlockRemoving(int var1, int var2, int var3, int var4) { if(this.blockHitWait > 0) { --this.blockHitWait; } else { if(var1 == this.curBlockX && var2 == this.curBlockY && var3 == this.curBlockZ) { int var5 = this.mc.theWorld.getBlockId(var1, var2, var3); ...
2850cea4-2f97-4def-a374-905d625b946f
6
private Float executeCommand(String commandLine) throws ATMException { // Break out the command line into String[] StringTokenizer tokenizer = new StringTokenizer(commandLine); String commandAndParam[] = new String[tokenizer.countTokens()]; int index = 0; while(tokenizer.hasMoreTokens()) { commandAndParam[...
9a0e9d79-ec5a-4b9c-acb2-2c8af2272b93
8
public static StackTraceElement getMarkedPoint(Class<?> clazz, String methodName) { mark = true; try { Method method = clazz.getDeclaredMethod(methodName); method.setAccessible(true); method.invoke(clazz.newInstance()); } catch (IllegalArgumentException e) { throw new IllegalStateException(e); } cat...
211ff049-a157-46a9-85f5-23cace76b77f
4
private void checkPluginDataDir() { log.debug("Checking plugin data directory " + this.getDataFolder()); File dir = this.getDataFolder(); if (!dir.isDirectory()) { log.debug("Isn't a directory"); if (!dir.mkdir()) { log.severe("Couldn't create plugin data directory " + this.getDataFolder()); return;...
b248bce8-16ec-436b-9a9c-cae0b045bbfc
7
@Override public Object[] importCells(Object[] cells, double dx, double dy, Object target, Point location) { if (target == null && cells.length == 1 && location != null) { target = getCellAt(location.x, location.y); if (target instanceof mxICell && cells[0] instanceof mxICell) { mxICell ...
448b8473-b775-4fa3-a9a5-8cca97ae7ced
0
public void setOriginal() { isOriginal = true; }
63c9861e-9f9f-498f-b017-c1e2cc17b649
9
public void run(){ try { //servidor System.err.println("\t\t\t\tServer started"); Random generator = new Random(); ProtocoloTCP p = new ProtocoloTCP(syn.getAddress().getHostAddress(), syn.getPort(), generator....
aa28aa86-4004-4df8-95a4-6618955932e9
3
static boolean array_equals(byte[] foo, byte bar[]){ int i=foo.length; if(i!=bar.length) return false; for(int j=0; j<i; j++){ if(foo[j]!=bar[j]) return false; } //try{while(true){i--; if(foo[i]!=bar[i])return false;}}catch(Exception e){} return true; }
74c0eeec-a7f4-4d7b-b1fd-26f338357e85
0
@Override public PermissionType getType() { return PermissionType.OP; }
a1fbbdbc-83d3-43f2-8a74-49f289565eef
1
@Override public void sortedStructure() { for (int i = 0; i < data.kitSize(); i++){ Arrays.sort((Integer[]) data.getFromKit(i)); } data.setState("Sorted"); }
6db1df5c-ede5-4d5f-a6c2-2033a350ab0b
9
public static java.util.Date[] toArrayOfDate(Collection collection) { if(collection == null || collection.size() == 0) return new java.util.Date[0]; java.util.Date[] aResult = new java.util.Date[collection.size()]; int i = 0; Iterator iterator = collection.iterator(); while(iterator.hasNext()) { Object o...
c4107614-22cf-4f84-81f7-5c73027d8548
1
private GameGraphic[] convertToGameGraphicArray(String name, BufferedImage[] bufferedImages) { GameGraphic[] gameGraphicArray = new GameGraphic[bufferedImages.length]; int i = 0; for(BufferedImage bufferedImage : bufferedImages){ gameGraphicArray[i++] = new GameGraphic(Helpers.concat(name, "#", i), buffere...
2298230d-e642-4c08-b5c2-ab6b0fb0f430
6
public void personDetailsForm() { // Initially clear the text fields name = null; email = null; contactNumber = null; address = null; errorMessage = ""; // Name field if (!nameField.getText().equals("")) { name = nameField.getText(); nameLabel.setForeground(Color.black); } else { errorMes...
0e290390-9810-4b9b-9995-3651fc5a9fdb
3
private int obtenerTipoPaquete() { if (rbPaqBasico.isSelected()) { return paqueteBasico; } if (rbPaqIntermedio.isSelected()) { return paqueteIntermedio; } if (rbPaqCompleto.isSelected()) { return paqueteCompleto; } //Si llega ha...
9002ffc1-09f3-49ee-b893-842ae4369446
9
@Override public void execute(Runnable r) { try { if(this.getQueue().contains(r)) return; super.execute(r); if((rejectCount>0)&&(System.currentTimeMillis()-lastRejectTime)>5000) { Log.warnOut(rejectCount+" Pool_"+poolName,"Threads rejected."); rejectCount=0; } } catch(final Rejected...
3ce61ab7-dd93-4d0e-a1ab-e8d84a3d2528
7
private void createCryptolexo() { // use random words from the WordList if words aren't set if(words == null) { words = WordList.getWords(nwords, Math.max(N,M)); } Arrays.sort(words, new CompareStringLength()); int w = 0; while(w<nwords) { ...
ae1c06fc-0979-4035-90cc-8a780f9cbcd7
8
private void updateCreature(Creature creature, long elapsedTime) { // apply gravity if (!creature.isFlying()) { creature.setVelocityY(creature.getVelocityY() + GRAVITY * elapsedTime); } // change x float dx = creature.getVelocityX(); ...
6025ff0b-61da-4c18-922e-6fcff14ab0fb
4
public synchronized void gridletMove(int gridletId, int userId, int destId, boolean ack) { // cancel the Gridlet first ResGridlet rgl = cancel(gridletId, userId); // If no found then print an error msg if (rgl == null) { System.out.println(super.resName_ + ...
3b4c8623-fa60-425c-90d4-4eb5e1e07456
5
public void update(float dt){ if(!resetType.equals(ResetType.NEVER)) time+=dt; position(); if(resetType.equals(ResetType.ON_TIME) && time>=resetTime){ owner.resetState(); } else { if(!finished){ if(main!=null) act(dt); else this.main = owner.main; }else owner.resetState(); ...
d537175a-56f7-48c0-9344-96b39ffa4649
4
public int comando(String args[]) { String ret = ""; int exitVal = -1; try { String osName = System.getProperty("os.name" ); String[] cmd = new String[2 + args.length]; if( osName.equals( "Windows NT" ) ) { ...
5f6ff45d-51b6-4326-ad5a-fe7f085659bb
5
@Override public void run() { while (true) { Service<?, ?> service; try { service = waiting.take(); } catch (Exception e) { continue; } if (service.setup()) { System.out.println("\t-> Successfully registered " + service.getClass().getSimpleName()); } servicer.sch...
61e116f0-8b93-4cce-9e4d-278163e5bacc
9
public void valueChanged(ListSelectionEvent e) { switch( searJ.getMinSelectionIndex() ) { case 0: inpGtria.setText("6\n") ; inpGtria.append("1 2 -3 -1 5 6\n") ; inpGtria.append("4 -5 3 -4 -2 -...
61d8f002-e6e6-4776-ae70-a9ef3162cd3b
6
public List<String> produceEmails2(){ List<String> emails2 = new ArrayList<String>(); try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException e) { System.out.println("Where is your MySQL JDBC Driver?"); e.printStackTrace(); } ...
ea16eb54-7655-41dc-a10f-4c3070bd86af
6
private void generateCorridors() { ArrayList<Integer> lstx = new ArrayList<Integer>(); ArrayList<Integer> lsty = new ArrayList<Integer>(); //all of this for loop is for checking if a room is there or not for (int x = 0; x < this.width; x++) { for (int y = 0; y < this.height; y++) { if (tiles[x][y].isGrou...
21ca7cf0-7df4-4f73-ac72-5b5e3e462a40
1
public Shader() { program = glCreateProgram(); uniforms = new HashMap<String, Integer>(); if (program == 0) { System.err.println("Shader Creation failed: Invalid memory location in constructor"); System.exit(-1); } }
13051418-6749-4ae3-81e7-a5923a78fc71
4
public void update(int deltaT) { if (transitioning) { float change = (float) deltaT / (float) SUNRISE_SET_LENGTH; if (isDay) { brightness -= change; } else { brightness += change; } if (timeSince < SUNRISE_SET_LENGTH) { timeSince += deltaT; } else { timeSince = 0; transitioni...
629a1762-d691-4892-aaf8-fcded5b781e0
9
void startEventLoop() { writeOutput("Type 'help' for a list of commands."); doNewGame(); while (true) { showBoard(); writeOutput(gameState.getCurrentPlayer() + "'s Move"); String input = getInput(); if (input == null) { break; // ...
2536d635-a6d9-4a1e-b249-bd218f1ec3a9
5
public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() >= 2) { zoomInAnimated(new Point(mouseCoords.x, mouseCoords.y)); } else if (e.getButton() == MouseEvent.BUTTON3 && e.getClickCount() >= 2) { zoomOutAnimated(new P...
823e8d5e-edfc-4c22-aa96-5e4c93478eba
2
public static void fliter(String s){ HashSet<Character> hs= new HashSet<>(); String temps=""; for(int i=0;i<s.length();i++) { if(!hs.contains(s.charAt(i))){ temps+=s.charAt(i); hs.add(s.charAt(i)); } } System.out.println(temps); }
be34bec0-d137-4a95-a036-2b64908223fd
3
@Override public void addToListaDeDesejos(UsuarioProduto usuarioProduto) { EntityManagerFactory factory = Persistence .createEntityManagerFactory("classeEncanto"); EntityManager em = beginTransaction(factory); Set<UsuarioProduto> listaDeDesejos = null; try { Usuario usuario = usuarioProduto.getUsua...
6866cd6c-0b6d-4037-844f-3207169b28b4
7
@EventHandler public void SkeletonWither(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.getZombieConfig().getDouble("Skeleton.With...
4325f0e4-1327-4f39-baa1-0f3708a5293b
3
private byte[] fillEightByte(byte[] rawByte){ int rawByteLength=rawByte.length; int byteamount=rawByteLength/8; //byte amount if(rawByteLength%8!=0){ byteamount=byteamount+1; } byte[] rawbytebyeightbyte=new byte[byteamount*8]; // for(int i=0;i<rawbytebyeightbyte.length;i++){ if(i+1>rawBy...
047ff84c-07cb-4e92-b59e-35bc2f7601b4
9
@Override public int open(String path, int flags, FuseOpenSetter openSetter) throws FuseException { try { EntityInfo entity = fileSystem.getFileMetaData(path); if (entity == null) System.err.println("Your file system returned null for getFileMetaData(" + path + ")"); boolean read = false; boo...
06dbd5df-8c75-4192-a0c7-ce4fb413f85b
7
private void trainTestPass(double[] inputs, double[] expected, double[] actual) { // Calculate the error. double[] errors = new double[actual.length]; for (int error = 0; error < actual.length; error++) { errors[error] = expected[error] - actual[error]; } ...
df5f184b-bd0d-4ba5-8624-845536d49e94
1
public void queryCorporations() throws SQLException { if (conn != null) { System.out.println("**********CORPORATIONS**********"); queryTable("crmcorporations"); System.out.println("**********CORPORATION-USER CONNECTIONS**********"); queryTable("crmcorporationuserconnection"); } }
a5ecdbe3-6373-4bf7-8ee5-bf406f64549a
3
public void setParameterTypes(Class<?>[] parameterTypes) { this.parameterTypes = parameterTypes == null ? new Class<?>[0] : parameterTypes; }
85ff57ee-3e12-4c1a-a47c-143fc9503b28
4
@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } Position other = (Position) obj; return this.x == other.x && this.y == other.y; }
51018c3f-e4f7-4d68-9517-f71806c85d39
0
public GameEvent(int points) { this.points = points; }
150cd306-16e5-4fc3-92a9-229f7fee5a9f
2
public double getEtxToNode(int nodeID) { Iterator<Edge> it2 = this.outgoingConnections.iterator(); EdgeOldBetHop e; while (it2.hasNext()) { e = (EdgeOldBetHop) it2.next(); if (e.endNode.ID == nodeID) return e.getEtx(); } return 0.0; }
aa4ffbab-01bc-4b52-96c9-710547927384
5
double smallestHumpTimeOfEmptyTrack(double pt){ double min = Double.MAX_VALUE; boolean empty = false; for(Track t : receivingTrack){ if(t.ifEmpty == true){ empty = true; if(pt >= t.humpTime) return pt; if(t.humpTime < min){ min = t.humpTime; } } } if(empty == true) return mi...
dc6357a0-5c72-4f5b-a55a-19b42d497464
7
@Override protected void buttonClicked(JButton button) { if (button == cancel) { ResizeModelFrame.this.setVisible(false); buttons[1][1].button.setSelected(true); } else if (button == execute) { int nw = 0, nh = 0; try { nw = Integer.parseInt(width.get...
404f5f23-0b7a-4aba-b962-43c4d1553d75
4
public set DeepCopy(set FirstSet, set SecondSet, int choice) { if (choice == 1) { for (int i = 0; i < FirstSet.stuff.size(); i++) { int item = FirstSet.stuff.get(i); SecondSet.stuff.add(item); } return SecondSet; } else if (choice == 2)...
b510f104-df53-43b7-ad3e-7629f4e756bb
4
public String get_plain_with_blank(String s) { String low_s=s.toLowerCase(); StringBuilder b=new StringBuilder(); for(char a:low_s.toCharArray()) { if(a==' ' || (a>='a' && a<='z')) { b.append(a); } } return b.toString(); }
8149b9e4-b396-47d7-84af-4db20dbfeb1c
2
private void siftUp(int pos) { if (pos == 0) return; if (heap.get(pos).compareTo(heap.get(pos / 2)) > 0) { swap(pos, pos / 2); siftUp(pos / 2); } }
81a5657b-d9d4-4b8b-b270-92b9ae65a143
3
public static void main(String[] args) { // Create an initial population Population myPop = new Population(50, true); // Evolve our population until we reach an optimum solution int generationCount = 0; int times = 0; int last = -1; while (myPop.getFittest().getFitness() <= FitnessCalc.getMaxFitness())...
67ef745e-c90e-4982-b602-44e1e9d2b582
4
protected Boardable[] pathBetween(Boardable initB, Boardable destB) { if (GameSettings.pathFree) { final Pathing search = new Pathing(initB, destB, -1) ; if (verbose && I.talkAbout == mobile) search.verbose = true ; search.client = mobile ; search.doSearch() ; return search.fullPath(Bo...
06f5503c-3c84-4770-a5e6-11ee5143fdb3
3
public static String trimSpaces(String text) { // Split the string into words: String[] splitText = seperateWords(text); // Make sure there are some words: if (splitText == null || splitText.length == 0) return ""; // Seperate each word by a single space: String parsedText = splitText[0]; for (int x ...
6d693871-25bd-4837-ae6c-5d579daa4f8e
5
public int getSelection() { if(selectionOvalY == 94) return 1; else if(selectionOvalY == 114) return 2; else if(selectionOvalY == 134) return 3; else if(selectionOvalY == 154) return 4; else if(selectionOvalY == 174) return 5; return 0; }
318984a7-7afd-4c85-b4b9-01689ecc6618
7
public void centerVertical(FastVector nodes) { // update undo stack if (m_bNeedsUndoAction) { addUndoAction(new centerVerticalAction(nodes)); } int nMinX = -1; int nMaxX = -1; for (int iNode = 0; iNode < nodes.size(); iNode++) { int nX = getPositionX((Integer) nodes.elementAt(iNode)); if (nX < nMin...
f1e91536-25b4-4eb9-8d4f-4c3324b18998
7
public void update() { int xa = 0, ya = 0; if (anim < 7500) anim++; else anim = 0; if (input.up) ya--; if (input.down) ya++; if (input.left) xa--; if (input.right) xa++; if (xa != 0 || ya != 0) { move(xa, ya); walking = true; } else { walking = false; } }
b4910e77-c59a-42fd-ad19-e83968ea8851
6
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Trade other = (Trade) obj; if (!Objects.equals(this.security, other.security)) { return false...
a723b498-54e4-4e1f-9923-fdaf57880fea
4
public Object invoke(Object who, String methodName, Object... args) { Preconditions.notNull(who); Preconditions.hasText(methodName); try { if (null == args || args.length == 0) { return Invokers.newEmptyArgsMethodInvoking(who, method(methodName)).invoke(); } Class<?>[] argTypes = Lang.evalToTypes...