method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
e889909c-75fd-46ad-9a65-ad06021e0e1c
1
@Override public void insertMoney(double amountInEuros) { if (amountInEuros < 0) throw new IllegalArgumentException("ERR00034512b"); totalAmountInEuros += amountInEuros; }
3ce41461-e5fb-4d68-b498-c57bea1f7855
9
public static <T> List<T> inorderTraversal(BinaryTree<T> root) { if (root == null) { return null; } List<T> list = new ArrayList<T>(); BinaryTree<T> prev = root.getParent(); BinaryTree<T> current = root; BinaryTree<T> next = null; while (current != nul...
039e20eb-f1fd-4736-86a1-3f70cd774f8e
8
@Override public void fill(Graphics2D g){ if(Display.player.me(0,1).intersects(phys))Display.player.dead=true; if(Display.player.me(0,-1).intersects(phys))Display.player.dead=true; if(Display.player.me(1,0).intersects(phys))Display.player.dead=true; if(Display.player.me(-1,0).intersects(phys))Display.player.de...
a8ffbc60-220b-4dff-b6dc-10b7316ce4ea
0
public int getId() { return id; }
28dca0e0-6f86-4bce-8a2f-53bd079153a0
0
public void loadWorld(World uploadWorld) { this.world = uploadWorld; }
1a626817-e6b7-46f9-bffd-7633c946c653
1
private TypedObject readDSK() throws EncodingException, NotImplementedException { // DSK is just a DSA + extra set of flags/objects TypedObject ret = readDSA(); ret.type = "DSK"; List<Integer> flags = readFlags(); for (int i = 0; i < flags.size(); i++) readRemaining(flags.get(i), 0); return ret; }
dc28f11f-5a10-4a80-bd79-77fc286885ce
5
public String summary() { String toReturn = ""; int drinkCount, snackCount; drinkCount = snackCount = 0; for (Dispenser tempDispenser : this.dispensers) { if (tempDispenser.getType().equalsIgnoreCase("drink") && !tempDispenser.getDispenserContents().isEmpty()) { drinkCount++; } else if (tempDispen...
2d7afb20-37b8-4d93-8fd8-8f166df958f5
8
public void mousePressed(MouseEvent e) { // where is the mouse pressed ? Point p = e.getPoint(); this.pressedIcon = null; // reset the pressed state int targetTab = findTabAt(p); if(targetTab != - 1) { Icon icon = tabbedPane.getIconAt(targetTab); if(icon instanceof JTabbedPaneSmartIcon) { JTabbedP...
e11591ff-dc46-4b68-8862-794f8e95ecb3
4
public int getBox(int r, int c){ if(r >= size || c >= size || r < 0 || c < 0){ System.err.println("Invalid dimentions (" + r + "," + c + ") for size " + size); System.exit(0); } return c/dimension + (r/dimension * dimension); }
ec098919-32b5-4e65-b565-1ecbaf20d063
4
public void undo() { if (prevSpeed == CeilingFan.HIGH) { ceilingFan.high(); } if (prevSpeed == CeilingFan.MEDIUM) { ceilingFan.medium(); } if (prevSpeed == CeilingFan.LOW) { ceilingFan.low(); } if (prevSpeed == CeilingFan.OFF) {...
b23502f9-3166-4c62-b311-cfd7f6553c7e
7
public void send(MidiMessage message, long deltaTime) { System.out.println("New MIDI message"); Event event = null; ByteArrayInputStream bais = new ByteArrayInputStream(message.getMessage()); DataInputStream dis = new DataInputStream(bais); try { dis.mark(2); ...
2a8d96af-f29f-4b08-b16e-af9c239189bf
1
public void kirjoitaOikeanmuotoinenSyote(){ try { PrintWriter kirjoitin = new PrintWriter(tiedosto); kirjoitin.println("opiskelu1 10"); kirjoitin.println("opiskelu2 20"); kirjoitin.close(); } catch (Exception e) { } }
2b8bdc59-33d4-4626-85c8-475d140627c9
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 Salario)) { return false; } Salario other = (Salario) object; if ((this.codsalario == null && other.codsalario ...
a487b152-bb5e-406f-96e5-7ca10fec032e
4
public static String guessContentType(Extension ext){ switch(ext){ case ttl: return TranslateEnumToContentType(ContentType.TURTLE); case rdf: return TranslateEnumToContentType(ContentType.RDF); case nt: return TranslateEnumToContentType(ContentType.NT); case n3: return TranslateEnumToCont...
2331f1e0-d0ae-4ee7-84d0-f7055799d25c
2
@Override public void windowGainedFocus(WindowEvent event) { if (event.getWindow() == this) { WINDOW_LIST.remove(this); WINDOW_LIST.add(0, this); for (PaletteWindow window : getWindows(PaletteWindow.class)) { window.setAppWindow(this); } } super.windowGainedFocus(event); }
c635797a-7158-4206-8c63-3e7521e69dd6
1
public DockLayout getRootLayout() { DockLayout root = this; while (root.mParent != null) { root = root.mParent; } return root; }
b4fcf7d6-f2e3-4768-8a16-7165a6a9932a
5
private void unfilter(byte[] curLine, byte[] prevLine) throws IOException { switch (curLine[0]) { case 0: // none break; case 1: unfilterSub(curLine); break; case 2: unfilterUp(curLine, prevLine); ...
b4695f94-42cf-400f-b36f-875e47271f05
1
public QueryOrdersByDateResponse queryOrderByDate(QueryOrdersByDateRequest request) throws GongmingConnectionException, GongmingApplicationException { URL path = _getPath(QUERY_ORDERS_BY_DATE); QueryOrdersByDateResponse response = _GET(path, request, QueryOrdersByDateResponse.class); if (response.co...
dc420aba-4143-4d26-8dfc-532d40ff342d
0
public void mouseEntered(MouseEvent e) { }
267818f2-ba8e-431f-aa9f-a2efbc7b690e
7
private void chaseUpdate(Vector3f orientation, float distance){ double time = ((double)Time.getTime())/((double)Time.SECOND); double timeDecimals = time - (double)((int)time); if(timeDecimals < 0.25) material.setTexture(animations.get(0)); else if(timeDecimals < 0.5) ...
0862931d-e525-4dc9-9cf6-d810724a83e2
6
@Override //Quick and dirty implementation, needs some hard revision public AbstractStochasticLotSizingSolution solve( AbstractStochasticLotSizingProblem problem, boolean[] setupPattern) throws SolvingInitialisiationException, ConvolutionNotDefinedException { //Check inputs if (problem.getPeriods().le...
fc933e3f-3164-46d2-8a2d-34d3d57d3705
9
public static ErrorLogs DAOController(Generator generator, TransactionSet transactionSet, RuleSet ruleSet) { System.out.println("Starting DAO Controller"); ErrorLogs errorLogs = new ErrorLogs(); VendorPersistenceController vpc = new VendorPersistenceController(); TransactionPersistenceController tpc = new Tr...
1451b23d-a736-465c-8e56-f1889c0b34de
7
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (!(o instanceof Type)) { return false; } Type t = (Type) o; if (sort != t.sort) { return false; } if (sort >= ARRAY) { ...
da52c105-8dbf-416a-8474-4b43ff0a5e88
7
private boolean jj_3_25() { if (jj_scan_token(DOT)) return true; if (jj_scan_token(ID)) return true; if (jj_3R_39()) return true; if (jj_scan_token(LP)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_116()) jj_scanpos = xsp; if (jj_scan_token(RP)) return true; if (jj_3R_38()) re...
ef4d22b6-ec8d-4af7-b2ce-dbc860e2880b
4
public static String optionsCount(String stock) { String httpdata = getHtml(yahoobase + "/op?s=" + stock); if (httpdata.contains(">There is no") || httpdata.contains("Check your spelling") || httpdata.indexOf("View By Expiration") < 0) return "0"; try { httpdata = httpdata.substring(httpdata .i...
89f32fa4-8863-4d05-b493-38e66a3fe7e3
2
public void setLimitCallDuration(int limitCallDurationSeconds) { for (Setting item : settings) { if (item instanceof SetLimitCallDurationSetting) { settings.remove(item); break; } } SetLimitCallDurationSetting limitCallSetting = new SetLimitCallDurationSetting( limitCallDurationSeconds); setti...
f20e0927-306c-405b-859a-615039925134
4
protected void updateLabeling(double slack) { for (int w = 0; w < dim; w++) { if (committedWorkers[w]) { labelByWorker[w] += slack; } } for (int j = 0; j < dim; j++) { if (parentWorkerByCommittedJob[j] != -1) { labelByJob[j] -= slack; } else { minSlackValueByJob[j] -= slack; } } }
2dc50ae5-764e-4f23-92f6-7d47a9208110
1
public void addItemToInventory(Item item) { if(item == null) throw new NullPointerException("An item can't be null."); // Checken of item niet in inventory van andere speler reeds voorkomt? inventory.add(item); }
158de81d-097a-4330-a319-6cf94cec77c4
1
public void sendMessage(String message) { try { PrintWriter out = new PrintWriter(socket.getOutputStream(), true); out.println(message); } catch (IOException e) { e.printStackTrace(); System.out.println("Failed at METHOD: SENDMESSAGE"); } }
ca5cf15c-1bbb-4ad6-ac39-23c86981348b
4
public ResultPage<Patron> getPatronList(int offset) throws SQLException { openPatronsDatabase(); PreparedStatement statement = patronsConnection.prepareStatement( "SELECT * FROM Patrons ORDER BY Name LIMIT 11 OFFSET ?"); statement.setInt(1, offset * 10); ResultSet resultSet = statement.executeQuery();...
97486c1a-5055-46de-b397-b919aad14eb2
5
public void parsePicToBoard(BufferedImage pic) { board = new char[20][20]; for (int i = 0; i < 20;i++) { for (int j = 0; j < 20; j++) { if (new Color(pic.getRGB(i, j)).equals(Color.GREEN)) board[i][j] = COIN; else if (new Color(pic.getRGB(...
9c282dae-3787-4676-8cbc-15a7a7e059d9
2
@Override public String toString(){ StringBuilder sb = new StringBuilder(); for (int i = 0; i < GRID_SIZE; i++ ) { for ( int j = 0; j < GRID_SIZE; j++) { sb.append("[ "); sb.append( StringUtils.rightPad(getLetterAt(i, j), 3) ); sb.append("]"); } sb.append(NEWLINE); } return sb.toSt...
8e1f7df0-aaf6-44c4-92c2-4c5d141c3e70
6
public void createRoom(int roomNumber){ list2.clear(); int[] neighbours = new int[4]; neighbours = roomNeighbour(roomNumber); //neighbours[0] ist oben, neighbours[1] ist rechts, neighbours[2] ist unten,neighbours[3] ist links for(int i=0; i<4; i++){ if(neighbours[i]!=-1){ int[] tmp = new int[6]; tmp ...
1e9d00a3-f270-49b9-895c-c1130a4552a7
3
@EventHandler public void onInventoryClick(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); if(player != null && bm.getSlot(player.getName()) != null && event.getInventory() instanceof Player) bm.setCurrentSlotContents(player.getName(), event.getInventory()); }
3c8cb884-6bf7-4eef-9081-a65eea2fda0e
0
public void pause_ingress() { synchronized (ingress_paused) { ingress_paused = true; } }
b359c42d-0bcf-4fe9-aece-e5fe22a669a8
7
public static Double distanceFromPoint(Point3D A, Point3D B) { if (A == null || B == null) return 0.0; if (B == A) return 0.0; if (!(A instanceof Point3D) || !(B instanceof Point3D)) return 0.0; if (A.isNull() || B.isNull()) return 0.0; return Math.sqrt(Math.pow((A.getOriginalX(...
8a621791-2632-4aa8-b661-6e9634c27e08
4
public void attack() { if(monsterLP <= 0 || lifepoints <= 0) { System.out.print("The winner has been chosen"); } else { if(damage > monsterD) { int gap = monsterD - damage; monsterLP = monsterLP + gap; ...
923ee952-5ce7-4114-8d29-5cca0e84696d
3
public void run() { long lastTime = System.nanoTime(); long timer = System.currentTimeMillis(); final double ns = 1000000000D / 60D; double delta = 0; int frames = 0; int updates = 0; requestFocus(); while (running) { long now = System.nanoTime(); delta += (now - lastTime)/ns; lastTime = now...
56fb192b-b63f-4955-80ea-f7df31411231
5
public void cancelPiece(Piece p){ if(conState != ConnectionState.connected){ throw new RuntimeException("Can only send requests on 'connected' connections"); }else if(peer_choking){ return ; } try { Iterator<Request> itor =ourRequests.iterator(); while (itor.hasNext()) { Request r = itor.next();...
5deed2b5-6837-494b-b317-dffc60d476c8
9
private boolean curious_fraction(int numerator, int denominator) { Preconditions.checkArgument(numerator >= 10 && numerator < 100); Preconditions.checkArgument(denominator >= 10 && denominator < 100); int first_numerator_digit = numerator / 10; int second_numerator_digit = numerator % 10...
0d6041dc-64b2-4705-8b89-43747610dc2e
7
public static Cons idlGetConstructorDefinitions(Stella_Class renamed_Class) { { Cons constructordefs = Stella.NIL; { Slot slot = null; Iterator iter000 = renamed_Class.classSlots(); Cons collect000 = null; while (iter000.nextP()) { slot = ((Slot)(iter000.value)); ...
0e059438-a559-4679-b4b2-2604bffc26c1
8
private boolean isGranadeOnMyWay(int grenade_x, int grenade_y, int grenade_dir){ int min_x = Math.abs(grenade_x-x); int min_y = Math.abs(grenade_y-y); int enX = grenade_x; int enY = grenade_y; int angle; if(x >= enX && y >= enY){ // KVADRANT 1 ...
cbd56c54-d068-4f12-9c7d-c184c741095d
1
public static boolean isPressed(int i) { return keyState[i] && !prevKeyState[i] ; }
2a3ef581-c3e1-456c-a064-e29bba248032
6
@Override public void run(){ while(!super.detener){ try{ if(!this.guerreroColaAtaques.isEmpty()) recibirdaño(); if(this.objectivo.x==0&&this.objectivo.y==0){ ...
89810d90-dc75-4dca-bc23-736b4032c5ad
1
public List<ExperienceType> getExperience() { if (experience == null) { experience = new ArrayList<ExperienceType>(); } return this.experience; }
a3cc2b5b-16fe-4a98-b5ac-62b0e089ba36
3
public DefaultComboBoxModel<String> buildList() { DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<String>(); String line; try { BufferedReader reader = new BufferedReader(new FileReader(System.getProperty("resources") + "/database/items")); while((line = reader.readLine()) != null) { ...
a938c5d6-71d7-4469-b532-b44b127918dc
3
protected String getRequestOption(String key) { if (this.options != null && this.options.containsKey(key)) { String param = this.options.get(key); if (GoCoin.hasValue(param)) { return param; } } //default to return null return null; }
ee8a5303-cbd4-479e-bfc9-2bc5a6a17f42
4
@Override public void messageHandler(String messageName, Object messagePayload) { if (messagePayload != null) { System.out.println("RCV (model): "+messageName+" | "+messagePayload.toString()); } else { System.out.println("RCV (model): "+messageName+" | No data sent"); } MessagePayload payl...
687a1296-a676-4a2a-a217-3ae98019c890
7
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { ArrayList<Game> games = gm.games; if (args.length >= 1) { if (args[0].equalsIgnoreCase("join")) { if (args.length > 1) { if (Integer.parseInt(args[1]) < games.size() && Integer.parseInt(args[1])...
14ccb6c7-a96b-441b-b70f-dc4abd7a7801
8
protected void initializeBoard() { tiles = new Tile[rows][columns]; int mid = columns / 2; int y = (((rows - 1) % 4 == 0)? 0 : 1); int x = 0; Tile wall = new Tile(); tiles[0][mid] = wall; tiles[tiles.length - 1][mid] = wall; for (int i = y; i < rows / 4 + y; i++) { tiles[i][mid - 2 * i + y] = wall; ...
56b258bc-d818-415f-8f63-23ca02473771
0
public String getCountry() { return super.getCountry(); }
aa04246b-2838-4819-b795-4deb52ddb892
3
public static boolean isOpaque(EntityType type) { boolean b = true; switch (type) { case OBJ_TREE: break; case OBJ_DOOR_WOOD: break; case ENTR_DUNGEON: b = false; break; } return b; }
08fcccd8-a9e1-4716-81b2-6e4f69cd771f
3
@Override public boolean isNull() { if (getX() != 0 || getY() != 0 || getZ() != 0) return false; return true; }
151e18ef-f87e-4470-80d0-b38754236ba8
1
public RotatingComponent(String imageName, int x, int y, int width, int height, final double angleSpeed) { this.setBounds(x, y, width, height); image = Utilities.resizeImage(width, height, imageName); //this.setSize(image.getWidth(null), image.getHeight(null)); timer = new Timer(20, new ActionListener() { ...
8fb52340-f0f6-4744-9fac-b3ebc148db14
3
public static LinkedList<String> findSignificantWords(Path path, int nbWords, HashFunction func, int k) { if (2 * k < nbWords) throw new AssertionError("Too much significant words asked for the given sample size."); SignificantWordsSample ws = new SignificantWordsArraySample(k, func); /...
ee0991b0-8596-4476-837e-aa153e9a2c7d
8
@Test public void testDeleteMiddleNode() throws Exception { head = new LinkedListNode(1).addNode(new LinkedListNode(2)).addNode(new LinkedListNode(3)).addNode(new LinkedListNode(4)).addNode(new LinkedListNode(5)); LinkedListNode middleNode = new LinkedListNode(6); head.addNode(middleNode).ad...
bdc0266d-b386-4e5a-bdbf-cdc7be7139f0
5
@Override public void atacar(){ for(int i = 0; i < ejercito.size(); i++){ int refPosX = ejercito.get(i).refLabel.getLocation().x; int refPosY = ejercito.get(i).refLabel.getLocation().y; Point pos = super.refPosToMatrizPos(refPosX, refPosY); ...
eb03f7a7-973a-4538-a4dd-54d81c4760cc
9
public FinishedJobRecord(String str) { StringTokenizer st = new StringTokenizer(str, ":"); int tokNumber = 0; while (st.hasMoreElements()) { tokNumber++; String val = st.nextToken(); // We only get what we need, fields which are not used by // p...
c288bd50-faeb-47fd-b8d4-cb1f48cfa20a
0
public SerialCtl(String aa, String bb) { a = "Not transient: " + aa; b = "Transient: " + bb; }
00d4884e-c1e0-4487-9bd9-7086abb967d9
2
public void UpdateAtividade(Atividade atividade) throws SQLException, atividadeExistente { AtividadeDAO atividadeDAO = new AtividadeDAO(); Atividade atividadeExistente = null; atividadeExistente = atividadeDAO.SelectATividadePorNome(atividade.getNome()); if (atividadeExistente == null ...
15395522-209a-47db-8b80-180330b2f879
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...
ee7282a6-df75-4bb1-8f48-16db1328bc88
2
public boolean isSenderPlayer() { if(sender != null && sender instanceof Player) return true; return false; }
a80d8aa9-012c-4dbb-9845-4cb37c93be29
5
public void searchDescricaoExames() { facesContext = FacesContext.getCurrentInstance(); renderizarDadosEncontrados = true; List<DescricaoExames> listDescricaoExames; if (!descricaoExames.getDes_codigoProcedimento().isEmpty() || !descricaoExames.getDes_nomeexame().isEmpty()) { try { listD...
b5091af8-6909-4e24-bbd1-e5dcb8fed11e
5
public void play(String audioFilePath) { File audioFile = new File(audioFilePath); try { AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile); AudioFormat format = audioStream.getFormat(); DataLine.Info info = new DataLine.Info(...
074c4a81-237f-423b-9d95-d0842b0890e5
5
@Override public boolean perform(final Context context) { // Example: /<command> reset[ <Player>] OfflinePlayer target = Parser.parsePlayer(context, 1); if (target == null && context.sender instanceof OfflinePlayer) target = (OfflinePlayer) context.sender; if (target == null) { ...
ce2d47f2-c929-4c15-b921-52da541191a9
2
public void set_Visit(MsgParse mp) throws SQLException { if (!mp.visit.getPatient_class().isEmpty()) try { PreparedStatement prepStmt = connection.prepareStatement( "insert into visit (patient_class, admission_type, location, prior_location, " ...
629bfd6e-018a-43ed-855f-74ba5f3e9a24
7
public void start() { for (int i = 0; i < level.length; i++) { for (int j = 0; j < level[0].length; j++) { Stack<GameObject> it = level[i][j].getGameObjects(); for (int k = 0; k < it.size(); k++) { GameObj...
83def0d0-997b-4bbc-8a2f-b8b3e3f4fe8d
6
public void onPreviewNativeEvent(NativePreviewEvent event) { if (!isDragging()) { // this should never happen, as the preview handler should be removed after the dragging stopped DebugLog.getInstance().printLine("Preview handler still registered, even though dragging stopped...
dc5e7a02-0efe-4616-8d97-a54f49083b09
8
@Override @SuppressWarnings("static-access") public void run() { boolean checar = true; while (checar) { if (contadorParaEfetuarATrocaDePosissoesNaFila < Integer.parseInt(Principal.tfQuantum.getText())) { JPanel panel = new JPanel(); for (int i = 0; i < Principal.processosEmExecucao.size(); i++) { ...
2ecc50c2-75a0-47b1-a8b9-202681a27326
3
private void createAlphaPixels(byte pixels[], int i, int j, int drawingAreaPixels[], int l, int i1, int j1, int k1, int l1, int alpha) { l1 = ((l1 & 0xff00ff) * alpha & 0xff00ff00) + ((l1 & 0xff00) * alpha & 0xff0000) >> 8; alpha = 256 - alpha; for (int j2 = -i; j2 < 0; j2++) { for (int k2 = -i1; k2 < 0; k2++)...
d6506a4e-088b-46b8-860b-aedfa6177d7b
7
public boolean save(Object obj) { boolean ret = false; Session session = sessionFactory.openSession(); try { session.beginTransaction(); int count = 0; if (obj instanceof Collection<?>) { List<?> list = (List<?>) obj; for (Objec...
73acaf60-2e0f-4d42-9f13-f861b2b572a9
4
public void createDoors(){ for(int i=0; i<map.size(); i++){ int[] tmp = new int[6]; tmp = getValue(i); int[] neighbours = new int[4]; neighbours = roomNeighbour(i); int orientation = 2;//startindex in map fuer tuer oben for(int x=0; x<4; x++){ if(neighbours[x]!=-1){ int[] tmp2 = new int[6];...
7f531601-8d67-45bc-9822-261cc36c5889
4
@Override public void applyAllChanges() throws ApplyChangesException { try { // Check if we have a valid xml file by attempting to create a xml // document from it DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder =...
0718a10b-3b8a-43a3-98a7-a269422495ac
7
int pack_books(Buffer opb) { opb.write(0x05, 8); opb.write(_vorbis); // books opb.write(books - 1, 8); for (int i = 0; i < books; i++) { if (book_param[i].pack(opb) != 0) { //goto err_out; return (-1); } } ...
f2244d6b-7e8e-4dd6-83a9-da53865cb338
5
public static JSONObject getJSONObject(String url) { try { String str = ""; Scanner x = new Scanner(new URL(url).openStream()); while (x.hasNextLine()) { str += x.nextLine() + "\n"; } return new JSONObject(str); } catch (JSONException e) { e.printStackTrace(); } catch (MalformedURLException ...
bc8a0a2e-547d-44f9-b55a-5891e0b381af
0
@Override public int attack(double agility, double luck) { System.out.println("I tried to do a special attack but I haven't set it so I failed at this turn..."); return 0; }
046a0f1f-a1f0-4657-ad2c-3f666f891a77
2
public boolean register() { boolean registered = false; try { registered = mServerInt.newUser(mUserName, mUserPass, ServerInterface.CLIENT); } catch(Exception ex) { if(connect()) return register(); System.out.println("A Login-Error occured: " + ex.getMessage()); return false; } return regis...
5afcaaff-7bc7-483f-92e5-21a49680835d
6
public static void main(String[] args) { List<String> numbers = new ArrayList<>(); for (int i = 1; i < 10; i++) { numbers.add("" + i); } Set<Integer> products = new HashSet<>(); List<String> pandigitals = permute("", numbers); for (String pandigital : pandigitals) { for (int i = pandigital.length()...
afaabc04-c6cf-4131-9dde-ffab758e0fa0
2
private void solve(int[][] board, int cx, int cy, int ideal, int workers) { FlipPuzzle flip = new FlipPuzzle( cx, cy, board ); Solver<FlipMove> solver = workers <= 1 ? new Solver<FlipMove>() : new ConcurrentSolver<FlipMove>( workers ); solver.setInitialState(flip); // Depth-First-Search solver.setBrea...
5dcaea8b-d45d-49a2-9fb3-84e0f307e877
1
public void rotACW() { if (!pause) { plateau.updatePosition(0, -1); updateObservers(); } }
9ca5e241-1c16-4b22-b013-c0055cb5e7e5
1
@Override public void logicUpdate(GameTime gameTime) { for (Entity entity : entityList) { processEntity(entity, gameTime.getElapsedTimeMilli()); } }
3f448391-e82e-433b-a497-518cb14d66c4
7
private Location findFood() { Field field = getField(); List<Location> adjacent = field.adjacentLocations(getLocation()); Iterator<Location> it = adjacent.iterator(); while(it.hasNext()) { Location where = it.next(); Object animal = field.getObjectAt(where); ...
328793df-faf9-4151-be1a-86f6014e677f
0
public static void main(String[] args) { String str = "abc"; Object obj = new Object(); obj=str; // works because String is-a Object, inheritance in java MyClass<String> myClass1 = new MyClass<String>(); MyClass<Object> myClass2 = new MyClass<Object>(); //myClass2=myClas...
a328107e-f2d3-4686-88fa-5e13a320c425
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; StringKey other = (StringKey) obj; if (m_name == null) { if (other.m_name != null) return false; } else if (!m_name.equals(other...
e5bcb821-64ac-4388-bfe3-08fc125be5e1
4
public NodeDLL deletekey(int key) { NodeDLL current = first; while(current.data != key) { current = current.next; } if (first == null) { return null; } if(current == first) { first = current.next; } else { current.previous.next = current.next; } if(current == last) { ...
0b050e1f-edbb-4ad3-965a-906ff2bb5a5a
4
private void runParser() { logger.debug("Start 'runParser'"); Path currentFile = null; while (true) { try { currentFile = pathStorage.get(); try { File fileForParsing = currentFile.toFile(); logger.debug("Start parsing '{}' file", currentFile); FileInputStream stream = new FileInputStrea...
70f5fd67-9240-4f3d-8744-71df28136d87
3
private void createPreview() { page = new Page[pg.getNumberOfPages()]; PageFormat pf = pg.getPageFormat(0); Dimension size = new Dimension((int)pf.getPaper().getWidth(), (int)pf.getPaper().getHeight()); if(pf.getOrientation() != PageFormat.PORTRAIT) size = new Dimension(size.height, size.width); for(int i=0...
b86b1e14-afd2-4b88-a826-402b77c22783
8
public Object nextValue() throws JSONException { char c = nextClean(); String s; switch (c) { case '"': case '\'': return nextString(c); case '{': back(); return new JSONObject(this); case '[': ...
16ec3ff8-81e6-427f-a49d-d211cc2cc7d0
9
public static ArrayList<Integer> findSubstring(String S, String[] L) { if (L.length == 0) return new ArrayList<Integer>(); ArrayList<Integer> rs = new ArrayList<Integer>(); HashMap<String, Integer> hasFound = new HashMap<String, Integer>(); HashMap<String, Integer> needToFin...
346e5579-0823-4330-bc52-c9a21b928cd4
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 TipoRecurso)) { return false; } TipoRecurso other = (TipoRecurso) object; if ((this.idTipoRecurso == null && ot...
b23135b2-de14-43aa-bc74-4f9b74b6bcc2
1
public ExprInfo(final LocalExpr def) { this.def = def; vars = new ArrayList[cfg.size()]; for (int i = 0; i < vars.length; i++) { vars[i] = new ArrayList(); } phis = new Phi[cfg.size()]; save = false; pushes = new HashMap(); pops = new HashMap(); defs = new HashMap(); cleanup = n...
d717b2e3-73de-47ad-94d1-7af2e773d7cd
9
@Override public String suggestSimilarWord(String input) throws NoSimilarWordFoundException { input = input.toLowerCase(); MyNode node_found = (MyNode) dict.find(input); String word_found = input; if (node_found == null) { word_found = ""; ArrayList<String> similar = new ArrayList<String>(); simila...
24b7a2a7-8fb0-4719-ba31-0b99faca0123
2
public void testPropertySetCopyDay() { LocalDate test = new LocalDate(1972, 6, 9); LocalDate copy = test.dayOfMonth().setCopy(12); check(test, 1972, 6, 9); check(copy, 1972, 6, 12); try { test.dayOfMonth().setCopy(31); fail(); } catch (Ill...
e541d7dd-ef69-4813-a23e-8c4f5da6b0c2
7
public static boolean aSubsumesB(RuleItem a, RuleItem b){ if(!a.consequence().equals(b.consequence())) return false; if(a.accuracy() < b.accuracy()) return false; for(int k = 0; k < ((a.premise()).items()).length;k++){ if((a.premise()).itemAt(k) != (b.premise()).itemAt(k)){ if(((a.premis...
4bcfc14f-90bc-4598-b65f-5f5481f5f4eb
7
public int lengthOfLIS(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int dp[] = new int[nums.length]; Arrays.fill(dp, 1); int longest = 1; for (int i = 1; i < nums.length; i++) { for (int j = 0; j < i; j++) { if (nums[j] < nums[i] && dp[j] + 1 > dp[i]) { dp[i] = d...
1c784020-a236-4318-b203-5da839a0001d
2
public EndOfGame(final String score) { //конструктор принимает счет //если честно, мне уже надоело эту шапку расписывать, поэтому не буду frame = this; this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/mainIcon.jpg"))); setTitle("Угадай картинку"); ...
0a542b4c-d758-4b91-b20e-69145cab3de7
8
public List buildRequest() { List request=new ArrayList<String>(); String params=""; if(this.method==Method.GET) { String data=""; for(Iterator i=this.getParameters().keySet().iterator();i.hasNext();) { String key=(String)i.next(); ...
57cf0546-e016-4607-8eaa-a695c207260d
9
public static boolean isSubstring(String searchStr, String pattern){ int[] table = new int[pattern.length()]; int pos, cnd; if (pattern.length()>0){ table[0] = -1; } if (pattern.length()>1){ table[1] = 0; } pos = 2; cnd = 0; while (pos<pattern.length()){ if (pattern.charAt(pos) ==...
613ac53b-e7f6-4092-a075-5b20a4f98ef8
8
public void updateText(String newMessage, int newType) { Image newImage = null; switch (newType) { case IMessageProvider.NONE: if (newMessage == null) { restoreTitle(); } else { showTitle(newMessage, null); } return; case IMessageProvider.INFORMATION...
f866efd0-cbd3-4614-b145-eb39e59d7c77
0
public void paint(DrawableItem di, Graphics2D g) { fillShape(di, g); drawShape(di, g); }