method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
12a6fc0c-5c94-49de-b956-c24720a80ac3
3
public LongOpt(String name, int has_arg, StringBuffer flag, int val) throws IllegalArgumentException { // Validate has_arg if ((has_arg != NO_ARGUMENT) && (has_arg != REQUIRED_ARGUMENT) && (has_arg != OPTIONAL_ARGUMENT)) { Object[] msgArgs = { new Integer(has_arg).toString() }; throw new IllegalArgumen...
2b92564c-da58-4165-9523-8ac0ce0ff46c
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...
ae8537d7-6dda-4616-bdd2-dba77816e232
9
@EventHandler public void onRegionEnter(RegionEnterEvent event) { try { if(event.getRegion().getFlag(DefaultFlag.PVP) == null || ((StateFlag.State)event.getRegion().getFlag(DefaultFlag.PVP)).toString() != "DENY") return; Player p = event.getPlayer(); if(HandleTag.contains(p.getName())) { if(mtime....
cf650823-3362-45a3-9db4-9cdc7ebf8fd2
9
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User user = (User) request.getSession().getAttribute("user"); try { String shipping = request.getParameter("shippingInfo"); String addressNick = request.getParameter("add...
c9ccb6c1-b676-41f4-b7e9-af6b27b77edb
7
public KarmaPlayer[] getTopKillers(int amount){ KarmaPlayer[] top = new KarmaPlayer[amount]; for(KarmaPlayer p : this.karmaPlayers.values()){ for(int i = top.length - 1; i >= -1; i--){ if(i == -1 || (top[i] != null && top[i].getTotalKills() > p.getTotalKills())){ if(i == top.length - 1){ //Poorer ...
a57af6ae-cb1f-4c04-85af-be61a5a70c28
1
public void setStorageLocation(String location) throws IOException { if (printWriter != null) close(); logFilePath = location; }
0510eed1-8869-48a4-9df8-aeafd7916a1f
2
@Override public Person delete(Integer id) throws NotFoundException { EntityManager em = emf.createEntityManager(); Person person = em.find(Person.class, id); if (person == null) { throw new NotFoundException("No person exists for the given id!"); } em.getTransact...
97d0b0e1-b327-45d3-9773-e4af053e9dce
5
public static boolean isPassword(String password) { if (isNull(password)) { return false; } if (password.length() < 4) { return false; } for (char c : password.toCharArray()) { if (!isChar(c) && !isDigit(c)) { return false; } } return true; }
588fe8d8-a4d3-4607-bf2c-1ec45e8ee649
9
public int addPacket(String id1, String id2, float size){ int index = 0; Nodo source = null, destination = null; while(index < _network.size() && (source == null || destination == null)){ if(source == null && _network.elementAt(index).getId().equals(id1)){ so...
c115f786-479a-41a2-af68-110e55c866db
1
public void rewindNbits(int N) { totbit -= N; buf_byte_idx -= N; if (buf_byte_idx<0) buf_byte_idx += BUFSIZE; }
48964b34-3f34-4144-92a3-b329b30b052c
0
@Override public void initialize(URL arg0, ResourceBundle arg1) { }
96aa625e-b231-4186-9897-4c5170d47126
3
private boolean checkDividerBlock(int da[]) { int a,zeroCount=0; for (a=5;a<da.length;a++) { if (da[a]==0) zeroCount++; } if (zeroCount>=30) return true; else return false; }
49ed91b2-098d-4148-84e0-eeb567e524d6
9
public final String getSomeFromFileWithDuplicate(final BufferedReader br, final char start, final char finish, final boolean goFromStart) throws IOException { int c = br.read(); int numberOfValue = 0; boolean trouver = false; String line = ""; if (goFromStart) { while (c != -1 && c != start) { c = b...
78ac9e14-547a-48b4-a202-f0e2ba3f2009
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ContactNumber other = (ContactNumber) obj; if (key == null) { if (other.key != null) return false; } else if (!key.equals(other.key)) ...
df68b980-e863-41b1-871d-b87ab5ceecda
2
public static void setOutputDir(final String outputDir) { final File testFile = new File(outputDir); if (testFile.exists() && testFile.isDirectory()) { Settings.outputDir = outputDir; } }
5aca8026-8ece-4dd1-a043-3c4d0c67500b
3
private void processMethods(CtClass clazz, boolean dontSearch) throws CannotCompileException, NotFoundException { CtMethod[] ms = clazz.getMethods(); for (int i = 0; i < ms.length; ++i) { CtMethod m = ms[i]; int mod = m.getModifiers(); if (Modifier.isPubli...
e2484ffa-aeba-4be6-af3d-36f1d65d07c6
0
public void setKeyDerivationFunc(AlgorithmIdentifierType value) { this.keyDerivationFunc = value; }
7d1e5bf1-b9fb-4fb7-98cc-a1d38060aab2
0
@Test(expected=IllegalNumberOfOperandsException.class) public void testIllegalNumberOfOperandsDivide(){ calculator.pushOperand(7.0); calculator.pushDivideByOperator(); calculator.evaluateStack(); //assertTrue("An IllegalNumberOfOperandsException should heve been thrown here.", false); }
26c3d80f-dac7-4d11-980b-66dc1ac1f149
3
public void appendToMacroWarn (String player) { BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter("data/macrowarn.txt", true)); bw.write(player); bw.newLine(); bw.flush(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { if (bw != null) try...
184c0be2-6804-4949-a8e6-6637ae035a7a
5
public static ArrayList<Member> searchMemberByName(String name){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<Member> members = n...
cd2c03af-4141-45b3-98b2-3725f0cb4337
0
@Test public void canGetWord_whenWordIsSubStringOfExistingWordInTrie() { trie.add("abc"); trie.add("ab"); assertTrue(trie.contains("ab")); }
377e54b3-3fcc-4e70-b75d-cdd81b47f179
0
public People(String name,String age,String address){ this.name = name; this.age = age; this.address = address; }
06f4ffda-cb8a-4a98-a507-626994349ca8
1
public static void main(String[] args) { try { calculate(1, 0); } catch (ArithmeticException e) { System.out.println(e); } }
48e1a1d9-4dbd-4d58-b96c-1c9d4f48e5f0
7
protected LinkedHashMap<Path, Patch> getFileDiffsOfDirectories(final Path src1, final Path src2) throws IOException { final LinkedHashMap<Path, Patch> src1ToSrc2Files = new LinkedHashMap<Path,Patch>(); Files.walkFileTree(src1, new SimpleFileVisitor<Path>() { @Override public File...
72dfb59a-1ff1-4d75-b413-155c9e911b6b
1
public boolean InsertarAplicacion(Aplicacion p){ if (p!=null) { cx.Insertar(p); return true; }else { return false; } }
32c4e5d5-2d51-43aa-b81b-ab907881adc3
4
@Override public long lastAccessibleCycleBefore(long cycle, AccessibilityGbState gbState) { if (cycle < getVramInaccessibleFrom()) // before first frame return cycle; int lineCycle = (int) (cycle % GbConstants.LINE_CYCLES); int frameLine = (int) ((cycle % GbConstants.FRAME_CYCLES) / GbConstants.LIN...
06e781d2-d360-4644-b036-fa4a9f532f6b
4
public void paint(GC gc, int width, int height) { if (!example.checkAdvancedGraphics()) return; Device device = gc.getDevice(); // diameter of the circle in pixels int diameter = ((width < height) ? width - 25 : height - 25); if (!getAnimation() && nextNumber == 0) { Font font = new Font(device, getPlatf...
e45f7067-0fad-4196-90dd-c1ac51ef84ff
1
protected void stateChange(AutomataStateEvent event) { if (event.isDelete()) selected.remove(event.getState()); super.stateChange(event); }
6b1770bd-ae4f-41ae-ba4f-3941d18ddf39
4
private Enemy createEnemy(String type) { if (type.equals("dwarf")) return new Dwarf(this); else if (type.equals("elf")) return new Elf(this); else if (type.equals("hobbit")) return new Hobbit(this); else if (type.equals("human")) return new Human(this); return null; }
705b60a3-cba3-41c6-92a4-20d1833f85cc
9
public ArrayList<Module> manageDupicateModules(ArrayList<Module> modules){ ArrayList<Module> managedModules = new ArrayList<Module>(); // array of now non repeated, coupled modules. ArrayList<Module> modulesWithClashes = new ArrayList<Module>(); // array ofModuels that need to be clashed Module tempModule; Arra...
dfd2441a-4b80-4e48-a776-f4cba9c5d2b1
6
@EventHandler(priority = EventPriority.HIGHEST) public void onPing(ProxyPingEvent e) { PendingConnection connection = e.getConnection(); if (connection == null || connection.getVirtualHost() == null || connection.getVirtualHost().getHostName() == null) { return; } ...
a3c5d04f-f33a-493d-8c82-28b1c3d1ffc9
3
protected int searchReservation(Collection obj, int reservationID) { ARObject arObj = null; int found = -1; // means the Gridlet is not in the list try { // Search through the list to find the given Gridlet object int i = 0; Iterator iter = ob...
17faba97-43f1-44a9-b042-26d8342c6974
7
@Override public void draw(Graphics g) { int segments = 16; int i; int ox = 0; int hs = sim.euroResistor() ? 6 : 8; double v1 = volts[0]; double v2 = volts[1]; setBbox(point1, point2, hs); draw2Leads(g); setPowerColor(g, true); double s...
0efef83f-4cd1-491b-b00f-294afabd1c06
6
public void loadLevel(Game game) { _loader = new LuaLoader("level_" + _currentLevel); String levelName = _loader.getValue("levelName").tojstring(); LuaTable table = (LuaTable)_loader.getValue("levelData"); System.out.println("Loaded level: " + levelName); for(int i = 0; i < table.length(); i++) { ...
4708642c-77c0-4f32-b159-fd88c4ca318d
7
public String setting() throws Exception { // 获取session Map<String, Object> session = ActionContext.getContext().getSession(); // 获取服务 ProfileService service = new ProfileService(); // 获取学生信息 StudentVO studentInfo = service.getStudentProfile((String) session .get("USER_ID")); if (oldPawword == null ||...
9a7dabd1-aa43-487d-89c2-764259d71f90
6
private void renderIntersections(Graphics2D g2) { Iterator<Intersection> it = data.intersectionsIterator(); while (it.hasNext()) { Intersection intersection = it.next(); // ONLY RENDER IT THIS WAY IF IT'S NOT THE START OR DESTINATION // AND IT IS IN THE V...
e01b933c-1f66-45fd-ac52-06d5bc160ca0
0
@Override public String getDesc() { return "HellFire"; }
5aa0c931-a48d-470f-a774-f7a65a69690f
3
@Override public void pickUp(Player playerToPickUp) throws InvalidActionException { if (playerToPickUp == null) throw new IllegalArgumentException("The given arguments are invalid!"); if (playerToPickUp.getInventory().findFlag() != null) throw new InvalidActionException("You can only have 1 PlayerFlag in you...
3485de32-587b-4c92-a427-5435c7076dc6
1
@Test public void testQuiz2() { Quiz quiz = Quiz.getQuizByQuizName("Bunny Quiz"); User stanford = User.getUserByUsername("stanford"); // QuizTakenRecord ArrayList<QuizTakenRecord> allHistory = quiz.getAllHistory(); assertEquals(allHistory.size(), 9); for (int i = 0; i < allHistory.size() - 1; i++) { as...
839e86ec-21d7-4687-9255-b249dd1d6a95
0
public void pause() { ++pause_count; }
d041d992-a187-4b01-9cd5-7c3f5df4a2e2
3
public String convertGameStateToString() { // Hey Maurice // habe die Funktion mal kurz implementiert // um die Aufgabe 4 zu testen, kannst sie gerne // neu schreiben String ergebniss = ""; Iterator<City> it = this.iterator(); while(it.hasNext()){ City c = it.next()...
eab16a39-905e-4109-8036-a264baf74b85
2
private boolean isPlaceholder(Object item) { return (item == null || item.equals(placeholder) || item.equals("")); }
9a2d61af-743f-45d3-b1db-e7ad0de68ca6
8
public PreferencesDialog(Frame parent, Preferences preferences) { super(parent, TITLE, true); this.parent = parent; this.preferences = preferences; this.setResizable(false); JPanel cp = (JPanel) this.getContentPane(); cp.setLayout(new GridBagLayout()); buttonPanel.add(okButton); ...
b8f26d9b-aacd-46b8-ae5a-73d16dedc69f
5
public void handleMessage(Message msg) { switch(msg.getType()) { case 0: this.stdmessageEventManager.trigger((STDMessage)msg); break; case 1: this.authmessageEventManager.trigger((AuthMessage)msg); break; case 2: this.usermessageEventManager.trigger((UserMessage)msg); break; case 3: this.channelmessageEve...
9b81a799-2db9-4012-860c-add2fc11fedd
1
private void print(String msg) { if (AzotConfig.GLOBAL.VERBOSE) { System.out.print(msg); } }
5f2b4e5b-46af-4a5c-bb51-53bbc162a358
1
@Override public int hashCode() { int hash = 0; hash += (idpagos != null ? idpagos.hashCode() : 0); return hash; }
ea0084ba-9f72-4bff-af61-a6344110ed85
9
public static Object loadObject(String filePath) throws IOException, FileNotFoundException, ClassNotFoundException{ //Initialized to null so they can be used in the catch blocks FileInputStream fileIn = null; ObjectInputStream in = null; //Attempt to read the object from memory and return it try{ f...
2d5ff3e4-955d-4f7f-a74a-6f4101ae6006
1
private boolean jj_2_37(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_37(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(36, xla); } }
037b0221-fea4-4bff-a520-be527ecc9288
0
public String getName() { return name; }
d26e0bd0-5970-4c0d-b383-9afd466c839c
5
private static void FileTestout(ArrayList<classifiedData> Data, String FileOutLoc){ PrintWriter writer = null; int CEDDSize = 144; int FCTHSize = 192; //write to the data file try { writer = new PrintWriter(FileOutLoc, "UTF-8"); } catch (FileNotFoundException e) { System.err.println("Could not open...
8c757988-9291-4021-a85c-69849af6567a
6
@EventHandler public void PlayerNightVision(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.getPlayerConfig().getDouble("Player.Nig...
a7b4511c-1ad0-44d1-9d60-37256b8fcbf4
3
public void announceNow (boolean pvpOn, String world) { if(pvpOn) { if((Boolean) getValue(pvpWorlds,world,"startMsgBroadcast")) { broadcastAllPlayersWorld(Bukkit.getWorld(world), (String) getValue(pvpWorlds,world,"startMsg")); } pvpAnnouncedWorlds.put(world, true); } else { if((Boolean) getVal...
f9703a9b-a2a1-450e-ad46-5dc14a41778a
9
private static void uninstallIntegrityClient() { // UNINSTALL OLD CLIENT Timestamp start, stop; try { start = new Timestamp(new java.util.Date().getTime()); System.out.println("[" + start + "] Uninstalling old Integrity Client..."); String oldClientDir = config.getString(PROPERTY_OL...
b7fe7502-c228-4464-a390-1a883714c39d
4
public Connection getConnection() { try { if ((this.username.equalsIgnoreCase("")) && (this.password.equalsIgnoreCase(""))) { return DriverManager.getConnection(this.dsn); } if (Misc.is(Constants.DatabaseType, new String[] { "sqlite", "h2", "h2sql", "h2db" })) { return this.h...
d715dd58-aae4-48d3-82e4-6ff3b210d476
9
@SuppressWarnings("deprecation") private void setArray(OMMArray array) { switch (array.getDataType()) { case OMMTypes.INT32: case OMMTypes.UINT32: { int[] value = new int[array.getCount()]; int i = 0; for (Iterat...
0a71e735-2a91-4fad-aca7-1d45a7fe9c1c
3
public Object getDomainMt() { if (domainMt == DEFAULT) { if (defaultDomainMt == null) { try { defaultDomainMt = (cyc.converseCycObject("(eval " + PPH_DOMAIN_MT.stringApiValue() + ")")); } catch (Exception e) { throw new RuntimeException("Unable to find PPH domain Mt", e); ...
d36697ba-55a7-49b7-9e29-a14f040add10
9
@Override public Location locate(Measurement currentMeasurement) { if(debug) { loadParameters(); } Location loc = null; // get all measurement in database List<Measurement> list = measurementHome.getAll(); /* check for similarity */ TreeSet<Measurement> hits = new TreeSet<Measurement>(new M...
7d6edbf8-70db-497d-98c8-21c3d5501079
3
public static String max( String string, int maxLength ) { if ( string == null ) { return EMPTY; } if ( maxLength < 0 ) { maxLength = 0; } if ( string.length() < maxLength ) { return EMPTY + string; } return string.substring...
415e7519-b3f6-49a5-bd23-26408ba31be0
3
private void updateScale() { this.scale = 1.0; if(this.getWidth() != 0 && this.getHeight() != 0) { double scaleX = (double)this.getWidth() / (double)WORLD_WIDTH; double scaleY = (double)this.getHeight() / (double)WORLD_HEIGHT; double newScale = Math.min(scaleX, scaleY); if(newScale ...
75da3ca8-3b84-4648-91b1-3da46b5250af
8
public static String[] validateCommand(String line){ String[] data = line.split(" "); for (int i = 0; i < data.length; i++){ if (!data[i].matches("[A-Za-z0-9]+")) return (new String[]{}); } if (data.length < 3 || data.length > 4 || (!data[0].equals("read") && !data[0].equals("write")) || (data[0].equ...
784e30bf-e07a-42b9-bfd6-6308de61b17c
8
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if(!super.okMessage(myHost,msg)) return false; if((msg.targetMinor()==CMMsg.TYP_DAMAGE) &&(msg.tool() instanceof AmmunitionWeapon) &&(CMLib.combat().isAShipSiegeWeapon((Item)msg.tool())) &&(affected instanceof MOB) &&(((...
b5d96bef-bc73-4357-a0a2-22d86eeb8df6
4
@POST @Consumes(MediaType.LIBROS_API_USER) @Produces(MediaType.LIBROS_API_USER) public User createUser(User user) { // TODO: get connection from database Connection conn = null; Statement stmt = null; try { conn = ds.getConnection(); } catch (SQLException e) { throw new ServiceUnavailableException(e....
826a45f8-946c-4bab-86f2-7939ff6a8311
2
public Modelo buscarModelo(String nome) { for (Modelo m : modelos) { if (m.getNome().compareToIgnoreCase(nome) == 0) { return m; } } return null; }
05dd7c57-c8f8-4a9a-a2d6-69c5dfbc8193
6
public void setModeControlsVisible(boolean b) { this.hue.radioButton.setVisible(b && this.hue.isVisible()); this.sat.radioButton.setVisible(b && this.sat.isVisible()); this.bri.radioButton.setVisible(b && this.bri.isVisible()); this.red.radioButton.setVisible(b && this.red.isVisible()); ...
d9f8424d-f68e-4bc7-829e-cbfc67333c78
9
public final void write(PBSerializer serializer, Object object, Object fieldName, Type fieldType) throws IOException { SerializeWriter out = serializer.getWriter(); Object[] array = (Object[]) object; if (object == null) { return; } int size = array...
de1ef907-a700-411f-86ee-c3c07efe5308
8
@Override public void eventSent(EntityRef entity, Event event) { if (event.getClass() == AfterComponentAdded.class || event.getClass() == AfterComponentUpdated.class || event.getClass() == AfterComponentRemoved.class) { entityModified(entity); } if...
5bcb0e80-4d86-4cf5-8449-5bf21af90d2e
8
public static void addConstraintViolationsRDF(List<ConstraintViolation> cvs, Model result, boolean createSource) { for(ConstraintViolation cv : cvs) { Resource r = result.createResource(SPIN.ConstraintViolation); String message = cv.getMessage(); if(message != null && message.length() > 0) { r.addPropert...
cd6eb6ca-2630-4080-931f-7df742ed2660
0
@Override public String getKey() { return String.valueOf(getSuppliercode()); }
3d4ae263-ab75-41c6-a73d-190b28dce33a
1
@Test public void removingSingleVertexThatIsANeighbour() { l.addVertex(v); l.addVertex(k); l.addEdge(v, k); l.removeVertex(1); assertTrue(l.getNeighbours(0).contains(v) && !l.getNeighbours(0).contains(k)); }
b2ef9782-dfe5-4995-9240-5329ef1bd426
6
public static int nextValidInt(Scanner s, int lo, int hi){ Integer input = null; do{ if (s.hasNextInt()){ input = (Integer) s.nextInt(); } else{ // Case: there is no integer in the next input System.out.println("Please input a number."); s.next(); // this prevents build up of empty lines when ...
56146e7c-ba4a-4638-9264-321540ab1fac
5
public static String[][] getCountedInventory(List<Item> list) { String[][] invenCount = new String[list.size()][2]; for (int i = 0; i < list.size(); i++) { for (int j = 0; j - 1 < i; j++) {//i should use a map here instead lol //short circuits here if (invenC...
e2dc8fab-a2f4-43dd-9353-1dc66affad5d
8
public void startGameForClients(MiniServer player[], String variation) { EuchreVariation euchreVariation = new EuchreVariation(variation); this.clientPlayersPlaying = player; //Disallow the player array from having nulls in between players: //TODO: test this loop this.numberOfPlayers = 0; for(in...
0f0ac82a-e763-4e43-bf77-2d33b12d60ba
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 fe...
c0fae51a-5037-484f-a245-7642c34cc741
7
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); int nCases = Integer.parseInt(in.readLine().trim()); int oo = Integer.MAX_VALUE; for (int i = 0; i < nCases; i++) { int n = Integer....
9a430b9c-9c87-414d-90c4-e1fb9f8aeeb8
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 Vendorcity)) { return false; } Vendorcity other = (Vendorcity) object; if ((this.vendorCityID == null && other....
c823892e-6b9e-4e1a-99fc-440df3fdb848
9
public static final DataState getInstance(int code) { switch (code) { case 1: return DATA; case 2: return NO_DATA; case 3: return NO_SOURCE; case 4: return NO_RIGHTS; case 5: return POSSIBLE_GAP; case 6: return END_OF_ARCHIVE; case 7: return DELETED_BLOCK; case 8: ...
e6f86dec-c917-4c8b-9647-c2f8d08ee11e
2
private static void invokeAndCreate(String name) throws Exception{ System.out.println(name); Class<?> objClass = Class.forName(name); FooObject obj = (FooObject) objClass.newInstance(); Constructor<?> c = objClass.getConstructor(String.class); FooObject obj2 = (FooObject) c.newInstance("It is a string"); ...
c73ae802-3f8c-4177-876d-a661bfc59bd1
8
private static float getCategorySimScore(String srcCat, String destCat) { String[] srcCats = srcCat.split("\\."); String[] destCats = destCat.split("\\."); float res = 0f; int minlen = Math.min(srcCats.length, destCats.length); if(minlen > 0) { if(srcCats[0].equals(destCats[0])) res += 8; } if(mi...
8fb34102-b203-4b5d-a3b0-a2bd09389da8
8
private ArrayList<Coordinate> take(Coordinate xy, int xdir, int ydir) { boolean test = false; if (test || m_test) { System.out.println("Othello :: take() BEGIN"); } if (!checkBound(xy, xdir, ydir)) { return new ArrayList<Coordinate>(); } Grid grid = getGrid(); Coordinate current...
b5f4fb5d-155e-4337-a33d-fe4c9335992f
0
public boolean checkDefeated(){ return hero.isAlive(); }
3883e67c-2c37-42d9-8c3c-1f7a241fdee2
4
public void enque(int data) { if (isFull()) { System.out.println("full queue"); return; } if (cursor < 0) { elements[++cursor] = data; } else { int temp = cursor++; while (temp >= 0) { if (data > elements[temp]) ...
2cabfa33-dc4b-44e6-b493-421028ca0e94
8
public WaveletCSFFilter(int width, int height, int levels, int channelType) { if (width < 8) throw new IllegalArgumentException("The width of the image must be at least 8"); if (height < 8) throw new IllegalArgumentException("The height of the image must be at least 8"); ...
10d664ec-683f-43bb-b17c-af3bc28e86f5
0
@Override public void actionPerformed(ActionEvent e) { AssignCoordinates.initialize(GraphInterface.getGraph()); }
0dac53ad-d61b-4aaa-a60e-c022d97783d4
0
public String getAcceptability() { return this.acceptability.location(); }
a783128e-9c7d-49c6-8298-72349d9e2638
0
public int getEmployeeCant() { return EmployeeCant; }
d9b1d7cc-65dc-4a59-9b9b-2709a46ebd00
9
protected void _buy(String title, int quantity, boolean limit_check) { CurrentDVD cdvd = dvd_collection.get(title); /* title does not exist */ if (cdvd == null) throw new IllegalArgumentException(SessionErrors.DVD_NOT_FOUND); if (quantity <= 0) throw new IllegalArgumentException( SessionErrors.INVA...
80094a97-89f6-4c54-adab-ebe0b17e43ca
1
public static void main(String[] args) { try { CycAccess access = new CycAccess("localhost", 3600); SubLWorker worker = new DefaultSubLWorker("(+ 1 1)", access); worker.addListener(new SubLWorkerListener() { public void notifySubLWorkerStarted(SubLWorkerEvent event) { System.out....
4ed896fe-4d0c-48fa-afcb-d8af63ad24b9
0
public List<Integer> getSavedFunctionArgs() { return savedArgs; }
cc51395d-f0fe-41cd-a2f5-a626437229b9
1
public void buildItemAgainstSource(VCNTreeItem sourceItem) { this.setText(sourceItem.getText()); this.content = sourceItem.getContent(); this.isWrap = sourceItem.isWrap; if (sourceItem.foregroundColor != null) { setForeground(new Color(this.getDisplay(), sourceItem.foregroundColor.getRGB())); } ...
a67e4962-8ea9-40f5-b878-07e2a22d3479
8
public String toString() { String string = getName() + " {"; string += "type=" + ((type != SWT.HORIZONTAL) ? "SWT.VERTICAL" : "SWT.HORIZONTAL") + " "; if (marginWidth != 0) string += "marginWidth=" + marginWidth + " "; if (marginHeight != 0) string += "marginHeight=" + marginHeight + " "; if (ma...
5c3ecc82-8aa2-4e62-bdfb-667b2399f70a
6
@Override public Movement getMove(Board b) { System.out.println("Board: "); b.show(); System.out.println("Use this format for your movement: "); System.out.println("i,j,direction,word"); Scanner reader = new Scanner(System.in); while (true) { try { String line = reader.next(); String[] parts = l...
5869600f-44b5-4655-af6a-2e9358c4753a
8
private void downloadFile(String link, File folder) { BufferedInputStream in = null; FileOutputStream fout = null; try { URL fileUrl = new URL(link); final int fileLength = fileUrl.openConnection().getContentLength(); in = new BufferedInputStream(fileUrl.openS...
8d8bea31-6a2d-4479-ae43-b821fac7e65d
6
private void updateNPCList(int amount, Buffer stream) { while (stream.bitPosition + 21 < amount * 8) { int npcId = stream.readBits(14); if (npcId == 16383) break; if (npcs[npcId] == null) npcs[npcId] = new NPC(); NPC npc = npcs[npcId]; npcIds[npcCount++] = npcId; npc.lastUpdateTick = tick; ...
e43083f3-8da5-45af-a00a-c8a7bc3e3c8c
3
private void unionHelper(UFNode<T> child, UFNode<T> parent) { if (child == parent) return; UFNode<T> curr = child; UFNode<T> temp = curr; while (curr != parent && curr != null) { temp = curr.parent; curr.addParent(parent); curr = temp; } }
699bc827-291b-4d3b-b5ad-7225c18dc4de
8
public HashMap<String, LinkedList<NGram>> getNGrams(int order){ HashMap<String, LinkedList<NGram>> nGrams = new HashMap<String, LinkedList<NGram>>(); Iterator<String[]> it = sentences.iterator(); while(it.hasNext()){//For each sentence String[] sentence = it.next(); if(sentence.length > order + 1){//If sent...
aa287808-cb90-405f-8fda-4c617c1e9eb2
2
public void loadMods(Room room) { File file = new File(data, "bot.settings"); Line[] lines = readFile(file); for (Line line : lines) { if (line.startsWith("mod:")) { Line[] data = line.substring(4).split(":"); room.addMod(data[0].toString(), Rank.parseLine(data[1])); } } }
22c36813-3a38-4536-a450-c666272464fc
0
private static void printPropertyList() { System.out.println(MediaFileUtil.supportReport(true)); }
9763e4bc-bd01-4bee-b50c-b7e7b060d2a3
6
private boolean riotGen(){ //Riots are generated randomly, scaled by the current happiness level and military Random riotlevel = new Random(); int riot = (int) Math.abs(Math.round(riotlevel.nextGaussian()*100/happy/Empous.Gov.getStat("military"))); if(riot>=1){ // System.out.println("Your citizens are rioting!!...
51c4a8d3-3310-4a8a-8c54-79d9197f6104
5
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page ...
a229892f-0b68-4739-9afb-f5823e6e6c4b
4
public Component getListCellRendererComponent(JList<?> list, Object value,int index, boolean isSelected, boolean cellHasFocus) { if(elementos.get(value) != null) { setIcon(elementos.get(value)); setText(""+value); if(isSelected) { setFont(new Font("Verdana",Font.BOLD,16)); }else{ setFont(nu...