method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
611173f4-7151-49b3-b4e3-f656dca26880
1
public static Integer idFromUrl(String url) { Pattern idPattern = Pattern.compile("http://myanimelist.net/(\\w+)/(\\d+)/?.*"); Matcher matcher = idPattern.matcher(url); if (matcher.find()) { return Integer.valueOf(matcher.group(2)); } return 0; }
9d9a7104-4663-41b5-828b-78e63cce2b9e
1
public boolean more() throws JSONException { char nextChar = next(); if (nextChar == 0) { return false; } back(); return true; }
e9fe58d0-5132-4069-b6dd-21818cc1a603
7
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double) o).isInfinite() || ((Double) o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
e11557cb-671e-43cd-9bcb-38a0fa807cd3
1
protected final void handleUpdate(Result result) { this.result = result; if (result == Result.UPDATE_AVAILABLE) { this.registerNewNotifier(); } else { result.handleUpdate(this.plugin.getLogger()); } }
98a5619c-7c4e-4a35-9b07-a787679d3df1
7
public void setOptions(String[] options) throws Exception { String optionString; optionString = Utils.getOption('X', options); if (optionString.length() != 0) { setAttsToEliminatePerIteration(Integer.parseInt(optionString)); } optionString = Utils.getOption('Y', options); if (optionStrin...
f6ab7500-8b1d-4ef4-829d-a8217e614d58
3
public static void delete(String filename) { try { File file = new File(filename); if (file.exists()) { if (file.delete()) { System.out.println(filename + " is deleted!"); } else { System.out.println("Delete operation is failed. " + filename + " cannot be deleted"); } } } cat...
21312a9b-621c-4748-99f9-db07a7e008a1
0
private BuilderPattern(Builder builder) { this.title = builder.title; this.auther = builder.auther; this.location = builder.location; this.published = builder.published; this.pageno = builder.pageno; }
07cd8e27-6abf-418b-8ad7-ccdf93e68e7d
3
public static void writeBlocking( WebSocketImpl ws, ByteChannel channel ) throws InterruptedException , IOException { assert ( channel instanceof AbstractSelectableChannel == true ? ( (AbstractSelectableChannel) channel ).isBlocking() : true ); assert ( channel instanceof WrappedByteChannel == true ? ( (WrappedByte...
4e85304c-8331-4a5e-b26e-6342e7b3e409
6
public int updateVariableData(byte[] newData, int offset) { int vertexCount = getVertexCount(); vertexIndexArray = new int[vertexCount]; for (int index = 0; index < vertexIndexArray.length; ++index) { ByteConversions.setUnsignedShortInByteArrayAtPosition(vertexIn...
da9c8552-0bda-48bd-89a2-824aed49a021
2
* @return the XML datetime string corresponding to the given CycL date * @deprecated use DateConverter. */ static public String xmlDatetimeString(final CycList date) throws IOException, CycApiException { try { final CycNaut dateNaut = (CycNaut) CycNaut.convertIfPromising(date); final Date javada...
8eed21e7-d453-442c-b518-e464e8f7a4bb
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 Defi)) { return false; } Defi other = (Defi) object; if ((this.id == null && other.id != null) || (this.id != n...
77e3a72d-c107-4fdb-ac48-a6a7c9cb4dc2
4
public boolean DownloadFile(String httpUrl,String saveFile){ int bytesum = 0; int byteread = 0; URL url = null; try { url = new URL(httpUrl); } catch (MalformedURLException e1) { System.out.println("URL format error"); // e1.printStackTrace(); ...
bb4fefc8-1377-4840-b2de-382a0707ea22
9
public static void createDefprintUnit(Stella_Class renamed_Class) { if (!(KeyValueList.dynamicSlotValue(renamed_Class.dynamicSlots, Stella.SYM_STELLA_PRINT_FORM, null) == null)) { Cons.walkAuxiliaryTree(Cons.list$(Cons.cons(Stella.SYM_STELLA_DEFMETHOD, Cons.cons(Stella.SYM_STELLA_PRINT_OBJECT, Cons.cons(Cons....
8fc9ed83-a2ea-4f15-a971-db485fbd553a
9
@Override protected String doPostWork(Params params) { String action = params.getValue("action"); if(action == null) { return WebUtil.error("unknown action!"); } if("list".equals(action)) { Templates templates = Global.getInstance().getTemplates(); return templates.listTemplatesJSON(); } String n...
8be7ff50-bf35-4d3c-9b26-712dd3a5aa82
4
void split(String filename, long cSize, File sf) throws FileNotFoundException, IOException { BufferedInputStream in = new BufferedInputStream(new FileInputStream(sf)); // get the file length long fileSize = sf.length(); // loop for each full chunk int subfile; for (subfile = 1; subfile < fileSize / ...
8b57cead-360a-4f32-b4e4-76d00fcdb115
6
public int readBit() throws IOException { int retVal; // 当前mBytePos指向字节已经读完 if(mBitPos == 8){ if (isEnd && mBytePos == mEndBytePos){ // 到达数据流的末端 throw new EOFException(); } // 缓冲区的数据完全读取完了 if(mBytePos == mByteBuf.le...
5d69b953-e235-4b6f-8ab9-11558752ced7
4
@Override public void action() { if(agente.getPasso() == 3){ if(agente.getQuantidadeDeAgentesVendedores() > 0){ System.out.println("Passo 3 AI"); ACLMessage mensagem = new ACLMessage(ACLMessage.CFP); mensagem.setProtocol(FIPANames.InteractionProtocol.FIPA_CONTRACT_NET); mensagem.setRe...
5ab9a747-4097-4e14-9a94-3e5ec55d9a16
3
public String toString(){ String result = ""; for(int i=0; i<=height+1; i++){ for(int j=0; j<=width+1; j++){ if (area[i][j]){ result+=1 ; }else{ result+=0; } } result+='\n'; } return result; }
03dc5d9f-3a07-4f8f-82f5-97e37227dc16
4
private double testDoublyLinkedListDeletions(int inserts) { System.out.println("Testing DoublyLinkedList with " + inserts + " deletions"); long[] times = new long[20]; long startTime; long endTime; for (int i = 0; i < 20; i++) { doublyLinkedList = new DoublyLinkedLi...
a9bc6d77-1463-47b6-b046-05534ae5dcf5
7
public void create(Software software) throws PreexistingEntityException, RollbackFailureException, Exception { if (software.getComputadoraCollection() == null) { software.setComputadoraCollection(new ArrayList<Computadora>()); } EntityManager em = null; try { em =...
4c568b37-813a-423f-853a-2dbcfce30b39
4
public List<Archivio> archiviCreatiIl(String data) { List<Archivio> lista = new ArrayList<>(); if (super.getDataCreazione().equals(data)) lista.addAll(this.elementi); for(Archivio elemento: this.elementi){ if (elemento.getClass() == Cartella.class && elemento.getDataCreazione().equals(data)){ lista.add(ele...
fad63fb4-94e2-4894-8be5-f952ce77d6a0
5
public boolean globtype(char k, KeyEvent ev) { if ((k == 27) && (this.menu_current_parent_resource != null)) { this.menu_current_parent_resource = null; menu_current_layer_elements_offset = 0; updlayout(); return (true); } else if ((k == 'N') && (layout[gs...
a220d580-d41e-44ae-9d91-ff7efce07195
4
@Test public void testLpaLimits() { Metabolism m = new Metabolism(); try { m.setLpa(0.); } catch(IncoherentLpaException e) { fail("An IncoherentLpaException has been thrown."); } try { m.setLpa(-1.); fail("An IncoherentLpaException should have been thrown."); } catch(IncoherentLpaException e) {...
a69134d2-65cd-45c8-bc77-8d396e4c8834
7
public void processEvent(Event event) { // the last directory response if (event.getType() == Event.COMPLETION_EVENT) { return; } if (event.getType() != Event.OMM_ITEM_EVENT) { System.out.println(_instanceName + " Received an unsupported Even...
be971b5d-1f65-4db0-9e44-ab87e419a5f8
8
@Override public Complex getPixel(Complex pixel) { /* LEFT */ if(parser[0].foundC()) { parser[0].setCvalue(pixel); } /* RIGHT */ if(parser[1].foundC()) { parser[1].setCvalue(pixel); } int result = expr[0].getValue().compare(e...
37dd330f-a6c5-4a59-a478-c336a4982be2
7
private Boolean fieldCheck(){ Boolean fields_pass_check; // If any of the conditions are true, popup a menu if ( course_name_field.getText().equalsIgnoreCase("") // course name empty || course_id_field.getText().equalsIgnoreCase("") ...
eee6d52f-378b-482c-8988-ab44bbe4cea8
4
public static boolean fuzzyEquals (double a, double b) { // value based on this table: // http://en.wikipedia.org/wiki/Machine_epsilon#Values_for_standard_hardware_floating_point_arithmetics final double EPSILON = 5.96e-08; if (Double.isNaN(a) && Double.isNaN(b) || Double.isInfinite(a) &...
3fa67ad4-5c5f-4c7a-bf6c-a96c1e98735a
5
public static void print(UndirectedGraphNode node) { if (null == node) return; List<UndirectedGraphNode> nodes = new ArrayList<UndirectedGraphNode>(); int index = 0; if (null != node)nodes.add(node); while (index != nodes.size()) { UndirectedGraphNode n = nodes.get(index); System.ou...
d59c512d-e038-4dcf-91c9-331e7308ee66
1
private boolean isOperator(String ch){ String operators = "*/%+-"; if (operators.indexOf(ch) != -1) return true; else return false; }
d61c9b6d-0c29-4f16-9a4a-eb6143a8e9b8
3
public boolean hasPrevious() { if(previousShort != null)//Already found. This is prevention for possible inappropriate call. return true; while(strings.hasNext()){ previousShort = strings.previous(); index--; if(previousShort.length() <= maxLen) previousIndex = index; return true; } previou...
93ebeed8-a3ef-4615-8e33-24dd70e07aa9
8
@Override public void openIF(boolean safeMode) throws RoombaIFException { serialPort = new SerialPort(portName); if (isOpened) { throw new RoombaIFException(RoombaIFException.TYPE_ALREADY_OPEN); } try { serialPort.openPort(); serialPort.setParams(B...
1b9c62ed-d856-455e-815a-5e8d6d18696a
8
public static Cons cppTranslateMethodCall(Cons tree, boolean referencedP) { { Symbol methodname = ((Symbol)(tree.rest.value)); Surrogate owner = ((Surrogate)(tree.value)); Cons arguments = tree.rest.rest; if ((methodname == Stella.SYM_STELLA_DEFINEDp) || (methodname == Stella.SYM_STELLA...
07e06796-7121-47bc-9b06-ee03c0aacb1d
4
public boolean isSolved() { boolean solved = true; for (int x=0; x < size*size && solved; x++) { for (int y=0; y < size*size && solved; y++) { solved = (!sudokuGrid[x][y].equals(new String("*"))); } } return solved; }
3362b3c9-bbec-42df-84d3-30b0a43175ca
2
private Expression equal( List<Expression> args, String caller ) { if ( args.size() != 2 ) { System.err.println("= expected 2 arguments and got " + args.size() ); System.exit(1); } DeferredSubst df = DeferredSubst.getInstance(); // if the values are the same ...
b4ad183d-0d89-483f-afb6-24fb1a65bb31
3
public int setCurrency(int amount) { ownCurrency = amount; int overflow = ownCurrency - 3904; int large = (int)Math.floor(ownCurrency / largeCurrency); if (large > 0) inventory.setItem(2, new ItemStack(largeCurrencyItem.getType(), large)); else { inventory.clear(2); } int m...
52e07461-2da5-405f-b0f2-6be8d214f057
8
public void saveToFile(File file) { String suffix = file.getAbsolutePath().substring( file.getAbsolutePath().lastIndexOf(".")+1); boolean saved = false; if (suffix.equalsIgnoreCase("fasta") || suffix.equalsIgnoreCase("fas") ) { FastaParser parser = new FastaParser(sunfishParent); parser.writeData(file, curr...
56bbb1c5-8156-437b-8552-b011588a6ed8
0
private static void handleError(String message, Throwable e) { MessageDialog.getInstance().showError(message); LOGGER.error(message, e); }
bec2a5b0-ec25-4c3d-9e25-c9641af9aca7
7
private void preencherCampos() { ArrayList<String> telefones; ArrayList<Premiacao> premiacoes; jTextFieldAltura.setText(Double.toString(piloto.getAltura())); jTextFieldBairro.setText(piloto.getEndereco().getBairro()); jTextFieldCategoriaPeso.setText(Double.toString(piloto.getPes...
c56b23a1-8b62-4b0f-a5c3-0910c0605535
3
static boolean player1Move(int x, int y) { if (getGame().m_board.anyValid(m_player1Colour)) { if (getGame().move(x, y, m_player1Colour)) { if (m_p1colour == Piece.OthelloPieceColour.WHITE) { m_gridButtons[x][y].setIcon(m_whitePiece); } else { m_gridButtons[x][y].setIcon(m_blackPiece); } O...
1e87ebd4-1a5d-4ec0-b4ea-34fecac771d9
3
public void run() { while(true) { try{ long t = System.currentTimeMillis(); //check if products are still up to date and put the new ppc id in ppc otherwise if(!vn.validateProducts(init.getPPC())) { barPanel.initBarProducts(); System.out.println("Er is een product geupdate"); } /...
811fb98d-5698-4c68-b52d-e56c5b708573
6
public void received(Connection c, Object o) { if(o instanceof Packet) { Packet p = ((Packet)o); p.decompressData(); // BlockyMain.console("Received packet "+p.name); if(p.name.equals("Ping+infos response")) { try ...
45998775-7059-43ea-ad5a-f3d4625e2530
8
@Test public void testSignedIntegerCompare() throws Exception { int[] testNumbers = { Integer.MIN_VALUE, -1000, 0, 1000, Integer.MAX_VALUE}; for (int n1 : testNumbers) { byte[] n1Bytes = toSortableBytes(n1);...
aff594a8-4f8b-4bee-ba5e-548ad4281446
8
public static Ime_Velicina_Adresa OBRADI_izravni_deklarator(int trenutacnaLabela){ String linija = mParser.ParsirajNovuLiniju(); // ucitaj IDN UniformniZnak uz_idn = UniformniZnak.SigurnoStvaranje(linija); linija = mParser.DohvatiProviriVrijednost(); UniformniZnak uz_1 = UniformniZnak.SigurnoStvaranje(linija...
9f21bccd-2e06-4c44-8b51-0a1160d3683b
7
protected void consumeMethodHeader() { // MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt // AnnotationMethodHeader ::= AnnotationMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt // Recovery...
2b64a1be-c76f-410c-8355-0504e6fe518f
0
public void setUserData(String userData) { this.userData = userData; }
b19a3fd6-4e99-4274-805b-76838576b35d
9
public void testStringSort() throws IOException, ParseException { r = newRandom(); ScoreDoc[] result = null; IndexSearcher searcher = getFullStrings(); sort.setSort( new SortField("string", SortField.STRING), new SortField("string2", SortField.STRING, true), SortField.FIELD_DOC )...
4f8ad93d-ba88-4dfb-b0b1-e1e6f1fc8397
5
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String action = (String)req.getParameter("action"); if (action == null) action = ""; ProductViewHelper productViewHelper; String url = "/ProductView.jsp"; switch (action) { case View...
403a9d88-cdb4-4f84-86b8-b9b63f97c68a
7
public void insertVisitingHours(VisingHoursBean bean){ ResultSet rs=null; Connection con=null; PreparedStatement ps=null; try{ String sql="INSERT INTO OFFICE_HOURS(p_id, weekday, timings) VALUES (?,?)"; con=ConnectionPool.getConnectionFromPool();; ps=con.prepareStatement(sql); ps.setInt(1, bean.get...
d6967b3e-f415-4f7f-b702-e4d49cd384c7
4
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IdCount idCount = (IdCount) o; if (id != idCount.id) return false; return true; }
1256af53-b679-4d4a-85c1-dd6ec029ac01
8
final public void AndExpression() throws ParseException { EqualExpression(); label_2: while (true) { switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) { case AND: break; default: jj_la1[2] = jj_gen; break label_2; } ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE); boolean jjtc001 = true; ...
b838ad4e-73e2-41aa-ad37-42035ac7aea0
8
public MapEntry acquire(int length) throws IOException { // length check int fIndex = mapLengthToFreeEntryArrayIndex(length); if (fIndex < 0 || fIndex >= FREE_ENTRY_ARRAY_SIZE) throw new IllegalArgumentException(length + " <= 0 or > max allowed data slot length " + MAX_DATA_SLOT_LENGTH); // metrics this.to...
1e528a55-117a-42c8-a641-245b770ccb5d
5
public void process() { List<CycleEventContainer> eventsCopy = new ArrayList<CycleEventContainer>(events); List<CycleEventContainer> remove = new ArrayList<CycleEventContainer>(); for (CycleEventContainer c : eventsCopy) { if (c != null) { if (c.needsExecution()) c.execute(); if (!c.isRunning()) {...
efabfaf4-db00-4ed9-96fe-321faec48b9b
1
public static AbstractTableModel getBoundProperties(final CSProperties p, String boundName) throws ParseException { final int rows = DataIO.getInt(p, boundName); final List<String> arr = keysByMeta(p, "bound", boundName); return new AbstractTableModel() { @Override pu...
fc938ea5-edca-4231-8dd0-85f7ad33cb63
1
public JSONObject optJSONObject(int index) { Object o = this.opt(index); return o instanceof JSONObject ? (JSONObject) o : null; }
7fd7375c-2a79-4a89-9b2c-3dbebfaeaab4
4
private static Tree setParents(Tree a, int[] L) { for(int i=0;i<L.length;i++){ if(L[i]==0){ a.addLeaf(i+1); } } for(int i=0;i<L.length;i++){ if(L[i]!=0){ a.addLeaf(L[i],i+1); } } return a; }
980c6ead-6726-4b45-82ea-747bfd111c0e
9
final private boolean jj_3R_189() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(85)) { jj_scanpos = xsp; if (jj_scan_token(86)) { jj_scanpos = xsp; if (jj_scan_token(83)) { jj_scanpos = xsp; if (jj_scan_token(84)) { jj_scanpos = xsp; if (jj_scan_token(92)) { jj_scanpos...
1efbcc26-251b-425e-83e1-b856008928a0
3
public static boolean isAlpha(int c) { return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); }
43ce7780-c788-40ca-938b-a39a61fca3e3
0
public static void main(String[] args) { Inner1 inner = new Inner1(); inner.dosomething(); }
e346abdb-be0a-4894-8e71-fcedef5f6ea7
6
@Override public void propertyChange(PropertyChangeEvent evt) { CompoundPainter<?> painter = ref.get(); if (painter == null) { AbstractPainter<?> src = (AbstractPainter<?>) evt.getSource(); src.removePropertyChangeListener(this); } else { String property = evt.getPropertyName(); ...
314077f7-63a1-44b2-bf2a-311732abf57f
4
@SuppressWarnings("unchecked") public static <T> ImmutableList<T> of( final ImmutableList<? extends T> left, final ImmutableList<? extends T> right) { if (right.isEmpty()) { return (ImmutableList<T>) left; } if (left.isEmpty()) { return (Immuta...
bdb20d79-4a24-4a72-8b66-053137992c92
7
public void doVictimsOfCrime(Area A, LegalBehavior B, Law theLaw, MOB mob, boolean allowedToModify) throws IOException { if(mob.session()==null) return; mob.tell(getFromTOC("P3"+(theLaw.hasModifiableLaws()?"MOD":""))); mob.tell(L("Protected victims: @x1",CMLib.masking().maskDesc(theLaw.getInternalStr("PROTE...
03be56d1-96ed-4bcd-a811-af591fc2b478
9
private byte[] handleHandshake(NfcMessage inputMessage) { // no sequence number in handshake if (inputMessage.isSelectAidApdu()) { /* * The size of the returned message is specified in NfcTransceiver * and is currently set to 2. */ if (Config.DEBUG) Log.d(TAG, "AID selected"); return ne...
9c1b4b1e-8401-4ba4-b26b-3f3f3e7c55ed
6
public void paintColorsMode(Graphics g, int x, int y) { Point p = new Point(x, y); String rbs =request.buttonGroup.getSelection().getActionCommand(); //radio button selected colorBiddableLand(g); Grid grid = request.operator.getGrid(); grid.goToSurface(); if (rbs.equals("B")){ //If the bid radio box ...
ee8119f9-4ecc-4031-92ae-1ce142c3c803
9
public PrintableDialog() { setTitle("Print Preview"); printMode.setStyle(CharProps.getIntProperty("last.printmode.style", PrintMode.STYLE_CRAM)); printMode.setText(CharProps.getIntProperty("last.printmode.text", PrintMode.TEXT_CHARS)); Container thiss = this.getContentPane(); th...
2203826e-9e3a-46d5-999d-30801c0583f8
3
public static void main(String[] args) { long start = System.nanoTime(); int found = 0, sum = 0; for (int i = 19; found < 11; i += 2) { if (isPrime(i)) { if (isTruncatable(Integer.toString(i))) { found += 1; sum += i; } } } System.out.println(sum); System.out.println("Done in " + (do...
716482db-8eb4-488e-8947-f243f2d5d3ce
0
private void setMenuItems(){ // file menu // help menu welcome = new JMenuItem("Welcome"); about = new JMenuItem("About this"); help.add(welcome); help.add(about); }
f8e95f6a-df97-49c2-b955-68c77357bf1c
1
public void enter(Miner miner){ if (miner.getLocation() != Location.saloon) { miner.changeLocation(Location.saloon); System.out.println(miner.getName() + " Boy, ah sure is thusty! Walking to the saloon"); } }
b62a3eff-6762-4a14-b798-31cb13ebd46d
9
public static final void login(final SeekableLittleEndianAccessor slea, final MapleClient c) { final String login = slea.readMapleAsciiString(); final String pwd = slea.readMapleAsciiString(); c.setAccountName(login); final boolean ipBan = c.hasBannedIP(); // final boolean macBan...
09430883-68c0-4bcb-928f-d0ac03bfc2bb
1
public void sendGuessMove(String guess){ check(isMyTurn() && currentMove == GUESS); int maxDigit = (Integer)state.get(MAXDIGIT); check(masterMindLogic.checkValidCode(guess, maxDigit)); this.sendGuessOperation(coderId, guesserId, guess, state); }
92c95279-cc27-4118-bf98-380d3fd8d15c
3
public static String shitWordN(String s,int n){ if(s!=null && n >= 0 && n <= s.length()){ char[] shit = s.toCharArray(); reverseChar(shit,0,n-1); reverseChar(shit,n,s.length()-1); reverseChar(shit,0,s.length()-1); return new String(shit); } return null; }
adff46d3-b530-448b-9c53-eabacbe13775
0
public Address getIndirizzo() { return address; }
9c18a593-9d36-447a-987d-7007f5e210c4
0
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void main(String[] argx) { List<String> listWithDup = new ArrayList<String>(); listWithDup.add("1"); listWithDup.add("2"); listWithDup.add("3"); listWithDup.add("1"); List<String> listWithoutDup = new Array...
f65658bb-9580-4789-9acf-390fcc3422bd
4
public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException, InterruptedException, ExecutionException { System.out.println("Running benchmark. Press any key to continue."); System.in.read(); Map<Class<?>, Map<String, String>> keyLookupCl...
8f6e5dfa-1d22-4b11-abd0-c8b5280cc108
1
public AttributeInfo copy(ConstPool newCp, Map classnames) { if (methodIndex() == 0) return new EnclosingMethodAttribute(newCp, className()); else return new EnclosingMethodAttribute(newCp, className(), methodName(), methodDescriptor()...
62c06494-8939-40ad-ad52-2e4cf4f9483e
5
public static Subject findSubjectOfBestHj(Data myData, Subject[] givenSubjects){ int i = 0; Subject bestSubject = givenSubjects[i]; for(int j=i+1; j<givenSubjects.length; j++){ if (findBestSubjectSemester(bestSubject)==null){ bestSubject = givenSubjects[j]; ...
249861c1-d7bc-4b59-bda0-773b86434cc2
6
public void run() { while(active){ if(freeze){ try { this.freeze = false; Ob.wait(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } sim = new Driver(); sim.Constants = this.Constants; sim.verbose = this.verbose; ...
28ce3441-f2d6-43d6-8f34-bf81650d90ca
2
public void assignRoles() { calculateRatio(); for (Player player : players.getPlayers()) { if (getRandomDecision()) { assignAsMafia(player); } else { assignAsVillager(player); } } }
cb212e1a-d38a-4714-9ea6-52e69b975f54
1
@Override public DefaultConnectionLabel toItem( ConnectionLabelData data, DefaultUmlDiagram diagram ) { AbstractConnection connection = (AbstractConnection)diagram.getItem( data.getConnection() ); if(connection == null){ throw new IllegalStateException( "cannot find connection of label" ); } DefaultConne...
741a14e0-f894-414d-82d2-70ef76da37a0
0
public static void main(String[] args) { long[]arr = new long[]{1,3,4,1,2,5}; display(arr); InsertSort.sort(arr); display(arr); }
80f79ba2-8c73-4d99-9f7b-c28574fc46ea
7
public static String producto(String archivo, String factorA, String factorB) { try { Workbook libro = Workbook.getWorkbook(new File("src/txts/" + archivo)); int altoTabla = libro.getSheet(0).getRows(); String[][] tabla = new String[libro.getSheet(0).getColumns()][altoTabla];...
d427492a-8a9b-40fa-a205-afa5d6e3a41a
2
public static ClassLoader getDefaultClassLoader() { ClassLoader cl = null; try { cl = Thread.currentThread().getContextClassLoader(); } catch (Throwable ex) { // Cannot access thread context ClassLoader - falling back to system // class loader... } if (cl == null) { // No thread context class load...
fb0c5ec7-6145-43e4-a868-d3e44240a597
4
@Override void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild) { // Replace child if(this._condicao_ == oldChild) { setCondicao((PExpLogica) newChild); return; } for(ListIterator<PComando> i = thi...
c4876ef8-7a4f-4a5a-8393-78a53bb96529
0
public String getStateName() { return stateName.get(); }
0289eb82-1fbf-434a-828b-ef51146a4b13
5
ArrayList<String> wordBreakDFS( String s, Set<String> dict ) { ArrayList<String> result = new ArrayList<String>(), tmpList; for( int i = 0; i < s.length(); i++ ) { String head = s.substring(0, i+1); String tail = s.substring(i+1); if( dict.contains(head) ) { ...
b6be7058-1268-4048-9d98-b7b75027bc74
3
public static void main(String args[]){ System.out.println("Digite o numero para verificar se é primo ou não:"); Scanner scan = new Scanner(System.in); int n = scan.nextInt(); boolean primo = true; for (int i = n-1; i > 1; i--) { if (n%i == 0) { ...
ba695ee5-bb1f-46de-b112-aba6733c4f4a
4
public Image[] getCells(ImageRetriever paramImageRetriever, int paramInt1, int paramInt2) { Integer localInteger = new Integer(paramInt1); if (animationList == null) animationList = new Hashtable(); Object localObject = animationList.get(localInteger); Image[] arrayOfImage; if (localObject =...
98962a3b-f96f-48fc-91c0-1e9fa94f4be6
1
@Test public void ensureSalaryItemInBudgetContainsDifferentValueFormObjectTestTwo() { when(budgetFormData.getSalary()).thenReturn(new BigDecimal("2500")); try { budget.buildBudget(budgetFormData); } catch (Exception e) { e.printStackTrace(); } asser...
6bcb4b3d-9ab0-4eac-9464-efbeb3e4b08e
7
public void render(Screen screen) { Vector2i pos = getPlayers().get(0).getPos().toVector2i(); int xOffset = pos.getX() - screen.w / 2; int yOffset = pos.getY() - screen.h / 2; screen.setOffset(xOffset, yOffset); int x0 = xOffset >> 4; int x1 = (xOffset + screen.w + 16) >> 4; int y0 = yOffset >> 4; int ...
136f2636-ce99-43d8-acd1-4ef31f0a38ab
0
public void mouseExited(MouseEvent event) { adapter.mouseExited(event); }
8ff690d2-2fee-4d19-baaa-a4e6d4d8b579
2
public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); HTTPTokener x = new HTTPTokener(string); String token; token = x.nextToken(); if (token.toUpperCase().startsWith("HTTP")) { // Response jo.p...
f3d281f6-d280-4ff4-a675-bd4826b1c63b
0
public int getPoints() { return points; }
f473605d-cb14-443f-b85f-a1c41a3bea53
8
public static String convert(String s, int nRows) { String result = ""; if (nRows < 2 || s == null) { return s; } String[] strings = new String[nRows]; int current = 0; int dir = -1; for (int i = 0; i < s.length(); i++) { if (strings[curre...
c081f730-34ed-481b-8917-0d914a3671d9
3
public static int triangleBsum1(int x[][]) { int sum = 0; for (int i = 0; i < x.length; i++) { System.out.println(); for (int j = 0; j < x[i].length; j++) { if (i >= j) { System.out.print(x[i][j] + " "); sum = sum + x[i][j]; } } } System.out.println(); return sum; }
2ab66c32-8668-47b7-8c9e-0ce1a52d9604
8
public boolean validateConnection(String direction) { switch (direction) { case "north": if (this.north[0].equals("X")) { return false; } else { return true; } case "east": if (this.ea...
ec3ab8d1-557a-4cc0-ae37-0687cd29e722
3
@Override public void render(GameContainer gc, Graphics g) throws SlickException { for (int x = 0; x < tiles.length; x++){ for (int y = 0; y < tiles[x].length; y++){ if (tiles[x][y] != null) tiles[x][y].render( x*tiles[x][y].getSprite().getWidth(), y*tiles[x][y].getSprite().getHeight() ...
b6c5ec94-2e0e-4c6d-b892-b86f8c1904fd
2
public void update(GameContainer gc, StateBasedGame sb, float delta) { if (cooldown <= 0) { cooldown = 0; onCooldown = false; } else if (onCooldown) { cooldown -= delta; } }
0eda051f-7efb-416c-93d5-4ac8c9883579
9
public void process(String dirname) { FileWriter fw = null; try { File dir = new File(dirname); fw = new FileWriter(output); BufferedWriter bw = new BufferedWriter(fw); File[] fa = dir.listFiles(new EndsWithFilter(extension)); for (File f : fa) { String name = f.getName(); System.out...
8200edaf-9c48-4b1f-9247-2cba821ac27e
8
private int addNewPlayers(List<Player> player, Message mg) { int numberOfPlayers = 0; while(numberOfPlayers == 0){ try{ numberOfPlayers = Integer.parseInt(getInput()); } catch (NumberFormatException e){ mg.displayMessage(3); } } /* * This code generates the new players by user input ...
1cffcadf-d159-4ec7-88ba-42f33d0f4dbd
3
World(int level) { walls = new ArrayList<Wall>(); walls.add(new Wall(0, 0, 600, 20)); walls.add(new Wall(0, 0, 20, 600)); walls.add(new Wall(0, 571, 600, 600)); walls.add(new Wall(571, 0, 600, 600)); switch(level) { case 1: initWorldLevelOne(); break; ...
92d760c4-0cf4-4c27-b9be-e13e3e6b392d
4
@Test public void testGetQuantidadeProduto() { try { Assert.assertEquals(10, facade.getQuantidadeProduto(1)); } catch (FacadeException e) { Assert.fail(e.getMessage()); } try { facade.getQuantidadeProduto(5); Assert.fail("era para lanÁa exceÁ„o"); } catch (FacadeException e) { // n„o È par...