method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
633ad4f9-9b9f-4b09-ba5d-f021270b4a64
8
public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine().trim()); for (int i = 0; i < n; i++) { String y[] = in.readLine().trim().split(" +"); int x = Integer.parseInt(y...
410a671a-dfc3-468b-ac25-3490d22a4174
3
public void updateBullets(long time) { // Loop through all the available bullets for(int i = 0; i < bullets.length; i++) { // Try block for safety. try { // If the bullet is alive, then let's update it. if(bullets[i].living == true) { bullets[i].update(time); } } // If th...
1a558c11-105c-4f0f-8e7b-df6099a55e50
2
@Test public void testNumberOfDoorways() { int numDoors = 0; int totalCells = board.getNumColumns() * board.getNumRows(); Assert.assertEquals(506, totalCells); for (int i=0; i<totalCells; i++) { BoardCell cell = board.getCellAt(i); if (cell.isDoorway()) numDoors++; } Assert.assertEquals(16, n...
ca6c9d9e-0d79-4ca8-bc09-6c3451ea18d9
1
public static void addCombo(LogAc logAc, JComboBox<String> comboBox){ int index = 0; while (logAc.getDoctor(index)!=null){ comboBox.addItem(logAc.getDoctor(index).getName()); index++; } }
98f94049-2460-4db9-99db-d6198ba86b09
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PersonVO other = (PersonVO) obj; if (firstName == null) { if (other.f...
8d9a081d-deec-466c-bb01-b2235e80eaf7
1
public void addProduct(Product product) { try { beginTransaction(); session.save(product); session.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { closeSesion(); } }
546f640d-7dac-4d46-a6b0-f401ffa18255
0
public void addPanel(AbstractPreferencesPanel panel, String title, int depth) { JScrollPane jsp = new JScrollPane(panel); panelJspMap.put(title,jsp); PreferencesFrame.RIGHT_PANEL.add(jsp, title); addPanelToTree(title,depth); }
d5eba4bf-ac6e-44ce-8629-09f7dc29918f
0
public synchronized byte[] digest(byte[] input) { md.update(input); byte[] hash = md.digest(); return hash; }
c4780968-a210-40db-ad37-b931ead5eb23
2
@Test public void test() throws IOException, RowsExceededException, WriteException, InterruptedException{ String url = "/Users/kimgyupyo/study/project/workspace/ResourceManager/src/test/java/data_write.xls"; WritableWorkbook workbook = null; WritableSheet sheet = null; File execFile = new File(url); Labe...
f383462d-871e-4cf0-8324-c7c5263f96bc
3
public synchronized void actualiza(long tiempoTranscurrido) { if (cuadros.size() > 1) { tiempoDeAnimacion += tiempoTranscurrido; if (tiempoDeAnimacion >= duracionTotal) { tiempoDeAnimacion = tiempoDeAnimacion % duracionTotal; indiceCuadroActual = 0; ...
e3d9edf2-55ae-46e3-91e1-de32d3072a5b
3
public static void hex(final ByteBuffer buffer, final StringBuilder out) { final int start = buffer.position(); final int end = buffer.limit(); for (int pos = 0; pos < end; pos += ELEMENTS_PER_LINE) { out.append(String.format("%04X - ", pos)); for (int i=0; i<ELEMENTS_PER_LINE; ++i) ...
757f3794-c224-4334-bc55-f32701810c3d
0
public void setLoginField(String userName2) { login.setText(userName2); }
efa95af2-223e-46db-906a-2af4cdaaf783
9
public void swap(int i1, int i2, int j1, int j2){ int ilength = i2-i1+1; int jlength = j2-j1+1; int diff = jlength - ilength; Set<Pair<Integer,Integer>> newAlignments = new HashSet<Pair<Integer,Integer>>(); for(Pair<Integer,Integer> alignment : sureAlignments){ int pos = alignment.getFirst(...
d3fa3f06-9e1a-4aec-9430-3b71f167f8a6
7
public static Rule_UNDERSCORE parse(ParserContext context) { context.push("UNDERSCORE"); boolean parsed = true; int s0 = context.index; ArrayList<Rule> e0 = new ArrayList<Rule>(); Rule rule; parsed = false; if (!parsed) { { ArrayList<Rule> e1 = new ArrayList<Rule>(); ...
7c398bd6-95f3-4ba2-9353-eae91497bd7e
5
public boolean/*Node*/ moveParty(Direction d) { Node node = null; switch(d) { case SOUTH: node = this.s; break; case NORTH: node = this.n; break; case EAST: node = this.e; break; case WEST: node = this.w; break; } if (node != null /*&& !node.getRoom().occupied()*/) { /* node....
ffac8cab-6080-4557-aa25-169376b92579
5
public void openNewCustomerAccount(CustomerUser c) { Scanner input = new Scanner(System.in); System.out.println("What kind of account will " + c.getFirstName() + " have?\n1. Checking\n2. Savings\n3. Line of Credit\n4. Loan\n5. Certificate of Deposit\n(Enter [1-5]: "); int choice = input.nextInt(); switch (choi...
6dbdb1e5-6bbd-456e-ad4b-fd796fd6ef06
2
public void SwitchTo(int lexState) { if (lexState >= 1 || lexState < 0) throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); else curLexState = lexState; }
4dd1ec9a-aa31-4cba-b448-7e14fa874be2
4
public void updateAmmo(char whatFiredIt){ switch(whatFiredIt){ case 'b': { if ((remainingAmmo - 1) <= 0) { gameOver(); } else { remainingAmmo -= 1; ammo.setText("Cannons Left: " + remainingAmmo); ...
bf6708a5-ac90-43e9-b9ed-a8f46bd12e09
6
public int setHolePos(Position newPos){ int nHole = -1; if(isInsideBoard(newPos)) { if(isEmpty(newPos)) { // Set Hole if(writeOnBoard(newPos, HOLE)) { Position hole = new Position(newPos.getX(),newPos.getY()); getHolesPos().add(hole); removeFromBoard(EMPTY, hole); nHole...
0fd9441c-d68a-4a2f-b057-949b95bd989f
5
public boolean emptyDatabase() { Connection conn = null; Statement ps = null; try { conn = iConomy.getiCoDatabase().getConnection(); ps = conn.createStatement(); ps.execute("TRUNCATE TABLE " + Constants.SQLTable); } catch (Exception e) { return false; } finally ...
2d3391c4-9dd4-4efb-b506-5433669b478e
4
final public List<Exp> ExpList() throws ParseException { List<Exp> l = new ArrayList<Exp>(); Exp e; e = Exp(); l.add(e); label_7: while (true) { switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { case 72: ; break; default: jj_la1[20] = jj_gen; break label_7; } jj_consume_token(72); ...
691d1bd4-51d9-494c-9c55-6958a9ceedb0
2
public void setReportState(int rId, ErrorCode state) { try { connect(); String strStatement = "UPDATE report SET rErrorCode=" + state.value() + " WHERE rId=" + rId; _statement.executeUpdate(strStatement); _logger.debug("State changed for: " + rId + "to " + state.value()); } catch (ClassNotFoundExce...
b493ecb8-7449-408e-9d1a-8fa4ba48c639
1
@Override public Object create(Object o) throws Exception { try { session = obtainSession(); session.beginTransaction(); session.save(o); session.flush(); session.getTransaction().commit(); return o; } catch (HibernateException ...
04ebdca2-2642-4fc4-8a00-0cb4ffbf0a2f
2
public static int randRange(int min, int max) { if (max - min == 0) { return min; } if (max - min <= 0) { Log.print("wat"); } int randomNum = random.nextInt(max - min) + min; return randomNum; }
215fd0ee-ff0c-445d-b58e-f05a19d36c65
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; }
29440886-38c8-4dc7-a4b9-041c488c49d0
2
public Geometry getMaxExtend(){ if(maxExtend!=null){ return maxExtend.getEnvelope(); } maxExtend = new MultiPolygon(null, Helper.getGeometryFactory()); for (Label candidate : candidates) { maxExtend = maxExtend.union(candidate.getGeometry()); } return maxExtend.getEnvelope(); }
b22ae7d9-c12b-46be-8ed3-6a05a4fad72d
7
public RosterView() { setLayout(new BorderLayout()); setPreferredSize(new Dimension(250, 200)); String[] headerStr = { "Student", "In-Class", "Allow 2 Draw", "Question" }; int[] columnWidth = { 100, 150, 100, 50 }; SortableTableModel dm = new SortableTableModel() { p...
d08b49be-8272-4fbf-b70b-460b4922dcd8
4
public static void DoTurn(PlanetWars pw) { // (0) Create a random number generator Random random = new Random(); // (1) Pick one of my planets at random. Planet source = null; // (1a) Take the list of my planets List<Plan...
1c16410f-4370-4a09-a302-0d657cdfb4f8
5
public void run(){ if(running == true) return; run = true; try { while(run){ running = true; simulateOneStep(); running = false; try { Thread.sleep(50); } catch (InterruptedException ex) {} synchronized (lock) { ...
eb00ca59-ce3c-482a-a43e-81ca69842a98
4
public void refreshCouples (ArrayList <Piston> others){ if (others.size() > 1){ couples.clear(); for (int i = 0; i < others.size(); i ++){ for (int j = i+1; j < others.size(); j++){ if (i != j) { couples.add(new Couple(others.ge...
49f45a77-f4d0-45e9-9128-85c757f33157
6
public boolean nextDuel() { Duel duel = null; Entity ent = null; Inventory[] i = new Inventory[2]; int c = 0; if (this.duelists.size() >= 2) { this.match_count++; duel = Duel.createEmptyDuel(); this.currentDuel = duel; PluginVars.duel_list.add(duel); duel.tournament = this; i[0] = Bukkit...
1a38ea9e-92e7-4ec5-8f84-659b05759fc8
0
public MessagesSender() { start(); }
c6e5cb21-b937-4da7-a11f-265dc4b90f63
7
public void calculateAllocation() { /* calculate processing rate of each site */ double tmp = 0; double[] daRelativeWeightBySite = new double[iSite]; for (int i = 0; i < iSite; i++) { tmp = 0; for (int j = 0; j < iClass; j++) { tmp += dmPrediction[j][i] * dmWeight[j][i] * dmDist[j][i]; } // Syst...
1f91d2f1-af1c-4917-b142-b00145b43408
2
public void setMousePosition() { if (robot != null && component.isShowing()) { Point copy = new Point(myX, myY); SwingUtilities.convertPointToScreen(copy, component); robot.mouseMove(copy.x, copy.y); } }
6595e763-3352-4897-bba2-cde0b999dd25
7
private void afficherCalculerMoyennes() { System.out.println("Calcul de moyenne."); System.out.println("1- Par module"); System.out.println("2- Par formation"); int indice = this.scan.nextInt(); while ((indice !=1) && (indice != 2)) { System.out.println("Indice incorr...
7f02e35d-1310-4543-8a29-76c2f445906b
9
public void changePosition(ArrayList <Rectangle>walls, ArrayList <Bullet> bullets) { // Temporary. Makes the monster move random. if (Math.random() < .5) direction.y *= -1; // keep him on the screen if ( (position.x + direction.x > Map.WIDTH) || (position.x + direction.x < 0)) direction.x *= -1; else i...
efcba940-4290-45cd-9bf7-3fdee8bdbb1e
0
public void setSolFechaDesde(Date solFechaDesde) { this.solFechaDesde = solFechaDesde; }
b7f5a14b-57de-413e-a05f-07fb55cb1531
5
private void calculateGlobalBest(){ int best = 0; if(maximum){ for(int i = 0; i < fitness.size(); i++){ if(fitness.get(i) > fitness.get(best)){ best = i; } } }else{ for(int i = 0; i < fitness.size(); i++){ if(fitness.get(i) < fitness.get(best)){ best = i; } } } globalBest...
b8cbdc1a-c25b-40be-a7b4-66b2141c7693
8
public int nLevelQuantize(int level, int pixel) { //edge cases if(pixel <= 0) return 0; if(pixel >= 255) return 255; int[] levels = new int[level]; for(int i = 0; i < level; i++) { levels[i] = (int) 255.0/(level-1) * i; } levels[level-1] = 255; int max = 0; int min = 0; for(...
3306a19a-f0c7-4e19-873e-4e07a718f1d5
8
public void onEnable() { // getServer().getPluginManager().registerEvents(this, this); // System.out.println(getServer().getPluginManager().getPlugin("WorldGuard")); Plugin got_plugin = getServer().getPluginManager().getPlugin("WorldGuard"); manager = new RegionFlagManager(this); createDefaultConfig(new ...
058f02ad-6d98-4139-a533-f7e9f7973730
2
public void Combinations( List<String> list, String letters,String digits,int index){ if(index <=0){ list.add(letters); return; } int j = digits.charAt(digits.length() -index)-'0' -1; for(int i=0; i < map[j].length; i++){ String lettersNew = letters + ...
fe9dc337-38a0-4696-a1fd-6454bd1c860c
8
private boolean moveTo(int id, int x, int y) { if (x < 0 || x >= N || y < 0 || y >= N) { return false; } switch (gameField[x][y]) { case PLAYER: return false; case EMPTY: changePlayerPosition(id, x, y); return true; case TREASURE: changePlayerPosition(id, x, y); updateTreasureForPlayer(id...
56c851bd-3d7b-4667-b0b6-ea099be9acbb
0
public CFService getCfService() { return cfService; }
a4ca62e8-b9b5-43ef-a7a5-567bc5c9dbac
0
public ObservacionFacade() { super(Observacion.class); }
97d7878c-0952-424f-af76-21020f3071d8
1
@Override public int getWidth() { int width = 0; if (this.fontmetrics != null) { width = this.fontmetrics.stringWidth(this.str); } return width; }
d619f26e-363a-4ffd-a12d-e4dcb21fde8c
0
@Override public ArrayList<Excel> getColoredExes() { return coloredEx; }
631230fc-890e-4f4c-b295-8b34a56a0ca5
4
private int jjMoveStringLiteralDfa26_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjMoveNfa_0(0, 25); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return jjMoveNfa_0(0, 25); } switch(curChar) { case 48: return jjMoveStringLiter...
ff6ce32d-34e5-4e21-b33b-4ae56165972f
2
public static Integer[] toIntegerArray(String... values) { if (values == null) { return new Integer[0]; } Integer[] casted = new Integer[values.length]; for (int i = 0; i < casted.length; i++) { casted[i] = Integer.parseInt(values[i]); } return casted; }
3c3759e5-dc32-4a3a-82d8-b0c125a6fc19
5
private void inputFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_inputFieldKeyReleased if (evt.getKeyCode() == KeyEvent.VK_ENTER) { if (inputField.getText().equalsIgnoreCase("database")) { LaunchItDbScreen dbScreen = new LaunchItDbScreen(); dbScreen....
77336be7-9ed9-4227-9127-9220a76e8d08
1
@Override public void mapInstructionLabel(List<String> instructionParts, int lineNum) { if (instructionParts.get(0).endsWith(":")) { //Ending with ":" indicates presence of a label, else do nothing String label = instructionParts.get(0).substring(0, instructionParts.get(0).length() - 1); //Trim colon from end ...
e658795f-6cd7-4042-990e-58cdee3309d9
9
public static boolean checkValidDate(Date date) throws IllegalDateFormatException { String message; if (date.getYear() <= 0) { message = "연도는 자연수만 입력 가능합니다!"; } else if (date.getMonth() <= 0 || date.getMonth() > 12) { message = "1 ~ 12월까지의 날짜만 입력해주세요!"; } else if...
24053e59-1a78-45fa-bbb4-1eb48a8d40c8
5
public static Model loadModel(File f) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(f)); Model m = new Model(); String line; while ((line = reader.readLine()) != null) { String prefix = line.split(" ")[0]; if (prefix.equals("#")) {...
0ba5dd55-ef92-4658-9366-7c5b5ec167f6
9
public boolean couldMove() { return !isDisposed() && getState() == UnitState.ACTIVE && getMovesLeft() > 0 && destination == null // Can not reach next tile && tradeRoute == null && !isUnderRepair() && !isAtSea() && !(isInEurope(...
5b4e3d00-b5bc-4381-8c54-5cbe89c188cc
6
public static void loadLevel(int offset) { try { int deadMonsters = 0; int totalMonsters = 0; boolean displayMonsters = false; if(level != null) { totalMonsters = level.getMonsters().size(); for(Monster monster : level.getMonsters()) { if(!monster.isAlive()) deadMon...
20108c7c-90b1-4dfe-b7ee-1155a9a1ff98
3
public String getImageFromBundles(String key) { if (key != null) { Iterator<mxImageBundle> it = imageBundles.iterator(); while (it.hasNext()) { String value = it.next().getImage(key); if (value != null) { return value; } } } return null; }
b8945382-6b46-4f54-9ed4-26bd4e2d4c32
7
public ArrayList<Message> fetchFeed() { ArrayList<Message> messages = new ArrayList<>(); try { String title = ""; String description = ""; XMLInputFactory inputFactory = XMLInputFactory.newInstance(); InputStream in = read(); XML...
adbbd951-1fd2-447d-9ac8-301361a5f20b
7
public void writeRawULong(long val, int bits) throws IOException { if (bits == 0) return; if (!ensureSize(bits)) throw new IOException("Memory Allocate Error"); val &= MASK32[bits]; totalBits += bits; while (bits > 0) { if (outBits == 0) { if (bits < B...
14d2a7f8-716b-40f4-9b2a-c191ac7248a9
2
public void run() { //runs them (calls them), these are called every 10 msecs ball.move(); //ball moves paddle.move(); shots(); for (Bullet bul : bulletList) bul.move(); for (Bonus bonus : bonusList) bonus.move(); c...
74c58a08-aa77-4d1f-8787-8a3796028eb7
9
public void test(int n, int order) { int total[] = new int[5]; int wrong[] = new int[5]; for(int i = 1; i <= 10; i++) { for(int err = 0; err <= 40; err += 10) { int numTotal = 0, numWrongTotal = 0; Graph graph = new TrainingSetReader("trainSets/train_set_" + String.format("%03d", i) + ...
be045571-93af-4ef7-8087-7f0b438a4f22
7
public void sendFirst () { boolean betray = true; if(betray) { System.out.println("betrayal incoming!"); } // create ElGamal cipher BigInteger p; ElGamalCipher elGamalC_a; ElGamalSignature elGamalS_a; { // note: q is p in elgamal...
d4f9051e-ca31-4862-831b-75268d3fa9bb
1
@Override public void push(T task) throws IllegalArgumentException, InterruptedException { try { taskExecutor.execute(task); } catch (Exception e) { e.printStackTrace(System.err); } }
0ec16dbe-9db8-4463-a381-2ad0c19791b3
9
private byte[] wrapCommandAPDU(byte[] capdu, int len) throws GeneralSecurityException, IOException { if (capdu == null || capdu.length < 4 || len < 4) { throw new IllegalArgumentException("Invalid type"); } /* Determine lc and le... */ int lc = 0; int le = capdu[len - 1] & 0x000000FF; if (len == 4) {...
b92bcdae-6aeb-4fde-b7a5-f9c7570f339a
3
public void tick() { double xm = (random.nextInt(4) < 2 ? moveX : 0); double ym = (random.nextInt(4) < 2 ? moveY : 0); xOffs += xm; yOffs += ym; life--; if (life <= 0) die(); }
a29745ca-63fb-44bd-a772-e2ad7dccfb33
5
@Override protected boolean doFirstPhase(String query, Configuration conf, String outputPath, String[] table) { try { // global information DistributedCache.addCacheFile(new URI(FULL_PATH_COLUMN), conf); DistributedCache.addCacheFile(new URI(FULL_PATH_FILTER), conf); DistributedCache.addCacheFile(new UR...
666e350a-944e-4187-a34f-a726aedb0070
2
public static String stripFilenameExtension(String path) { if (path == null) { return null; } int sepIndex = path.lastIndexOf(EXTENSION_SEPARATOR); return (sepIndex != -1 ? path.substring(0, sepIndex) : path); }
0e596ef8-1215-4745-a626-b863477d9dfb
2
private final boolean setDisplayMode(int width, int height, int bitDepth) { if (!graphicsDevice.isDisplayChangeSupported() || !isDisplayModeAvailable(width, height, bitDepth)) { logger.info("Display change not supported, or display mode not available"); return false; } else { graphicsDevice.setDisplayMode(...
471ee11d-48a0-441e-bee7-ca88335d8170
7
private void findDescriptor( Class beanClass, String type ) { if( type==null ) { type=beanClass.getName(); } ClassLoader classLoader=null; if( beanClass!=null ) { classLoader=beanClass.getClassLoader(); } if( classLoader==null ) { class...
1c82900a-c8f6-43c7-9abc-e132fcb9bffc
5
public int getBlackjackValue() { int val; // The value computed for the hand boolean ace; // This will be set to true if the // hand contains an ace. int cards; // Number of cards in the hand. val = ...
4647d574-d389-4665-8a79-bceb4757ca90
6
public void mousePressed(MouseEvent e) { JTable table = (JTable) e.getSource(); int rowNum = table.rowAtPoint(e.getPoint()); int colNum = table.columnAtPoint(e.getPoint()); if(colNum == 0) { table.setColumnSelectionInterval(0, table.getColumnCount()-1); } if(SwingUtilities.isRightMouseB...
38227381-c6e9-4e12-a388-05b75908ce10
0
public void setDocument(Document doc) {this.doc = doc;}
53f2ee3a-0392-4994-9077-0888b5682b4d
3
public void saveUrl(final String fileName, final String urlString) throws MalformedURLException, IOException { BufferedInputStream in = null; FileOutputStream fout = null; try { in = new BufferedInputStream(new URL(urlString).openStream()); fout = new...
76aa3337-aa69-489f-96bf-21165f6a409f
2
public void revert() { Tile[][] newLayout = new Tile[layout.length][layout[0].length]; // Iterate through original and copy the tile values to the new array. for (int x = 0; x <= layout.length; x++) { for (int y = 0; y <= layout[0].length; y++) { newLayout[x][y] = ori...
683c89be-736b-471a-97e6-c34dd3a79ebe
3
public static void ascii(final ByteBuffer buffer, final StringBuilder out) { final int start = buffer.position(); final int end = buffer.limit(); for (int pos = 0; pos < end; pos += ELEMENTS_PER_LINE) { out.append(String.format("%04X - ", pos)); for (int i=0; i<ELEMENTS_PER_LINE; ++i...
eae2fe1d-6479-45e0-97da-abb62869543b
0
@Test public void findHandFromCardSet_whenHandContainsBothStraightAndFlush_returnsJackHighFlush() { Hand hand = findHandFromCardSet(sixFlushWithStraight()); assertEquals(HandRank.Flush, hand.handRank); assertEquals(Rank.Jack, hand.ranks.get(0)); }
9b662815-c62d-440c-8467-196be28e1a73
0
public void setColor(int red, int green, int blue){ _red.set(red); _green.set(green); _blue.set(blue); }
1ba95ffb-af85-485d-8477-2ff44bc91af6
8
protected String getHttpResponse(String url) throws JmdbException { String content = null; HTTPConnection connection = null; try { URL requestURL = new URL(url); String host = requestURL.getHost(); String file = requestURL.getFile(); in...
5d63feb6-3eff-4f68-9b4d-02176bd2d547
3
void createChildWidgets() { /* Create the "children" table */ table = new Table (childGroup, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); table.setLinesVisible (true); table.setHeaderVisible (true); FontData def[] = display.getSystemFont().getFontData(); t...
3ae3e2ac-7786-4ab5-a8ec-047a73ae646c
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final LibraryMaterial other = (LibraryMaterial) obj; if (!Objects.equals(this.author, other.author)) { ...
9a930c72-1003-4310-8acd-faa746207154
2
private final static boolean compare(byte[] b1, byte[] b2) { //if(b1.length != b2.length) { // return false; //} for(int i = 0; i < b2.length; i++) { if(b1[i] != b2[i]) { return false; } } return true; }
78e90bd4-4cdb-4314-880d-f29638724f85
5
public void update() { move(); if (walking) animSprite.update(); else animSprite.setFrame(0); if (ya < 0 ) { animSprite = up; dir = Direction.UP; } else if (ya > 0) { // else is here so we can't select both up and down at one time animSprite = down; dir = Direction.DOWN; } if (xa < 0) ...
f75b9090-8ecf-4f1c-9107-c0d4e4806a25
0
@Test public void combine_shouldReturnCombOfSpecifiedLength() { String word = "abcd"; assertEquals("[[a], [b], [c], [d]]", combination.combine(word, 1).toString()); assertEquals("[[a, b], [a, c], [a, d], [b, c], [b, d], [c, d]]", combination.combine(word, 2).toString()); assertEquals...
e640e99c-02c4-46d3-ba1d-f52ceb0d5e99
5
public void move() { x += dx; y += dy; if (x < 1) { x = 1; } if (y < 1) { y = 1; } //System.out.println("OLD-Mouse: " + this.oldMousePos[0] + " | " + this.oldMousePos[1] + " Neue Mouse-Pos " + this.mousePosition[0] + " | " ...
e4b97022-e934-4330-88e3-11e4f53be321
1
@Test public void muutaPisteiksiTest() { Piste a = new Piste(100, 150); Piste b = new Piste(200, 250); ArrayList<Integer> koordinaatit = new ArrayList(); int j = 100; for (int i = 0; i < 4; i++) { koordinaatit.add(j); j += 50; ...
7e4b4bc7-8816-4fa3-9c80-becbb1387674
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; RecordTypeNode other = (RecordTypeNode) obj; if (fieldLists == null) { if...
c05c5af4-7dd3-4f3b-b5dd-3ea5cd6f1e5c
7
@Override public void mutate(){ TspPopulation offspring = new TspPopulation(); for (int i = 0; i < population.getSize(); ++i){ double r; synchronized (rng){ r = rng.nextDouble(); } if (r < PROBABILITY){ TspIndividual mut...
96563f25-94c9-40f6-8c25-53b5435587fd
3
public static boolean getPassword(OTPassword theOutput) { if (null == password) return false; StringBuilder str = new StringBuilder(); for (int i = 0; i < password.length; i++) { str.append(password[i]); } if (str.length() > 0) theOutput.setPa...
9f61c371-1ffd-446e-9426-87710db2f4a5
3
public int correlLookback( int optInTimePeriod ) { if( (int)optInTimePeriod == ( Integer.MIN_VALUE ) ) optInTimePeriod = 30; else if( ((int)optInTimePeriod < 1) || ((int)optInTimePeriod > 100000) ) return -1; return optInTimePeriod-1; }
837cd9ec-28d1-4827-ab16-1a163f8d2bad
5
@Override public String execute() throws Exception { User_Dao UD = new User_DaoImpl(); boolean re = UD.checkName(userId) && UD.checkUsername(userName); status = re ? "" : "用户名或团队名已经存在!"; if(re){ boolean result = userService.addUser(this); status = result ? "" : "error"; if(result) return "success"; ...
65639498-d0df-42c4-a399-b917701443cd
7
public void testValueCollectionAdds() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>(); Map<String,Integer> map = TDecorators.wrap( raw_map ); for ( ...
8942a6a3-1d8b-4c11-9a50-c880f98cdc80
1
public void fichierQuitter() { // Confirmer avant de quitter int rep = JOptionPane.showConfirmDialog(getVue(), "Quitter l'application\nEtes-vous sûr(e) ?", "GSB", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (rep == JOptionPane.YES_OPTION) { // mettre fin à l'applicat...
1800f558-f23d-439f-a65a-0570173b1576
2
@Test public void testPowerFailureLifeTimeDecrementing() throws InvalidActionException { PowerFailure powerFailure = null; List<Element> elements = grid.getElementsOnPosition(new Position(1, 8)); for(Element element: elements){ if(element instanceof PowerFailure){ powerFailure = (PowerFailure)element; ...
1e9f7844-d9de-4d41-b547-813abe08c5f1
0
public Date getTime() { return time; }
2e5d9d61-9cb5-4209-bcd3-4e22456dd179
8
@Override protected void setExceptionError(InvalidFieldException e) { if (e.isHandled()) return; MainFrame mf = MainFrame.getRunningFrame(); switch (e.getField()) { case USER_ID: if (!GameData.getCurrentGame().isSeasonStarted()){ mf.setStatusErrorMsg("Invalid ID (must be between 2 and 7 chars" ...
0f54885d-f09e-467a-8fbc-f2e6cc8de301
7
public void print(String s,AST t) { // assume less than 1000 nodes; no problem for csc 413 int num = t.getNodeNum(); AST decoration = t.getDecoration(); int decNum = (decoration == null)? -1 : decoration.getNodeNum(); String spaces = ""; if (num < 100) spaces += " "; ...
ed2e4cae-a7d3-4429-baea-cecf5e1e74e8
2
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/profesor/form.jsp"); ProfesorBean oProfesorBean; ProfesorDao oProfesorDao; oP...
82ce0a89-0a67-4bd6-b380-ebf343bee21f
6
public MonoCipher(String keyword) { char [] key = keyword.toCharArray(); //create buffAlphabet alphabet = new char [SIZE]; for (int i = 0; i < SIZE; i++) alphabet[i] = (char)('A' + i); // create first part of cipher from keyword cipher = new char [SIZE]; ...
14825850-dc4a-4def-8095-08a019a518c2
1
@Override public void Update(float delta) { if(m_renderingEngine != null) { Quaternion newRot = GetTransform().GetLookAtRotation(m_renderingEngine.GetMainCamera().GetTransform().GetTransformedPos(), new Vector3f(0, 1, 0)); //GetTransform().GetRot().GetUp()); GetTransform().SetRot(GetTransform().G...
6d819b12-6a17-4a5e-9ec7-32556e27d9a8
3
public boolean exist(ValueType value) { if (!isEmpty()) { for (ValueType current : this) { if (current == value) { return true; } } return false; } return false; }
ef0d5355-f339-458b-b810-32e6766ccb8a
0
protected Rectangle2D getBounds(Graphics2D g, String string) { return g.getFontMetrics().getStringBounds(string, g); }
fe3dc883-1b35-4453-bf24-4a263911bf64
0
@Override public JSONObject main(Map<String, String> params, Session session) throws Exception { JSONObject rtn = new JSONObject(); rtn.put("rtnCode", this.getRtnCode(200)); long activeUserId = session.getActiveUserId(); session.setActiveUserId(0L); Notification.stop(activeUserId); return rtn; }