method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
c65d3076-e1c3-413a-a34c-57bdbc73aef6
3
public void actionPerformed (ActionEvent event) { String eventName=event.getActionCommand(); // Cancel if (eventName.equals("Cancel")) { changedTriggers=false; dispose(); } // OK if (eventName.equals("OK")) { // Check the entries if (checkTrigger()==true) { changedTriggers=true;...
32d5de9d-eb19-4ed1-b211-6f4a610d6475
8
public HashMap<String, Integer> printCheck(Check check) throws Exception { HashMap<String, Integer> result = new HashMap<String, Integer>(); if ( ! check.validate()) throw new Exception("Ошибка заполнения чека"); int command = check.getCommand(); ArrayList<Integer> ans...
c7c797c4-8d05-44a0-bf2d-08b4c1a0a9c4
2
String genoStr(String geno) { if (geno.equals("x") || geno.equals("0")) return ""; return geno; }
30b8c22d-8a7e-4034-8756-099afff2ed85
8
private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { String eol = System.getProperty("line.separator", "\n"); StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expe...
5d7ca3d6-4e6d-4eb5-8048-ee7a228d2a44
2
public void ls() { System.out.println(CompositeDemo.g_indent + m_name); CompositeDemo.g_indent.append(" "); for (Object obj : m_files) { // Recover the type of this object if (obj instanceof Directory) { ((Directory) obj).ls(); } else { ...
8cb80bfe-cab6-49c5-a3af-4536fa2f6089
2
public static void saveToPreferences() { Preferences prefs = Preferences.getInstance(); prefs.removePreferences(MODULE); for (String key : DEFAULTS.keySet()) { Font font = UIManager.getFont(key); if (font != null) { prefs.setValue(MODULE, key, font); } } }
5021efc2-d3e1-43c7-9eec-c342b2e92d47
0
public void setReal (boolean b) { real = b; }
c69bd3df-f2e3-4ff9-8283-5bb56d5911e8
7
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { String label = scanner.next(); //first value entered is label if(scanner.hasNextInt()) { //check if next input is integer ...
588a4c6d-8d90-4bbf-8990-4bfa7d86f0a2
3
@Override public Hit intersect(Ray ray) { Vector x0 = ray.getOrigin().sub(center); Vector d = ray.getNormalizedDirection(); float t1 = 0.0f; float t2 = 0.0f; if ((x0.dot(d) * x0.dot(d)) * ((x0.dot(x0)) - (radius * radius)) < 0) { return null; } if ((x0.dot(d) * x0.dot(d)) * ((x0.dot(x0)) - (radius...
a367c1c7-066a-422e-97bf-98b11074a513
5
private void addNeighbour(int x, int y, Cell cell) { if (x >= 0 && x < maxCols && y >= 0 && y < maxRows) { LogicCell c = new LogicCell(x, y); if (!nextStep.containsKey(c)) { c.neigbour = 1; nextStep.put(c, c); } else { nextStep....
0f6eb5c4-4761-46a7-be0f-473cf4b849be
8
public int send(short dest, byte[] data, int len) { //can't have too many unacked things to send if (toSend.size() > 3)//if there is 4 unacked { stat.changeStat(Status.INSUFFICIENT_BUFFER_SPACE); if(debugLevel > 0) output.println("Too many packets. Not sending"); return 0; } if(len < 0) { s...
ee956baa-551b-4eae-b635-2fab9d83ed88
3
public double compareStrings(String text1, String text2) { ArrayList<String> pairs1 = wordLetterPairs(text1.toUpperCase()); ArrayList<String> pairs2 = wordLetterPairs(text2.toUpperCase()); int similarityCounter = 0; int completeSize = pairs1.size() + pairs2.size(); for (int i = 0; i < pairs1.size(); i++) {...
8c3c4400-5f9c-4354-a0e2-4fdaed651374
7
public static List<Double> findRoots(Function f, double startPoint, double endPoint, int numberOfProbes, double tolerance) { double distance = Math.abs((endPoint - startPoint) / numberOfProbes); double[] evaluationPoints = getEvaluationPoints(startPoint, distance, numberOfProbes); List<Double> startingPointsT...
7f8516b0-7f23-429c-91ee-c5d7d3f401a0
1
private String getWordInSingularOrPluralForm(String word, long count) { return (count > 1) ? word + "s" : word; }
d7651cc7-edaa-473f-a73c-a3c7131f9f68
9
protected boolean encodeHeader(int alphabetSize, int[] alphabet, int[] frequencies, int lr) { EntropyUtils.encodeAlphabet(this.bitstream, alphabet, alphabetSize); if (alphabetSize == 0) return true; this.bitstream.writeBits(lr-8, 3); // logRange int inc = (alphabetSize > 64) ? 16 :...
a22910b6-b0c8-43e1-9af1-951f7fe89e7e
9
protected void resolveConflict(int s, int newValue) { // The set of children values TreeSet<Integer> values = new TreeSet<Integer>(); // Add the value-to-add values.add(new Integer(newValue)); // Find all existing children and add them too. for (int c = 0; c < alphabetLength; c++) { int tempNext = ge...
83972e32-6674-4324-b6c3-7bee112d544d
5
public boolean preaching() { if (preaching == 1){ if (holyBook){ startAnimation(1335); } if (unholyBook){ startAnimation(1336); } if (balanceBook){ startAnimation(1337); } preaching = 2; } if (preaching == 2){ resetPreaching(); } return true; }
e1c3d372-74a2-4779-9e48-eb60ece6bf1e
9
public String getMergedfile(SmartlingKeyEntry updateEntry) throws IOException, JSONException { // for each locale (for the specific project) , get translated file from smartling String responseHtml = SmartlingRequestApi.getFileFromSmartling(updateEntry.getFileUri(), updateEntry.getProjectId(), update...
8d28a7d4-993f-4936-bd5d-8aef60750c9f
2
public Lep(int i, int j, int k, int l, int[][] t){ logger.info("Meghívták a konstruktort."); aktualispoz1=i; aktualispoz2=j; hovaakar1=k; hovaakar2=l; for(int a=0; a<8; a++) for(int b=0; b<8; b++) sajat[a][b]=t[a][b]; }
1b6f5d9d-401b-45af-88af-86640893467c
6
private ArrayList<File> dirFilelist(File f) { ArrayList<File> res = new ArrayList<>(); if (f.exists() && f.isDirectory()) { File[] chld = f.listFiles(); for (File sf : chld) { if (!sf.getName().equals(".") && !sf.getName().equals("..") && sf.isFile()) { res.add(sf); } } } return res; }
b494f577-a563-4ef4-aabc-7442dd952af7
1
public void resetPositions(){ // Reposition game objects p1.setX(initialPosX_p1); p1.setY(initialPosY_p1); p2.setX(initialPosX_p2); p2.setY(initialPosY_p2); b.setY(gameWindow.getCenterY() - 14); b.setVelX(0); b.setVelY(0); // alternate the...
43ddb0ff-28d7-423c-81b6-e7d051c14dc3
9
@Override public void handlePacket(Packet packet, Socket s, Main game) { if (!packet.getBoolean()) { // success JOptionPane.showMessageDialog(game.gameFrame, "You cannot do that.", "Error", JOptionPane.ERROR_MESSAGE); game.setButtons(true); return; } int rank = 0; Group group = null; for (int i...
17845d29-ecaf-4678-97b8-6b1adba09170
9
public CommandHandler(String command, String pitch, String commandGrammar, String where, String summary, List<String> notes, String input, String output, String example, Options options) { if ((command == null)) { throw new IllegalArgumentException("command cannot be null.")...
5bf58301-e882-4088-a801-9304f87ead9b
7
public boolean addElementField(ElementField element) { gameFieldView().addElementFieldView(element); if (element instanceof Ball) { return _balls.add((Ball) element); } else if (element instanceof DestructibleBrick) { return _dBricks.add((DestructibleBrick) element); ...
befad3ae-90bd-4e3f-8588-cba429796132
4
public void dumpLayers() { System.out.println("<layers>"); for (Layer l : layers) { if (l instanceof CodeEntry) { System.out.println("CodeEntry: " + ((CodeEntry)l).clnm); } else if (l instanceof Code) { System.out.println("Code: " + ((Code)l).name); Field[] classfields = ((Code)l).getClass().getFi...
a91f4b1b-190e-499b-8400-c0bfd0b410df
3
public void run(){ long lastTime = System.nanoTime(); long timer = System.currentTimeMillis(); final double ns =1000000000.0 /60.0; double delta =0; int frames =0; int updates =0; requestFocus(); while(running){ long now =System.nanoTime();//re-sets time to computer time lag delta += (now-lastTime) /ns; last...
9b853ac2-a417-4fee-8a51-3351dfa056c0
6
private static Point2D getProjectionOnEdge(Point2D source, Point2D wayPoint, double panelWidth, double panelHeight) { final LineEquation eq = new LineEquation(source, wayPoint); double interX; // X coord of the intersection double interY; // Y coord of the intersection if (eq.a > 0) { ...
2b05a059-7023-4d4a-ba9e-45f37ab194c2
5
@Override public List<Group> findGroupByUserId(int userId) { List<Group> list = new ArrayList<Group>(); Connection cn = null; PreparedStatement ps = null; ResultSet rs = null; try { cn = ConnectionHelper.getConnection(); ps = cn.prepareStatement(QTPL...
bda193e8-69a5-4d26-af2c-d73f9a29f67e
7
public Passenger(JSONObject json) throws JSONException { try { if (json.has(AMOUNT)) { this.setAmount(Float.parseFloat(json.getString(AMOUNT))); } if (json.has(TOTAL)) { this.setTotal(Float.parseFloat(json.getString(TOTAL))); } if (json.has(NETAMOUNT)) { this.setNetamount(Float.parseFloat(j...
f1cead48-335c-4f6d-be8d-41a24731a52c
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Shelf other = (Shelf) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return fals...
570f216c-d599-429e-bf73-1a8f52770ebd
6
public static final void itemSort(SeekableLittleEndianAccessor slea, MapleClient c) { slea.readInt(); // timestamp byte mode = slea.readByte(); boolean sorted = false; MapleInventoryType pInvType = MapleInventoryType.getByType(mode); MapleInventory pInv = c.getPlayer().getInvento...
28327f11-b788-482e-9f78-211058be19cd
0
public int getSize() { return statusRepo.size(); }
809c7f21-5bda-44d1-96c0-d556d483f663
9
double calculatescore() { total = 0; for (int i = 0; i < seedlist.size(); i++) { double score; double chance = 0.0; double totaldis = 0.0; double difdis = 0.0; for (int j = 0; j < seedlist.size(); j++) { if (j != i) { totaldis = totaldis + Math.pow( distanceseed(seedlist.g...
a6f2cb71-7a59-4de2-bbde-6cdecfe6d864
3
private boolean exitTableBody(Token t, HtmlTreeBuilder tb) { if (!(tb.inTableScope("tbody") || tb.inTableScope("thead") || tb.inScope("tfoot"))) { // frag case tb.error(this); return false; } tb.clearStackToTableBodyContext(); ...
54a9eeb6-447a-419c-9913-518f6d451a93
7
public static String extractTitleFrom(String filePath) /* * The extractNameFrom method checks the ID3 version of the mp3 file and * extracts the song title from the MP3 file. */{ String title = null; try { Mp3File mp3File = new Mp3File(filePath); if (mp3File.hasId3v2Tag()) { ID3v2 id3v2Tag ...
0bc93023-6e68-4539-b7f7-4d439dc13bc8
4
protected static Ptg calcInt( Ptg[] operands ) { if( operands.length != 1 ) { return PtgCalculator.getNAError(); } double dd = 0.0; try { dd = operands[0].getDoubleVal(); } catch( NumberFormatException e ) { return PtgCalculator.getValueError(); } if( new Double( dd ).isNaN() ) // Not a ...
31485828-5f9f-4276-931e-12c4b56295e2
7
public void setFrame(String panel){ switch(panel){ case "login": frame.remove(curPanel); frame.add(login); login.refresh(); frame.validate(); frame.repaint(); curPanel=login; frame.setSize(425,300); break; case "createUser": frame.remove(curPanel); frame.add(createUser); ...
2777ee16-1840-4008-845b-7a9e5e8601da
0
public void destroy() { targetNode = null; currentRenderer = null; prevRenderer = null; }
872ff0d1-5c56-49b0-a73f-4b580af3eed5
4
private LinkedHashMap<Rashi, ArrayList<Nakshatra>> getStarsInRashi() { LinkedHashMap<Rashi, ArrayList<Nakshatra>> starsInRashi = new LinkedHashMap<Rashi, ArrayList<Nakshatra>>(); ArrayList<Nakshatra> starsForRashiList = new ArrayList<Nakshatra>(); for (Nakshatra nakshatra : Nakshatra.values()) { if (nakshatra...
e2542c1b-085f-47af-8e47-4ab2931e902b
4
private void useTeamPiece(char teamSymbol) throws Exception{ if (!NineManMill.DEBUG_VERSION){ throw new Exception ("This is not a debug version, cannot call useTeamPiece()!"); } switch (teamSymbol){ case EMPTY: return; case PLAYER1: /* Find some way to get the coordinates */ // team1.usePiece(ne...
b0cb0ddd-5d53-4713-bc27-769218f0d23d
1
public static void main(String[] args) { int elements[] = {5, 3, 2, 6, 3, 1, 8, 7, 1, 2, 4, 1, 6, 2, 3, 4, 5, 2, 3, 2, 6, 1, 1, 8, 7, 1, 2, 4, 1, 2, 2, 3, 4, 5, 2, 3, 2, 6, 1, 1, 8, 7, 1, 2, 4, 1, 1, 2, 3, 4, 5, 2, 3, 2, 6, 1, 1, 8, 7, 1, 2, 4, 7, 1, 2, 3, 4, 5, 2, 3, 5, 6, 1, 1, 8, 7, 1, 2, 4, 1, 1, 2, 3, 4, 5, 2 };...
f0f54cc4-1149-41af-a4c6-3fcc0d20af0c
1
public MyCanvas() { setDoubleBuffered(false); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { oX = e.getX(); oY = e.getY(); } }); addMouseMotionListener(new MouseMotionAdapter() { public void mouseDra...
a3714e05-81c2-4ebb-9d9d-fac114523235
5
private int upgradeForGood(Service type) { final Integer key = (Integer) SupplyDepot.SERVICE_KEY.get(type) ; final Upgrade KU ; if (key == null) return -1 ; else if (key == SupplyDepot.KEY_RATIONS ) KU = RATIONS_STOCK ; else if (key == SupplyDepot.KEY_MINERALS) KU = PROSPECT_EXCHANGE ; els...
38ab6442-5707-46e7-ae6a-915241708fb2
8
public boolean similar(Object other) { if (!(other instanceof JSONArray)) { return false; } int len = this.length(); if (len != ((JSONArray)other).length()) { return false; } for (int i = 0; i < len; i += 1) { Object valueThis = this.ge...
b3484565-e229-4ac7-ae91-3b892e46523e
1
public void close(){ //called when room is closing, should kick all users for (ChatServerThread thread : threads){ thread.disconnect("Room is closing."); } }
f9335c9b-3ac5-4368-9621-8b6eeab50a74
7
private void salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarActionPerformed Contato contato = new Contato(); contato.setNome(nome.getText()); if((null != tel_1.getText()) && !(tel_1.getText().isEmpty())){ contato.setTelefone1(Integer.parseInt(tel_1.ge...
32c2c353-0766-44b0-8c91-383acaa09370
6
public final float apply(float x, float y, float z) { // Skew input space to relative coordinate in simplex cell s = (x + y + z) * onethird; i = fastfloor(x+s); j = fastfloor(y+s); k = fastfloor(z+s); // Unskew cell origin back to (x, y , z) space s = (i + j + k...
ab37041e-f009-4ea4-b491-c691f88119cc
7
public CheckResultMessage check27(int day) { int r1 = get(39, 5); int c1 = get(40, 5); int r2 = get(41, 5); BigDecimal b = new BigDecimal(0); if (checkVersion(file).equals("2003")) { try { in = new FileInputStream(file); hWorkbook = new HSSFWorkbook(in); for (int i = r1 + 21; i < r2; i++) { ...
16694960-3959-48fc-9787-f31abcb59a76
2
private Move getMinimaxMove(StateTree tree) throws Exception { TicTacToeBoard state = tree.getState(); if (state.getTurn() == MIN_PLAYER) { return this.getMinMove(tree); } else if (state.getTurn() == MAX_PLAYER) { return this.getMaxMove(tree); } else { throw new Exception("Invalid player turn"); ...
c3da6b7f-0964-4b09-aaff-1d23c9b2e192
7
public void attdam(int maxDamage, int range) { for (Player p : server.playerHandler.players) { if(p != null) { client person = (client)p; if((person.playerName != null || person.playerName != "null")) { if(person.distanceToPoint(absX, absY) <= range && person.playerId != playerId) ...
ca69173e-7b89-4821-a22d-0ce6c127e5e6
1
public boolean jumpMayBeChanged() { return (catchBlock.jump != null || catchBlock.jumpMayBeChanged()); }
ff64e17a-afd4-4c18-a226-ea6095cc06fc
4
@Override public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, ServletException { Integer id = null; String name = null; String surname = null; Date dateOfBirth = null; Double salary = null...
bb8b89e6-6219-4bbf-98b1-be96b8696d4f
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 Pessoa)) { return false; } Pessoa other = (Pessoa) object; if ((this.id == null && other.id != null) || (this.i...
0aafa330-c407-4b43-bd7f-e60360f9894e
9
public boolean eventGeneratable(String eventName) { if (m_listenee == null) { return false; } if (m_listenee instanceof EventConstraints) { if (eventName.equals("instance")) { if (!((EventConstraints)m_listenee). eventGeneratable("incrementalClassifier")) { return false; } } ...
20b4eb87-1455-4632-a2b4-65dc55cde0cb
6
TabbedPane() { super(new GridLayout(1, 1)); JTabbedPane tabbedPane = new JTabbedPane(); java.net.URL imgURL = getClass().getResource("img/db.jpg"); ImageIcon iconDB = new ImageIcon(imgURL); panelDB = new JPanelCluster("MINE", new java.awt.event.ActionListener() { public void actionPerformed(Acti...
b7921633-3988-458b-875e-f6af8e185c9b
3
private void setPauseResume(ButtonMode mode) { BattleRunner runner = engine.getCurrentBattle(); if(mode == ButtonMode.PAUSE) { if(runner != null) { runner.setPaused(true); } btnPause.setText("Resume"); } else { if(runner != null) { runner.setPaused(false); } btnPause.setText("Pause"); ...
55c17911-cb9b-41f4-b986-8a4c67b4ba77
1
public static void main(String[] args) throws InterruptedException { Thread [] threads = new Thread[5]; CountDownLatch latch = new CountDownLatch(5);//tell it how many count downs there will be for(int i = 0; i<threads.length; i++){ final int current = i; threads[i] = new Thread(){ public void run(){...
89b9a1b4-3537-416e-ba5a-eaa6f18c76c0
5
public void addSum(int[] num,List<Integer> list,int target,int index){ if(target <= 0){ if(target == 0 && !result.contains(list)) result.add(new ArrayList<Integer>(list)); return; } for (int i = index;i < num.length ;i++ ) { if(num[i] > target)...
c371e96c-3df4-4595-a81a-0653cbc654fd
1
public Encryption(String m, String k) { if (k != "error") { char[] ck = fill(k); int[] i = fill1(ck); char[] cm = fill(m); int[] s = fill(cm); int[] r = scramble(s, i); o = em(r); }else{ //Do Nothing } return; }
1acb5463-0e8b-40bd-aa82-4dc040b10ef4
3
public void clearCache() { BufferedImage cache = cachedImage == null ? null : cachedImage.get(); if (cache != null) { cache.flush(); } cacheCleared = true; if (!isCacheable()) { cachedImage = null; } }
e15f1b4e-9297-4d10-9fca-2f72e37fe51f
4
public void setWidth(int width) { if(rotation == 90 || rotation == 270){ if(zoom == 1){ this.height = (int) (width/zoom); }else{ this.height = (int) (width/zoom)+1; } }else{ if(zoom == 1){ this.width = (int) (width/zoom); }else{ this.width = (int) (width/zoom)+1; } } }
a356c6f3-7540-4312-b3d6-bc3a8942970f
8
public int AddInstanceToBestCluster(Instance inst) { double delta; double deltamax; int clustermax = -1; if (clusters.size() > 0) { int tempS = 0; int tempW = 0; if (inst instanceof SparseInstance) { for (int i = 0; i < inst.numValues(); i++) { tempS++; tempW++; } } else...
1bf68c47-236b-401f-9fbe-67a06b75eaae
9
private void okButtonClick(ActionEvent evt) { Object[] selectedValues = templatesList.getSelectedValues(); if (selectedValues.length==0) { JOptionPane.showMessageDialog(this, "请选择模板.", "提示", JOptionPane.INFORMATION_MESSAGE); return; } String targetProject = textTa...
5ee451f3-260b-48b8-975b-aaa0c3466764
6
public final boolean is888() { if (!trueColour) return false; if (bpp != 32) return false; if (depth != 24) return false; if (redMax != 255) return false; if (greenMax != 255) return false; if (blueMax != 255) return false; return true; }
432ba8bb-4c23-47af-9d91-2f0bb4f066ff
9
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed boolean ch=false,ch2=false; for (int i = 0; i < cont.getText().length(); i++) { if(cont.getText().charAt(i)=='['||cont.getText().charAt(i)==']'||!Character.isDigit(cont.getText().c...
d7439d32-7734-4c02-a415-6c36cf7f1f0a
6
static public Object deserializeArray(InputStream in, Class elemType, int length) throws IOException { if (elemType==null) throw new NullPointerException("elemType"); if (length<-1) throw new IllegalArgumentException("length"); Object obj = deserialize(in); Class cls = obj.getClass(); ...
1b5e5cb9-6c40-47eb-9c09-f5c6227d2f80
1
@Override public int getIndex(TreeNode node) { if (!(node instanceof MyFile)) { throw new IllegalArgumentException("Unsupported type for the tree node " + node); } return this.files.indexOf(node); }
b0e2f9f6-ba38-4808-8cb0-c5aae2433864
2
public double PrecessionEpoch(double y, int type) { switch (type) { case JULIAN_EPOCH: return JulianEpoch(y); case BESSELIAN_EPOCH: return BesselianEpoch(y); default: return 0.0; } }
e0efdb06-7d14-4a52-a2ab-6617216a6075
6
public static Point[] getBlastRadius(Point point, int blockSize, int radius) { if(radius == 0) { return new Point[] {}; } else if(radius == 1) { return new Point[] {new Point(point.x, point.y - blockSize), new Point(point.x - blockSize, point.y), new Point(point.x + blockSize, point.y), new Poi...
2df81548-e3bc-4053-a975-3b162ad065b7
6
@Override public void repaint(Graphics graphics) { Graphics2D g2 = (Graphics2D) graphics; g2.setStroke(new BasicStroke(1)); g2.setFont(g2.getFont().deriveFont(10f)); int x = X; int y = Y; g2.setColor(COLOUR_BACKGROUND); g2.fillRect(x - 2, y - 2, WIDTH, HEIGHT); g2.setColor(COLOUR_BACKGROUND_BORDER);...
33248860-02ba-4b45-898e-35369e7783e6
0
public Fly(Animation left, Animation right, Animation deadLeft, Animation deadRight, Animation standingLeft, Animation standingRight, Animation jumpingLeft, Animation jumpingRight) { super(left, right, deadLeft, deadRight, standingLeft, standingRight, jumpingLeft, jumpingRight); }
bf1276ad-7d8f-40bf-bb17-200a24430883
6
public void run() { int p1Win = 0; int p2Win = 0; for (int i = 0; i < turn; i++) { Game game = null; if (i % 2 == 0) game = new Game(player1, player2, true); else game = new Game(player2, player1, true); game.clearBoard(); int result = game.play(); if (result == 1) { if (...
18cb7146-313c-4ef3-9777-5527ac964280
9
public void await() { // Set to 1 for ourselves. readyCount = 1; // Send out-going confirmations. new Thread(new Runnable() { @Override public void run() { for (ServerIdentifier identifier : servers) { if (identifier.equals(myI...
4cfa53ea-1356-4d4b-9688-e41ed2e1fb4c
4
@Override public void paintComponent(Graphics g){ Paint paint; Graphics2D g2d; if (g instanceof Graphics2D) { g2d = (Graphics2D) g; } else { System.out.println("Error"); return; } RenderingHints qualityHints=new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); ...
50a9ee97-09fc-4ed0-b360-5a1890a3a596
6
public String getInsertStatement(String ver, int book, int chapter) throws ParseException, IOException { // String strBook = String.format("B%02d", book); // String strChapter = String.format("C%03d", chapter); String strHtml = getOneChapterContent(ver, getBookChapter(book, chapter)); int ...
21354a1c-ef31-4aed-a1d0-6d3e0c397bda
5
private void despacharSolicitud(Solicitud psolicitud) { Operario operario1 = (Operario) listaOperarios.get(0); // Si hay mas de un operario, entonces asignar la solicitud a quien // tenga menos asignadas. if (listaOperarios.size() > 1 && solicitudesDespachadas.size() > 0) { Operario operario2 = (Operario...
10e5d2cd-7a22-4a70-b05c-54a56787ce0f
1
public int getSize() { int counter = 0; Occurrence temp = head; while (head != null) { counter++; head = head.next; } head = temp; return counter; }
af21167d-e38e-4ef4-9abd-b4ae032dc567
5
public void insert() { Connection conn = null; PreparedStatement pstmt = null; try { //1、加载驱动 Class.forName("com.mysql.jdbc.Driver"); String mysqlUrl = "jdbc:mysql://localhost:3306/rock"; //2、建立连接 conn = DriverManager.getConnection(mysqlUrl,"root","123456"); String sql = "insert into emp2(ename,...
dca9bb44-762d-41b8-a5c9-8ca9bac94f77
4
private static DefaultComboBoxModel createModel(Color[] colors, String[] names, boolean allowCustomColors) { DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i = 0; i < colors.length; i++) { Color c = colors[i]; String text = null; if (i < names.lengt...
570d782b-ba5c-428b-9049-49fecbd148a4
5
private void addActionListeners() { importDataMenuItem.addActionListener(e -> firePropertyChange(MainWindowController.IMPORT, 0, 1)); exportDataMenuItem.addActionListener(e -> firePropertyChange(MainWindowController.EXPORT, 0, 1)); ItemListener itemListener = new ComboBoxItemListener(); ...
34c36789-2e7e-4582-981f-bae3111f6b20
1
private String makeName(DateTimeField fieldA, DateTimeField fieldB) { if (fieldA.getName().equals(fieldB.getName())) { return fieldA.getName(); } else { return fieldA.getName() + "/" + fieldB.getName(); } }
c44c1c8d-cc6d-46de-9002-31d943418a33
5
private boolean zzRefill() throws java.io.IOException { /* first: make room (if you can) */ if (zzStartRead > 0) { System.arraycopy(zzBuffer, zzStartRead, zzBuffer, 0, zzEndRead-zzStartRead); /* translate stored positions */ zzEndRead-= zzStartRe...
5e62087c-4a74-4cef-942c-df8d4666670b
0
public static void prochaineGeneration(JCellule[][] grid, double nbrGenerations, JLabel lblGeneration, JButton btnProchaineGeneration) { ControllerGrille.grid.incrementGeneration(nbrGenerations); synchroniser(grid, lblGeneration, btnProchaineGeneration); }
d3456143-0691-4143-b896-23ce0fc44782
4
public static void setQt (String id, char signe) throws ParseException { for (int i=0;i<list.size();i++){ if (list.get(i).getId() == Integer.parseInt(id)){ if (signe == 'd') list.remove(i); else if (signe == '+') list.get(i).setQt(list.get(i).getQt()+1); else list.get(i).setQt(list.get(i...
5fdcaa44-cea5-4789-b360-843fb74bf596
5
public static void main(String[] args) { /* Activity 2.1 Scanners */ Scanner k = new Scanner(System.in); while ( k.hasNext() ) { // press Ctrl/Cmd + D(?) to stop input int d = 0; String s = ""; if (k.hasNextInt()) { d = k.nextInt(); } if (k.hasNext()) { s = k.next(); k.nextLine(); // s...
d918c1e8-95bd-47c8-835f-4f8ea7f3bca4
7
private void Competicao_ComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Competicao_ComboBoxItemStateChanged //Atualiza Jornadas_ComboBox Jornada_ComboBox.removeAllItems(); Competicao competicao; int max_jornadas; if (Campeonato_RadioButton.isSelected()) ...
283a7ded-2f49-48e9-ac9e-68f0b0aee41b
5
public long skip(long n) throws IllegalArgumentException, IOException { if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } // illegal argument if (n < 0) { throw new IllegalArgumentException("negative argument not supported"); } /...
20ed58d0-aed2-4153-bd2c-d1991fc78fd8
7
public Piece makePiece(String s) { boolean color = 'W' == s.charAt(0); switch (s.charAt(1)) { case 'X': return new Blank(color); case 'B': return new Bishop(color); case 'R': return new Rook(color); case 'P': return new Pawn(color); case 'Q': return new Queen(color); case 'K': ...
ef53e4d6-2b37-44c4-8959-a624725f88e6
0
@Override public void windowIconified(WindowEvent e) { }
f08056d4-07b4-4e77-893e-0b4f56180437
2
public static String wrapString(String str, double maxLength) { StringTokenizer st = new StringTokenizer(str); double spaceLeft = maxLength; int spaceWidth = 1; StringBuilder sb = new StringBuilder(); while (st.hasMoreTokens()) { String word = st.nextToken(); if ((word.length() + spaceWidth) > spaceLeft...
5d413e8a-e8fb-421e-b903-f9dc12d91c74
2
@Override public void printValueToConsole(List<Integer> list) { // checking input parameter for null if (list == null) { throw new IllegalArgumentException("array not specified!"); } System.out.printf("\n%s", "Value of array: \n"); for (Integer foo : list) { ...
46b58a25-b9ef-4145-bd9b-22fa2a091c12
2
public static void hypothesizeLambda(GrammarEnvironment env, Grammar g) { LambdaProductionRemover remover = new LambdaProductionRemover(); Set lambdaDerivers = remover.getCompleteLambdaSet(g); if (lambdaDerivers.contains(g.getStartVariable())) { JOptionPane.showMessageDialog(env, "WARNING : The start v...
ad44dca9-5d10-40e1-8116-d321b9f7cebf
1
public byte[] removeAttribute(String name) { if (unknownAttributes != null) return (byte[]) unknownAttributes.remove(name); return null; }
df14dc61-4b76-4be2-b09d-f654b3d27eea
6
private boolean processGMCommand(MapleClient c, MessageCallback mc, String[] splitted) { DefinitionGMCommandPair definitionCommandPair = gmcommands.get(splitted[0]); MapleCharacter player = c.getPlayer(); if (definitionCommandPair != null) { try { definitionCommandPai...
ea34cc02-3d92-4605-8867-8e7ac28a7573
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } @SuppressWarnings("rawtypes") Pair other = (Pair)...
1a19de45-52c5-44ec-a7ff-7c32b1cce514
8
public static int[] getTopBins(int[] bins, int binCount, int collapseBins){ int[] topBins = new int[binCount]; List<Integer> sortedBins = new ArrayList<Integer>(); Map<Integer, List<Integer>> binCountMap = new HashMap<Integer, List<Integer>>(); for(int i = 0; i < bins.length; ++i){ if(!binCountMap.containsKe...
339ae46f-d5df-4860-9724-0b35c9d38077
1
public static boolean oneIn(int x) { if (random.nextInt(x) == 0) { return true; } return false; }
81566949-67ff-491e-a73c-f04eb400d240
6
protected BufferedImage getCache() { if (floodFill != null) return myCache; floodFill = new FloodFill(canvas,source,origin,threshold); floodEdge = null; int w = floodFill.maxX - floodFill.minX + 1; int h = floodFill.maxY - floodFill.minY + 1; int rgb = c1.getRGB(); myCache = new BufferedImage(...
d538ac3a-6404-461f-a6fc-6f7fdf5d149f
3
public boolean checkEnemies() { for (Tile t : getMap()) { if (t.getClass() == Road.class) { if (((Road) t).hasEnemy() != null) ; return true; } } return false; }
45bba1d3-362a-4a31-9d1c-8437a81ed9a1
9
public final void printHTML(PrintStream out) { out.println("=== " + fcommand + " ==="); if (!fcommandGrammar.trim().equals("")) { out.println("*Usage:*"); out.println(); out.println("{{{"); out.println("java randoop.main.Main " + fcommandGrammar); ...