method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
cea2919e-56b4-40ce-9964-5e4328c9aa76
7
public static OOXMLElement parseOOXML( XmlPullParser xpp, Stack<String> lastTag, WorkBookHandle bk ) { BodyPr b = null; P para = null; try { // need: endParaRPr? int eventType = xpp.getEventType(); while( eventType != XmlPullParser.END_DOCUMENT ) { if( eventType == XmlPullParser.START_TAG )...
7c165753-497d-48cd-8221-5d2a1c9aee02
8
public void convert(){ m = new int[s.length+1][t.length+1]; for(int i=0;i<=s.length;i++){ m[i][0]=i; } for(int i=0;i<=t.length;i++){ m[0][i]=i; } for(int i=1;i<=s.length;i++){ for(int j=1;j<=t.length;j++){ System.out.print(s[i-1]+":"+t[j-1]+";"); int rep = m[i-1][j-1]+((s[i...
59e190e4-0d6c-4c98-bafe-612211dfcbaa
9
public void initAsErdosRenyi(final List<Integer> clusterSizes, final List<Double> pInValues, final double pOut) { this.pOut = pOut; // node count final int n = (int) ListUtils.sumUp(ListUtils.mapType(clusterSizes, Double.class)); /* * Create clusters */ for (int index = 0; index < pInValues.size(); ...
1d2dab36-9c81-4783-946c-500d212fd41b
3
public byte[] writeFont () { // allocate a buffer to hold the font ByteBuffer buf = ByteBuffer.allocate (getLength ()); // write the font header buf.putInt (getType ()); buf.putShort (getNumTables ()); buf.putShort (getSearchRange ()); buf.putShort (getEntrySelec...
f81d1a2b-b731-4610-86a8-f87a8fe5c2cc
4
@GET @Produces(MediaType.LIBROS_API_LIBRO_COLLECTION) public LibroCollection getLibros() { LibroCollection libros = new LibroCollection(); Connection conn = null; Statement stmt = null; String sql; try { conn = ds.getConnection(); } catch (SQLException e) { throw new ServiceUnavailableException(e.g...
32de1c61-1a91-468f-a7b7-5e4ede5abfab
6
public void removeChannelGroup(long id, boolean lenient){ if(getChannel(id) instanceof ChannelGroup){ if(lenient){ if(getChannel(id).getParent() != null){ Vector<Long> childrenId = new Vector<Long>(((ChannelGroup)channelTree.get(id)).getChildren()); for(long cid : childrenId) getChannel(cid).s...
1a70d6b3-b1a0-431e-9626-880bca67f3b3
9
private void move() { Player player = this.getCurrentPlayer(); if (player.getMovePogression() == 1) { int up_target = player.getIndex() - this.board.getCols(); int down_target = player.getIndex() + this.board.getCols(); int left_target = player.getIndex() + 1; ...
659eb4c9-351c-43b6-8e9b-8a5e7927633a
0
private void printTime(double time) { System.out.println("Average time taken: " + time + " ms"); }
e51ce2e9-7928-47bd-8cfc-bfccb37ce678
5
HashSet<String> find(char[][] matrix, boolean[][] flag, int x, int y, StringBuilder sb, TreeNode root) { HashSet<String> res = new HashSet<String>(); if (root.isWord()) { res.add(sb.toString()); } for (int k = 0; k < 8; k++) { int i = x + d[k][0]; int j = y + d[k][1]; if (isValid(matrix, i, j) &&...
6afba8a3-0874-4b1a-934f-49af266407d5
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; HumanData other = (HumanData) obj; if (email == null) { if (other.email != null) return false; } else if (!email.equals(other.ema...
333c7111-a5d9-4f6f-9491-af950dfeb28f
6
public void run(Object parent) { // Separate out unconnected hierarchies List<Set<Object>> hierarchyVertices = new ArrayList<Set<Object>>(); Set<Object> allVertexSet = new LinkedHashSet<Object>(); if (this.roots == null && parent != null) { Set<Object> filledVertexSet = filterDescendants(parent); thi...
35cc596e-c1d8-4891-bc04-cc52a83682ef
1
protected void execute(Runnable task, final C context) { if (!context.isTerminated()) { executor.execute(task); } }
6dfd50b6-ca64-4e1b-a283-af3dc67f60c1
4
public Sea(int width, int height) { if (width > 0 && height > 0) { if (width <= MAX_WIDTH && height <= MAX_HEIGHT) { this.width = width; this.height = height; initialPlayField(width, height); } else { System.out.println("The...
badd3f08-e10e-4541-8726-19d759272db5
7
public Object getServiceObject(IMyxName arg0) { if (arg0.equals(msg_IChat)) { return this; } if (arg0.equals(msg_IHistoryRetrive)) { return this; } if (arg0.equals(msg_ISendFileListener)) { return this; } if (arg0.equals(msg_ISendImage)) { return this; } if (arg0.equals(msg_IGame)) { re...
5c5c7951-4d35-485c-abf5-9573789c2382
6
public static void main(String[] argv) { HashCodeAccessSet<Integer> hcas = new HashCodeAccessSet<Integer>(); hcas.add(Integer.valueOf(6)); hcas.add(Integer.valueOf(7)); hcas.add(Integer.valueOf(9)); System.out.println(hcas.forHashCode(7).intValue()==7 ? "good" : "bad"); S...
cd2ffc3f-88ff-4c1c-ab7f-b4c3806b7732
8
@Override public List<V_Detalle_Carga_Academica> Lista_detalle_academico(String idtr, String facultad, String eap, String ciclo, String dni) { this.conn = FactoryConnectionDB.open(FactoryConnectionDB.ORACLE); String sql = "SELECT * FROM RHVD_DETALLE_CARGA_ACADEMICA WHERE campus is not null"; ...
32186cc9-7ad7-4c16-b9d2-62f3108b6ded
5
@Override public void run() { try { if (MFServer.DEBUG_SERVER){ System.out.println("==> [SERVER] Waiting connection..."); } while(ACCEPT_CONNECTIONS){ Socket socket = ss.accept(); new Connection(...
0158ab6a-6b47-414b-8f52-0b1450ddf92b
6
private boolean validarCampos(){ boolean error= false; if(txtNum.getText().isEmpty()){ txtNum.setBorder(javax.swing.BorderFactory.createEtchedBorder(Color.lightGray, Color.red)); txtNum.setToolTipText("Por favor digite el numero de factura."); error= true; } ...
21dc46a1-92e4-4103-a8c0-30a1b4719ffc
2
private final void register (SelectableChannel handle_, int ops, boolean negate) { PollSet pollset = fd_table.get(handle_); if (negate) pollset.ops = pollset.ops &~ ops; else pollset.ops = pollset.ops | ops; if (pollset.key != null) ...
fe00dca7-31f3-4ee4-a386-26547c26388b
0
public Object getParameters() { return parameters; }
be3ffc04-e3f5-4334-8a66-9e8756dccfb8
9
public static void getStockFromYahoo(String stockName, Date startDate, Date endDate, List<Double> prices) throws IOException, ParseException { Calendar calendar = Calendar.getInstance(); calendar.setTime(startDate); int startDay = calendar.get(Calendar.DAY_OF_MONTH); int startMonth = calendar.get(Calend...
5c2ddfa7-6c0a-4d0b-b183-9319f6ced3c3
7
public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner s = new Scanner(System.in); String op = s.nextLine(); double sum = 0; for(int i = 0; i < 7; i++){ for(int j = 0; j < 12; j++){ s.nextDouble(); } } ...
d28878b2-464a-4289-b48f-1795ce6b4708
4
public static PVector resolveBottomRight(PVector v) { PVector result = new PVector(); if (((v.heading() > (float)(3*Math.PI/4)) && (v.heading() <= (float)Math.PI)) || ((v.heading() > (float)-Math.PI) && (v.heading() < (float)(-Math.PI/4)))) { result.x = -(float) (v.mag() * Math.cos(Math.PI/4)); result.y...
e5a45f19-cf20-4994-960a-9c142cc025f6
3
public static void main(String[] args){ BankAccount account = new BankAccount(1111111111, 1000000); for(int i=0; i<7; i++){ account.deposit(50000); } for(int i=0; i<7; i++){ account.withdraw(30000); } for(int i=0; i<10; i++){ System.out.println(account.history().history[i]); } }
9d8455e3-183b-43b2-819c-663a0bf98260
2
public void piocheCartesTroupes(LinkedList<CarteTroupe> llct, LinkedList<Kokus> llk, int nbcartes){ // On pioche x cartes troupes où x dépend selon le nombre de joueurs for(int i=0; i<nbcartes; i++){ alct.add(llct.getLast()); llct.removeLast(); } // Le no...
016cdda1-3a01-444e-abc5-a8926423f5f5
7
public void table(String what) throws NoSuchMethodException,IllegalAccessException,InvocationTargetException { PrintfFormat dfmt = new PrintfFormat("Dataset %2d:"); PrintfFormat fmt = new PrintfFormat(" %9.5f "); PrintfFormat nfmt = new PrintfFormat(" %11s"); if (expt==null) compute(); for (int i=0; i<block...
f9307e59-f3bc-4dd2-a01f-9da88f2a6446
5
public ControllerV1(int threads, int limit, boolean gui) { this.threads = threads * threads; this.limit = limit; this.groupFuturePrimes = new ArrayList<>(); this.groupPrimes = new ArrayList<>(); this.executorService = Executors.newFixedThreadPool(1 + this.threads); thi...
53b39cb2-4ee2-4ae6-8060-3e348da0512c
8
@Test public void testCreateDatabase() throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; Connection connection = null; String databasePath = "db" + File.separator + "test" + File.separator + "test-create-database.sqlite"; File newDatab...
5b34deeb-ab04-463a-9415-da16aca0c100
2
public static double[][] random( int m, int n ) { double[][] matres = new double[m][]; for ( int i = 0; i < m; ++i ) { matres[i] = new double[n]; for ( int j = 0; j < n; ++j ) matres[i][j] = Math.random(); } return(matres); }
18b321ad-ce8d-4d73-ae2d-03552f4de46f
7
protected CtClass getCached(String classname) { CtClass clazz = getCachedLocally(classname); if (clazz == null) { boolean isLocal = false; ClassLoader dcl = getClassLoader0(); if (dcl != null) { final int lastIndex = classname.lastIndexOf('$'); ...
92718836-bcb4-4c29-bb8d-b3d3e984dc61
8
private static boolean checkRoute(int[] pos) { if(pos[X] < size/4.0*3.0 && pos[X] > size/4.0 && pos[Y] < size/4.0*3.0 && pos[Y] > size/4.0) // Check the center square return false; else if(pos[X] < 0 || pos[Y] < 0 || pos[X] > size || pos[Y] > size) // Check outer square return false; return true; }
bf346b1b-56bb-401a-9131-61ac154d6b10
2
private static void loadAllTheCardImagesFromFileNames(String[] cardImageFileNames, MediaTracker tracker) { String curDir = System.getProperty("user.dir"); Image pic; for (int i=0; i < cardImageFileNames.length; i++) { pic = Toolkit.getDefaultToolkit().getImage(curDir + "/cla...
640d493b-fcf2-4461-b25c-decd47c9b5a8
6
@SuppressWarnings("unchecked") private Map<AccountsField, String> getAccountPaths(Document doc) throws UtilityException { Map<AccountsField, String> toReturn = new HashMap<AccountsField, String>(); for (AccountsField f : AccountsField.values()) { String path = f.getPath(); if (f.equals(AccountsField.ERROR...
c48df95d-dbe1-41d0-bb10-1d8297c4145b
8
private double calcPizzaPrice() { double price = 0; // Pizza Size if (jrbMedium.isSelected()) { price = PRICE_MEDIUM; }else if (jrbLarge.isSelected()) { price = PRICE_LARGE; }else{ price = PRICE_SMALL; } ...
d5671a0e-7f23-462c-bb70-c0b06d3b1e08
1
public OfflinePlayer getCofferOwner(Chest chest){ if(chest==null) return null; return coffers.get(chest); }
b9458220-a574-40f6-8421-0ba0544c94e6
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...
b2761580-e1f2-4ddf-8886-04c1fd1a66a4
2
private int getIntFromUser(String prompt) { while (true) { try { return Integer.parseInt(getUserInput(prompt)); } catch (Exception e) { System.out.println("FUCK OFF THATS NOT A NUMBER"); } } }
b9bfdfe8-99f9-4ae4-938f-de1ffb165877
7
public void drawSelectedOmegaVector(Graphics2D g, Color background, boolean adjusting) { if (!oselected || !showORects) return; if (adjusting) { g.setStroke(ViewAttribute.THIN); g.setColor(getContrastColor(background)); double ex = oHotSpot.getX() - rx; double ey = oHotSpot.getY() - ry; double ...
a7cd9646-c836-467b-80ac-b15c61801361
2
@Override protected void doAction(int option) { switch (option) { case 1: resetAll(); break; case EXIT_VALUE: doActionExit(); } }
f93539af-9b12-4513-a439-7787a0cb37aa
6
public static BlockFace getDirection(Block block) { byte north, east, south, west; if (block.getType().equals(Material.PUMPKIN) || block.getType().equals(Material.JACK_O_LANTERN)) { south = 0x0; west = 0x01; north = 0x02; east = 0x03; } else { north = 0x02; south = 0x03; west = 0x04...
f7d96877-0a75-40b3-917e-749e95e836d2
7
public int findKiller() { int killer = c.playerId; int damage = 0; for (int j = 0; j < Config.MAX_PLAYERS; j++) { if (PlayerHandler.players[j] == null) continue; if (j == c.playerId) continue; if (c.goodDistance(c.absX, c.absY, PlayerHandler.players[j].absX, PlayerHandler.players[j].absY, 40) ...
31f20367-2675-4920-ac93-283211e3f3e7
2
public void set(BacklogBean oBacklogBean) throws Exception { try { oMysql.conexion(enumTipoConexion); oMysql.initTrans(); if (oBacklogBean.getId() == 0) { oBacklogBean.setId(oMysql.insertOne("backlog")); } oMysql.updateOne(oBacklogBean...
eb506046-2f19-44d3-99c9-a1c170408582
8
public void setGallery(String base, String spef) { galleryImageIcons.clear(); galleryImageDesc.clear(); currentIndex = 0; String dirPath = "/img/" + base + "/" + spef + "/"; for(int i = 0; i < 20; i++) { SpecialImageIcon imgIcon = null; try { ...
7ddd990e-4864-4198-8bc9-f6e25770426c
7
synchronized Rectangle[] getRects53(Graphics g) { if (g == null || model == null) { repaint(200); return null; } if (model != null && model.getDNA() == null) return null; Rectangle[] rs = new Rectangle[model.get53StrandLengthFromCurrIndex()]; FontMetrics fm = g.getFontMetrics(); int sy = scroller.g...
79feea69-a674-4697-a530-a18043115ac2
0
public void afficherPraticiens(){ CtrlPrincipal ctrlP = new CtrlPrincipal(); ctrlP.action(EnumAction.PRATICIENS_AFFICHER); }
ecf9c0a0-222f-4cb7-ac5d-2672e8bdd02e
7
@Override public void characters(char[] ch, int start, int length) throws SAXException { if ((thisElement.equals("title")) && (titleFlag == 0)) { inf.setChanelltitle(new String(ch, start, length)); list.add(new String(ch, start, length)); } else if ((thisElement.equals("t...
20af185e-4744-4e49-aada-1a21a2818199
4
protected void commonInit() { for(int x = 0; x < bigBoxes.length; x++) { for(int y = 0; y < bigBoxes.length; y++) { BigBox bigBox = new BigBox(this, x, y); parts.add(bigBox); bigBoxes[x][y] = bigBox; } } for(int x = 0; x < columns.length; x++) { Column column = new Column(this, x); parts.a...
ec9ac620-ac07-4b03-8ea2-bc38da350cf7
3
protected void tallennaActionPerformed() { String ryhmanNimi = ryhmanNimiField.getText().trim(); if ("".equals(ryhmanNimi)) { JOptionPane.showMessageDialog(this, "Ryhmän nimi ei voi olla tyhjä.", "Virhe", JOptionPane.ERROR_MESSAGE); return; } if (ryhmanNi...
9c47b5d4-da70-43be-a460-68af3a0ff38e
4
static String[] getPortForwarding(Session session){ java.util.Vector foo=new java.util.Vector(); synchronized(pool){ for(int i=0; i<pool.size(); i++){ Object[] bar=(Object[])(pool.elementAt(i)); if(bar[0]!=session) continue; if(bar[3]==null){ foo.addElement(bar[1]+":"+bar[2]+":"); ...
fad8d738-4269-46f8-a8c9-2b9679e8e4ef
9
@Override public ApiResponse deleteRow(String tableName, Condition condition) throws IllegalArgumentException{ if(connexion == null && path == null) return ApiResponse.MYAPI_NOT_INITIALISE; Statement stat = null; try { if(connect == null || connect.isClosed()) return ApiResponse.DATABASE_NOT_CONNECT; ...
781928bd-3723-40e5-8b5f-1f33463b9299
7
public static void main (String[] args) { //declarations and conversion String quakeValue = JOptionPane.showInputDialog(null,"Please enter the richter scale measurment for the earthquake"); int richterMeasurement = Integer.parseInt(quakeValue); String oneToThree = "Detectable only ...
af62f43b-3df1-415c-98d8-6ce6a9a99957
4
public static ArrayList<databook> showAllInfo(String authorid){ int i=0; double d=0; ArrayList<databook> bkinfo = new ArrayList<databook>(); try{ contct=connector.getConnection(); Sttt=contct.prepareStatement("select * from bk where authorid= '"+authorid+"'"); restl=Sttt.executeQuery(); whi...
3cd81393-068d-4e4f-b6f4-364219f507e8
7
static void loadPhrasalVerbs() throws IOException { String prevVerb = null; //valoare care retine verbul de pe linia precedenta din fisier String rest = new String(); //String care retine prepozitiile/adverbele care alcatuiesc PV-urile impreuna cu verbul ArrayList<String> restList = new Arra...
835f4a5a-df50-4c97-9aef-e310d47a2c8d
0
public static void changeFocusToIcon(Node currentNode, JoeTree tree, OutlineLayoutManager layout) { tree.setSelectedNodesParent(currentNode.getParent()); tree.addNodeToSelection(currentNode); // Record the EditingNode and CursorPosition tree.setComponentFocus(OutlineLayoutManager.ICON); // Redraw and Set Fo...
64a93d77-98c6-4596-8a91-6a541623c5ae
6
public void paintComponent(Graphics g) { if(Snake.skipping) Snake.lastSkip = !Snake.lastSkip; if(Snake.lastSkip) return; if(System.currentTimeMillis() - Util.skipStart > 10000) Snake.skipping = false; updateTiles(g); if(Util.gameAwaitingStart) { return; } if(Util.paused) { label.setText...
251bce1a-b117-47a5-ace5-5b91abcf7073
4
@Override public Set<Annotation> annotations() { Map<Location, Integer> coloring = new HashMap<Location, Integer>(); Collection<Node> frontier = new ArrayList<Node>(); Collection<Node> visited = new HashSet<Node>(); frontier.add(new Node(hunter.location(), 0)); while(!frontier.isEmpty()) { Node nod...
fedc1857-1e1f-4c84-b951-c9a0cd1e73f8
4
private void display(){ //display data Node currentNode=firstNode; while(currentNode!=null){ Class<?> c = currentNode.getData().getClass(); try { Object instance = c.newInstance(); System.out.println(new Integer((Integer) (currentNode.getData()))); currentNode=currentNode.getNext(); }...
d5a8b5cc-b0ac-4869-9c16-aae4c1a8fee1
1
private void createPath() { if( path == null ) { EndPointAttachement source = getSourceEndPoint().getAttachement(); EndPointAttachement target = getTargetEndPoint().getAttachement(); Point sl = source.getLanding(); Point sa = source.getApproach(); Point ta = target.getApproach(); Point tl = target....
f5de8e2b-736d-4d14-838c-ef79666c6ac1
7
protected String getCommonSuperClass(final String type1, final String type2) { Class<?> c, d; ClassLoader classLoader = getClass().getClassLoader(); try { c = Class.forName(type1.replace('/', '.'), false, classLoader); d = Class.forName(type2.replace('/', '.'), false, cla...
6dc09092-a463-4a87-a5c7-bbda2c789701
4
public ArrayList<Package> getAllPackages(Connection conn) { ArrayList<Package> packages = new ArrayList(); PreparedStatement statement = null; Package p = null; int tjek = 0; int packNo = 0; String SQLString = "SELECT * FROM pakker NATURAL JOIN pakkedetails"; try ...
8329497c-30fc-485d-a768-240cf058af6e
3
private static TypeParameter[] parseTypeParams(String sig, Cursor cur) throws BadBytecode { ArrayList typeParam = new ArrayList(); if (sig.charAt(cur.position) == '<') { cur.position++; while (sig.charAt(cur.position) != '>') { int nameBegin = cur.posi...
5dcc02f6-3d25-498a-bd98-fdc04e7139de
5
@Override public void tick(double dt) { super.tick(dt); if (playerNumber == 1) player1Input(); if (playerNumber == 2) player2Input(); if (chargingCannon) cannonCharge += 0.015 * dt; if (jetPackFuel + 5 > 100) jetPackFuel = 100; else jetPackFuel += 2 * dt; handleTerrainIntersection(); a...
7b4a5ef5-c024-4e1f-99a9-587a24ebb7c6
6
public void doCommand(String[] command) throws GateException { if (command[0].toUpperCase().equalsIgnoreCase("LOAD")) { if (command.length != 2) throw new GateException("Illegal number of arguments"); if (gui != null) gui.showMessage("Loading..."); ...
e41ab18a-5287-4bc0-a2d4-d9b879be8c3c
5
public void actionPerformed(ActionEvent ae) { // // Process the action command // // "ok" - Data entry is complete // "cancel" - Cancel the request // "help" - Display help for asset accounts // try { switch (ae.getActionCommand()) { ...
7690f293-960d-4fc2-bac1-a60589892b18
4
public static long kadane(long[] comp) { long sum = 0, max = 0; int startRow = 0; for (int i = 0; i < m.length; i++) { sum += comp[i]; if (sum != 0) { sum = 0; startRow = i + 1; } else if (max < i - startRow + 1) max = i - startRow + 1; max = Math.max(max, comp[i] == 0 ? 1 : 0); } retu...
c9897827-e733-4438-9870-9fa68e513f7c
2
public void updateDetails(DetailObject detailObject) { for (DetailPanel detailPanel : detailPanels) { if (detailPanel.getLanguage().equalsIgnoreCase(detailObject.getLanguage())) { detailPanel.setBlankLinesLabel(detailObject.getBlankLines()); detailPanel.setLineOfCodeLabel(detailObject.getLineOfCode()); ...
d7a1ee97-c23d-4b9c-b95e-20126b2435ec
3
@Override public void processEvent(GameEvent event) { switch (event.type) { case StartGame: userData.put(event.userId, new UserData(event.timestamp, event.experience)); break; case Experience: userData.get(event.userId).increaseExperience(event.experience); break; case FinishGame: int ag...
02f801cf-179e-4dee-b4e9-6f804aab0626
3
@Raw public Weapon(Worm owner, double mass, int damage, int cost, double baseForce, double maxForce) throws IllegalArgumentException { if(!isValidProjectileMass(mass)) throw new IllegalArgumentException("The provided mass for this Weapon isn't valid."); if(owner == null || !owner.isAlive()) throw new Illegal...
a8be29ef-8440-4d96-81a5-deb734cc9fc8
3
public void visitForceChildren(final TreeVisitor visitor) { if (visitor.reverse()) { for (int i = params.length - 1; i >= 0; i--) { params[i].visit(visitor); } receiver.visit(visitor); } else { receiver.visit(visitor); for (int i = 0; i < params.length; i++) { params[i].visit(visitor); }...
8358af9f-9040-4d24-9542-5ad2b3eef8f6
2
@SuppressWarnings("unchecked") ArrayList new54() /* reduce ANonTerminal$Vardecl */ { @SuppressWarnings("hiding") ArrayList nodeList = new ArrayList(); @SuppressWarnings("unused") ArrayList nodeArrayList2 = pop(); @SuppressWarnings("unused") ArrayList nodeArrayList1 = pop(); Link...
08192db4-6ac8-460f-9bf6-6d082b848960
0
public LogFile getInfoLog() {return this.infoLog;}
98c4555b-3905-4c40-9056-3619708cb9aa
6
* @return boolean <b>true</b> if the orders were cleared */ public boolean clearOrders(Unit unit) { if (!requireOurTurn() || unit == null || !unit.checkSetState(UnitState.ACTIVE)) return false; if (unit.getState() == UnitState.IMPROVING && !gui.showConfirmDialog(unit.ge...
a6bcf037-e534-43c0-92a2-84fab636129c
6
public int getCurrentCount() { int count = 0; boolean isAces = false; for(Card c : turnCards) { // Special case with ACES if (c.type == CardType.ACE) { isAces = true; continue; } // With othe...
91123933-fa81-4f12-91f4-27be2c3143a3
4
private static List<MPoint> addLineType( PathwayElement pwElt, String connectorType, List<Double> mPointsDoubles) { List<MPoint> mPoints = new ArrayList<MPoint>(); // type of line if (connectorType.toLowerCase().equals("curved")) { pwElt.setConnectorType(ConnectorType.CURVED); createMPoints(pwElt, ...
563e5116-abd3-4670-9676-19c3aaecb0b3
2
public void setToolTipsEnabled(boolean flag) { if ("hide".equals(System.getProperty("info.gridworld.gui.tooltips"))) flag = false; if (flag) ToolTipManager.sharedInstance().registerComponent(this); else ToolTipManager.sharedInstance().unregisterComponent(t...
32e1eaa7-ef3a-4549-8731-c68282d9ea58
5
public GUIServer(final Controller con) { this.con = con; isClosed = true; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 666, 380); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null...
6b85d58f-c1be-4627-a77a-09f462ae8ac4
5
public void defaultStudentList (LYNXsys system, int page) { // to show All students in the system displayedSearchResults.removeAll(displayedSearchResults); // empty search results for (int i = 0; i < system.getUsers().size(); i ++) { // loop through arraylist of students // new search result displayedSearchRe...
111b36dc-1260-42db-ac2b-bb39e4e25649
6
public int getTotalProductionOf(GoodsType type) { if (type.isRefined()) { if (type != goodsToMake()) return 0; // Pretend 1/3 of the units present make the item with // basic production of 3. return getUnitCount(); } int potential = 0; int...
02451e66-9870-4b00-a069-9324884eb63e
6
public AudioInputStream getStream( ) { int chs = Matrix.getNumOfRows(data); int len = Matrix.getNumOfColumns(data); AudioFormat format = new AudioFormat(sampleRate, 16, chs, true, false); // determine absolute maximum double max = 0.0; for ( int i = 0; i < chs; ++i ) for ( int j = 0; j < len; ++j ) if ( Math...
43287b27-af1b-49ac-a583-22ad44c4286f
4
private Canvas() { component = new CanvasComponent(); if (System.getProperty("com.horstmann.codecheck") == null) { frame = new JFrame(); if (!System.getProperty("java.class.path").contains("bluej")) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)...
a51b46a4-74cb-4bd4-8d60-2158a1f2ccba
4
private boolean inMapUnlimited(Position pos) { if (pos.getX() < 0) { pos.setX(width - 1); } if (pos.getX() >= width) { pos.setX(0); } if (pos.getY() < 0) { pos.setY(height - 1); } if (pos.getY() >= height) { pos.setY...
d13e210c-2abb-4511-925b-47bdfc113551
8
public void pruneExternalNode(JadeNode node) { if (node.isInternal()) { return; } /* * how this works * * get the parent = parent * get the parent of the parent = mparent * remove parent from mparent * add !node from parent to mparent */ double bl = 0; JadeNode parent = (JadeNode) node...
cbcc9891-a51c-4f75-adad-12a8f8f8578d
8
@Test public final void testGetMoves() { g.getMoves().clear(); for (int i = 0; i < 5; i++) { g.getMoves().add(ms[i]); } // doppelt adden duerfte nicht gehen: for (int i = 0; i < 5; i++) { try { g.getMoves().add(ms[i]); fail("duplicates are allowed"); } catch (Exception e) { } } ...
8e485675-61a4-46e5-96b5-d1ad013a2d96
9
public Bus parseBusTimes( InputStream in ) throws JsonParseException { Bus bus = new Bus(); JsonParser jp = null; try { jp = jsonFactory.createParser( in ); while ( jp.nextToken() != JsonToken.END_OBJECT ) { String fieldName = jp.getCurrentName(); ...
af28568a-94b2-49e3-9dec-d203889cea32
1
boolean isSubstring(String s1,String s2){ if(s2.equals(reverse(s1))){ return true; }else{ return false; } }
c81e6d52-5772-4a44-bb71-cc8e10827ab5
6
@EventHandler public void CaveSpiderWaterBreathing(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.getCaveSpiderConfig().getDouble(...
a27664f8-a8b9-4544-8bb9-56e1fbb38d3c
7
@Override public void handleIt(Object... args) { Scanner inputReader = new Scanner(System.in); // Getting current user and socket from passed arguments. currentUser = (User) args[1]; sock = (Socket) args[0]; // This loop is only broken when the user has successfully specified // a recipient for the m...
d5af5e47-f6c3-46d3-ac46-cc61ce568ed8
5
@Test public void getIncome() { TopAthlete test = null; TopAthlete test1 = null; try { test = new TopAthlete("Franz", 3); test1 = new TopAthlete("Karl", 5); } catch (Exception e) { fail("Unexpected Exception"); } try { TopAthlete test3 = new TopAthlete("Sepp", 12); } catch (ValueException e)...
16b09762-fb80-4bb4-aa05-0b4071ab73b6
6
@SuppressWarnings("deprecation") private static void waitForMethodThreads( LinkedList<java.lang.Thread> threads, final Throwable[] error) throws Throwable { for (java.lang.Thread t : threads) try { if (t.isAlive() && error[0] != null) t.stop(); else t.join(); } catch (Interrupte...
b0c40558-de17-4e46-a09c-f3c43c84735d
7
public void headTowards( Target target, float speed, boolean moves ) { // // Determine the appropriate offset and angle for this target- if (target == null) return ; final Vec2D disp = displacement(target) ; final float dist = disp.length() ; float angle = dist == 0 ? 0 : disp.normalise()...
115e2edc-f84d-4808-9032-2c7f7800d0ba
6
public void keyPressed(KeyEvent e) { int keycode = e.getKeyCode(); System.out.println("key pressed: "); switch(keycode) { case KeyEvent.VK_UP: System.out.println("up"); Sounds.move.play(); ShipShopThrustersMenu.moveSelectionOvalUp(); break; case KeyEvent.VK_DOWN: System.out.println("do...
04be5dae-0da1-42a6-ab9e-5af41cc2356d
6
public boolean equals(Object o) { if(!(o instanceof AsciiImage)) return false; AsciiImage co = (AsciiImage)o; if(co.getHeight() != height || co.getWidth() != width) return false; for(int x=0; x<width; x++) { for(int y=0; y<height; y++) { ...
a8ea143e-fe71-4112-933a-ee221b40e07a
6
protected void processFuzzify(String block, Engine engine) throws Exception { BufferedReader reader = new BufferedReader(new StringReader(block)); String line = reader.readLine(); String name; int index = line.indexOf(' '); if (index >= 0) { name = Op.makeValidId(line...
d0af4204-8364-40fa-b4ea-f9104298c902
2
protected boolean scanFileData(byte[] fileData) { if(fileData == null) { return false; } this.fileSize = fileData.length; if(this.crc32==null) this.crc32=new CRC32(); this.crc32.reset(); this.crc32.update(fileData); return true; }
37187423-b0aa-45d4-afc7-d6d23c33e487
7
public static Cons yieldExceptionConstructorBody(Stella_Class renamed_Class, Symbol messageparameter, Cons requiredassignments) { { Cons initialvalueassignments = Stella_Class.yieldInitialValueAssignments(renamed_Class, (Stella_Class.decidedToRecycleP(renamed_Class) ? Stella.KWD_INITIAL_VALUE_ONLY : Stella.KWD_ANY_...
bf7f198d-29b8-4db1-a714-bd129df02f25
9
public double classifyInstance(Instance instance) throws Exception { double result; double[] dist; int index; switch (m_CombinationRule) { case AVERAGE_RULE: case PRODUCT_RULE: case MAJORITY_VOTING_RULE: case MIN_RULE: case MAX_RULE: dist = distributionForInstance(ins...
3e77db5a-8c85-49ea-9d8f-fc38cb0651a7
5
private void listEntries(ContactsExampleParameters parameters) throws IOException, ServiceException { if (parameters.isGroupFeed()) { ContactGroupFeed groupFeed = service.getFeed(feedUrl, ContactGroupFeed.class); System.err.println(groupFeed.getTitle().getPlainText()); for (Co...
44713bd1-6c1b-4a08-b3f1-eeb40678c019
7
@Override public void run() { while (true) { try { Job j = jobs.poll(); if (j == null) { waiting = true; synchronized (waiter_finish) { waiter_finish.notify(); } while (j == null) { synchronized (waiter_begin) { waiter_begin.wait(); } j = ...
d3cb7ff0-03b0-4afb-9ca3-f47b515bae75
2
public static void main(String[] args) { // Set server mode if -server flag is set if (args.length >= 1) { if (args[0].equals("-server")) { AuctionSystemServer.main(args); } else { System.err.println("Invalid arguments. Use -server to run system as a server."); System.exit(1); } } else { A...
926376f4-269a-4eed-bced-356be7067e19
9
public static <InterfaceType> InterfaceType getClient( Class<InterfaceType> interfaceType, String serverAddr) { try { String className = "Impl" + interfaceType.getSimpleName(); CtClass proxy = classPool.getOrNull(className); if (proxy == null) { proxy = classPool.makeClass(className); CtClass inte...