method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
5d94b04e-c3f5-4e96-893c-e3b5284bba55
4
public String generate() { String error = "No errors."; if (details) System.out.println("Temperature flags: PRODUCE="+ioflags.PRODUCE+", SAVE="+ioflags.SAVE+", LOAD="+ioflags.LOAD); if (Utils.flagsCheck(ioflags) != 0) { System.out.println("ERROR: IOFlags object is corrupted, error: "+Utils.flagsCheck(...
90dd256e-9512-4a2b-802e-722989b92f1d
2
public void doHit() { if (goinUp < 20) { setY(getY() - 5); } else if (goinUp < 40) { setY(getY() + 5); } goinUp++; }
13c9de7e-d1c0-46af-845a-5d5c29e77360
6
public static void main(String[]args) { int limit = 100; int n = 2; ArrayList<Integer> primes = new ArrayList<Integer>(); for(int i = 2; i <= limit ; i++) { System.out.println("i is " + i); boolean isNotPrime = true; while(isNotPrime) { for(int j = 2; j < i; j++) { if(i % j == 0) ...
0e999f2c-ebc5-4623-bf09-0168e9cc1724
9
private static void processMessage(GameState state, byte[] data, String senderGID){ Decoder dec = new Decoder(data); try { if(dec.getTypeByte()==UpdateShip.asnType && state==GameState.PLAYING) { if(DEBUG)System.out.println("processMessage: UpdateShip(start)"); ...
a9c55527-941c-4201-b53f-b7da3a1c76bb
5
public synchronized boolean dispatch() throws IOException { try { while (this.messages.isEmpty()) { wait(); } } catch (InterruptedException ex) { //The thread was interrupted, silent failure. System.out.println("Thread interrupted"); return false; } Message msg = this.messages.remove(0...
32d7340b-a1aa-403d-a2f4-21662536fe4d
8
public int decodeInstruction(int instruction) { switch (instruction & 0b11110000) { case 0b00000000: return 0; case 0b00010000: return 16; case 0b00100000: return 32; case 0b00110000: return 48; case 0b01000000: return 64; case 0b01010000: return 80; case 0...
26b5b530-d1ac-48dd-a0f9-910eb91836da
8
private void searchZipCode(String zipcodeOrg) { lstM.clear(); //郵便番号検索 String serchZip = zipcodeOrg.replaceAll("-", ""); int serchL = serchZip.length(); if ((serchL == 3) || (serchL == 5) || (serchL == 7)) { //3桁・5,7桁指定 //CSVファイルの読み込み ...
99568655-7a75-4444-bbdb-6241d58f952c
9
public static QuestionEquation decode(String str) throws DecodeException { QuestionEquation res; if (str.substring(0, 17).compareTo("#QuestionEquation") == 0) { res = new QuestionEquation(); int i = 17; if (str.charAt(i) == '<') { while (str.charAt(i) ...
a59ed90a-4919-4193-816b-cf946d7d7af8
9
private void attachPushedMBlocks(Direction dir) { int x = 0; int y =0; if (dir == Direction.LEFT) x = -1; else if (dir == Direction.RIGHT) x = 1; else if (dir == Direction.UP) y = -1; else if (dir == Direction.DOWN) y = 1; for (MBlock b : mBlocks) { Point p = b.location(); if (gBlock.getAttachedPoin...
b970e561-7569-448f-88f0-6aeebed49bf5
9
public void printSubtree(int spaces) { if (child4 != null) { child4.printSubtree(spaces + 5); } if (keys == 3) { for (int i = 0; i < spaces; i++) { System.out.print(" "); } System.out.println(key3); } if (child3 != null) { child3.printSubtree(spaces + 5); }...
fe0d90c8-21c7-4f85-974d-ba6ff10320c8
9
@Override public JList load() { if (loaded) return this; String body = null; try { body = JHttpClientUtil.postText( context.getUrl() + JHttpClientUtil.Lists.URL, JHttpClientUtil.Lists.GetList.replace("{listName}", String.format("{%s}", get...
94ba500c-f592-49f2-82e4-3bff8f6badd0
7
public void actionPerformed(ActionEvent e){ //button 1 if(e.getSource()==XD){ //change button function when a player wins to change if(win) { for(Player p : players) { p.update(gametrack.getStart()) ; } gamedeck.shuffle() ; counter.setText(pl1.getName() + "'s turn"); ...
af357817-972a-48e9-83e2-badae5c608e3
0
public void setAmount(double amount) { this.amount = amount; }
af662bed-304a-45e2-b6d8-867b57865b4d
0
public static Long getLongValue(String key){ return Long.valueOf(getStringValue(key)); }
76cd80be-45d4-4894-b63c-e52951fd28df
5
@Override public Date deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException { String value = jp.getText(); if (value.contains("y")) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.MONTH, Calendar.JANUARY); cal....
b639d2c0-aab2-418e-a5ff-a498485505ab
9
public boolean validaComponenteProtheus(String produto, String componenteDigitado) { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; String setor = jComboBoxSetor.getSelectedItem().toString(); String sql = "select G1_COD, G1_COMP, G1_QUANT fr...
10943f44-400f-4f68-9809-3f3e606c7de9
9
@Override public File download(URI uri) throws FileSizeLimitExceededException, FileDownloadException { InputStream input = null; OutputStream output = null; try { log.debug("Connecting to {}", uri); HttpClient client = new DefaultHttpClient(); HttpGet ge...
3a6ddd48-8a86-466f-af53-1d976c6dd373
2
private InferenceParameter getInferenceParameter(CycSymbol parameterName) throws RuntimeException { InferenceParameterDescriptions descriptions = getDefaultInferenceParameterDescriptions(); if (descriptions == null) { throw new RuntimeException("Cannot find inference parameter descriptions"); } In...
77002865-95b4-462f-a74c-5f7509a6848c
5
@SuppressWarnings("unused") private static void RollADiceAgain(){ Scanner keyboard = new Scanner(System.in); Random r = new Random(); int roll1 = 1 + r.nextInt(6); int roll2 = 1 + r.nextInt(6); int tries = 1; String input = ""; System.out.println("HERE COME THE DICE!\n"); do{ System.out.printl...
54d6bb5b-1e41-4605-af01-cc041d2cc91d
3
public static String decimalToBinary(int decimal) { String binary = ""; while (decimal != 0) { if (decimal % 2 == 0) binary = "0" + binary; else binary = "1" + binary; decimal = decimal / 2; } for (int i = binary.length(); i < 16; i++) { binary = "0" + binary; } return binary; }
aa7389b3-4304-4eaa-b4ba-fe92c3e6b74a
4
@Override public double getElementAt(int row, int column) throws OutOfBoundsException { if (row > _rowNum || column > _colNum || row < 1 || column < 1) { throw new OutOfBoundsException(); } return _values[row-1][column-1]; }
f2f97c57-4408-4138-8249-1375ad30e870
1
public List<Class<? extends APacket>> getPackageClassList(){ return new ArrayList<>(classes); }
2a4e8e56-14aa-4c59-8dc2-c255bee8da95
6
private void validateOptions() { // No validation if we found a help parameter if (m_helpWasSpecified) { return; } if (!m_requiredFields.isEmpty()) { StringBuilder missingFields = new StringBuilder(); for (ParameterDescription pd : m_requiredFields.values()) { missingFields.append(pd.getNa...
121c7fe2-3ea9-4ac6-bffb-4acdc8367ef4
5
public void update(long nowTime) { // TODO: probably we should do something else here. if ((m_dt = nowTime - m_lastUpdate) < m_updateFreq) { return; } float dThetaMax = 0.01f; float vMax = 2.1f; double accMax = 0.01f; float dt = 1; Point2D.Float v = new Point2D.Float(); for (Entity e : m_world.ge...
9a1f7686-6a91-42e6-9f48-c57c1fc23072
4
private boolean isAttacking(){ if(state == StateActor.ATTACKINGUP || state == StateActor.ATTACKINGDOWN || state == StateActor.ATTACKINGLEFT || state == StateActor.ATTACKINGRIGHT){ return true; } else return false; }
d5249cca-cbaf-44fb-8869-c30038bb6573
9
public static int computeMaximumCardinality(NamedDescription relation, Stella_Object instance) { { Object old$ReversepolarityP$000 = Logic.$REVERSEPOLARITYp$.get(); try { Native.setBooleanSpecial(Logic.$REVERSEPOLARITYp$, false); { Surrogate relationref = relation.surrogateValueInverse; ...
6e5709ec-bc3a-4068-a143-8aeb6e7fe284
4
private void automaticallyCreateOrders() { createSupplyProductList(); orderStockItemList = new ArrayList<StockItem>(); for (int i = 0; i < 308; i++) { for (ArrayList<Product> list : productList) { orderStockItemList = new ArrayList<StockItem>(); for (Product product : list) { int randomQuantity =...
22ed324b-45ce-4719-a664-2cb4c79a63e2
7
public ShellCommand lookupCommand(String discriminator, List<Token> tokens) throws CLIException { List<ShellCommand> collectedTable = commandsByName(discriminator); // reduction List<ShellCommand> reducedTable = new ArrayList<ShellCommand>(); for (ShellCommand cs : collectedTable) ...
97e4d1b7-2bcf-4218-8ec2-273e073b3c6f
0
public long getMilliseconds() { return milliseconds; }
237137d6-e4ef-480b-9dd0-e9a30e0e0d87
3
@Override public void saveToFile(ArrayList<ArrayList<String>> code, String filename) { if (code != null && filename != null) { if (!filename.endsWith(".cecil")) { filename += ".cecil"; } Program program = new Program(code); File file = model.programToFile(program, filename); view.setFilename(file....
98f1e5da-b4a4-4a00-8451-0ede9a462f32
4
@RequestMapping(value = {"/TransaccionBancaria"}, method = RequestMethod.POST) public void insert(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse, @RequestBody String json) throws JsonProcessingException { try { ObjectMapper objectMapper = new ObjectMapper(); ...
7c189aaf-4562-4c9e-b3a8-280349e77935
6
public static void main(String[] args) throws Exception { int ponder = 5; if(args.length > 0) { ponder = Integer.parseInt(args[0]); } int size = 5; if(args.length > 1) { size = Integer.parseInt(args[1]); } ExecutorService exec = Executors...
4a28a9e2-c5fc-4d19-856f-55485f95cdb4
9
void removeColumn (CTableColumn column, int index) { int columnCount = parent.columns.length; if (columnCount == 0) { /* reverts to normal table when last column disposed */ cellBackgrounds = cellForegrounds = null; displayTexts = null; cellFonts = null; fontHeights = null; GC gc = new GC (parent); com...
36c890da-63be-48da-8b65-aa389fca163b
3
@Override public Collider getCollider() { if(hover == null) hover = new Vector2(0,0); Vector2 point1 = this.point1.x==-1 ? hover : this.point1; Vector2 point2 = this.point2.x==-1 ? hover : this.point2; return point1.getColliderWithDim(point2.subtract(point1)); }
73a9224c-f337-4821-96ef-0d36ad4cff7d
2
public void initTiles() { Tile voidTile = new Tile(game); for(int i = 0; i < 64; i++) { for(int j = 0; j < 46; j++) { voidTile = null; voidTile = new Tile(game); tileArray[i][j] = voidTile; } } }
287adcef-4b38-48b3-928e-36456f2e67c3
2
public static void clearFilter(){ if (results.containsKey(currentTab) && sorters.get(getCurrentTab()) != null ) sorters.get(getCurrentTab()).setRowFilter(null); }
544fe475-d15b-45c3-9aa8-6039373fb26a
9
public void DrawSingleNode (Node node, Graphics2D g2d) { int nLvl; if (asap) nLvl = node.GetASAPLevel (); else nLvl = node.GetALAPLevel (); int nSeq = node.GetSeqNo (); int pLvlSize = (nodeLevels.get (currentLevel - 1)).size (); if (nLvl == currentLevel) { if (pLvlSize >= 1) currentX +...
0da35887-c8ff-405d-b525-be91f8d3756b
2
public static ArrayList<Kill> findVictim(ArrayList<Kill> killboard, String victim) { ArrayList<Kill> resultBoard = new ArrayList<Kill>(); for (Kill K : killboard) { if (K.getVictim().findAttribute(victim)) { resultBoard.add(K); } } return resultBoard; }
2a1c798b-1510-43dd-8b2f-fbae1926ed78
6
@Test public void test() { Suggestion suggestion = (Suggestion) MongoHelper.fetch(mySuggestion, "suggestions"); if (suggestion == null) { TestHelper.failed("suggestion not found"); } suggestion.setSubject("Test Subject"); if (!MongoHelper.save(sug...
b99e48f0-0587-487e-9a1f-fe866639b5cd
0
public static void main(String[] args) { Context ctx = new Context(new ConcreteState_Morning()); // 呼び出すたびに状態がかわる。 ctx.doSomething(); ctx.doSomething(); ctx.doSomething(); }
c83b7686-b83e-4659-94f1-8e6fe8135d45
6
public void restButtons(String type) { ResultSet rs = null; for (JButton but : restButtons) { this.remove(but); } restButtons.clear(); try { db = new JDBC(); rs = db.getRestByType(type); int x = 200; int y = 65; int count = 0; while (rs.next()) { String str = rs.getString("name"); ...
ce31d1d6-b8aa-4238-8b5d-626721c58fb0
5
public static void printNewUserToXMLFile(String userName, String password, String id){ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; Document doc = null; try { db = dbf.newDocumentBuilder(); } catch (ParserConfiguratio...
5bae1d53-834b-419b-a1da-7dbfeaadc931
9
public List<Interval> merge(List<Interval> intervals) { List<Interval> res = new ArrayList<>(); Collections.sort(intervals,new Comparator<Interval>() { @Override public int compare(Interval o1, Interval o2) { if(o1.start < o2.start) return 1; ...
580f7b7d-7917-4a6e-b420-1ad3403ece12
8
private Alphabet(int codeLength, int alphabetSize, String[] letters, Map<String, Byte> letterIndices, Map<Byte, Byte> reverseComplements) { if (Math.pow(alphabetSize, codeLength) != letters.length) { throw new IllegalArgumentException("letters array size should be equal to alphabetSize ** codeLength"); } ...
008c1c19-4247-4d4d-8e9b-64524fb60c79
9
@Override public RowCol getBestBox() { int minPos = 10; int row = -1; int col = -1; int countMinPos = 0; for (int r = 0; r < 9; r++) { for (int c = 0; c < 9; c++) { int size = grid[r][c].getPossibleValues().size(); if (size != 0) { if (size == minPos) { countMinPos++; } else if ...
4e36f110-3587-482b-a142-f53f3a42e91c
5
public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); int n = Integer.parseInt(br.readLine()); for(int i = 0; i < n; i++){ String[] words = br.readLine()...
dc2a4d8c-f856-4dd6-8163-a3cf0fb5ccbe
1
public void setStatustextFonttype(Fonttype fonttype) { if (fonttype == null) { this.statustextFontType = UIFontInits.STATUS.getType(); } else { this.statustextFontType = fonttype; } somethingChanged(); }
055c0353-79df-4f6b-8301-0e868aed1f6c
9
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String action = request.getParameter("action"); String forwardTo = ""; if (action != null) { if (action.equals("creerUtilisateursDeTest")) { ...
f6b9ab40-38be-4d08-b410-16f05d759f1d
4
public double noise(double xin, double yin){ double s = (xin + yin) * F2; int i = fastFloor(xin + s); int j = fastFloor(yin + s); double t = (i+j) * G2; double X0 = i - t; double Y0 = j - t; double x0 = xin - X0; double y0 = yin - Y0; int i1, j1; if(x0 > y0){ i1 = 1; j1 = 0; }else{ i1 ...
c40cbefb-02d6-407a-852d-1fd327a60737
9
public Instances defineDataFormat() throws Exception { // initialize setOptions(getOptions()); checkCoverage(); Random random = new Random (getSeed()); setRandom(random); Instances dataset; FastVector attributes = new FastVector(3); Attribute attribute; boolean classFlag = getClas...
855597f5-70df-4ded-989e-5108836cd9f2
6
public boolean isRecordWithNumber(int rowId, Object[] row){ final int orderColumnNum = 0; final int startColumnNum = 1; try{ if(records != null){ for(ArrayList<String> l : records){ if(Integer.parseInt(l.get(orderColumnNum)) == rowId){ for(int i=0;i<l.size()-1;i++){ String rowValue...
ef77f9ba-0de1-4a6f-b8ff-d0e83b18a3f6
5
private Token getTokenConstant(char[] input, int start) { TokenConstant token = null; Pattern pattern = getPattern("^[0-9]"); Matcher matcher = pattern.matcher(String.valueOf(input[start])); if (matcher.find()) { pattern = getPattern("^[0-9]*\\.?[0-9]+"); String subString = getSubString(input, start, MAX_...
c05e19b0-42fe-4e9c-8070-5dcfb562a898
6
@Override public void keyTyped(KeyEvent event) { char ch = event.getKeyChar(); if (ch == '\n' || ch == '\r') { if (mModel.hasSelection()) { notifyActionListeners(); } event.consume(); } else if (ch == '\b' || ch == KeyEvent.VK_DELETE) { if (canDeleteSelection()) { deleteSelection(); } e...
f24c31bb-8bc6-4e44-b7ab-f046fce90d34
5
public int read() throws IOException { boolean weiter = false ; int back = 0 ; while ( !weiter ) { back = inStream.read() ; if (back > -1) { if ( back != '#') // no comment sign { if (comment) // comment found in previous loop { if ...
08d342a2-967f-473f-a742-ed1fbe073e15
6
public static HashMap<String, ItemMold> loadItems(){ HashMap<String, ItemMold> terrainMap = new HashMap(); try{ // Open the file that is the first // command line parameter FileInputStream fstream = new FileInputStream("resources/configfiles/items.txt"); /...
9d5bc758-7a12-4e64-a2a4-e0acedd4e524
5
public static void handleEvent(int eventId) { if(eventId == 1) { System.out.println("Exit high score menu selected"); Main.highScoreMenu.setVisible(false); Main.highScoreMenu.setEnabled(false); Main.highScoreMenu.setFocusable(false); Main.mainFrame.remove(Main.highScoreMenu); Main.main...
ef22eb25-d2c6-40eb-a70e-a0fb1cc5d53f
4
public static String encryptMD5(String pwd) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(pwd.getBytes()); StringBuffer stringBuffer = new StringBuffer(); int n; byte[] b = md.digest(); for (int i = 0; i < b.length; i++) { n = b[i]; if (n < 0) { ...
afbce169-2acc-4479-af22-5a30e7173c05
5
@Override public double predict(T data) { if (log) System.out.println("Trying to predict: " + data.getNome()); double result = 0; for(int i = 0; i < w.length; i ++) { if (log) System.out.print("w[" + i+ "]=" + w[i] +" "); result += w[i]*data.getAttr(i); } if (log) { System.out.println(); ...
ebab3351-474f-45e7-9543-6991eca6293f
2
public void mouseClicked(MouseEvent e) { if (isInside(e.getX(), e.getY())) { if (first == null) { first = this; select(); } else { this.deselect(); first.deselect(); panel.permut(this, first); first = null; } } }
5b0faab3-36a5-4524-9194-55ef2c9fe8a0
9
@Override public Object getValueAt(int row, int col) { switch(col) { case 0: int x = row+1; switch(x) { case 1: return "Sunday"; case 2: return "Monday"...
b7d0a27f-b9ec-4a7c-ac0b-a45b3fdbfc9b
3
@Override public Class getColumnClass(int column) { Class returnValue; if ((column >= 0) && (column < getColumnCount())) { if(getValueAt(0, column)==null) return String.class; returnValue = getValueAt(0, column).getClass(); ...
e7b85387-85cb-42f5-8b41-7588e49300f0
6
public static int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (w == 0 || h == 0) { return new int[0]; } if (pixels == null) { pixels = new int[w * h]; } else if (pixels.length < w * h) { ...
bea39b6c-a6b1-43c8-8e5d-1b0d12be39bc
3
public static byte[] gzip(String input) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null; try { gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8")); } catch (IOException e) { e.printStackTrace(); } finally { if (gzos != null) { try { ...
c5beaef7-c4f5-4ae3-b6a7-6c65e12cc097
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."); ...
a9774992-2ded-464d-8ed1-fc1e510c37cf
6
public void run() { while(!killed()) { long nextFlushLocal = nextFlush.get(); long currentTime = System.currentTimeMillis(); //System.out.println("next flush local: " + nextFlushLocal + " currentTime " + currentTime); if(nextFlushLocal != 0 && nextFlushLocal < currentTime + 2) { //if(l...
76b69276-df6f-406a-b8a2-360decc2f518
2
public Class getTypeClass() throws ClassNotFoundException { if (clazz != null) return Class.forName(clazz.getName()); else if (ifaces.length > 0) return Class.forName(ifaces[0].getName()); else return Class.forName("java.lang.Object"); }
30f8bf82-8ea1-4269-b3d7-110e4519137b
6
final void method1970(int i, int i_61_, int i_62_, boolean bool, int i_63_, int i_64_, int i_65_, int i_66_, byte[] is, int i_67_) { if (i_63_ == 0) i_63_ = i_62_; anInt8539++; if (bool) { int i_68_ = Class183.method1382(i_65_, -6409); int i_69_ = i_68_ * i_62_; int i_70_ = i_63_ * i_68...
88e0a70e-3422-4d1a-aa36-78795b42018e
7
public TetrisEngine(){ this.score = 0; this.fLines = 0; this.toggle = true; // @todo pull initialization out of constructor and add to variable definitions t = new Tetrimino(); b = new Tetrimino(); next = new Tetrimino(); p = new Playfield(); pause = false; gameStatus = true; gui = new Te...
097ee9cc-5425-4f76-b5bf-a80838f77ee6
5
public void addPersoon(Geslacht geslacht, String[] vnamen, String anaam, String tvoegsel, GregorianCalendar gebdat, Gezin ouderlijkGezin) { if (geslacht != null && vnamen != null && anaam != null && tvoegsel != null && gebdat != null) { Persoon persoon = new Persoon(nextPersNr, vnamen, a...
823062de-8e3b-4028-a083-3e7cf60e54c2
5
public void insertString( int off, String string, AttributeSet abr ) throws BadLocationException { if ( string == null ) { return; } boolean ok = true; char[] chars = string.toCharArray(); for ( int i = 0; i < chars.length; i++ ) { ...
5721eb81-7e71-4795-bbc9-c88d23c1d96e
8
public String to(String field, int min, int max) { String newField = ""; for(int i = 1; i <= field.length(); i++) { if(isNumber(field.substring(i - 1, i))) { newField = newField + field.substring(i - 1, i); } else {...
f2e1af55-4ba6-498c-8855-518242d8f199
8
public static void main(String[] args) { //creates an array to store student data LAB6 CLASS[] = new LAB6[11]; //basic counter and [i] is place in the array int i,j,k = 0,counter=0; boolean is_running=true; //creates new columns for the array for(i=0;i<CLASS.length;i++) CLASS[i]= new LAB6(); //defines...
12f784d3-6539-4160-8c13-0b929e4f297c
7
public static JsonObject getJsonForURL(String url, List<ResponseErrors> possibleErrors) { HttpURLConnection connection = null; StringBuilder builder = null; JsonObject json = null; try { URL inputURL = new URL(url); connection = (HttpURLConnection) inputU...
44314ff3-d3b9-4c8b-b0cb-ae527c4d8cd6
5
@Test public void testRetirarProduto() { try { Assert.assertEquals(10, facade.getQuantidadeProduto(1)); } catch (FacadeException e) { Assert.fail(e.getMessage()); } try { facade.retirarProduto(1, 5); Assert.assertEquals(5, facade.getQuantidadeProduto(1)); } catch (FacadeException e) { Assert.f...
1e861d8e-de18-4554-bd7c-6f9a8f1590f7
8
@Override public long invert(long element) { isInField(element); if (element == 1) { return 1; } if (element == 0) { throw new MathArithmeticException("Cannot find inverse for ZERO."); } //prepare for division long remainder = elemen...
b6e580eb-6425-49f9-9a21-aeddac7dcbc1
6
@EventHandler public void GiantInvisibility(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.getGiantConfig().getDouble("Giant.Invis...
756dc24c-751c-41c5-98ca-69b336274362
3
void close(Dockable dockable) { int count = getComponentCount(); for (int i = 0; i < count; i++) { Component child = getComponent(i); if (child instanceof DockTab) { if (((DockTab) child).getDockable() == dockable) { remove(child); return; } } } }
979ba058-4f7b-4088-9e0b-c593cbbefbfa
8
public static void main(String[] args) { Scanner in = new Scanner(System.in); String input = in.nextLine(); String[] inputSplit = input.split(" "); Integer[] num = new Integer[inputSplit.length]; int caunt = 1; int indexI = 0; int sumCaunt =0; ArrayList<Integer> sample = new ArrayList<>(); for (int i ...
b67c2bca-04e3-427f-ac53-7b786ed6cb99
2
private int getNumberOfSuits(int suit) { int num = 0; for (int i = 0; i < 5; i++) { if (hand[i].getSuit() == suit) { num += 1; } } return num; }
ce44047e-2a3d-4dad-b4d6-7a4bdf3eca0a
7
@Test public void kingAndRook() { Map<String, Integer> figureQuantityMap = new HashMap<>(); figureQuantityMap.put(KING.toString(), 2); figureQuantityMap.put(ROOK.toString(), 2); int dimension = 7; assertThat("all elements are not present on each board", prepa...
59c282ff-6dd0-43dc-a61d-06d6555c2dbb
0
public String getConsumerKey() { return consumerKey; }
1ff25ca9-6efc-4409-b4d2-8469ae66224a
2
public static <T extends DC> Set<DC> dMax(Set<Pair<Pair<PT<Integer>,T>,Pair<PT<Integer>,T>>> indexedDelta) { if(indexedDelta!=null) { if(indexedDelta.getNext()!=null) { return new Set(indexedDelta.getFst().fst().delta(indexedDelta.getFst().snd()).diff(),dMax(indexedDelta.getNext())); } else ...
73209ccf-1512-4711-9390-fc8b2166b733
6
public static Cons yieldInitialValueAssignments(Stella_Class renamed_Class, Keyword mode) { { Cons assignments = Stella.NIL; Stella_Object initialvalueassignment = null; { Slot slot = null; Iterator iter000 = renamed_Class.classSlots(); while (iter000.nextP()) { slot = ((Slot...
ef5b50ed-6509-4300-8316-52c5cdd736c7
1
public static void main(String[] args) { int mapsize = 2000; int aircraftAmmount = 50; int objectAmmount = 100; //int [][]m = map.getMap(); float objectMap[][] = new float[objectAmmount][5]; Map map = new Map(mapsize); for (int i = 0; i < objectAmmount; i++) ...
95cfe099-7026-4d8b-8938-17aeb68afd89
3
public LinkedList<TuileBonus> initialisationTuileBonus(){ LinkedList<TuileBonus> lltb = new LinkedList<TuileBonus>(); for(Troupes t : hashTroupes){ for(Bonus b : hashBonus){ TuileBonus tb = new TuileBonus(t, b); for(int i=1; i<3; i++){ ...
418edca2-7b41-4719-826b-6597f64f82b3
5
public static MoveRequestState swigToEnum(int swigValue) { if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) return swigValues[swigValue]; for (int i = 0; i < swigValues.length; i++) if (swigValues[i].swigValue == swigValue) return swigValue...
740ff0a7-081e-4991-9816-9f767abee946
2
public boolean isRGB() { return colorType == COLOR_TRUEALPHA || colorType == COLOR_TRUECOLOR || colorType == COLOR_INDEXED; }
28d6917b-8559-48e8-9a5b-ba14dbe290f4
9
public String getMessage() { if (!specialConstructor) { return super.getMessage(); } StringBuffer expected = new StringBuffer(); int maxSize = 0; for (int i = 0; i < expectedTokenSequences.length; i++) { if (maxSize < expectedTokenSequences[i].length) { maxSize = expectedTokenSeq...
e8d287c9-2caa-4237-af96-de459b30cb25
5
private void read() throws IOException { if (isEndOfText()) { throw error("Unexpected end of input"); } if (index == fill) { if (captureStart != -1) { captureBuffer.append(buffer, captureStart, fill - captureStart); captureStart = 0; } bufferOffset += fill; fill = reader.read(buffer, 0, buf...
fdbbf603-af22-49c0-b0c2-1181122d4d8b
1
public EventList() { muffinbag = new EnumMap<Priority, ArrayList<RegisteredListener>>(Priority.class); for (Priority o : Priority.values()) { muffinbag.put(o, new ArrayList<RegisteredListener>()); } synchronized(mail) { mail.add(this); } }
fc8e4896-52a1-4c9c-a22b-5fc9ef49d101
5
public void onRandomTick (World world, int x, int y) { int xa = (world.random.nextBoolean()) ? 1 : -1; int ya = world.random.nextInt(3) - 1; Tile tilea = world.getTile(x + xa, y + ya); if (tilea != null && tilea.id == Tile.dirt.id) { Tile tileb = world.getTi...
067fc4bb-b97e-40d6-a54e-c964ac9a47cc
6
private void copyRGBtoRGBA(ByteBuffer buffer, byte[] curLine) { if(transPixel != null) { byte tr = transPixel[1]; byte tg = transPixel[3]; byte tb = transPixel[5]; for(int i=1,n=curLine.length ; i<n ; i+=3) { byte r = curLine[i]; by...
c933fc59-7bad-46ef-8a02-03b939e95a13
5
public void validate_insert(String dataBaseName, String tableName, ArrayList<Field> entries) { boolean flag = true; if (check_dataBase(dataBaseName)) { if (check_table(dataBaseName, tableName)) { for (Field element : entries) { if (!check_type(dataBaseName, tableName, element.getValue(), el...
8c621dc7-84b2-4727-b1b1-fa78e6fabd87
9
public TravelFileBean getFileName(int idx) throws Exception{ Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; TravelFileBean fileBean = null; String sql = ""; String filename = ""; String fileTmp = ""; try{ conn = getConnection(); sql = "select * from travelfile where i...
180888a3-73d5-40d4-bd9d-679a11f80479
3
public static void connectToDatabase() { if(connect != null) return; try{ Class.forName("com.mysql.jdbc.Driver"); connect = DriverManager.getConnection("jdbc:mysql://localhost/CN?user=shas&password=shas"); } catch(ClassNotFoundException cnfe) { cnfe.printStackTrace(); } catch (SQLException e) { e...
c234ed77-1d1b-4f1c-99b0-cc7ea799f0fd
7
private void setDimensions(String dataType) { if (dataType.equals("xor")) { Point.nrDimensions = 2; Point.setClasses(new int[]{-1,1}); } else if (dataType.equals("diabetes")) { Point.nrDimensions = 8; Point.setClasses(new int[]{0,1}); } else if (dataT...
4414fa4e-522c-4438-b68d-198cb752e441
1
@Override public boolean containsAll(Collection<?> c) { // TODO Auto-generated method stub return false; }
5712603a-e78c-4c23-9ea4-cf072224ecdb
2
public void showCustomerOrders() { textArea.setText(""); for (int i = 0; i < driver.getOrderDB().getCustomerOrderList().size(); i++) { Order order = (driver.getOrderDB().getCustomerOrderList().get(i)); textArea.append("Order " + order.getId() + " was created by " + order.getCurrentlyLoggedInStaff().getNa...
aee5a12c-2e69-42d9-8dee-ecb1b68db168
8
public void init() { TotalBudget.getInstance(); Integer height = null; Integer width = null; Map<String,List<String>> parameters = Window.Location.getParameterMap(); if ( parameters.containsKey("w") && parameters.containsKey("h") ) { height= Integer.parseInt( parameters.get("h").get(0) ); width ...
29a47606-8cfe-40b3-a95a-0e062f86ce7e
5
@Override public void messageReceived(IoSession session, Object message) throws Exception { String text = UTFCoder.decode(message); System.out.printf("Recieved : %s \n", text); String[] parameter = parse(text); if(parameter.length>=1){ if (parameter[0].equalsIgnoreCase("prepared")) { this.sendAccept(key...