method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
b3001c4a-82d9-4bd4-99f2-eae447c6a9f7
8
static String formatHanyuPinyin(String pinyinStr, HanyuPinyinOutputFormat outputFormat) throws BadHanyuPinyinOutputFormatCombination { if ((HanyuPinyinToneType.WITH_TONE_MARK == outputFormat.getToneType()) && ((HanyuPinyinVCharType.WITH_V == outputFormat.getVCharType()) || (HanyuPinyinVCharType.WITH_U...
bfcdc235-13ff-4cba-9c20-8e6564f3c8b3
0
@Override public boolean supportsAttributes() {return true;}
5d6954a1-f80c-48ca-8b24-4cebbaf766cc
4
private static int count(int[] array) { // this is a brute force approach ... int count = 0; for (int i = 0; i < array.length; i++) { for (int j = i + 1; j < array.length; j++) { for (int k = j + 1; k < array.length; k++) { if (array[i] + array[j] + array...
388f8dd8-804a-4fec-987c-b1c4d4c1c24d
5
@Override public void run() { try { DataOutputStream outToSlave = new DataOutputStream(slaveSocket.getOutputStream()); InputStream in = slaveSocket.getInputStream(); BufferedReader inFromSlave = new BufferedReader(new InputStreamReader(in)); String line; ...
e96c8422-f86f-4fbc-8be8-81c5b87a7b7b
1
private Boolean addBracketOpen(CalculatorReader expressionReader) { String el = expressionReader.getSymbol(); if (el.equals("(")) { //System.out.println("--addBracketOpen = " + el); expressionReader.incPosition(); expressionStack.bracketStack.push(expressionStack.oper...
bf3e1ecb-85f4-4129-9bc2-d672449163c1
1
public void setSelectGraphElement(GraphElement ge, boolean b) { if (!b) { this.selectlist.remove(ge.getId()); } else { this.selectlist.put(ge.getId(), ge); } }
d6a58971-1930-4885-b3a5-5905bc72127b
8
private void boardMenu(GameState state, Scanner inputScanner) { String choice = ""; while(!choice.equals("q")) { System.out.println("\nBoard Menu: \n"); System.out.println("d: View Deck"); System.out.println("l: View Loot"); System.out.println("q: Quit to Previous Menu\n"); choice = inputScann...
1c376411-a7a0-4916-8baa-f6f9067e23fc
6
public static boolean handleDoor(Player player, WorldObject object) { if (World.isSpawnedObject(object)) return false; WorldObject openedDoor = new WorldObject(object.getId(), object.getType(), object.getRotation() + 1, object.getX(), object.getY(), object.getPlane()); if (object.getRotation() == 0) ...
0df82588-9b66-4ec1-aa3d-15d3e86a69af
9
public boolean isPopOrder(int[] line1,int[] line2) { if(line1==null || line2==null) return false; int point1=0; Stack<Integer> stack=new Stack<Integer>(); for(int i=0;i<line2.length;i++) { if(!stack.isEmpty() && stack.peek()==line2[i]) { stack.pop(); } else { if(point1==line1.len...
8a7f4dff-005e-45f6-bbbc-1aabaedca08a
3
public TreeNode buildTree(int[] preorder, int[] inorder) { if(preorder.length == 0) return null; int pos = indexOf(inorder,preorder[0]); TreeNode node = new TreeNode(preorder[0]); //have left subTree if(pos >0){ node.left = buildTree(Arrays.copyOfRange(p...
a4be422c-5f1b-42dd-84e5-7ffabad7f841
7
public long insert(String name, String _abstract) { if (Config.LOGD) Log.d(TAG, "insert name=" + name + " _abstract=" + _abstract); PreparedStatement statement = null; try { statement = mConnection.prepareStatement(SQL_INSERT, Statement.RETURN_GENERATED_KEYS); statement....
456085f7-bd83-4093-af00-83c38dc142c6
0
public Message() { }
3e7a4f2a-7b8f-455f-be2f-568923f852d0
7
private void downloadTransactions(int level, String endDate) { Map<Integer,String> codeLookup = new HashMap<Integer,String>(); for (Account a : mongoDao.getAccounts()) { codeLookup.put(a.getId(), a.getCode()); } try { accountService.clearTotals(); Obje...
98528bf5-bc81-45da-a217-a09e61a58b78
1
private BufferedImage getIcon(String picture) { try { URL file = this.getClass().getResource("/data/" + picture); return ImageIO.read(file); } catch (Exception e) { JOptionPane.showMessageDialog(this, e); } return null; }
b920d30a-7303-4e8a-8faa-855382c9ed46
5
@Override public Card drawCard(int playerId) throws ActionNotAllowedException { if (gameStatus.isBeginningCardDrawn() && playerOnTheMove(playerId)) { throw new ActionNotAllowedException(EXCEPTION_DRAW_MORE_THAN_ONE_CARD); } if (playerIsNotOnTheMove(playerId)) { throw...
848bca77-3a4a-4dbc-a4b6-94171eea5da1
9
public String runCommand() { int commandNumber = rand.nextInt(100); try { if (commandNumber < 10) { this.currentMachine.powerToggle(); System.out.println("Machine turned " + (this.currentMachine.isOn() ? "on" : "off")); } else if (commandNumber < 30) { insertFunds(); System.out.println("More m...
048556cd-6adf-47e6-8b44-2be73b642501
1
private int[] toArray(int val) { int ret[] = new int[4]; for (int j = 3; j >= 0; --j) { ret[j] |= ((val >>> 8*(3-j)) & (0xff)); } return ret; }
547f8eaa-e329-4fad-9ef4-067759d90d4e
3
private static void loadRules() { int k= da.getNumberOfRules(); for(int i=1; i<=k; i++) { if(da.getRuleCounter(i) == -1 || da.getRuleCounter(i) > THRESHOLD ) { Rules.add(new Rule(da.getRuleCondition(i),da.getRuleAnswer(i), da.getRuleCounter(i))); ...
a67f4e37-22b5-4185-ab77-58915a9e7a60
6
public void loadProducts(){ Product p = null; productList.clear(); if(strat != null){ do{ try { p = strat.readObject(); if(p == null) { } else add(p); } catch (IOException e) { e.printStackTrace(); } } while (p != null); } else { JOptionPane.showMessageDialog(...
dc7c8b65-4ade-40cc-b548-aba6f3ec5ca1
5
private void Diagnose_Combobox_NameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Diagnose_Combobox_NameActionPerformed name=(String)Diagnose_Combobox_Name.getSelectedItem(); try { try { try { try { try { ...
68b61b2d-6f5f-490f-afd3-fba94776fa72
6
private void renderLevelBlend(final Graphics g) { switch (renderlevel % 6) { case 0: // 1 rect, left-up to right-down rect.x = 0; rect.y = 0; rect.width = (MAX_LEVEL_BLEND - levelBlendTimeleft) * WIDTH / MAX_LEVEL_BLEND; rect.height = (MAX_LEVEL_BLEND - levelBlendTimeleft) * HEIGHT / MAX_LEVE...
a96a7306-8891-49fd-bf31-28022f192dc0
2
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if(user != null) { UserModel usermod = DataStore.getUser(user.getUserId()); ...
26bc59e8-12ff-4b5a-92a4-430f36d08dae
4
public boolean inputIsNULL() { if(inputUser.getText().length()==0)return false; if(inputPass.getText().length()==0)return false; if(inputFirstName.getText().length()==0)return false; if(inputSureName.getText().length()==0)return false; return true; }
4dd6d895-a01c-443a-935d-6d7162d36971
7
private void findEndOfStatement() { do{ try { token = lexer.get_token(); } catch (SyntaxError e) { controller.consoleOut(e.toString()+" at line: "+e.getLine()+'\n'); } }while(!token.value.equals(";") && !token.value.equals("}") && !token.value.equals("{") && token.type!=token_type.FINISHED); if(token.val...
caa10002-abd3-4182-8bfd-42b79ced7907
1
public boolean add(String hostName, int ip){ return ipAddresses.put(hostName, ip) && hostNames.put(ip, hostName); }
c08717a7-42b0-4ae2-a934-23e4630b73f6
6
private void setRoles() { //initial states roleStateAdministrator = 0; roleStateProjektledare = 0; roleStateSpecialist = 0; cbAdministrator.setEnabled(false); cbProjektledare.setEnabled(false); cbSpecialist.setEnabled(false); int pl; int sp; ...
bb1f043c-f112-4fcb-b832-bb306ebdf1ed
7
public System( String name, String houseName, String description, String imgName, float starX, float starY, Trait climate, int gravity, Object... args ) { super(name, null, null, -1, NOT_A_GUILD, args) ; this.houseName = houseName ; this.description = description ; this.image = imgName == ...
dd4d5d9d-a266-4906-835f-cbee9eb4c285
2
public V valAt(K key) { for (int i = 0; i < lookups.length; i++) { V val = lookups[i].valAt(key); if (val != null) return val; } return null; }
9bc1ac88-5098-40f1-8c73-343f336745da
1
private static void printNetworkInterfaceInfo(NetworkInterface netint) { Enumeration<InetAddress> inetAddresses = netint.getInetAddresses(); for (InetAddress inetAddress : Collections.list(inetAddresses)) { System.out.printf("InetAddress: %s\n", inetAddress); } }
28b9f64a-32b6-4826-a327-0306389f73a7
7
public boolean isRelation() { if (getType() == TYPE_SEQUENCE) { return true; } if (getType() == TYPE_BAG) { return true; } if (getType() != TYPE_SET) { return false; } if ((m_s...
3924c0a1-1a0a-4713-bf2d-faff887738ba
5
public void drawGrid(Graphics g) { if (!Settings.displayGrid) { return; } g.setColor(new Color(255, 255, 255, 15)); int width = instance.getCanvasWidth(); int height = instance.getCanvasHeight(); int horizontalCount = width / (Main.horizontalScale != 0 ? Main.horizontalScale : 1); int verticalCount = h...
d2c00479-657e-4743-8561-2de10256d928
0
private JDBCUtils() { }
a4a3f647-ef6f-4e0c-b5de-8612b879e3db
1
public void ReadfromProperties(){ Properties prop = new Properties(); try { //load a properties file prop.load(new FileInputStream("config.properties")); setEmail(prop.getProperty("gmailPassword")); //get the property value and print it out ...
cd0d8a0a-5091-4d1f-9260-1267249dc6f9
5
protected TerminalSize waitForTerminalSizeReport(int timeoutMs) { long startTime = System.currentTimeMillis(); synchronized(readMutex) { while(System.currentTimeMillis() - startTime < timeoutMs) { Key key = inputDecoder.getNextCharacter(); if(key == null) { ...
4afdee2f-4c9a-434c-a768-a93a97a46010
6
public String recieve() { String input = null; try { try { if (this.client.isClosed()) { this.running = false; return null; } else if (!this.client.isClosed()) { InputStreamReader stream = new InputSt...
b9159748-052a-4d46-9d66-2a55e1680f3b
5
private File[] getFiles(String path) throws FileNotFoundException { File file = Enigma.resolvePath(path); if (file != null && file.exists()) { if (file.isDirectory()) return file.listFiles(); // path was single directory else return new File[] { fi...
059ca127-2e08-4c98-b87b-78cb8442a559
5
final void reflectY() { byte[] is = ((ImageSprite) this).colorIndex; if (((ImageSprite) this).alphaIndex == null) { for (int i = ((ImageSprite) this).indexHeight - 1; i >= 0; i--) { int i_98_ = i * ((ImageSprite) this).indexWidth; for (int i_99_ = (i + 1) * ((ImageSprite) this).indexWidth; i_98_ < i_9...
7846ee6d-5aaf-40c6-98c8-425c2f1dfdc1
1
public static java.sql.Timestamp javaDateToSQL(java.util.Date date) { if (date != null) { java.sql.Timestamp time = new java.sql.Timestamp(date.getTime()); return time; } else { return new java.sql.Timestamp(0); } }
86cc7890-421b-440f-90cc-9a8b2621d319
8
private byte[] decompress(Sprite s) throws IOException { byte[] buffer = new byte[0]; // Size of data in file int compsize = 0; // uncompressed size int datasize = 0; int testsize; // while we still need data while (true) { if (s.hasFlag(SpriteInfo.Compressed)) { testsize...
6ee1742e-4244-42b8-a74a-d124aa808fbf
9
public void receiveMessage(Message message) { ServerHelper.log(LogType.CONTROLLER, "Empfange Nachricht [Typ: " + message.getType().name() + "]" + ": " + message.getMessage()); switch(message.getType()) { case GENERAL: { break; } ...
8cf6bb52-f00f-4bc7-9456-7563a02ce3f0
0
private void beginScopeSymbolTable() { symbolTable.beginScope(); }
cfe1d7a2-85ad-48ce-9cb0-3f96bb7c8cb8
2
public static String splitCasCode(String casCode){ String result = ""; if(isBlank(casCode)){ return result; } for(int i =0; i <casCode.length()/3;++i){ result += "," + casCode.substring(i*3, (i+1)*3); } return result; }
ec196983-8bbb-46cb-bdb7-24bb909f4fad
7
public String toString() { if (m_Instances == null) { return "Bayesian logistic regression: No model built yet."; } StringBuffer buf = new StringBuffer(); String text = ""; switch (HyperparameterSelection) { case 1: text = "Norm-Based Hyperparameter Selection: "; break; ...
12417133-f9c0-4777-b999-4e7f9460bc83
2
public static void forceAppToFront() { if (Platform.isMacintosh()) { Application.getApplication().requestForeground(true); } else if (OK_TO_USE_FULLSCREEN_TRICK) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); AppWindow windo...
4a101fac-cce1-42f9-ae84-2ecadb800df9
2
public void setSelectedFontStyle(int style) { for (int i = 0; i < FONT_STYLE_CODES.length; i++) { if (FONT_STYLE_CODES[i] == style) { getFontStyleList().setSelectedIndex(i); break; } } updateSampleFont(); }
67d28ca7-c88d-4a72-9267-e0b3ffa1e164
5
public static void listFilesForFolder(final File folder) { for (final File fileEntry : folder.listFiles()) { String filename = fileEntry.getName(); String filePath = fileEntry.getPath(); String filePathExtension = filePath.substring(filePath.indexOf(targetFolder)+targetFolder.length(), filePath.l...
9b97c80c-3ab3-4d34-a634-329a5d2b843b
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 Mahnung)) { return false; } Mahnung other = (Mahnung) object; if ((this.id == null && other.id != null) || (thi...
3723f700-ba35-463b-8902-3799c5ac2d3d
2
public boolean regresaBuscaLogin(String login) { boolean res = true; Statement statement; ResultSet resultSet; try { Connection con = DriverManager.getConnection(connectString, user, password); statement = con.createStatement(); resultSet = statement....
6a05ba8f-ea4a-4805-a7d1-4f4184b2e791
5
public static void main(String[] args) { Scanner sc = new Scanner(System.in); String firstLine = sc.nextLine(); String secondLine = sc.nextLine(); String[] firstStrArr = firstLine.split(" "); String[] secondStrArr = secondLine.split(" "); ArrayList<Character> l1 = new ArrayList<>(); ArrayList<Cha...
959d52cc-891e-4273-98cf-a4881773cd44
9
public static Request parse(final SocketChannel socketChannel, final ByteBuffer buffer) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buffer.array()))); final String uri; final Map<String, String> params = new HashMap<String, Strin...
3242c828-a4da-4006-b007-a8b298f06089
0
public hasNotChosenCharactersState(GameMachine gumballMachine) { this.gumballMachine = gumballMachine; }
1335df76-5e92-40b2-9b82-27bef60c3ae8
9
private int[] initiation(List<Adventurer> adventurers) { int[] init = new int[adventurers.size()]; Adventurer adventurer; for (int i = 0, end = adventurers.size(); i < end; i++) { boolean valid = false; boolean match = false; adventurer = adventurers.get(i);...
e26c71c8-6e71-42d9-a578-0a7fc2d8f3a9
0
@Basic @Column(name = "debt") public double getDebt() { return debt; }
c73c37af-42d8-4e91-9370-e8c6a0d64a5f
5
private void updateTabla(){ //** pido los datos a la tabla Object[][] vcta = this.getDatos(); //** se colocan los datos en la tabla DefaultTableModel datos = new DefaultTableModel(); tabla.setModel(datos); ...
c720261e-04ad-447d-8f28-0f7c2a0ca31d
5
public void makeConnection(Socket insock) { log.debug("makeConnection()::" + insock.toString()); if ((connectionFilter == null) || ((connectionFilter != null) && connectionFilter.isAllowed(insock.getInetAddress()))) { // we create the connection data object at this point to // st...
f8fb8c5a-3428-47ff-aac7-c117373ee2a0
2
public static boolean isValidProduction(Production production, Set set) { String lhs = production.getLHS(); for (int k = 0; k < lhs.length(); k++) { if (!isInUsefulVariableSet(lhs.charAt(k), set)) return false; } return isUsefulProduction(production, set); }
93b52d14-bbf2-44e5-b228-276c076095ff
9
private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpos = jj_...
636c2e10-0b7e-445b-90f2-05e76173577f
4
public boolean readBoolean() { String s = readString(); if (s.equalsIgnoreCase("true")) return true; if (s.equalsIgnoreCase("false")) return false; if (s.equals("1")) return true; if (s.equals("0")) return false; throw new java.util.InputMisma...
6a09fd79-eb32-4510-a290-f19084524a0f
5
private void process(String name,long timestamp) { if(!name.endsWith(".class")) return; // not a class name = name.substring(0,name.length()-6); name = name.replace('/','.'); // make it a class naem // find a match for( Classes c : patterns ) if(c.include....
ef4b3524-291c-49fa-be4b-3781af86537f
3
private void doit() { TransactionManager tm = this.createTM(); Queue<Request> requests = new LinkedList<Request>(); Scanner scanner = new Scanner(System.in); String line = ""; while (true) { line = scanner.nextLine(); String[] instructions = line.trim()....
44e3f52b-6b98-4914-9d05-8610bad6e2df
0
public int getId() { return id; }
514e7d70-73c9-429b-978d-f2dd9cff02d4
5
@Override public void update(GameContainer gc, int delta) { sprite = ((Mob) gameObject).getSprite(); switch (gameObject.getMoveDir()) { case MOVE_UP: lastSprite = idleUp; sprite = up; break; case MOVE_DOWN: lastSprite = idleDown; sprite = down; break; case MOVE_LEFT: lastSprite = idleLef...
114fa640-b33a-4c6a-ad45-410d855c71a3
6
public static void initALServerLog() { if(g_bInit) return ; g_bInit = true; Properties properties = new Properties(); InputStream propertiesInputStream = null; try { propertiesInputStream = new FileInputStream("./con...
6209fa27-6638-4336-b4f8-3d175fa6e61d
1
public void extractOperators(String input){ String operatorRegex = "[+//*^-]"; // String numInput = ("3 + 2 / 4.0 * 1 ^ 17.34"); //[+//*^-]\ //extracts all operators in math equation //extractOperators("3 + 2 / 4.0 * 1 ^ 17.34") = ["+", "/", "*", "^"] p = Pattern.compile(operatorRegex); m = p.matcher(input...
aa1b48f5-4871-48e7-aa74-d64b4c2d0049
0
@EventHandler public void load(FMLInitializationEvent event) { }
18d9ee15-0ce1-4147-b5b5-f9155474cc9e
8
public void setPackInfo(PackInfo packInfo) { //HACK //I need to rework the way platform & solder data interact to produce a complete pack, but until I do so, this //awesome hack will combine platform & solder data where necessary if (packInfo instanceof SolderPackInfo && this.packInfo i...
5f990ead-b2de-4e9e-93cd-c9a9a25c6b4c
4
protected void moveView(int x, int y) { boolean xTest = (viewPort.x + x + this.getWidth() <= mapImage_Scaled .getWidth() && viewPort.x + x >= 0); // Checks new position is valid if (xTest) { // changes position. viewPort.x = viewPort.x + x; } boolean yTest = (viewPort.y + y + this.getHeight() <= map...
3c74383f-9718-4491-a8f3-af33898f4859
2
public static <T extends Model> List<T> where(final Class<T> cls, final String query, final String... params) { final String tableName = Reflection.getSimpleClassName(cls); final List<T> result = new ArrayList<T>(); final StringBuffer sql = new StringBuffer(); sql.append("SELECT * FROM "); sql.append(tableN...
ccc47e12-e28e-4c12-9177-36bb461e630b
2
@Override public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { HandlerMethod handlerMethod = (HandlerMethod) handler; ExceptionResolver exceptionResolver = handlerMethod ...
cf2187ac-50dd-4be4-a219-8cb7eb276bc1
8
Class367_Sub9(NativeOpenGlToolkit class377, IndexLoader class45, Class269 class269) { super(class377); try { aClass269_7375 = class269; if (class45 != null && ((NativeOpenGlToolkit) class377).aBoolean9921 && ((NativeOpenGlToolkit) class377).aBoolean9922) { Class39 class39 = (Class328.method2608 ...
a532a254-9097-49d4-9fbe-7b54718244a1
0
@Test public void twoEdgesCompareCorrectly() { Edge e = new Edge(null, null); Edge f = new Edge(null, null); Edge g = new Edge(null, null); e.setWeight(1); f.setWeight(1); g.setWeight(2); assertTrue(e.compareTo(g) < 0); assertTrue(g.compareTo(e) > 0); ...
0ff4210d-edcb-411a-8e8c-5f78d80548df
1
private String replaceLogs(String calculation) { Matcher matcher = Pattern.compile("log (\\d+(\\.\\d+)?)").matcher(calculation); StringBuffer out = new StringBuffer(); while (matcher.find()) { double num = Double.parseDouble(matcher.group(1)); matcher.appendReplacement(ou...
bfcbf340-e252-42cc-bf9b-5c986d0d5204
3
public static String showTable(List<String> ids ,List<TrigerState[]> signals){ String result = ""; for (int i = 0; i < ids.size(); i++) { result += ids.get(i) +" "; } result += "\n"; for (int i = 0; i < signals.size(); i++) { for (int j = 0; j < s...
1d88c73d-4a66-4e45-b218-a922dc1dc932
2
public static BufferedImage[] load(String s, int x, int y, int subImages) { BufferedImage[] ret; try { final BufferedImage spritesheet = ImageIO.read(Images.class .getResourceAsStream(s)); ret = new BufferedImage[subImages]; for (int i = 0; i < subImages; i++) { ret[i] = spritesheet.getSubimage(...
d70aed3c-3fae-4bb9-93ef-83f5ad4d083f
3
public JMenuBar addFileMenu(JMenuBar menubar) { String text ="hello"; // create the file menu JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); // add menu items and mnemonics/ tool tips JMenuItem exit = new JMenuItem("Exit", null); exit.setMnemonic(KeyEvent.VK_E); ...
ec51bc61-d985-482b-9071-87953ed45027
3
public void op1() { if(have(Token.Kind.ADD)){ expectRetrieve(Token.Kind.ADD); } else if(have(Token.Kind.SUB)){ expectRetrieve(Token.Kind.SUB); } if(have(Token.Kind.OR)){ expectRetrieve(Token.Kind.OR); } }
01f2e84b-fac7-4475-874e-31b92e8ebe1d
0
private boolean fireExceptionEvent(ExceptionEvent evt) { return true; }
d08a9750-723e-4ae3-a306-95ed46a1e146
2
protected HttpUriRequest addAuthHeader(HttpUriRequest request) { if (!request.containsHeader(AUTH.WWW_AUTH_RESP)) { if (mToken != EMPTY_TOKEN) { request.addHeader(createOAuthHeader(mToken)); } } return request; }
acd6c09e-1140-4fa8-bae2-375fdbb83273
2
public GreeterComponent(GUIComponentGroup superGroup) { super(superGroup); bannerImage = new ImageComponent(this); bannerImage.setImage("giant_eight"); bannerImage.setImageLocationC(this.getLocationXC(), this.getLocationYC()); bannerImage.animateColor(new AlphaColorAnimation(200...
be28d93d-8861-47ae-af0f-78af145796c2
7
public Shape(int row, int col) { super(row,col); // Set Superclasses Constructor moveable = true; // The shape can move Random Generator = new Random(); //Generate Random Numbers Orientation = 1 ; // Set Default Orientation int randomShape = 1 + Generator.nextInt(7); Shapetype = randomShape...
2f8c037c-c933-4d7d-acc4-bdf9e1c6f252
7
public int calculate(String s) { int result = 0; Stack<Integer> stack = new Stack<Integer>(); int operator = 1; int number = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '+': result += operator * number; number = 0; operator = 1; break; case '-'...
88aed3cd-8aa4-4a1d-aaf9-b7b49ebbf244
6
public static Node<Integer> reOrder(Node<Integer> head) { //take care of zero size and single size lists if(head == null || head.next == null) { return head; } // first break the list into two equal parts and reverse the later part Node<Integer> slow = head; ...
85fd7a09-5c2b-4254-8eeb-16ea842e0b28
8
static int nextIndex(int index, int size) { if (size <= 1) { return -1; } // TODO: refactor, simplify int i = index + 1; // switch to 1-based if (isMinLevel(index)) { // we are at min level if ((i & (i + 1)) == 0) { // complete min level if (i == size) { ...
820dd5b9-37d5-4c8b-a38d-741bbf3af520
6
public void territoryFill(int r, int c, List<Intersection.Piece> colors, boolean checked[][], List<Coord> area){ if (r < 0 || c < 0 || r >= 9 || c >= 9) { return; } if(checked[r][c]==true){ return; } else if(board[r][c].getContents()!=Intersection.Piece.EMPTY){ colors.add(board[r][c].getContents()); ...
5d0319db-f236-4ad0-a9dd-710cde51229c
2
public static void main(String[] args) throws InterruptedException { GWCAConnection gwcaConnection = null; try { LOG.info("Executing \"Java GWCAConstants\" (version {})", Version.getVersion()); //TODO: Fill in the PID here gwcaConnection = new NamedPipeGWCAConnectio...
2c5432b9-6e83-40d7-b857-94adec992828
0
public void driver() { System.out.println("benz car drive"); }
4b4e2f23-dae5-41ae-a6dd-ce40c06575ed
6
public Set<OrderStatus> possibleTransitions(OrderStatus from_status, DeliveryType for_deliveryType) { Set<OrderStatus> ret = new HashSet<>(); if(from_status != null) switch(from_status) { case PROCESSING: ret.addAll(Arrays.asList(DELIVERY, CANCELLED)); break; case DELIVERY: if(for_deli...
ae25dcd1-417c-4bbc-b349-53641802b595
5
@Override public int getMetricInternal() { EflUtil.runToAddressNoLimit(0, 0, 0xe28d); // RodResponse boolean bite = (curGb.getRegister(Register.DE) & 0xFF) == 1; if (!bite) return 0; int bc = curGb.getRegister(Register.BC); int curLvl = (bc >> 8) & 0xFF; int curMon = bc & 0xFF; if((lvl > 0 && lvl != ...
31840663-538e-4ce2-911a-26278dca9b9f
4
public static byte[] decrypt(byte[] data, byte[] key) { int i; byte[] tmp = new byte[data.length]; byte[] bloc = new byte[8]; K = generateSubKeys(key); for (i = 0; i < data.length; i++) { if (i > 0 && i % 8 == 0) { bloc = encrypt64Bloc(bloc,K, true); System.arraycopy(bloc, 0, tmp, i - 8, bloc.l...
98d0d9fd-dc74-4259-a9b0-5cb8b902105b
7
public int[] howMany(String answers) { charIntMapping.put('A', 0); charIntMapping.put('B', 1); charIntMapping.put('C', 2); for (int i = 0; i < answers.length(); i++) { countABC[charIntMapping.get(answers.charAt(i))]++; } for (int i : countABC) ...
5ac3f627-c254-4307-a09c-f6fdbb6869c1
1
public static <A, E extends A> A[] toArray(Enumeration<E> enumeration, A[] array) { ArrayList<A> elements = new ArrayList<A>(); while (enumeration.hasMoreElements()) { elements.add(enumeration.nextElement()); } return elements.toArray(array); }
d67010cb-c303-439c-ac4c-05ca048c0c91
9
public ServerImpl(String ip, String inputfile) throws RemoteException { servers = new HashMap<Integer, Server>(); transactionCounter = 0; nofAborts = 0; activeTransaction = null; readGlobalParameters(inputfile); resources = new ArrayList<Resource>(); for (int i = 0; i < Globals.NOF_RESOURC...
4717d3f5-79fc-42db-b4e3-3441b1e2c3f6
4
public void getPhone(String phone) { boolean isPhonefound = false; int noOfPages = Integer.parseInt(pageCount.getText()); System.out.println("Total number of pages : " + noOfPages); for (int i = 0 ; i< noOfPages ; i++) { List<WebElement> elements = Page.driver.findElements(By.cssSelector("span.l...
54ccf3c7-ea20-4c36-a22c-44d21f7c0bfc
8
public void save() { //create a buffered writer stream FileOutputStream fileOutputStream = null; OutputStreamWriter outputStreamWriter = null; BufferedWriter out = null; try{ fileOutputStream = new FileOutputStream(filename); outputStreamWriter = new Outpu...
7df96c1b-5ca3-4849-997d-efecd0ae6f2a
7
public Object nextContent() throws JSONException { char c; StringBuffer sb; do { c = next(); } while (Character.isWhitespace(c)); if (c == 0) { return null; } if (c == '<') { return XML.LT; } sb = new Str...
64ab0304-e7b1-4531-acd4-5a1a02eb0436
5
@Test public void testBuildSettlement() { VertexLocationRequest location1 = new VertexLocationRequest(0, 0, VertexDirection.NorthWest); BuildSettlementRequest request = new BuildSettlementRequest(0, location1, true); ServerModel aGame; aGame = gamesList.get(1); int totalBuildingsBEFORE = aGame.getMap().ge...
f432a109-ecd8-47cb-abe5-f3a969540cd3
7
int calc(String a, String b){ int n = a.length(); int m = b.length(); int[][] dp = new int[n+1][m+1]; for(int i=0; i<=n; i++){ for(int j=0; j<=m; j++){ if(i==0) dp[i][j] = j; else if(j==0) dp[i][j] = i; else dp[i][j]=m+n; if(i==...
5cbdeddc-5bf9-4cbb-ad83-b1ee61e81337
4
public void wasAttacked(int dmg, int debuff){ health -= dmg; if (health <= 0){ death(); } if (dmg == 0 && !tenacious && jolly){ cc = debuff; jolly = false; crowdControlled(cc); } }
1142cf6f-844c-4d5d-9710-5a9751336771
7
public void move(int xa, int ya) { if(xa != 0 && ya != 0) { move(xa, 0); move(0, ya); numSteps--; return; } numSteps++; if(!hasCollided(xa,ya)) { if(ya < 0) movingDir = 0; if(ya > 0) movingDir = 1; if(xa < 0) movingDir = 2; if(xa > 0) movingDir = 3; x += xa * speed; y += y...
586d14d9-c391-4241-a970-1aaeb32f102d
9
public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine().trim()); for (int t = 1; t <= T; t++) { int n = Integer.parseInt(br.readLine().trim()); int[] arr = n...