method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
e99ce2f7-8afb-4cea-a558-1d272c932b32
6
@EventHandler public void MagmaCubeStrength(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.getMagmaCubeConfig().getDouble("MagmaCu...
37c66435-53bf-4ec2-8d56-f68895c8beb0
3
private WatcherValues(Object... obj) { for (int i = 0; i < obj.length; i += 2) { if (!values.containsKey(obj)) values.put((Integer) obj[i], obj[i + 1]); else try { throw new Exception("Values in WatcherValues already contains " + obj + ...
c9f96441-b9bd-4ebb-b1c8-34a25c6b0410
6
public void cargarCasillas() { int num; for(char c='A';c<='J';c++) { for (Entry<Character, List<Definicion>> e: CatalogoDefiniciones.getCatalogoDefiniciones().buscarPorLetra(c).entrySet()) { num=(int)(Math.random()*e.getValue().size()); listaCasillas.add(new Casilla(e.getKey(),e.getValue().get...
681b359b-27cc-4fd9-a95a-f026303b1c38
4
public mjDate Djcal(double djm) throws palError { double fd, df, f, d; long jd, n4, nd10; int yr, mn, dy; Status = 0; TRACE("Djcal"); /* Validate */ if ((djm <= -2395520.0) || (djm >= 1.0e9)) { Status = -1; throw new palError(Status, "Djca...
8b8473f3-e8c1-4572-8ca3-e1889efb27e4
8
public void initScacchiera(Giocatore pGiocatore1, Giocatore pGiocatore2){ //pedine bianche int pb=0; for (i = 0; i < 8; i++) { for (j = 7; j > 4; j--) { if(pb<12){ if (isCasellaNera(this.scacchiera[i][j])==true){ this.sc...
37005cb3-d796-40a0-84d7-eae3cafada2b
0
public double getMoney(){ return this.money; }
85088fe6-0526-4df1-86ee-a454d6da4041
1
@Override public void execute(VirtualMachine vm) { if (vm.popRunTimeStack() == 0) { vm.setPc(address - 1); } }
83e27267-064b-4298-ba8d-0e4efab84e50
8
public int minCut(String s) { if (s == null || s.length() == 0 || s.length() == 1) { return 0; } int[][] palindrome = new int[s.length()][s.length()]; int[] cut_num = new int[s.length() + 1]; for (int i = s.length() - 1; i >= 0; i--) { cut_num[i] = s.length() - i; for (int j = i; j < s.lengt...
dcfb281f-8669-4385-addf-75433b53c946
1
private boolean setupChat() { if (getServer().getPluginManager().getPlugin("Vault") == null) { return false; } RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class); chat = rsp.getProvider(); return chat != null; }
0f587adf-7def-4688-9f6e-4c2a92f64387
8
private void consumer(String[] subscriptions) { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); try { Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.exchangeDeclare(EXC...
6e38bdee-7ba8-4f2f-8a86-832804031a19
0
public JScrollPane getjScrollPane1() { return jScrollPane1; }
338da7a0-d279-4e8a-bae7-4c33b1910611
3
public int findNearest(int[] num, int target){ int i = 0; int j = num.length - 1; int mid = 0; while(i <= j){ mid = (i + j) >> 1; if(num[mid] == target){ return mid; }else if(num[mid] > target){ j = mid - 1; }else{ i = mid + 1; } } return mid; }
fa053519-ef04-43b9-b46a-ea77fb899765
2
public static void main(String[] args) { Stack<String> stack = new Stack<String>(); for (String s : "My dog has fleas".split(" ")) stack.push(s); while (!stack.empty()) System.out.print(stack.pop() + " "); }
f0f7137f-ff5e-433e-9f64-18ab5af15031
7
@Override public void invoke(final ChatSocket socket) throws InvalidCommandException { // The user with address zero is reserved if (dest.equals(new LongInteger())) { throw new InvalidCommandException("Cannot send to user with address zero"); } // Bump the seq number ...
e0cafb86-bd38-486e-9767-bcc188ed25f5
7
@SuppressWarnings("serial") BodyPanel(Model model, ModelControl mControl) { super(true); this.control = mControl; model.addBodiesChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // if the state change is the one we're interested in... if (evt.getPr...
4f3c84cf-3289-4a89-909b-637f732e9d83
8
public Scriptable construct(Context cx, Scriptable scope, Object[] args) throws RhinoException { if (args.length == 2) { Class<?> clazz = null; Object obj1 = args[0]; if (obj1 instanceof Wrapper) { Object o = ((Wrapper)obj1).unwrap(); if (o...
1961f765-e417-43ec-9c6b-768b3de34d9c
7
public static Set<Property> getRelevantPropertiesOfClass(Resource cls, SPINModuleRegistry registry) { Set<Property> results = new HashSet<Property>(); StmtIterator it = cls.getModel().listStatements(null, RDFS.domain, cls); while (it.hasNext()) { Resource subject = it.next().getSubject(); if (subject.isU...
be8ed902-862e-40c6-8328-b4ac018cc34f
6
private void acao172() throws SemanticError{ if(tipoVariavelIndexada == Tipo.CADEIA){ if(tipoExpressao == Tipo.INTEIRO){ tipoVariavel = Tipo.CARACTERE; } else { throw new SemanticError("Índice deveria ser Inteiro"); } }else if(tipoExpressao == ((IdentificadorVariavelVetor) idAtual).getTipoIndice())...
e41d1386-483f-4bfd-a068-0c03ad241f7c
4
private int getPercentageDiscount(int customerRelationDiscount, int customerLongevityDiscount) { int pecentageDiscount = 0; String discountCalculationStrategy = ConfigurationPropertyReader.getInstance().getProperty( ConfigurationConstants.PERCENTAGE_DISCOUNT_CALCULATION_STRATEGY); ...
88eda4ac-28e9-41fc-bba1-9ac63610a38c
0
public void setMember(Member member) { this.member = member; }
fa8687a6-38b4-4326-b72f-c7680ef8a566
2
public String scanString() throws StringScanException { int idxSave = idx; skipWhiteSpace(); try { if (buf[idx] == '"') { return scanQuotedString(); } else { return scanNonWhiteSpaceString(); } } catch (StringScanException e) { idx = idxSave; throw e; } ...
8a5657cf-af9c-4ff2-9d84-64d416e87690
3
public void update(int delta) { Vector2f v = facing.copy().normalise().scale(this.getSpeed() * delta); if(timeAlive >= lifeTime) { if(this.target != null) { this.faceAt(target.copy()); this.lookAt(target.copy()); this.target = null; } if(!world.isEntityColliding(this, this.getBB(loc.co...
65b5711a-ce20-467d-b526-e949becc2f3a
7
public boolean setSessionAndStreams() { outputBuffer = new StringBuilder(); try { Channel channel = sesConnection.openChannel("shell"); in = new DataInputStream(channel.getInputStream()); out = new DataOutputStream(channel.getOutputStream()); c...
3012414b-bd33-41e4-b260-3a7faa7e3b73
2
public static StdImageSet getIconsForFileExtension(String extension) { if (extension != null) { extension = normalizeExtension(extension); StdImageSet icons = ICONSET_MAP.get(extension); if (icons != null) { return icons; } return StdImage.FILE; } return StdImage.FOLDER; }
53c7c682-7f36-4af0-8428-c96ff39d8aa0
1
private static String parseItemInformation(ItemStack[] items) { ItemStack[] stock = InventoryUtil.mergeSimilarStacks(items); StringBuilder message = new StringBuilder(15); Joiner joiner = Joiner.on(' '); for (ItemStack item : stock) { joiner.appendTo(message, item.getAmount...
6af6596c-c160-4827-a5e4-377c88a3b51d
4
public static ArrayList<String> readAllLines(File file) throws IOException { ArrayList<String> linesRead = new ArrayList<String>(); BufferedReader bufferedReader = null; FileReader fileReader = null; try { fileReader = new FileReader(file); bufferedReader = new Bu...
1653aeca-3b6a-4c93-a72c-72bdefcbd32d
2
public static void moveFilesToDirectory(String hdfsUrl, String sourceDirectory, String targetDirectory) throws IOException { Configuration conf = new Configuration(); conf.set("fs.default.name", hdfsUrl); conf.set("hadoop.job.ugi", DEFAULT_UGI); FileSystem fileSystem = FileSystem.get(conf); FileStatus[] statu...
9e62d3c1-9b73-4b41-b918-d9ed437ac1ea
9
public synchronized void removeListener(EventListener listener) { List<Class<?>> removeKeys = new LinkedList<>(); for (Class<?> key : eventListeners.keySet()) { List<RegisteredListener> listeners = eventListeners.get(key); if (listeners == null) { removeKeys.add(key); continue; } List<Regist...
d4e69680-db6e-4f65-8f2d-808e6e552c8a
6
@Override public void runStartupChecks() throws EngineException { Engine eng = FreeForAll.getInstance().getEngineManger().getEngine("Storage"); if (eng != null) { if (eng instanceof StorageEngine) { this.SE = (StorageEngine) eng; } } eng = FreeForAll.getInstance().getEngineManger().getEngine("Invento...
65fdb0e3-060e-49d8-a925-5ad7bbf7fd5d
9
private Elem compruebaFueraRango(String tipoResultado, Object valorResultado) throws Exception { Elem resultado = new Elem(tipoResultado,valorResultado); if (!tipoResultado.equals("boolean")&& !tipoResultado.equals("character")) { double valorR = Double.parseDouble(valorResultado.toString()) ; ...
d84c9ec5-0850-4735-8c62-76f893293ff1
0
OperatingSystem() { }
e448c8dd-040f-49e4-a960-9c99ddf3d33e
7
public void setState(int i) { lastState = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); allowClick = false; previousState = currentState; unloadState(previousState); changing = true; currentState = i; game.jukeBox.play(game.jukeBox.tracks.transition); if (i == F...
45de56d1-8b48-44f2-89dd-7ff875ab8195
2
public boolean accept(File f) { if (f == null) return false; if (f.isDirectory()) return true; return extension.equals(getExtension(f)); }
99fee368-f33d-4b43-ba97-48adb35c3c7c
2
public void updateGravity(Character ch, Character mon) { // manages gravity from black holes Character character = ch; Monster black = (Monster) mon; int chX = ch.getX(); int chY = ch.getY(); int monX = mon.getX(); int monY = mon.getY(); if (chX <= monX) { ch.changeX(2); } else { ch.changeX(-...
a5853867-4f23-41cc-a516-e44f03f84195
6
@Override protected void refreshStatus() { if (rollStatus == RollStatus.ROLL_THIRD) { status = FrameStatus.FINISHED; scoreStatus = ScoreStatus.FINAL; } if (rollStatus == RollStatus.ROLL_TWICE && status != FrameStatus.STRIKE) { status = FrameStatus.FINISHED; scoreStatus = ScoreStatus.FINAL; } ...
b8a4ebcb-ca97-4902-b029-c9ba76517b4c
2
public void omniGirlSet(int a){ rover = head; while(rover!=null){ if(rover.status == 1){ rover.currgirl = a; } rover = rover.next; } }
511cfa36-2633-4b70-8d9c-6089f77de000
2
private String getStringToParse(Scanner sc) { String s = sc.next(); String aux = ""; aux += s + " "; while (getMonth.get(s) == null && sc.hasNext()) { s = sc.next(); aux += s + " "; } return aux; }
69fbf386-d7e2-4a50-9526-1b5b17dacece
9
public static void main(String args[]) { ServerSocket serverSocket; try { serverSocket = new ServerSocket(12129); } catch (Exception e) { System.err.println("Create server socket: " + e); return; } while (true) { try { ...
74d2493d-2eca-4628-ae28-0fd759f9f0e4
2
public UnificationPair(Term lhs, Term rhs) { if (lhs == null || rhs == null) { throw new IllegalArgumentException( "Both terms must not be null."); } this.lhs = lhs; this.rhs = rhs; }
5313c0c1-6b6d-46be-b645-e0eb2d901794
0
public VueSeries() { initSerie(); }
821d4386-d962-4a02-9ca0-cc0e788fe5a8
5
public String setParametros(String host, String port, String database, String user, String password) { //<editor-fold defaultstate="collapsed" desc="setParamtros"> if (!host.isEmpty() && !port.isEmpty() && !database.isEmpty() && !user.isEmpty() && !password.isEmpty()) { FachadaB...
fb26c2b6-dea8-4aac-9171-6b53bec0e10e
8
public HashMap<Integer, Double> rank_term(ArrayList<Integer> paperList) { HashMap<Integer, Double> rank = new HashMap<Integer, Double>(); for (int i = 0; i < paperList.size(); i++) { int paperid = paperList.get(i); HashMap<Integer, Double> termMap = Store.getInstance().pt .get(paperid); if (termMap =...
dfacad45-12b8-423d-ac3c-7dbb871ef92e
0
public void setPopNitProveedor(Integer popNitProveedor) { this.popNitProveedor = popNitProveedor; }
3924e280-d691-428a-b494-bc36971df501
3
public Sprite create(Owner owner, Resource res, Message sdt) { int m = sdt.uint8(); GrowingPlant spr = new GrowingPlant(owner, res); spr.addnegative(); Random rnd = owner.mkrandoom(); int n = Config.simple_plants?1:num; for(int i = 0; i < n; i++) { Coord c; if(Config.simple_plants){ ...
9c5f3ade-2989-4327-b3f7-8514d505e190
2
public static boolean isCached(int id) { if (Model.modelHeaderCache == null) { return false; } ModelHeader modelHeader = Model.modelHeaderCache[id]; if (modelHeader == null) { Model.fileRequester.get(id); return false; } else { return true; } }
9b02d3b5-4746-4e59-9d7b-4eb805d99ea9
8
@Override protected byte[] getData() { byte[] imgHeader = new byte[61]; // BSE header = 36 bytes, BLIP record header = 24 bytes, then imageData bytes follow imgHeader[0] = (byte) imageType; //btWin32 imgHeader[1] = (byte) imageType; //btMac // 20071004 KSC: Unknown type of record, does not follow belo...
d4d2d3a6-30cc-46a6-acbe-71b6be50e952
7
public void render(GameContainer arg0, Graphics g) throws SlickException { if(title) { titleDoor1.draw(-doorshift,0); titleDoor2.draw(doorshift,0); } else {//order of render: backgrounds -> walls -> items -> player+mobs grassMap.render(x-820, y-64,0); // background grassMap.render(x-820, y-64,1); //...
540c2e50-97e6-45e5-ae73-60b1ee35bdac
5
@Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Tuser)) { return false; } Tuser other = (Tuser) object; if ((this.idUser == null && other.idUser != null) || (t...
2b9f93be-ed90-46ea-aaea-480fef050226
2
private void sentString(String sentData){ OutputStream out = null; try { out = socket.getOutputStream(); } catch (IOException e) { System.out.println("Не удалось получить поток вывода."); System.exit(-1); } BufferedWriter writer = new Buffered...
a1f493f9-562b-42cd-8a64-06e1b625f7af
7
public static String optimizeText(String text) { char buf[] = text.toCharArray(); boolean endMarker = true; for(int i = 0; i < buf.length; i++) { char c = buf[i]; if(endMarker && c >= 'a' && c <= 'z') { buf[i] -= 0x20; endMarker = false; } if(c == '.' || c == '!' || c == '...
1f2ebe8a-0453-47e1-b6f6-223b71fd4321
8
public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) { if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); if (this.averageGroundLevel < 0...
a1586de3-f8ea-4adb-ad57-032b632b8526
2
private void updateHexField() { this.adjustingHexField++; try { int r = this.red.getIntValue(); int g = this.green.getIntValue(); int b = this.blue.getIntValue(); int i = (r << 16) + (g << 8) + b; String s = Integer.toHexString(i).toUpperCase(...
8c2bc68e-df97-4403-be85-17103b7ba49f
5
public boolean setSize(int mapSize, int numOfPlayers) { if ((mapSize < 5) || (mapSize > 50)) return false; if ((5 <= numOfPlayers) && (numOfPlayers <= 8)) { if (mapSize < 8) return false; } size = mapSize; return true; }
bbede35f-1300-45b5-b66c-c39cd2d3dc68
9
@Override public boolean tick(Tickable ticking, int tickID) { if(tickID==Tickable.TICKID_MOB) { if((affected!=null) &&(affected instanceof MOB) &&(invoker!=null)) { final MOB mob=(MOB)affected; if(((mob.amFollowing()==null) ||(mob.amDead()) ||(!mob.isInCombat()) ||((invoker!=null)&...
7fce928c-246e-4af1-abc8-7edb56246626
5
@Test public void testLetsGo() { Random rand = Mockito.mock(Random.class); // On s'assure que le terrain et toujours franchissable. Mockito.when(rand.nextInt(Land.CountLand())).thenReturn(0); Robot r = new Robot(); r.land(new Coordinates(0,0), new LandSensor(rand)); ...
0fce7d21-f777-4432-ba5b-ab5484eaf313
5
private void drawCircles(final Graphics2D g2, final Color fillColor, final Color outlineColor, final int height) { Point upperLeft = this.getUpperLeft(); int startX = upperLeft.x + (this.getWidth() / 2); int startY = height + upperLeft.y; Point tailStart = new Point(startX, startY); Point tailEnd = this.ge...
83bec0a6-eb3b-4b93-a30c-4e2fea5ed01d
8
public synchronized boolean removeSubscription(String clientSessionToken, Long subscriptionId) { if (clientSessionToken == null || clientSessionToken.isEmpty()) return false; if (subscriptionId == null) return false; // Clients subscriptions Map<Long, Subscription> clientSubscriptions = retrieveSubscript...
51ffe4ee-dcd5-470e-af72-ecef56356049
8
public State<ET> call() { try { // WARNING: Must synchronize adding listener and setting // initial state or you can miss a notification from the state // machine. synchronized (stateMachine) { stateMachine.addListener(this)...
0daa6ed1-6c49-4c3b-afbe-1c485f2852f7
4
public boolean has_in () { // There are subsequent parts of the partly-read message available. if (more) return true; // Note that messing with current doesn't break the fairness of fair // queueing algorithm. If there are no messages available current will //...
4ac04530-2d75-4859-bad1-4303143b3491
3
public int[] generate(int nplayers, int bowlsize) { int nfruits = nplayers * bowlsize; int sum1 = 0, sum2 = 0; int[] dist = new int[12]; Random r = new Random(); for (int i = 0; i < nfruits; i++) { // mean 6.5 stdev 3 int fruitToIncrease = (int) Math.round(r.n...
f1c291ef-75ed-41f9-89de-9b503e5214f9
6
public int place(Piece piece, int x, int y) { // flag !committed problem if (!committed) throw new RuntimeException("place commit problem"); boolean sanityCheck = true; // get candidate squares for placement TPoint[] coordPts = getCoords(piece, x, y); // check if piece is in bounds, if square is curre...
2fba0fc2-2620-4f24-92b7-7a7096b8573c
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...
393eab33-362f-4269-bdbb-35e59a0ff5a3
5
public static void writeToFile(){ File output = new File(".data\\nnsave"); FileWriter writer; try{ writer = new FileWriter(output); writer.write(inHid.length + "," + inHid[0].length + "\n"); for(int i = 0; i < inHid.length; i++){ for(int j = 0; j < inHid[i].length; j++){ writer.write(inHi...
b303757f-ae32-4562-bc93-1cffab03bbcb
0
public void setEmailId(String emailId) { this.emailId = emailId; }
bafa7913-f5b8-42c0-97b3-232024db571a
0
public Participant addParticipant(int idEvent, String name){ tx.begin(); Event event = getEvent(idEvent); Participant participant = new Participant(); participant.setName(name); participant.setEvent(event); manager.persist(participant); tx.commit(); return participant; }
279cfbeb-c85c-4b82-be62-443bdd94fa1e
0
public Cell(int x, int y) { this.x = x; }
1060e848-3f7d-40dd-b637-42fd74ffdcc1
6
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
7c462c4a-af10-4dd0-a892-eca8dc12e636
7
@Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { canasta.setMoveLeft(true); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { canasta.setMoveRight(true); } else if (e.getKeyCode() == KeyEvent.VK_P) { if (!pausa) { ...
b265d8b5-0ccd-4a8e-88a0-bcd98accb8c9
5
private int[] searchForRest(ArrayList<Production> list, Production p, int[] visited) { HashSet <Production> visitedProd=new HashSet <Production>(); // System.out.println("Searching through "+list); int[] original=visited; int count=0; for (int i=0; i<myTrace.size(); i++) { if (list.contains(myTrace.get(...
3cf7f51d-2f5c-4655-a013-ab168a17077c
3
public void insertPoint(int n, int x, int y) { if (type!=TYPE_POLY) return; Polygon pnew = new Polygon(); for (int i=0; i<poly.npoints; i++) { pnew.addPoint(poly.xpoints[i], poly.ypoints[i]); if (i==n) pnew.addPoint(x,y); } poly=pnew; }
b34ecbac-a3fc-4f21-a02c-0a0d60413eb6
7
int getNegative(int i){ int octaveOffset = i/ Constants.NOTES_IN_SCALE; int mod = i% Constants.NOTES_IN_SCALE; int noteOffset = 0; if(mod > 0){ switch(mod){ case 6: noteOffset += steps[1]; case 5: noteOffset += steps[2]; case 4...
3c0099c8-0eb9-494d-9d31-3c01f819aaf8
1
public static void insertLigneCommandeClient(int idarticle,int idcommande,int quantite, Float prixht,Float prixttc,Float remise ) throws SQLException { String query=""; try { query = "INSERT INTO LIGNE_COMMANDE_CLIENT (ID_ARTICLE,ID_COMMANDE,LIGQTE,LIGPXHT,LIGPXTTC,LIGREMISE) VAL...
0fd12391-fad1-404d-a234-0af1b91a866a
5
public static void main(String[] args) { Comparable[] arrayChar = {'S','H','E','L','L', 'S', 'O', 'R', 'T', 'E', 'X', 'A', 'M', 'P', 'L', 'E' }; int length = arrayChar.length; int h = 1; while (h < length / 3) { h = h * 3 + 1; System.out.println("top==>"+h); } while (h >= 1) { for (int i = h; ...
6bd7841b-c10c-4548-982a-72e0e0c1a17c
9
@Override public boolean okMessage(Environmental host, CMMsg msg) { if(msg.amITarget(this)) { switch(msg.targetMinor()) { case CMMsg.TYP_ACTIVATE: if(!checkActivate(msg.source(),msg.targetMessage())) return false; break; case CMMsg.TYP_DEACTIVATE: if(!checkDeactivate(msg.source(),msg....
75c9e6fd-cb01-4a78-976a-abde9cbb3212
8
public final ActionListener createButtonListener(final ToolButtons toolButton) throws IllegalArgumentException { switch (toolButton) { case MINUS: return new MinusButtonListener(); case PLUS: return new PlusButtonListener(); case RESET: return new ResetButtonListener(); case START: ret...
d3faa389-9dd8-49fc-bba8-7e1d06236979
6
private void knightTopTopLeftPossibleMove(Piece piece, Position position) { int x1 = position.getPositionX(); int y1 = position.getPositionY(); if((x1 >= 1 && y1 >= 0) && (x1 < maxWidth && y1 <= 5)) { if(board.getChessBoardSquare(x1-1, y1+2).getPiece().getPieceType() != board.getBlankPiece().getPieceType...
cba34660-a384-4850-b853-a8fc62ee6627
2
public NewPaperDocumentDialog(final Domaine domaine) { setResizable(false); setTitle("Choisir un fichier papier"); setModalityType(ModalityType.APPLICATION_MODAL); setBounds(100, 100, 450, 280); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContent...
864aeb6f-34d4-4d34-b9c1-2f8e6672ecff
3
public ResultSet executeQuery(String sql) { ResultSet rs = null; closeConnections(); try { Class.forName(MYSQL_DRIVER); String connectionString = String.format("%s?user=%s&password=%s",MYSQL_URL + database, databaseUser, databasePassword); //String c...
03be5863-cc26-4817-b6ff-2de498e111e2
4
public void placecards() { if((display[0] < Client.mo.playedcards[0] && display[1] == Client.mo.playedcards[1] || Client.mo.playedcards[0] == 0) && display[1] != 0){ int[] check = new int[13]; System.arraycopy(newhand, 0, check, 0,13); Client.mo.users.get(myRank).setHand(check); Client.mo.users.get(myRank...
20bfdc79-1f92-462d-b6a0-2a2ab0e5595d
2
public void loadUserData (String fileName) { try { JsonReader reader = new JsonReader(new FileReader(fileName)); JsonParser parser = new JsonParser(); JsonArray array = parser.parse(reader).getAsJsonArray(); for (JsonElement elem : array) { UserData info = gson.fromJson(elem, UserData.class); Use...
583417e5-ed49-4151-af5d-e02e5ccc03fe
5
private static boolean dfs(Node2 currentNode, Node2 end) { currentNode.setSearched(true); if (currentNode.equals(end)) { path.add(currentNode); return true; } else { if (currentNode.getChildren() != null) { for (Node2 child : currentNode.getChildren()) { if (!child.isSearched()) { if (dfs(...
08c39a21-a089-4bd8-bc10-d3fb9f1669a5
8
private static double power(double x, double y) { double value; if (y < INFINITESIMAL && y > -INFINITESIMAL) { value = 1.0; } else if (y - 0.5 < INFINITESIMAL && y - 0.5 > -INFINITESIMAL) { value = Math.sqrt(x); } else if (y - 1.0 < INFINITESIMAL && y - 1.0 > -INFINITESIMAL) { value = x; } else...
25f85273-9898-40f0-bfc1-6223032396b9
8
public Artist convertArtist(JsonObject artistObj){ if(artistObj.get("artist") != null){ JsonObject artist = artistObj.get("artist").getAsJsonObject(); ArrayList<String> similarArtistsURL = new ArrayList<String>(); ArrayList<String> tagsArray = new ArrayList<String>(); String name = artist.get("name").ge...
c9dd226d-9f05-41e0-a46a-ec7594e2f387
4
private boolean check(int pN){ boolean val = true; int[] a = toSortedIntArray(pN, false); if (a != null) { for ( int i = 2; i < 7 && val; i++) { int[] b = toSortedIntArray(pN*i, true); if (!Arrays.equals(a, b) ) val = false; } } else { val = false; } return val; }
75bdc00d-faa9-424d-9e2d-107fa5ff5b1a
7
public static Map<String, String> parseParams(String s) { if (s == null || s.length() == 0) return Collections.emptyMap(); Map<String, String> params = new LinkedHashMap<String, String>(8); Scanner sc = new Scanner(s).useDelimiter("&"); while (sc.hasNext()) { Stri...
4ec93a5b-553e-481b-9814-f5accc6140d4
2
public static boolean isEnglish(String str) { for (char c : str.toCharArray()) { if (!CharUtils.isEnglishLetter(c)) { return false; } } return true; }
20289a7a-8923-42e4-b5a9-33d44e9dd6c6
2
public List<Palaute> haePalautteet() throws DAOPoikkeus { //avataan yhteys Connection yhteys = avaaYhteys(); ArrayList<Palaute> palautteet = new ArrayList<Palaute>(); try { // Haetaan palautteet tietokannasta String sql = "SELECT palauteID, kategoria, tilausID, nimi, sahkoposti, pvm,...
32429557-9ab3-4c98-b30c-97f8bb2d82df
8
@Override public void body() { AGRSpace agrs = (AGRSpace) ((IExternalAccess) getScope().getParent()).getExtension("mundo").get(this); Group group = agrs.getGroup("agents"); IComponentIdentifier[] drivers = group.getAgentsForRole("Driver"); IComponentIdentifier[] drivers2 = group.g...
e807c0c7-4495-41d8-be61-44f158900f0c
0
protected Implementor getImplementor() { return implementor; }
b3335001-ecea-4bab-87fa-a7c3bdb4b874
8
@Override public void startElement ( String uri, String localName, String qName, Attributes attr ) throws SAXException { String tag; if ( !qName.equals( "" ) ) { tag = qName; } else { tag = localName; } if ( tag.equals( Constants.xmlMenuStart ) ) { fValidFile = true; } // set to fa...
3ee352d9-f668-40a4-ba31-a6264cacbd8e
5
public void bfs(String label, Function<Vertex, Vertex> action) { int index = getVertexIndex(label); if (vertices[index].wasVisited() == false) { vertices[index].setVisited(true); action.apply(vertices[index]); } for (int cols = 0; cols < COLS; cols++) { if (graph[index][cols] == 1 && vertices[cols...
23508220-67b9-497d-90b5-927aecbdfa95
0
public static Collection<Watcher> getRegisteredWatchers() { return registeredWatchers.values(); }
9078ea24-7f25-41a1-a89d-7f301ab99227
2
public void setPoints(int points) { if(0 <= points && points <= 11) { this.points = points; this.repaint(); } else { throw new IllegalArgumentException("invalid points value"); } }
694dd4f2-eeee-4db3-b335-5ce4dab9f411
0
@Override public void destroy() { System.out.println("SHS Servlet: destroy()"); }
6d658070-cdfd-46cc-8047-28ba37cc10a3
8
public ArrayList<ArrayList<Integer>> fourSum(int[] num, int target) { HashMap<Integer,char[]> m = new HashMap<Integer, char[]>(); m.put(2, new char[] {'a', 'b', 'c'}); // Note: The Solution object is instantiated only once and is reused by each test case. ...
da44ccc4-cf23-4e9f-8947-fb7debf489fb
4
public boolean equals(Object obj) { if (!(obj instanceof EllipseObject) || !super.equals(obj)) return false; EllipseObject that = (EllipseObject) obj; return this.topLeft.equals(that.topLeft) && this.width == that.width && this.height == that.height; }
21425d58-897b-48d4-af94-1d64207b8602
3
public void setCustomParameters(String... customParameters) { StringBuilder data = new StringBuilder(); try{ for (int i = 0; i < customParameters.length; ++i) { data.append('&').append(customParameters[i]); if (++i < customParameters.length) data.append('=').append(URLEncoder.encode(customParameters...
e087016c-6bfc-4437-aaf6-c8cffa58b28e
3
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...
b9b041da-fb32-4bbf-8f16-5cf00fa96f32
9
public float getMeasureFromKeysChars(String[] state, List<String> attributes, String measure){ float res = -1; String keys = ""; for(int i = 0; attributes.size() > i; i++){ if(state[i].equals("#")){ continue; } keys = keys + at...
55ce1971-e2f9-4a55-aa74-12f0208843cb
5
@Override //FIXME make lombok work with unit tests on eclipse and use it instead! public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Location other = (Location) obj; if (x != other.x) return false; if ...