method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a7fae19f-1645-4589-a405-57f8a6e00e60
5
public boolean checkPreconditions(ArrayList<Predicate> pl, int maxN){ boolean accomplished = true; int i = 0; while(i < pl.size() && accomplished){ // for each predicate boolean found = false; int j = 0; while(j < predList.size() && !found){ Predicate ext_pred = pl.get(i); if(ext_pred.getName().e...
bec7dcf7-fc02-4d06-ad3f-bb2a168665e9
9
public ArrayList<Integer> postorderTraversal(TreeNode root) { ArrayList<Integer> res = new ArrayList<Integer>(); if(root==null) return res; LinkedList<TreeNode> stack = new LinkedList<TreeNode>(); stack.addFirst(root); TreeNode pre = null; while(!stack.isEmpty()){ TreeNode c...
81d9f137-1ea5-4720-83ec-1f01bc1ab5e1
0
public void setName(String name) { Name = name; }
fa7147eb-8c79-43de-9f9e-9c84ab920cf9
4
public boolean Update(String ticket, String lastName) throws Exception { try { //Load the MySQL driver Class.forName("com.mysql.jdbc.Driver"); //Setup the connection with the database conn = DriverManager.getConnection("jdbc:mysql://" +dbHost+ ":" +dbPort+ "/" +dbName, dbUser, dbPass); //Create ...
e1ddb911-c77d-4ead-a894-41d87d033959
1
public String[] Interface2StringArray(NetworkInterface[] devices) { //turns the device array into an array of strings String[] DevicestoString = new String[devices.length]; //Sets a String variable array equal in size to devices for (int i = 0; i < devices.length; i++) { //For each object in devices Devicesto...
ae9d1748-c5ad-479b-a497-6d2038ceab7d
4
private int jjMoveStringLiteralDfa11_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 10); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return jjMoveNfa_0(0, 10); } switch(curChar) { case 48: return jjMoveStringLiter...
be7834fe-ed88-4128-83e2-f08fc64a8fb2
5
public static void main(String[] args) { out.println("Booted HAL on " + OS_NAME + " " + OS_ARCH + ". Running Java " + JAVA_VERSION + ".\n"); long halStart = System.nanoTime(); out.println("Loading HAL memory model..."); for (File f : new FileWalker().findExtensions( "C:\\Documents and Settings\\Tu...
df6bc7f8-200e-4864-827e-85b68199e59e
0
public void printModel() { class ModelPrinter { void print() { System.out.println(getModel() + " " + getPower() + " " + getNumberCylinders()); } } new ModelPrinter().print(); }
c5ab27bc-0967-4634-ba69-d19d4461174e
3
void findDosToChase() { Dos closestDos = null; float closestDosSquaredDis = 0; for (Entity entity : DOServer.entities) if (entity instanceof Dos) { float distanceSquared = new Vector2f(x, y) .distanceSquared(new Vector2f(entity.x, entity.y)); if (distanceSquared > closestDosSquaredDis) { clo...
663f32a0-3dbb-466d-94ec-c29dcabd7d85
4
@Override public String toString(){ String nodeToString = "Node "; nodeToString += Calculator.bytesToHex(nodeId); //only add node positions, if the exist if(x != -1 && y != -1 && z != -1){ nodeToString += " at the coordinates "+x+" , "+y+" , "+z+" "; } if(broadcast){ nodeToString = "Broadcast"; } ...
35f657b3-0a9a-4fb0-97c7-5e2ec7106b6d
4
private String parseDocx() throws IOException, SAXException, ParserConfigurationException { String result = ""; _logger.debug("Filetype = DOCX"); ZipFile zipFile = null; try { // Entzippt die Docx, parst die XML zipFile = new ZipFile(_file); ZipEntry zipEntryXML = zipFile.getEntry("word/document.x...
d31531b3-e187-4aee-b021-7fd61b3bc5ab
1
private static Image addGaussionNoise(Image image, double mean, double variance) { if (image == null) return null; Noise filter = new Noise(); filter.setMean(mean); filter.setVariance(variance); image = filter.filter(image); return image; }
9a575579-d190-47e0-b40a-ab01f6314695
2
private void moveTowardTarget() { if (destinationReached && target != null) setDestination(target.getLocation()); }
5cfcad91-ee02-48d9-8e4d-74656d162dc4
4
public void WriteDBLPToFile() { ResultSet resultSet = null; String query = "select distinct indexid from dblpcitation union select distinct citationid from dblpcitation;"; ResultSet rs = sqLconnection.Query(query); try { int n = 0; String content = ""; while (rs.next()) { n++; int index = rs.ge...
8ffb47b2-296b-4cbc-a2e9-929253862568
9
public Projectile fire(Creep target) { Projectile temp = new Projectile(xpos, ypos, damage, type, level, target); switch(type) { case 0: temp.setSplash(splashRadius); break; case 1: temp.setExtraGold(extraGold); break; case 2: break; case 3: temp.setPoision(poisonDmg, poison...
48f137cc-31ad-4671-85da-599c74374130
7
/* */ public Projectiles(int x, int y, int aimX, int aimY, int bulletSpeed, int damage, Unit owner) /* */ { /* 19 */ this.x = x; /* 20 */ this.y = y; /* 21 */ this.bulletSpeed = bulletSpeed; /* 22 */ this.aimX = aimX; /* 23 */ this.aimY = aimY; /* 24 */ this.damage = damage; /*...
0ff485f9-e72e-419f-814a-9fb07a8e2471
8
public void update() { UP = key[KeyEvent.VK_UP] || key[KeyEvent.VK_W]; DOWN = key[KeyEvent.VK_DOWN] || key[KeyEvent.VK_S]; LEFT = key[KeyEvent.VK_LEFT] || key[KeyEvent.VK_A]; RIGHT = key[KeyEvent.VK_RIGHT] || key[KeyEvent.VK_D]; if (UP != prevUP) { System.out...
76e402ec-0329-4997-9058-b24b4e107f50
7
@Override public List<TipoApartamento> Buscar(TipoApartamento obj) { String consulta = "select ta from TipoApartamento ta"; String filtro = ""; HashMap<String, Object> parametros = new HashMap<String, Object>(); if (obj != null) { if (obj.get...
666023b2-b729-495f-9a95-a8ee94cdb3cf
9
@Override protected void endElement(String qName) throws SAXException { if (qName.equalsIgnoreCase("ROW")) { voList.add(vo); } else if (qName.equalsIgnoreCase("ID")) { vo.ID = Integer.parseInt(this.temp); }else if (qName.equalsIgnoreCase("USER_ID")) { vo....
c83b5482-d8ed-4672-85e9-1d056f5254b4
2
private void EscalaoCampeonato_ComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_EscalaoCampeonato_ComboBoxItemStateChanged // TODO add your handling code here: jList6.setModel(new DefaultListModel()); DefaultListModel model = (DefaultListModel) jList6.getModel(); ...
354f2d7a-0fb9-4b29-8243-3cf68dd018f8
2
public boolean isADirectoryFileMatch(String[] fileList, Request request) { String URI = request.getURI(); for (String file : fileList) { if (file.equals(URI)) return true; } return false; }
93b67536-ec91-4087-bcaf-ff4855dc42f5
2
@Override public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.white); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_O...
18ed9efa-e599-43d2-ab67-642956780383
7
private void setLocations(Map<String, ArrayList<Job>> jobs) { Iterator i = jobs.keySet().iterator(); Geocoder geocoder = new Geocoder(); while (i.hasNext()) { String key = (String) i.next(); ArrayList<Job> jobList = jobs.get(key); for (Job j : jobList) { ...
802a5b82-d891-4f56-9225-c5f379c48899
7
public boolean Loging(String nick, String pass) { //ok //verificar logueo boolean flag = false; try { String queryString = "Select password from Usuarios where nick = ?;"; connection = getConnection(); ptmt = connection.prepareStatement(queryString); ...
09d4c210-d42a-458a-9a70-50eccbec4382
5
public static void InvSee() { int count = 0; for(int m=0; m<Inventory.length; m++) { count++; if(Inventory[m] != 0) { count--; } } GUI.log(">> You have "+count+" slots left in your inventory"); for(int m=0; m<Inventory.length; m++) { if(Inventory[m] == 7) { System.out.print("Key "); ...
cddea597-8ebf-469b-b9a5-e2a0f1ee1b4b
6
public void scrollSelectionIntoView() { int first = mModel.getFirstSelectedRowIndex(); if (first >= getFirstRowToDisplay() && first <= getLastRowToDisplay()) { scrollSelectionIntoViewInternal(); } else if (mProxies != null) { for (Outline proxy : mProxies) { if (first >= proxy.getFirstRowToDisplay() && ...
5f0a8389-1366-4313-8a13-1f41d8ad65b2
7
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
a25bda1a-94f4-4dcf-8a8e-df8bf55671c3
7
public void izvrsi(HttpServletRequest req, HttpServletResponse res){ try{ KorisnikBean korisnik = (KorisnikBean)session.getAttribute("korisnik"); if(!ime.equals("")){ korisnik.setIme(ime); } if(!prezime.equals("")){ korisnik.setP...
32c30f19-7a65-488e-a62d-1753659bc41b
5
protected void run(){ try { props.load(new FileInputStream(propertiesFileName)); } catch (FileNotFoundException e) { log.info("Properties file " + propertiesFileName + " not found, using defaults."); } catch (IOException e1) { log.info("Error reading properties file " + propertiesFileName + ", using defa...
cdec64a4-e9aa-426a-95ac-019cc072388f
8
public void startGameForClients(MiniServer player[]) { this.clientPlayersPlaying = player; //Disallow the player array from having nulls in between players: this.numberOfPlayers = 0; for(int i=0; i<this.clientPlayersPlaying.length; i++) { if(this.clientPlayersPlaying[i] != null) { numberOfPlayers++...
6132bcba-485e-4a0a-bf35-62acbd8cf790
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...
bc9b3a60-bd35-4f1a-82df-8421105cdec0
4
private void addFiredBallToStrand() { switch(strand) { case 0: inPlayOne.add(firedBall); break; case 1: inPlayTwo.add(firedBall); break; case 2: inPlayThree.add(firedBall); break; case 3: inPlayFour.add(firedBall); break; } }
f14a0cce-9fc6-4276-ab88-0d1e23708ae4
0
public Integer getIdDiagnostico() { return idDiagnostico; }
cf233603-c3c7-438f-9560-9f98de627e9e
0
public void showAll() { defaultVisible = true; visibleNodes.clear(); }
3e03f703-1035-4542-9f78-8c41761eb81b
3
public static ShortImageBuffer apply(ShortImageBuffer input) { ShortImageBuffer after = input.copyShape(); for(int y=1;y<input.getHeight()-1;y++) { for(int x=1;x<input.getWidth()-1;x++) { int g00 = input.get(y-1, x-1) & 0xFF; int g01 = ...
dd8a1434-e211-47ca-8efe-4e42bfd85184
2
public Set getParamsForDim(Dimension dim) { TreeSet params = new TreeSet(); for (Iterator i = parameters.values().iterator(); i.hasNext();) { Parameter p = (Parameter)(i.next()); if (p.isDimensionedBy(dim)) { params.add(p); } } return...
d45c6e39-e5ca-4e48-aae8-6865c8fea672
2
private int checkColumnHeight(int x) { int rtnHeight = 0; for (int i = 0; i < height; i++) { boolean tmpBool = grid[x][i]; if (tmpBool) rtnHeight = i + 1; } return rtnHeight; }
63504f81-6298-4511-9599-79bdbd5c3e7a
6
public static void Play() { boolean done = false; String [][] words = { {"Penguin", "Bird"}, {"Pizza", "Food"}, {"LawL", "Troll"} }; String [] scramble = new String [SIZE]; for(int i=0; i < words.length; i++) { scramble[i] = words[i][0]; scramble[i] = scramble(scramble[i]); ...
9147ade0-a41b-4b7d-83f0-6c8ac7e78b17
0
public void setHidden(boolean hidden) { this.hidden = hidden; }
b443895a-8352-4cc0-9070-5cbf40515abd
7
protected void animateCell(Object cell, mxCellStatePreview move, boolean recurse) { mxGraph graph = graphComponent.getGraph(); mxCellState state = graph.getView().getState(cell); mxPoint delta = null; if (state != null) { // Moves the animated state from where it will be after the model // change b...
2d0e7994-5b68-4e4a-9f11-950b9302da82
0
public Moon(){ setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal()); setColor(ColorRGBA.White.set(0.6f, 0.6f, 0.8f, 0f)); this.setName("Moon"); }
317098f8-2f04-4412-97cb-45049ca7f1bd
7
protected void writeAttributes(AttributeSet attr) throws IOException { // translate css attributes to html if (attr instanceof Element) { Element elem = (Element) attr; if (elem.isLeaf() || elem.getName().equalsIgnoreCase("p-implied")) { super.writeAttributes(attr...
bca18725-f717-4b3c-96e6-32092153599a
1
@Override public int hashCode() { int hash = 0; hash += (idWorkstation != null ? idWorkstation.hashCode() : 0); return hash; }
74483168-16c9-4c3e-884c-1e71b4d80a60
2
@Override public Boolean existsOne(String strTabla, int id) throws Exception { int result = 0; Statement oStatement; try { oStatement = (Statement) oConexionMySQL.createStatement(); String strSQL = "SELECT count(*) FROM " + strTabla + " WHERE 1=1"; ResultS...
03e51dc2-24d5-4e0e-9a44-4c348f316a73
0
public ProcessList() // Constructor. { head = tail = null; }
ee984474-9616-4324-9704-20da10680333
4
@Override public void outOfBound(int i, int j) { if (!(0 <= i && i < m) || !(0 <= j && j < n)) throw new IndexOutOfBoundsException(); }
31abfbd4-e053-4289-99ca-27f81ce48b1d
5
public boolean entryExists(byte[] table, byte[] row, byte[] cf, byte[] cq, byte[] value) throws RedisForemanException { Map<RedisBigTableKey, byte[]> entries = getByQualifier(table, row, cf, cq); for (Entry<RedisBigTableKey, byte[]> ent : entries.entrySet()) { if (ent.getValue().length == value.length) { ...
b647a0b9-36b2-45f7-9f98-36fb9203faa8
1
public void makeVisible() { if( !visible ) { visible = true; getGraph().addItem( this ); } }
3f1f67e5-f071-45c7-8596-d55d72d6c11b
1
protected AudioDevice instantiate(ClassLoader loader, String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException { AudioDevice dev = null; Class cls = null; if (loader==null) { cls = Class.forName(name); } else { cls = loader.loadClass(name); } ...
e979130f-0233-46f7-9e2c-0beb29c73a6c
2
@EventHandler public void onPlayerChat(PlayerChatEvent event) { if (plugin.chatlogs) { Player plr = event.getPlayer(); try { OKLogFile.writeChat("[CHAT] <" + plr.getName() + "(" + plr.getAddress().getAddress().getHostAddress() + ")>@" + plr.getWorld().getName() + "(" ...
930f15bd-d75c-4a21-8c27-16c081d3fecc
2
private void run() { Object[] options = {"Host a game", "Join an existing game"}; final int n = JOptionPane.showOptionDialog(this, "Would you like some green eggs to go " + "with that ham?", "A Silly Question", JOption...
3358320e-3403-4b25-8f5c-b7c4452d2df5
4
@Override public Animation getAnimation() { Animation animation = super.getAnimation(); if (getState() == STATE_START && animation.getFrame() == animation.getFrameCount() - 1) { setState(STATE_FLY); setSpeed(FLY_SPEED); } if (getState() == STATE_HIT && animation.getFrame() == animation.getFrameCoun...
f3706753-6461-4730-bb5f-26df4bb0f56e
6
public void testCommitThreadSafety() throws Throwable { final int NUM_THREADS = 5; final double RUN_SEC = 0.5; final Directory dir = new MockRAMDirectory(); final IndexWriter w = new IndexWriter(dir, new SimpleAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED); w.commit(); final AtomicBoolean fai...
03c16a2e-912c-473e-a7ef-1687cb6d41b3
5
public JSONObject increment(String key) throws JSONException { Object value = this.opt(key); if (value == null) { this.put(key, 1); } else if (value instanceof Integer) { this.put(key, ((Integer) value).intValue() + 1); } else if (value instanceof Long) { ...
0f042026-0d02-49a2-92b6-32f93baffed1
0
@SuppressWarnings("rawtypes") public Operator getOperator() { return operator; }
75d35c7a-4441-4df6-9846-10978a0756f5
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...
24b3a5f8-e31f-45e5-83a1-337e7a2abd11
0
public double getBonus() { return bonus; }
2da8542c-1ffc-48a3-8ea5-2cca1f92e001
9
private List<String> getDiskNameByFile() { List<String> diskNameList = new ArrayList<String>(); BufferedReader br = null; try { br = new BufferedReader(new FileReader("/proc/partitions")); String line = null; try { while ((line = br.readLine()) != null) { if (line.length() != 0) { line = l...
33464cbe-243c-4281-8dcb-00e4132a0751
8
@Override public void run() { Graphics g = bstrategy.getDrawGraphics(); if(bstrategy.contentsLost() == false){ Insets insets = frame1.getInsets(); g.translate(insets.left, insets.top); if(isgameover == true){ g.setColor(Color.RED); g.setFont(new Font("Sanserif", Font.BOLD, 80)); draw...
8f71c076-f8fb-4a6b-adee-ba684bdf6c44
4
public void updatePlayerVisibility(Player player, boolean newStatus) { for (Player p : Bukkit.getOnlinePlayers()) { if (p.getName().equalsIgnoreCase(player.getName())) { continue; } if (newStatus) { if (!p.hasPermission(this.getPermission() + "...
4969b7c3-d0b3-4d1f-b414-bf430196473b
9
protected static boolean isFirstDegreeExpression(Expression expr) { if(expr.length() != 2 || !expr.sign() || expr.exponent() != 1) return false; AlgebraicParticle a = expr.get(0), b = expr.get(1); //if one is a variable or variable with exponent, and the other is a number/mixed number/simplified fraction if(...
4268d24b-f10a-42a5-90bd-bbc947e26910
2
public static boolean isSTAB(Pokemon.Type type1, Pokemon.Type type2, Pokemon.Type move) { if(type1==move) return true; else if(type2==move) return true; else return false; }
930a6929-f927-4c1d-be5d-534b0089ce55
2
@Override public int compareTo(CardGroup cardGroup){ if(cards.size() > cardGroup.cards.size()) return 1; else if(cards.size() < cardGroup.cards.size()) return -1; return 0; }
d1bbf01c-ddc4-4b59-8251-77f04e40f3aa
4
@Override public void mouseClicked(int button, int x, int y, int clickCount) { GameContainer container = Window.getContainer(); if (x > (container.getWidth() / 2) - ((WzFont.getStringWidth(g2, "Login")) / 2) - 200 && x < (container.getWidth() / 2) - ((WzFont.getStringWidth(g2, "Login...
e9d2ee6b-cb0e-45c5-b7c6-13b0ee79e352
9
public void types(char c){ if(Character.isDigit(c)){ contents+=c; long max=0; long min=0; if(repByte){ max=255; min=-256; } if(repInt){ max=Integer.MAX_VALUE; min=Integer.MIN_V...
daa7a13a-4e7e-42da-8cbe-9f852f2006c8
0
public void setDescription(String description) { this.description = description; }
180af367-c21f-4a19-bb90-05cd53d16923
0
public float getDeadZone(int index) { return deadZones[index]; }
191a6ca0-4361-4965-ba54-84059d74a2c4
5
public void setLength(double length){ if(length == 0.0625 || length == 0.125 || length == 0.25 || length == 0.5 || length == 1) this.length = length; else throw new IllegalArgumentException(length + " is not a valid note length"); }
36f394b9-1c5d-4a0d-818a-f38e69a8f351
7
public int middleLargeOptimize(int[] A) { int result = 0; for (int i = 1; i < A.length; i++) { int left = 0, right = 0; for (int j = 0; j < A.length; j++) { if (j == i) continue; if (A[j] < A[i] && j < i) left++; if (A[j] < A[i] && j > i) right++; } result += left * right; }...
0beaea63-2896-46fe-a4a2-e2453764764e
6
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<String> fouten = new ArrayList<>(); String campusNrString = request.getParameter("campusNr"); if (campusNrString == null) { fouten.add("Kies een campus."); } String managerNrString...
ea20ceba-9492-4727-9ef8-b7318e1cc0ab
9
@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { if (aValue == null || !(aValue instanceof String)) return; if (placeholderVisible && rowIndex == keys.size()) { if (columnIndex == 0) { String key = ((String) aValue).trim(); hidePlaceholder(); if (!key.isEm...
3ef6c344-1df7-4e3e-811a-1c8bbb39adee
1
public void act() { if (getGrid() == null) return; ArrayList<Actor> actors = getActors(); processActors(actors); ArrayList<Location> moveLocs = getMoveLocations(); Location loc = selectMoveLocation(moveLocs); makeMove(loc); }
6abb5d83-082a-4872-a676-415ea456e308
2
public String getBinaryInput(){ if(!this.inputSet)throw new IllegalArgumentException("No input has been entered"); if(!this.trueDtoA){ System.out.println("Class - DtoA; method - getBinaryInput"); System.out.println("This instance of DtoA is not a true simulation of an DAC"); ...
299b92fc-f841-4801-b09b-e8720472725b
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Recipe other = (Recipe) obj; if (ingredients == null) { if (other.ingredients != null) return false; } else if (!ingredients.equals(ot...
2822372b-8f1e-4e8a-bb89-fa10d0356b7d
9
public void paint(Graphics g) { // Displays text on the right displaySidebar(g); // This draws the gameboard with NOTHING on it, handles pacman "residue" for (int count1 = 0; count1 < 18; count1++) { for (int count2 = 0; count2 < 20; count2++) { switch (game....
0254f005-c56d-4aec-866d-1277f768d59f
7
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
b1e0cf04-4307-4929-93b9-ec8dd487cf13
5
private void findAdmins(){ try { String temp = ""; while ((temp = conf.readLn()) != null){ if (temp.startsWith("ADMINS: ")){ temp = temp.substring(8); String[] t = temp.split(","); for (Strin...
990f65d3-f25d-4ae0-9aaf-73621823c57e
0
public void setRecipient(String value) { this.recipient = value; }
8239c050-8ed3-4da5-bcc8-27acba3630e5
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the...
15399fd0-cd52-4208-b2e9-adec4be7c9be
0
public String getURI() { return uri; }
2bc5d5c3-0076-45b9-98b6-c2c699979feb
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Edge other = (Edge) o...
e584136c-d5bd-417b-8fce-d6a4b98589a4
9
private void pickUpActionPerformed(java.awt.event.ActionEvent evt) { if(!game.getInBattle()) { String text = game.pickUp(); outputText.setText(text); if(text != "There is nothing in this room.\n") { int slot = game.getNewestItemSlot(); ...
b7ddc623-3b41-4ef4-9d4f-3c73a242b3a1
6
public ArrayList<Gebruiker> getAlleKlantenJongerDan2010(){ if(alleKlantenJonger.isEmpty() && jongerAutos.isEmpty()) { alleKlantenJonger = new GebruikersDAO().getAlleGebruikersDB(); jongerAutos = new AutosDAO().getAlleAutosDB(); int x = 0; for(Auto a: jongerAutos){ if(a.getBouwjaar() ...
c010ad20-bc53-4278-b051-966f438ecbfc
8
public int threeSumClosest(int[] num, int target) { int n = num.length; if(n<2){ return -1; } int check,start,end,result; result = num[0]+num[1]+num[2]; Arrays.sort(num); for (int i=0;i<n;i++){ check = target-num[i]; start = i+1...
fa9e03b4-9305-4c4f-bcf6-362931d75596
1
public void Stop() { try { Reader.close(); Writer.close(); Socket.close(); Listener.stop(); } catch(Exception e) { Utils.LogException(e, "Stopping client"); } }
32cec3a1-1edd-4a52-8628-d969066e2c51
7
public void convertString(String code) { for (int c = 0; c < code.length(); c++) { switch (code.toUpperCase().charAt(c)) { case 'B': elements[c] = new Peg(Colors.BLUE); break; case 'G': elements[c] = new Peg(Colors.GREEN); break; case 'O': elements[c] = new Peg(Colors.ORANGE); brea...
a5ac707a-a183-4c2e-a02e-ad652ccfb6cd
9
@Override public void execute(CommandSender sender, String gateName, List<String> args) { this.sender = sender; Integer radius = 10; if (gateName != null) { try { radius = Integer.parseInt(gateName); } catch (Exception ex) { error("Invalid radius number: " + gateName); return; } } ...
34fc4b66-31fd-4fb2-9124-447c304dc424
5
private static void quit(Socket socket, BufferedReader input, ObjectOutputStream output, Scanner menu, BufferedReader in) throws IOException { ClientData clientData = new ClientData(); clientData.setName(name); clientData.setCloseRequest(true); output.writeObject(clientData); output.flush(); if ...
38487a4a-8189-41ea-b1a5-8f460d4e8c28
1
public void notifyPropertyChangeListeners(PropertyChangeEvent event) { for(PropertyChangeListener listener:listeners) { listener.propertyChange(event); } }
098f5500-0df5-4a9c-8528-20b86da27f47
8
int adjustForResolution(){ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int height = (int)screenSize.getHeight(); int preferredHeight = 200; if (height < 768 && height >= 600 ){ preferredHeight = 100; }else if(height < 1024 && height >= 768 ){ preferredHeight = 100; }else if (h...
5c2b92bc-ada8-410e-8d02-2d0409885b44
6
private String translatePos(int row, int col) { if (row < RowNum && col < ColNum && row >= 0 && col >= 0) { // if the row and column number is valid for our grid StringBuilder str = new StringBuilder(); str.append(""); if (reverse) { str.append((char)('E' - col)); ...
3a9760ff-dfbc-4004-a530-5001f690c505
8
private static int run_upward(char[][] grid, int[][] from, int[][] to, int N, int M, int max) { for (int j = 1; j < M; j++) { for (int ihigh = N-1; ihigh > 0; ihigh--) { if (grid[ihigh][j] == '#' || from[ihigh][j-1] < 0) continue; int left = from[i...
79f07e35-a83c-46a2-b7f1-1a291bd12d95
8
public boolean epsilonEquals(Matrix3f m1, double epsilon) { return Math.abs(m00 - m1.m00) <= epsilon && Math.abs(m01 - m1.m01) <= epsilon && Math.abs(m02 - m1.m02 ) <= epsilon && Math.abs(m10 - m1.m10) <= epsilon && Math.abs(m11 - m1.m11) <= epsilon && Math.abs(m12 - m1.m12) <= epsilon && Math.abs(m20...
c7ae01e0-6225-435a-a824-63364f7299b8
9
public LinkedList<UploadedFile> getParts(File dir, int maxPostSize) throws IOException { LinkedList<UploadedFile> files = new LinkedList<UploadedFile>(); // Check the content type to make sure it's "multipart/form-data" String type = getContentType(); String typeLC = type.toLowerCase(); if (typeLC.contains("...
9e109625-1386-4c7d-ba8b-beec64440469
6
public ResultSet PreencheTabelaDepartamentos() throws SQLException { Connection conexao = null; PreparedStatement comando = null; ResultSet resultado = null; Departamento DEP = null; try { conexao = BancoDadosUtil.getConnection(); comando = conexao.prep...
7368f27d-2f21-4cf3-9688-7bc9135cc23d
7
@Override public void received(final Connection connection, final Object object) { Runnable r = new Runnable() { @Override public void run() { if (object instanceof PlaceUnit) { Log.info("Placing unit"); PlaceUnit pu = (PlaceUnit)object; UnitActor ua = addUnit(pu.unitClass, pu.x, pu.y, pu.te...
6d29a2d5-a2a4-46f8-ab92-d49da77a2e93
3
private Object unmarshalFromSequence( Class c, CharSequence seq ) throws JAXBException { Object result = null; try { JAXBContext jc = JAXBContext.newInstance(c); Unmarshaller u = jc.createUnmarshaller(); result = u.unmarshal( new StreamSource(new StringReader(seq.toString())) ); } catch (JAXBException e...
751f13af-91ab-40b1-a0f5-c35646df30c0
6
void readInput() { // line 1 if(nodeNum != readInt()-1) { throw new Error("input out of sync"); } city = readString(20); for (int i=0; i<maxLevel; i++) { zip[i] = readInt()-1; } population = readInt(); latatude = readInt(); ...
9fbd696f-e6e3-4a3e-82d1-7b5a8f06293d
8
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int caso = 0; for (String ln; (ln = in.readLine()) != null; ) { if(caso++>0)System.out.println(); int[] arr = new int[256]; Arrays.fill(arr, Integer.MAX_VALUE); char[] st ...
3adaa28c-fa7e-4538-a3cf-afa43286051d
4
public static void bTurn() { Random r = new Random(); int bMove = r.nextInt(2) + 1;//+b1.getMoveNum(); if (bMove == 1) { System.out.println("\n" + b1.getName() + " uses " + b1.move1.getName() + "!"); // System.out.println(b1.move1.getType().getTypeName() + " " + a1.getType().getTypeName()); a1.hp -= ...