method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
a45927a2-5482-4167-a614-ccdf69e773c6
1
public static UserAction show(Window owner) { final Region root; try { root = FXMLLoader.load(PosApplication.class.getResource("MessageBox.fxml")); } catch (IOException e) { throw new RuntimeException(e); } MessageBox messageBox = new MessageBox(); messageBox.initModality(Modality.AP...
4f1bb041-1358-41e3-8b7f-202706e41d5b
2
private static int expectInteger ( Object value ) throws SocketException { int v; try { v = (Integer) value; } catch ( ClassCastException e ) { throw new AFUNIXSocketException("Unsupport value: " + value, e); } catch ( NullPointerException e ) { ...
8fe34f9c-db8d-4c34-87b1-c132b438f388
8
private void createProGuardFile(Set<String> keepNames) throws IOException { JavaFileManager.Location location = StandardLocation.SOURCE_OUTPUT; final String relativeName = UUID.randomUUID().toString(); FileObject resource = processingEnv.getFiler().createResource(location, "", relativeName); ...
fbaa4e13-e641-428d-b6f8-3d06e8a46c0a
7
public int getWeek(String week) { int pos = 0; if(week.equals("SUN")) pos = 1; else if(week.equals("MON")) pos = 2; else if(week.equals("TUE")) pos = 3; else if(week.equals("WED")) pos = 4; else if(week.equals...
a6381bc0-c07f-4b97-87b8-0c7c7d728a77
9
private String convert(String infix){ if(infix==null) return null; infix = "("+infix+")"; Stack<Character> s = new Stack<Character>(); HashMap<Character,Integer> map = new HashMap<Character,Integer>(); map.put('-', 1); map.put('+', 1); map.put('*', 2); map.put('/', 2); map.put('^', 3); for(cha...
db2190ff-e2e8-43ad-b6b5-1aa158adf654
7
public void mouseClicked(MouseEvent e) { synchronized ( waitObject ) { if (event == null) return; CellPanel found = null; // Figure out which cell this was in for (CellPanel c : zOrder ) { if ( c.isVisible() && c.screenPos.contains(e.getPoint()) ) { found = c; break; } } if ...
0486c0d4-67cd-4d97-b185-3558926189f0
3
private void startMigrating(Socket socket, MigratableProcess process, String hostName) throws IOException { ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); DataInputStream in = new DataInputStream(socket.getInputStream()); boolean status = false; try { ...
bbcd1830-d3c5-4b79-9a9b-a72a486fd08c
0
@Override public String getDesc() { return "FireBall"; }
771dd096-0580-4ab6-90b0-9d3a13b76ca3
1
public void writeToFile(String content) { try { Date dte = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy_HH-mm"); File file = new File("D:/ALL.csv"); // if file doesnt exists, then create it /*if (!file.exists()) { fil...
7e27fb67-84a9-46ec-b58b-46db546553a2
8
public void ia() { //*/ int [] temp1 = coord; for(int i =coord[0]; i>=0; i--) { for(int j =coord[1]; j>=0; j--) { int [] temp = {i,j}; if (canWin(temp)) { setCoord(temp); } } } if (temp1 == coord) { for(int i =coord[0]; i>=0 && (temp1 == ...
b84ffb67-d53b-4fe3-9df9-5b54bc9db214
5
private LinkedList<String> changeDetect(String file) { FileInputStream fis = null; InputStreamReader isr = null; BufferedReader br = null; LinkedList<String> res = null; try { fis = new FileInputStream(file); isr = new InputStreamReader(fis); br = new BufferedReader(isr); res = new LinkedL...
85d7b64e-b5ca-4105-8a1d-74dbe608beba
7
protected void readImage() { ix = readShort(); // (sub)image position & size iy = readShort(); iw = readShort(); ih = readShort(); int packed = read(); lctFlag = (packed & 0x80) != 0; // 1 - local color table flag interlace = (packed & 0x40) != 0; // 2 - inte...
d57cd6de-9858-48ec-9348-7793cf79d5ee
7
@Override public void actionPerformed(ActionEvent e) { JMenuItem source = (JMenuItem) e.getSource(); if(source.equals(toolbox)){ tb.setVisible(!tb.isShowing()); }else if(source.equals(figlist)){ fl.setVisible(!fl.isShowing()); }else if(source.equals(percent25) || source.equals(percent50)){ p.s...
2c3d8dfa-1add-438d-bb48-497311a73cdc
5
public boolean isHoliday(Date date) { int offset = 0; switch (m_policy) { case CLOSEST: offset = figureMonday(date,1); int previous = figureMonday(date,1); if (previous < offset) offset = -previous; break; case F...
2bd68f51-9b90-428f-b061-3af35250fe06
3
public void run() { playSound("ambience.wav", true); 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(); delta += (now...
2ab96fd1-aefa-43cd-9e26-c99b9db592b6
1
public synchronized void markCompleted(Piece piece) { if (this.completedPieces.get(piece.getIndex())) { return; } // A completed piece means that's that much data left to download for // this torrent. this.left -= piece.size(); this.completedPieces.set(piece.getIndex()); }
b454ea17-f6ea-48e9-af4c-5414d5de743f
3
public static void method166() { Soundtrack.noise = new int[32768]; for (int i = 0; i < 32768; i++) { if (Math.random() > 0.5D) { Soundtrack.noise[i] = 1; } else { Soundtrack.noise[i] = -1; } } Soundtrack.sineTable = new int[32768]; for (int j = 0; j < 32768; j++) { Soundtrack.sineTable[j]...
a14a88cf-78c2-4847-94eb-06c9688f7fb9
6
public FSList getEnrichmentsFromAnnotation(FsNode annotation) { if (annotation != null) { Response response = null; try { response = HttpHelper.sendRequest("GET", MAGGIE+"&id="+annotation.getId()+"&enrichments"); } catch(Exception e) { return new FSList(); } if (response.getStatusCode() != 200)...
a71a5c3e-9528-45b2-8c5c-4081bc951cbd
5
@Override public int buffersProcessed() { processed = 0; // Stream buffers can only be queued for streaming sources: if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING, "Buffers may only be queued for streaming sources." ) ) { ...
70d2bb48-330c-4d77-a01a-632ca66c9d59
1
public static double round(double value, int places) { if (places < 0) { throw new IllegalArgumentException(); } BigDecimal bd = new BigDecimal(value); bd = bd.setScale(places, RoundingMode.HALF_UP); return bd.doubleValue(); }
8dcc0b29-6b4a-4727-81e3-3266bd285cbf
3
private Socket connect () { Socket s = null; int attempts = 0; do { attempts ++; try { s = new Socket(host, port); s.setKeepAlive(true); s.setSoTimeout(0); } catch (Exception e) { String msg = String.format("Warning: connection attempt %d to %s failed.", attempts, ge...
303e80d9-0cd6-4f77-8bcc-6f8a99cc096d
8
public int longestValidParentheses(String s) { int rst = 0; int[] f = new int[s.length() + 1]; for (int i = 0; i<= s.length() ; i++) f[i] = 0; for (int i = s.length() - 2; i>=0 ;i--) { if (s.charAt(i) == '(') { int j = i +1; int k = 1; while (j < s.length()- k ...
a5f6a686-bab5-4b3d-8538-4fd0cbc980a6
4
private void handleCoordinates() { switch (curDirec) { case 0: curLocY--; break; case 1: curLocX++; break; case 2: curLocY++; break; case 3: curLocX--; ...
01f71d6f-3713-45c4-9489-425e7770f700
8
public void tree(File file) { if(file.isFile() || file.listFiles().length == 0) { System.out.println(space + file.getName()); } else { File[] files = file.listFiles(); System.out.println(space + file.getName()); List<File> fileList = new ArrayList<File>(); for (File f : files) { ...
305c5dc0-e6e3-48ae-9c9d-1aa9abf2efe6
0
public static TimeManager getInstance() { return instance; }
a9ba9d62-d9ae-43fa-946a-09f7103c6a57
5
public int getLinkType() { // border style has W value for border with if (borderStyle != null) { if (borderStyle.getStrokeWidth() > 0) { return VISIBLE_RECTANGLE; } } // look for a border, 0,0,1 has one, 0,0,0 doesn't else if (border != nu...
8e647a68-fbe9-44ae-abda-1866fcb4263e
2
private String getUrl() { if (last == null || !last.hasNext()) { last = getRandom(); } else { last = last.getNext(); } return last.getUrl(); }
b93720b1-e668-4ce9-a58e-dee03218a567
9
public MainViewController() { this.view = new MainView(); view.setViewListener(new ISelectActionViewListener() { @Override public void setSelectedType(String selectedItem) { if (selectedItem.equals("Create Customer")) { innerPanelPresenter = new AddCustomerPresenter(); } else if (selectedItem.eq...
5670bdf3-d7ae-4971-a94b-c01c4ffe76dd
5
public void keyReleased(KeyEvent e) { switch(e.getKeyCode()) { case 27: exitGame=true; break;//ESC case 40: p.deleteArrow(1); break;//downArrow case 37: p.deleteArrow(2); break;//leftArrow case 39: p.deleteArrow(3); break;//rightArrow case 38: p.deleteArrow(4); break;//UpArrow } p.initData();...
b53a638f-2f5e-4aaf-b315-16fed729715a
1
public String getFileName() { if (getFileOrWindow() == 1) return textField.getText(); else return null; }
3167eb56-9b34-4a01-8508-f4986feb6fe6
4
private Nodo<T> findBefore(Nodo<T> novo) { Nodo<T> atual = getHead(); Nodo<T> anterior = null; while (atual != null) { int comp = atual.compareTo(novo); if (comp < 0) { anterior = atual; atual = atual.getNext(); } if (comp == 0) return atual; if (comp > 0) return anterior; } ...
8b60be22-eb13-4a36-86f7-e93c677fab64
8
public Quality verify() { double min_lambda = 1; // for center-in-convex-hull check double max_overlength = 0; // for all-points-in-ball check double min_underlength = 0; // for all-boundary-points-on-boundary double ball_error; double qr_error = support.representationError(); // Center reall...
d03e37e0-a2fd-4416-adae-db268b9bb47b
2
public Object execute() { // in C++, you do something like --- return receiver->action( args ); try { return action.invoke(receiver, args); } catch (IllegalAccessException e) { System.out.println(e); } catch (InvocationTargetException e) { ...
20d57842-8e2d-450e-bf1b-cb76fe2e3d15
4
private void boundsCheck() { if(announcerInterval <= 0) { announcerInterval = 15; } if(announcements == null) { announcements = new ArrayList<String>(); } // Check default channel if(defaultChannel == null) { if(channels.isEmpty()) { ...
1b49fcf4-3684-4d26-a1ff-643ec05390c5
0
public static void main(String[] args) { CoffeeMakerService.set(new SimulatedCoffeeMaker()); }
3c0de54d-7007-475f-9fd5-32ba8a2aaa9a
4
public void run() { //Create Map map = new HashMap<Double, Planet>(); for (Planet p : oldPlanets) { map.put(p.getId(), p); } for (Planet p : currentPlanets) { if (map.get(p.getId()) == null) { continue; } if (!(map....
2d2844e2-4117-49b0-9281-1b94ce7036cc
8
public static StringBuffer powers(Deity E, HTTPRequest httpReq, java.util.Map<String,String> parms, int borderSize) { final StringBuffer str=new StringBuffer(""); if(parms.containsKey("POWERS")) { final Vector<String> theclasses=new Vector<String>(); if(httpReq.isUrlParameter("POWER1")) { int num=1;...
2012936d-579c-44e7-8830-5e670d73013b
7
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 targetCell =...
06bbfb90-b34a-4a8d-af9e-b392e6e62550
0
public static void main(String[] args) { //************** T E S T I N G *********************** int inputBuffers = 4; int outputBuffers =4; int pulse = 5; //every two ticks the router attempt to move a packet int packetSize = 15; int fabricSpeed = 2; int tota...
a0ce3ed5-c95c-4833-aed3-439b6cfd99be
5
public static boolean isBlack(int i) { int num = i % 12; if(num == 1 || num == 3 || num == 6 || num == 8 || num == 10) return true; return false; }
e58fb518-146d-4be6-9d74-801695fe6985
3
private void selectEntity() { int x = (input.mouse.x - POS_TILESET_X) / Tile.SIZE + tilesetDisplayStart.x; int y = (input.mouse.y - POS_TILESET_Y) / Tile.SIZE + tilesetDisplayStart.y; if ( y * NB_COL_ENTITY_AREA + x < EnemyType.values().length) { if (currentEntity == EnemyType.values()[y * NB_COL_ENTITY_ARE...
933c6345-85f6-46dd-b88f-0384ef2f6d3d
9
public List<MemberBean> getSearchMemberList(int start, int end, String colName, String search) { Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; List<MemberBean> memberList = null; String sql = null; try { conn = getConnection(); sql = "select a.* from (select ROWNUM a...
1bc6fa3c-e0b9-46a5-8e01-8ef7de93f91a
3
@Override public void rotateYMinus() { if(orientation == Y) return; orientation = (orientation == Z ? X : Z); for(int i = 0; i < others.length; i++) { IntPoint p = others[i]; others[i] = new IntPoint(-p.getZ(), p.getY(), p.getX()); } }
5ce4a4d1-62f7-4f9b-b816-663d4a632919
8
public String[] encrypt(String[] text) { StringBuilder sb; for(int i = 0; i < text.length; i++) { sb = new StringBuilder(); if(!hasNonVowel(text[i])) continue; else { for(int j = 0; j < text.length; j++) { if(text[i].charAt(j) == 'a' || text[i].charAt(j) == 'e' || text[i].charAt(...
1bb62d4b-9453-44a3-a38e-a90f9dd06e58
4
private static String readUrl(String urlString) { StringBuffer buffer = null; BufferedReader reader = null; try { URL url = new URL(urlString); reader = new BufferedReader(new InputStreamReader(url.openStream())); buffer = new StringBuffer(); int read; char[] chars = new char[1024]; while ((read...
11a0d259-dc12-4c4c-8200-63ca9f5264e1
5
private final void method640() { for (int i = 0; i < anInt5351; i++) { short i_287_ = aShortArray5388 != null ? aShortArray5388[i] : (short) -1; if (i_287_ == -1) { int i_288_ = aShortArray5311[i] & 0xffff; int i_289_ = (i_288_ & 0x7f) * anInt5344 >> 7; short i_290_ = Class25.method303(i_288_ & ~0x7f...
cfaadbb8-7bf7-4253-b6d3-86d72cafe3f3
0
private void setFrameModificar(){ modificarFrame.setVisible(true); modificarFrame.setTitle("Modificar Cliente"); modificarFrame.setSize(500, 300); }
2a461ba5-3271-4a6a-8d03-11a86b28dd63
4
public void traceBack() { if (!myTraceAvailable) return; CYKTracer cykTracer=new CYKTracer(grammar, myParser.getTrace()); cykTracer.traceBack(); myAnswers=cykTracer.getAnswer(); /* System.out.println("Answer is "); for (int i=0; i<myAnswers.length; i++) System.out.println(myAnswers[i].getLHS()+" ->...
f71c9ca8-b779-4d54-bc12-c953e087d275
0
@Test public void dedup_whenInputContainsDuplicatedChars() { List<Character> chars = new ArrayList<Character>(Arrays.asList('a', 'b', 'b')); String expected = "[[a, b, b], [b, a, b], [b, b, a]]"; String actual = permutation.permute(chars).toString(); assertEquals(expected, actual); ...
9c85f72e-1816-49b8-8ba5-dfb963860cdd
9
public static void drawLine(Graphics g, int x0, int y0, int x1, int y1, Color color) { g.setColor(color); int dx, dy, d, x, y, deltaE, deltaNE, stepx = 0, stepy = 0; dx = x1-x0; dy = y1-y0; if (dx<0) { dx = -dx; stepx = -1; } else if (dx>0) { stepx = 1; } if (dy<0) { dy = -dy; stepy = -...
65447457-88e6-4db1-99a5-78bd29ae218c
9
private static boolean checkForUpdate(final View _view, final boolean _showNoUpdateMSG) { try { // Create a URL for the desired page URL url = new URL("http://juliushuelsmann.github.io/paint/currentRelease"); // Read all the text returned by the server BufferedReader in = new Bu...
1202b07b-0b83-4ba1-b7f0-e7b3d7203fd5
9
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) { final UText shape = (UText) ushape; final FontConfiguration fontConfiguration = shape.getFontConfiguration(); final UFont font = fontConfiguration.getFont().scaled(param.getScale()); final Dimension2D dimBac...
9ec93fb5-6c0c-406c-9cdd-a68edafd1850
9
private int block() throws HU01Exception { ByteBuffer b = buffer.slice(); // slice to prevent changing buffer until we now we've got a full block b.order(buffer.order()); if (b.remaining() < 20) { // We need at least 20 bytes for the header return 0; } in...
68b36688-6b8e-4c65-90d1-9f26d5779ca1
1
public int getNumberOfMatchPlayers(String matchName){ try { cs = con.prepareCall("{ call GET_MATCH_PLAYERCOUNT(?,?) }"); cs.setString(1, matchName); cs.registerOutParameter(2, Types.INTEGER); cs.executeQuery(); //System.out.println("number of players in match: " + cs.getInt(2)); return cs.getInt(2);...
3ec2c4bf-b732-4b5b-b95c-80911624b95b
6
public void runBattle() throws IOException, InterruptedException { Move move1 = friendlyPokemon.getMove1(); Move move2 = friendlyPokemon.getMove2(); AI ai = new AI(enemyPokemon); WindowHandler window = new WindowHandler(enemyPokemon, friendlyPokemon) ; window.initComponents(); //creates window B...
3caafbfb-91d7-4f41-82fc-da3f12c3a19e
4
private ArithmeticResult expression(Block codeBlock) throws IOException, SyntaxFormatException { ArithmeticResult leftTerm = term(codeBlock); if (leftTerm != null) { while (checkCurrentType(TokenType.PLUS) || checkCurrentType(TokenType.MINUS)) { TokenType op = lexer.getCurrentToken().getType(); moveToNex...
dd40f8fb-b50d-46b0-a518-4b016e5052da
5
private void merge(int[] input, int lo, int mid, int hi) { int i = lo; int j = mid + 1; for (int k = lo; k <= hi; k++) { aux[k] = input[k]; } for (int k = lo; k <= hi; k++) { if (i > mid) { input[k] = aux[j++]; } else if (j > ...
28f8e10e-6acb-4a46-9498-cdbca0f10da9
4
public static final String getIntString(int length) { if (length <= 0) { return ""; } String str = Double.toString(Math.random()).substring(2); int realLen = str.length(); if (length > realLen) { StringBuilder sb = new StringBuilder(length).append(str); int remain = length - realLen; while (remain...
ed5ef2f0-db70-4682-898f-edc51e248103
7
public void setUserInfo(){ Student usr = Database.db[Database.user]; if (!userName.getText().isEmpty()){ usr.setUserName(userName.getText()); } if ( !jTextField1.getText().isEmpty() ){ usr.setStreet(jTextField1.getText()); } if( !jTextField2.getTex...
e99ed949-809d-47e3-80ce-3c684b2ff179
0
private void initTable(){ Object[] columns = {"English", "Russian"}; DefaultTableModel tableModel = new DefaultTableModel(); tableModel.setColumnIdentifiers(columns); table = new JTable(tableModel); tableView = new JScrollPane(table); }
6bdd726c-3247-4ab5-bb85-d4116b12c9bf
8
public boolean isSameTree(TreeNode p, TreeNode q) { if (p == null && q != null || p != null && q == null) return false; if (p == null && q == null) return true; if (p.val == q.val) return isSameTree(p.left, q.left) && isSameTree(p.right, q.right); else return false; }
d5239892-06be-4190-9bb9-2869a611798e
4
private void readFile(File diffMapperFile) { try { BufferedReader reader = new BufferedReader(new FileReader(diffMapperFile)); String[] title = reader.readLine().split("\t"); String line; while((line = reader.readLine()) != null) { String[] value = line.split("\t"); for(int i = 0; i < title.le...
ef638658-ae40-41b5-9b51-a602d526bd70
0
@Override public boolean isValid(File file) { return true; }
6aaceeac-26ee-4f2a-97de-78c169b2d3a1
0
private void updateStatus() { pane.stackDisplay.setText(stackString()); pane.inputDisplay.setText(STRING.substring(P)); }
b42fc584-031f-42d8-adca-03cbd34bcfda
5
public int[] getImagePixels(String filename, int width, int height) throws IOException { File f = new File(filename); BufferedImage image = ImageIO.read(f); //rescale to resample pixel data Image scaledImage = image.getScaledInstance(width, height, 1); PixelGrabber grabber; int[] pixels = new int[scale...
bb42110e-990f-4b88-b9a5-8611bef002fc
3
public String connectToServer(int port, String host) { PORT = port; HOST = host; /** * Trying to establish a connection to the server * in the try/catch block below. */ try { connectionToServer = new Socket(HOST,PORT); // Attempt to establish a connection to the server... /* Establish stre...
16942e58-c466-461b-b980-a724f5387697
8
void output( int code, OutputStream outs ) throws IOException { cur_accum &= masks[cur_bits]; if ( cur_bits > 0 ) cur_accum |= ( code << cur_bits ); else cur_accum = code; cur_bits += n_bits; while ( cur_bits >= 8 ) { char_out( (byte) ( cur_...
ed34bcec-638e-40e6-adef-1d724ba5a983
9
public T openForWrite() { Transaction me = Transaction.getLocal(); switch (me.getStatus()) { case ACTIVE: Locator locator = this.locator.get(); if (me == locator.owner) { return locator.current; } Locator newLocator = new Locator(me...
24bde613-5e9a-4d78-841f-d1d95d928887
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...
e70ef58b-6e98-4f2c-8524-4325eb6a8f56
3
@Override protected String toString(int indent) { String str = toString(indent, "ModuleNode\n"); if(ident != null) str += ident.toString(indent+1) + "\n"; if(declaration != null) str += declaration.toString(indent+1) + "\n"; if(statementSequence != null) str += statementSequence.toSt...
92391d39-e31c-46c9-a858-5904fc76f4af
5
public void buffmsg(Message msg) { String name = msg.string().intern(); synchronized (buffs) { if (name == "clear") { buffs.clear(); } else if (name == "set") { int id = msg.int32(); Indir<Resource> res = sess.getres(msg.uint16()); String tt = msg.string(); int ameter = msg.int32(); in...
b723857d-853f-41fd-9ce4-a903c0506de5
0
private static void startGame(){ new Game(); }
dcb56b8d-5424-4b68-9fd5-9be819817a44
0
@Test public void testGetNombre() { System.out.println("getNombre"); Cuenta instance = new Cuenta(); instance.setNombre("Martin"); String expResult = "Martin"; String result = instance.getNombre(); assertEquals(expResult, result); // TODO review the generated ...
81397857-267e-4361-a914-ea9fc0d4bd45
3
private boolean noIdentityDiscOnWall(Grid grid) { List<IdentityDisc> identityDiscs = getIdentityDiscsOfGrid(grid); for (IdentityDisc idDisc : identityDiscs) { final Position idDiscPos = grid.getElementPosition(idDisc); for (Element e : grid.getElementsOnPosition(idDiscPos)) if (e instanceof Wall) ...
946336eb-62fa-46fb-bcae-c66fc5b21cd9
0
@Test public void testInitial() throws Exception { assertEquals(view.getDialog().getTitle(), "title"); assertEquals(view.getTextArea().getText(), "Calculating"); assertEquals(view.getProgressBar().getValue(), 0); assertEquals(view.getButton().isEnabled(), true); }
c67771eb-483f-4b84-a8ba-6b64b5cd41b9
7
private void initDeck() { if(DeckofCards !=null){ for (int j = 0; j < 4; j++){ // load for each card type for (int i = 1; i < 14; i++) { //load for each card type, it's value. switch (j) { case 0: DeckofCards.add(new Card(CardType.values()[j], i,new String("/GameImages/Club-"+ i + ".png"))); ...
baf09b6f-abd4-4728-b04e-e669432b2d74
9
public void send(final byte[] frame, final boolean blocking) throws KNXAckTimeoutException, KNXPortClosedException, InterruptedException { boolean ack = false; try { for (int i = 0; i <= REPEAT_LIMIT; ++i) { if (logger.isLoggable(LogLevel.TRACE)) logger.trace("sending FT1.2 frame, " + (blocking ? "" ...
acd67f8f-d5a2-4eef-8422-a34a6e057f20
7
public static void lookUpMovie(String str, int width) { char[] arr = str.toCharArray(); int prevPosition = 0; int prevRow = 0; for(char c : arr) { // Tricks I learned from a solution on CareerCup. // Get the horizontal distance moved. int position = (c - 'a') % width; // Get the vertical dis...
b166223d-2cba-4349-a864-adb45e863dc0
4
public RankedPlayer getRankedPlayer() { switch(permission) { case "rank.vip": return new VIP(uuid); case "rank.sponsor": return new Sponsor(uuid); case "rank.supporter": return new Supporter(uuid); case "rank.donator": return new Donator(uuid); default: return new NoRank(uuid); } }
3f9a25da-df3c-44d8-945f-7020b947ffe2
5
private void createMenuBar() { fileMenu = new JMenu(settings.getLanguage().getLabel("menu_file")); fileConnectMenuItem = new JMenuItem(settings.getLanguage().getLabel("menu_file_connect")); fileDisconnectMenuItem = new JMenuItem(settings.getLanguage().getLabel("menu_file_disconnect")); fileSettingsMenuItem ...
b80a7f79-90f0-4250-8e33-0272d5db6f03
6
@Override public void run() { switch(state) { case COUNTDOWN: obj.setDisplaySlot(DisplaySlot.SIDEBAR); System.out.println("Count Down: " + ChatColor.DARK_AQUA+secondsToMinutes(counter)); obj.setDisplayName(ChatColor.DARK_AQUA+secondsToMinutes(counter)); if(arena.getNumberOfPlayers()==0) { a...
c44a3b7d-18cf-4df7-88f4-2ab8282d626f
5
@Override //Disparado quando a tag de inicio eh encontrada public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { String tipo = getTipo(); if(tipo.equals("getCPU")){//tag atual. Ex.: <host...> switch(qName){ //Cria um novo objeto...
aff0487c-8427-4dd3-98bc-211a16169ea3
9
public void newGame() { // Called when our game is executed. This is the game loop. while (true) { // Repeat forever. Makes sure you can keep playing using the same settings, as this way, it just repeats the game startup process. gameOver = false; // Game is no longer over. resetTiles(); // Reset the tiles to c...
fa7d9334-53fc-48ef-8ef1-0b9ee9d7e43c
1
public int getZAxisValue() { if (zaxis == -1) { return 127; } return getAxisValue(zaxis); }
179a221c-882e-48f6-a377-f4cc62faabd8
3
public void generateConversationLengthVsFreq() throws IOException{ conversationLengthVsFreqFileWriter = new BufferedWriter(new FileWriter(convLengthVsFreqFile)); TreeMap<Integer, Integer> conversationLengthVsFrequency = new TreeMap<Integer, Integer>(); for( Long rootId : roots ) { ...
58918ac1-fabc-496d-99e0-df2fe9c54323
8
private static Boolean validateBraces(final String braces) { // count to keep track of opening and closing braces int count = 0; if (braces != null && !braces.isEmpty()) { // This condition is ONLY on assumption that input string has only // braces. If input string has characters other than braces then, ...
62cd9040-ce6f-4626-9e9b-ab388a88a7da
9
public void setSrcType(String type) { if ("string".equalsIgnoreCase(type)){ this.srcType = SrcColumnType.STRING; } else if ("integer".equalsIgnoreCase(type)){ this.srcType = SrcColumnType.INTEGER; } else if ("blob".equalsIgnoreCase(type)){ this.srcType = SrcColumnType.BLOB; } else if ("list".equalsIgno...
8e5d0931-25cc-4687-b227-dc841106bc36
4
private void telecharger() { try { //on compte le nombre d'image à enregister nomImage = "img\\img"+ijk+".png"; System.out.println(nomImage); // On crée les variables pour télécharger le fichier URL adresse = new URL(url); URLConnection con...
3638cf2b-30b6-4a36-b590-46123b64f76e
4
public void run(){ while(true){ //System.out.println("here"); byte[] buf = new byte[Mediator.MTU]; DatagramPacket recv = new DatagramPacket(buf, buf.length); try { socket.receive(recv); if ((Math.random()*100) > 20 || recv.getData()[0] == Mediator.DISCONNECT) { mediator.handleReceivedPacket...
16d5ff1f-6975-4ecf-a95c-491ea4e5453b
1
@Test public void multiply() { try{ double [][]mat= {{1.0,2.0}, {3.0,1.0}}; mat = Matrix.mult(mat, Matrix.transpose(mat)); double [][]expMat= {{5.0,5.0}, {5.0,10.0}}; Assert.assertArrayEquals(mat, expMat); } catch (Exception e) { // TODO Auto-generated catch block fail("Not yet implemente...
851caeda-4325-40ee-a566-b78eef8b9aca
5
public CodonOptimizationPanel(int purpose){ mode = purpose; // get vectors of component names organismVector = MainFrame.myss.getOrganismNames(); for(int i = 0; i < MainFrame.myss.standards.size(); i++){ standardVector.add(MainFrame.myss.standards.get(i).getName()); } for(int i = 0; i < Mai...
168f4afd-8e9b-438c-920e-2b3991e90d66
8
private BufferedImage getSource(ImageResizeRequest request) { try { if (request.getSourceImage() != null) { return request.getSourceImage(); } if (request.getSourceFileStream() != null) { return ImageIO.read(request.getSourceFileStream()); } File sourceFile = null; if (request.getSourceFi...
9e3f1aca-d2b6-4a15-8cec-df0d91655a87
8
public void migrateDelete(int from, int to){ migrateRate tempmigrate = migrations; migrateRate delmemigrate = null; boolean done = false; if (tempmigrate == null) return; if (tempmigrate.getFromPop() == from && tempmigrate.getToPop() == to) { migrations = migrations.next; ...
bce20551-70ee-450e-8b73-223f861ee93b
1
@Override public void setDecoration( Decoration decoration ) { if( decoration == null ) { throw new IllegalArgumentException( "decoration must not be null" ); } this.decoration = decoration; }
089bbfd8-30fa-4dbf-8d5e-d09f81a51607
9
@Override public void onEnable() { try { long timetemp1 = System.nanoTime(); getLoggerUtility(); Exception ex1 = null; try { this.config = new ConfigHandler(this); this.config.loadConfigonStart(); try { ...
1dc0a20a-91fc-4f09-92ae-756c4e385447
3
public void insert(T x) { if (size == heapArray.length - 1) { doubleSize(); } int pos = ++size; for (; pos > 1 && x.compareTo(heapArray[pos / 2]) < 0; pos = pos / 2) { heapArray[pos] = heapArray[pos / 2]; } System.out.println("inserted " + x + " at " + pos); heapArray[pos] = x; }
9b839ced-6e7e-4e24-b8eb-faf6a9761908
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...
5d9a3623-caa6-4e50-892b-741329845888
0
public static void main(String[] args) { float float_pi = 3.145926535897896F; double double_pi = 3.145926535897896D; System.out.println(float_pi); // 3.1459265 System.out.println(double_pi); // 3.145926535897896 }
b2192047-a3ca-4e6b-a3bf-284fdf400708
6
public static boolean parsable(String s){ int j = s.indexOf('('); if(j < 1) return false; if(!Util.areAllNumerals(s.substring(0, j)))return false; String frac = s.substring(j); //make sure frac matches (<numerals>)/(<numerals>) int i = frac.indexOf(")/("); return i > 1 && frac.charAt(0) == '(' && frac.cha...
a6973ece-c7cc-4a74-8023-6b50d287f8ce
6
private void downloadModTextures() { final byte[] buffer = new byte[1048576]; new File(Strings.TEMPORARY_DATA_LOCATION_A).mkdirs(); new File(Strings.TEMPORARY_DATA_LOCATION_A).deleteOnExit(); ArrayList<String> temp = new ArrayList<String>(); for(int i=0; i<Soartex_Patcher.tableData.length;i++){ if(Soarte...