method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
8edb9054-bc25-4590-8cd7-2b6e7d6e7d49
5
public void run(){ while(running){ try { Object ob = inStream.readObject(); if(ob instanceof ArrayList<?>){ @SuppressWarnings("unchecked") List<Player> players = (ArrayList<Player>) ob; moveService.UpdateAllPlayersMovement(players); } } catch (ClassNotFoundException e) { System.er...
20159fb1-5781-4001-9f63-31c8cae52018
0
public void postInit(FMLPostInitializationEvent event) { }
5a489ec7-bae5-41f5-92d8-257c7dd4b307
7
public List<Character> getCharacterList(String path) { List<?> list = getList(path); if (list == null) { return new ArrayList<Character>(0); } List<Character> result = new ArrayList<Character>(); for (Object object : list) { if (object instanceof Charac...
d9efaada-621b-4f7a-8a7c-979891d6f545
7
public Message readMessages(String m1Command) throws IOException { Message msg = null; Iterator<Message> itr = messages.iterator(); while (itr.hasNext()) { msg = itr.next(); if (msg.getType().equals(m1Command) || m1Command == null) { itr.remove(); return msg; } } String s; MessageFactory m...
6f873469-fb89-4796-85ee-2a7fc9485b7b
2
public EmployeeScreen() { setBounds(new Rectangle(0, 0, 1365, 799)); EmployeeService empService = new EmployeeService(); getContentPane().setLayout(null); panelVizualizare = new JPanel(); //list= new JList<>(); list = new JList(new BooksListModel(empService.getBookList())); listPanel = new JScrollPane(...
e7273ebd-4ff0-43d7-8af6-20e1bd0d9782
1
public void setImgPath_ShutdownUpdateSym(Path img) { this.imgShutdownUpdateSym = handleImage(img, UIResNumbers.SHUTDOWNUPDATESYMBOL.getNum()); if (this.imgShutdownUpdateSym == null) { this.imgShutdownUpdateSym = UIDefaultImagePaths.SHUTDOWNUPDATESYMBOL.getPath(); deleteImage(UIRe...
b21f4e2e-ec97-4c1c-8f9d-7c10a27d52b4
8
@Override public void unInvoke() { final Physical P=affected; super.unInvoke(); if((P instanceof MOB)&&(this.canBeUninvoked)&&(this.unInvoked)) { if((!P.amDestroyed())&&(((MOB)P).amFollowing()==null)) { final Room R=CMLib.map().roomLocation(P); if(!CMLib.law().doesHavePriviledgesHere(invoker(), ...
21355f6c-7a14-4a9e-ba2b-d99f7e7fab85
8
@SuppressWarnings("unchecked") private static final Object[] decodeDictionary(byte[] bencoded_bytes, int offset) throws BencodingException { HashMap map = new HashMap(); ++offset; ByteBuffer info_hash_bytes = null; while(bencoded_bytes[offset] != (byte)'e') { //...
d246b76b-852a-4b7a-8b87-c47cc66be9f2
4
public PeerHost(){ this.bitfield = new boolean[0]; for(int i = 1; i < 10; i++){ port = 6880 + i; try { socket = new ServerSocket(port); System.out.println("Listen port is: " + port); break; } catch (NumberFormatException e) { /* Nope */ } catch (IOException e) { System.out.println("...
fc156a08-e312-49d5-b005-7a25e1c4d972
4
@GET @Produces(MediaType.LIBROS_API_USER_COLLECTION) public UserCollection getUsers() { UserCollection users = new UserCollection(); // TODO: Retrieve all stings stored in the database, instantiate one // Sting for each one and store them in the StingCollection. Connection conn = null; Statement stmt = nul...
b21b21f0-6ad7-4f6e-a2a8-5adb5a5a241f
5
public void inputHandler() { if(Keys.isPressed(Keys.ESCAPE)) gsm.setPaused(true); if(blockInput || player.getHealth() == 0) return; player.setUp(Keys.keyState[Keys.UP]); player.setLeft(Keys.keyState[Keys.LEFT]); player.setDown(Keys.keyState[Keys.DOWN]); player.setRight(Keys.keyState[Keys.RIGHT]); player.s...
c107fbdc-4b82-41c0-a400-da23441d6bef
4
public static void main(String args[]){ int firstNumber, secondNumber; firstNumber = 11; secondNumber = 40; if(firstNumber > 10 || secondNumber < 60){ //will be true by default System.out.println("First statement is true"); }else{ System.out.println("FIrst statement was not true"); } if(firstNum...
87d2b1d5-208f-4717-92e1-c9fd62e2e149
6
public int getMin(int start, int end) { if (this.start == start && this.end == end) return minVal; int mid = (this.start + this.end) / 2; if (mid >= start && mid >= end) return left.getMin(start, end); if (mid < start && mid < end) return right.getMin(start, end); return Math.min(left.getMin(start, m...
e0efdd8c-659f-47f6-a980-6482a893ab70
7
public static boolean ismetabolite(PathCaseNodeRole r) { return r == PathCaseNodeRole.SUBSTRATEORPRODUCT || r == PathCaseNodeRole.REGULATOR || r == PathCaseNodeRole.INHIBITOR || r == PathCaseNodeRole.ACTIVATOR || r == PathCaseNodeRole.COFACTOR || r == PathCaseNodeRole.COFACTORIN || r == PathCaseNodeRole.COFACTO...
d4c96909-36a7-40be-b3f2-13ba9624b17c
9
public void reset() { if (!refresher.isRunning()) refresher.start(); if (timer != null) timer.stop(); // Create players winDelay = false; playersLeft = playerNum; playerList = new ArrayList<Tank>(); for(int i = 0; i <= playerNum; i++) { switch(i) { case 1: createPlayer(Color.RED,...
b506ddab-8ae5-416e-ba58-81d0564549f3
2
public XMLLevelLoader() throws LevelLoaderException { initColorMap(); boxes = new ArrayList<BoxObject>(); playerPos = new Vector3f(); goalPos = new Vector3f(); ccolor = new Color(Color.WHITE); filename = null; cattributes = null; try { SAXParserFactory spf = SAXParserFactory.newInstance(); spf.se...
636999b1-2f22-41a9-9bf3-a1fb64ce2a97
8
public void upDateLocations(Drawable i) //Updates the locations of moving objects in the game and moves things to different sectors when needed. { i.setX(i.getX() + i.getVelocityX()); i.setY(i.getY() + i.getVelocityY()); if(i.getX() <= 0){ if(activeX !=0) { activeX--; setActiveSector(...
72eae324-245d-4379-bd07-73ae66cd9af7
1
@Override public int find(int p) { // The component to which p belongs is immediate from its component-id, // id[p] only if id[p] is the same as the vertex itself // Else the component-id is just a link in the path which leads to the // actual component-id while (id[p] != p) p = id[p]; return p; }
c71e200e-8486-4c79-96af-740092dfe5f4
3
boolean SetLcLpPb(int lc, int lp, int pb) { if ((lc > 8) || (lp > 4) || (pb > 4)) return false; m_LiteralDecoder.Create(lp, lc); int numPosStates = 1 << pb; m_LenDecoder.Create(numPosStates); m_RepLenDecoder.Create(numPosStates); m_PosStateMask = (numPosStates - 1); return true; }
e155f283-0f0b-456d-a780-95fe93651557
9
public int firstMissingPositive(int[] a) { if (a == null || a.length == 0) { return 1; } for (int i = 0; i < a.length; i++) { int num = a[i]; if (num > 0 && num < a.length && a[num - 1] != num) { a[i] = a[num - 1]; a[num - 1] ...
a88529b9-af0a-4057-9423-c364eb2a3792
0
public void playOverSound() { overClip.start(); }
826302d1-1b7f-417b-8f05-c51f670596fc
0
public void setMask(int mask) { this.mask = mask; }
aa36d242-5d75-4e9b-aff3-6263d490db31
8
public User(String u) throws FileNotFoundException{ Username = u; Scanner sc = new Scanner(new File("Users/" + Username + ".txt")); while(sc.hasNext()){ String text = sc.next(); if(text.equals("Password:")) Password = sc.next(); if(text.equals(...
ba20e336-93f2-4311-9acb-ac13105f844e
9
public FieldInfos(FieldInfo[] infos) { boolean hasVectors = false; boolean hasProx = false; boolean hasPayloads = false; boolean hasOffsets = false; boolean hasFreq = false; boolean hasNorms = false; boolean hasDocValues = false; boolean hasPointValues = false; TreeMap<Integer, ...
7c61a32d-a857-4c2e-9542-20b8b457448a
3
private float calculaVendasDoMes(List<Venda> vendas, int mes, int ano) { float vendasDoMes = 0; ListIterator<Venda> iteradorDeVendas = vendas.listIterator(); while( iteradorDeVendas.hasNext()) { Venda venda = iteradorDeVendas.next(); if( venda.getAno() == ano && venda.getMes() == mes) { v...
f8914a2b-e30e-4800-8a04-e79a3cad0a4a
8
public static TreeMap<String, Integer> getSystems(ArrayList<Kill> Kills) { TreeMap<String, Integer> output = new TreeMap<String, Integer>(); // the // output // result // (Name, // Number of // occurance) ArrayList<int[]> systemStats = new ArrayList<int[]>(); // (ID, number of ...
604ea333-adc7-4a56-8b98-07aae60c75ac
4
public double getAngle() { double angle; double rawAngle; // Let's avoid dividing by zero. if (_y == 0) { if (_x < 0) { angle = 3 * Math.PI / 2; } else { angle = Math.PI / 2; } ...
57a4da1c-3893-463a-b182-12235fb75c1f
1
private void loadManifestEntry(Element activity, String baseClass, String packageName) { if (activity.getAttribute("android:enabled").equals("false")) return; String className = activity.getAttribute("android:name"); entryPointsClasses.add(expandClassName(className)); }
fc00fd5c-d0b8-4e01-8e07-a4b2b91de01b
0
private void addToken (StringBuffer chunk, int type, String name) { tokens.add(chunk.toString()); tokenNames.add(name); tokenTypes.add(new Integer(type)); }
0aaee2d7-bc43-4b82-9c50-fb4d7d260f57
8
public static Cons javaTranslateDefineMethodUnit(TranslationUnit unit) { { Object old$Localgensymtable$000 = Stella.$LOCALGENSYMTABLE$.get(); Object old$Methodbeingwalked$000 = Stella.$METHODBEINGWALKED$.get(); Object old$Currentdummyindex$000 = Stella.$CURRENTDUMMYINDEX$.get(); Object old$Dummyde...
f58c9d35-b283-4f17-92d3-9aa84b1ec550
0
public static void main(String[] args) { launch(args); }
aa7ea466-9db3-4213-a522-0aa62deafa15
9
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if(!super.okMessage(myHost, msg)) return false; if((msg.source()==affected) &&(myListen != null) &&(msg.tool() == myListen) &&(msg.target() instanceof Room) &&(msg.target() != msg.source().location()) &&(CMLib.flags().i...
ef7a0582-34a1-415d-b6e7-9d3965a75cdf
4
public void act(){ if (clicked){ if (counter >= 10){ counter = 0; clicked = false; } else{ counter++; hoverCounter = 0; this.setImage (bg[2]); } } else if (selected){ ...
314ed36e-713f-401e-85dd-71d73d64c00d
1
public static TimerController getInstance(){ if(instance == null){ instance = new TimerController(); } return instance; }
ef7b6331-4e89-4d09-b1ce-c3ebb06c7ba0
5
public String toString() { StringBuilder sb = new StringBuilder(); // sb.append("Edges:"); // for (Edge<E> e : edges) { // Vertex<V>[] verts = endVertices(e); // sb.append(String.format(" (%s->%s, %s)", verts[0].getElement(), verts[1].getElement(), e.getElement())); // } // sb.append("\n...
c2645f50-a663-4435-8239-4bb3f77ddce4
4
public static boolean playerExists(String playerName){ try { SQL_STATEMENT = SQL_CONNECTION.createStatement(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { SQL_RESULTSET = SQL_STATEMENT.executeQuery("SELECT COUNT(*) AS rows FROM names WHERE username='" +...
9c6a49ca-d09f-47b0-bafd-fe3c0e21ec0c
8
private static Object[] getDefinition(Object classname, String key, String type) { Object currentname = classname; while (classname != null) { for (int i = 0; i < dtd.length; i += 3) { if (dtd[i] == classname) { Object[][] attributes = (Object[][]) dtd[i + 2]; if (attributes != null) { for (i...
cf0b31d2-63f4-4f77-97eb-a6a56e532afb
2
public SoundTester() { // Set JFrame properties this.setTitle(TITLE); this.setResizable(false); this.setSize(WIDTH, HEIGHT); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); // get content pane pane = this.getContentPane(); pane.setLayout(new FlowLa...
8b0d669f-67ec-4699-b7b2-050014c134a7
1
void init() { display = new Display(); shell = new Shell(display); shell.setText(TITLE_WITH_VERSION_AND_PATH); lockProgrammProcess(shell); try { shell.setImage(new Image(display, VermilionCascadeNotebook.class.getResourceAsStream("/images/logo.png"))); GridLayout gl = new GridLayout(1, false); gl....
cb95cbc5-3be7-4934-97ba-72d388c3d933
7
private boolean isObjectDependsOnDataset(final Data data) { if(data.isPlain()) { final AttributeType att = data.getAttributeType(); if(att instanceof ReferenceAttributeType) { final ReferenceAttributeType referenceAttributeType = (ReferenceAttributeType)att; if(referenceAttributeType.getReferenceType() ...
23b210f0-f722-481f-8941-f4969d6f3dec
2
public int isMember(String classname, String membername, int index) { MemberrefInfo minfo = (MemberrefInfo)getItem(index); if (getClassInfo(minfo.classIndex).equals(classname)) { NameAndTypeInfo ntinfo = (NameAndTypeInfo)getItem(minfo.nameAndTypeIndex); if (getUtf...
cbb3d5f3-bb81-4aed-a620-8fcbc0987dd3
2
public void syncUsers(ArrayList<NetworkSharedUser> users) { model.removeAllElements(); for(NetworkSharedUser u : Users.getUsersOnline()) { // We don't want to add ourself to the online list. if(u.getId() == thisUser.getId()) continue; model.addElement(u.getName()); } }
ef1a83c4-49f5-4d07-a5d9-90aa1047b054
4
private boolean jj_3R_10() { Token xsp; xsp = jj_scanpos; if (jj_3R_15()) { jj_scanpos = xsp; if (jj_3R_16()) { jj_scanpos = xsp; if (jj_3R_17()) { jj_scanpos = xsp; if (jj_3R_18()) return true; } } } return false; }
ca73b6e8-daee-4e43-9386-9b7abc088767
5
public void onAction(String name, boolean isPressed, float tpf) { if (isPressed && name.equals(KeyMapper.RELOAD_WEAPON)) { long tempTime = System.currentTimeMillis(); if (tempTime - 3000 > timeStamp) { timeStamp = tempTime; final List<Spatial> handChildr...
71f7e462-fc5f-448d-a4c1-b282cf76a346
6
@SuppressWarnings("rawtypes") public boolean equals(Object o) { if (this == o) return true; // Misma entidad if (!(o instanceof List)) return false; // Objetos incompatibles List list = (List) o; if (this.getSize() != list.getSize()); // Tamanos diferentes ListIterator i1 = this.iterator(); Lis...
cb5fdc1f-6576-4c4c-94a8-95107329ae54
5
public void alterar(Consulta consultaAnt) throws Exception { if(consultaAnt.getCodMedico() == null){ throw new Exception("Medico não foi selecionado !"); } if(consultaAnt.getCodPaciente() == null){ throw new Exception("Paciente não foi selecionado !"); } i...
2b6cbead-696c-4e6f-859c-10356ccfcbf8
0
@Test public void itShouldSerializeMultiPoint() throws Exception { MultiPoint multiPoint = new MultiPoint(new LngLatAlt(100, 0), new LngLatAlt(101, 1)); Assert.assertEquals("{\"coordinates\":[[100.0,0.0],[101.0,1.0]],\"type\":\"MultiPoint\"}", mapper.toJson(multiPoint)); }
fa419573-72fc-442e-b209-4b10f4a3a9fb
3
@Test public void WhenStaticRandomSelect_ExpectRefMaxHostsInResult() throws UnknownHostException { ArrayList<Host> list = new ArrayList<Host>(1); Host host0 = new PGridHost("127.0.0.1", 3333); Host host1 = new PGridHost("127.0.0.1", 1111); list.add(host0); list.ad...
6208636c-c5cc-45d7-bfd1-75e2099c6eec
2
public boolean isHomeCollision(int x, int y, home Home) { if (Home.x == x && Home.y == y) { return true; } return false; }
17bcce28-8ed9-469d-a75c-875eee95b83c
4
private boolean matches(Recreation r) { final int tA = r.type, tB = this.type ; if (tA == Recreation.TYPE_ANY || tB == Recreation.TYPE_ANY) return true ; if (client != null && client != r.actor()) return false ; return tA == tB ; }
f61279a9-1f82-4de4-b735-5803a2c7e835
0
public HeroClass getBossClass() { return bossclass; }
9533b929-a32c-4f47-b142-44ae457fa8b0
4
public static boolean isNumeric(String string) { if (string == null || string.length() == 0) return false; int l = string.length(); for (int i = 0; i < l; i++) { if (!Character.isDigit(string.codePointAt(i))) return false; } return true; ...
745f4a43-00e7-4234-9e8d-62d1cff7311c
4
private void cargaPorDefecto() { File f1 = new File(RUTA_CARGADO1), f2 = new File(RUTA_CARGADO2), f3 = new File(RUTA_CARGADO3); try { if (f1.exists()) { cargarDesdeCSV(f1.getAbsolutePath()); } else if (f2.exists()) { cargarDesdeCSV(f2.getAbsolutePa...
4f37b66c-f2a8-48db-9c5d-4011e208a00a
3
void scrollVertically(ScrollBar scrollBar) { if (image == null) return; Rectangle canvasBounds = imageCanvas.getClientArea(); int width = Math.round(imageData.width * xscale); int height = Math.round(imageData.height * yscale); if (height > canvasBounds.height) { // Only scroll if the image is bigger than ...
08eae09d-54f0-49f1-8478-b807829698fb
9
private void chainRecurse(Stack<ArrayList<Point>> visited, int score, WordBuilder wb) { if (Thread.currentThread().isInterrupted()) { return; } if (wb.grid.cellsRemaining() == 0) { score += 500; } wc.grid = wb.grid; Collections.sort(wb.buildWordList(), wc); if (Thread.currentThread().isInterrupted()...
a04d4836-1290-461a-88b1-5a7d8613f9a5
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...
d0618106-8309-45e6-8b95-e9432aeabc4a
5
private static Object parseJSONObj(Object obj) { Object result = null; if (obj == null) { // error return null; } else { if (obj instanceof JSONArray) { JSONArray arrayObj = (JSONArray) obj; List<Object> list = new ArrayList<Ob...
dd5969fe-d560-453a-ac64-28e537d07dc2
7
public void downToNext(){ try { if(allowedValue == null){ int n = this.getValue(); if(specialValue != null){ for(int i=specialValue.length; i>0; i--){ if(n > specialValue[i-1] && specialValue[i-1] % increment == 0){ setNormal(); setText(Integer.toString(specialValue[i-1])); retur...
efe1749c-5560-49c2-9926-93ffba025455
8
public MapReader(String mapName, int mapSize, InternalDisplay output) { this.mapChars = new char[mapSize][19][19]; this.playerInitialX = new int[mapSize]; this.playerInitialY = new int[mapSize]; this.androidInitialX = new int[mapSize]; this.androidInitialY = new int[mapSize]; this.output = output; for ...
69b674a7-e5cb-477c-bf61-af4cfc49f5a5
1
public static Article selectArticleById(int id) throws SQLException { String query; Article article = new Article(); ResultSet resultat; query = "SELECT * from ARTICLE where ID_ARTICLE=? "; PreparedStatement pStatement = ConnectionBDD.getInstance().getPreparedStatement...
a84145f1-0948-4d57-8075-15e4c8ebd6bf
8
public void parseCNFFormula(String file) { setRunning(true); setGlobalAction(GLOBAL_ACTION_LOAD_FORMULA); setCurrentAction(CURRENT_ACTION_LOAD_CLAUSES); formula = new CNFFormula(); testSuite = null; mutants.clear(); try { BufferedReader in = new Buffer...
0f549a9f-8d22-4d96-ad67-4d02153e2779
9
public void fire(){ if (currentForm!=4){ if(currentForm==-1){ if(timeSinceLastShot>laserFireRate){ timeSinceLastShot = 0; shots.add(new Projectile(imageLib,(ship.x + 5),(ship.y + ship.height)-13,0)); shots.add(new Projectile(imageLib, ship.x + 5, ship.y+7, 0)); } } else if(currentForm ==...
2ab3aec6-253b-465b-9105-763230e84de3
3
@Override public void logicUpdate(GameTime gameTime) { deleteRequiredLayers(); for (GameLayer gameLayer : gameLayers.values()) { if (gameLayer.currentState != GameLayer.GameLayerState.PAUSED) { gameLayer.logicUpdate(gameTime); // We poll this information to see if the game layer now wants // remove...
13d9f713-0c17-4129-ba48-dadab8032717
6
private static void readData() { try { b = new BufferedReader(new FileReader(fileDirectory + dataFile)); String line; while ((line = b.readLine()) != null) { String[] s = line.split(":"); int usr = Integer.parseInt(s[0]); int mov = Integer.parseInt(s[2]); int rat = Integer.parseInt(s[4]); ...
d7f175e6-b4ad-4bd8-a79b-18516f0bca4a
8
static void terminateBits(int numDataBytes, BitArray bits) throws WriterException { int capacity = numDataBytes << 3; if (bits.getSize() > capacity) { throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " > " + capacity); } for (int i = 0; i < 4 && bits.get...
a469ecbb-ecc6-4bda-9700-81e92daaed37
6
public void tv(){ /* * verificacao de seguranca. * se nao houver nenhuma canal na memoria secundaria. */ if(canais.isEmpty()) if(JOptionPane.showConfirmDialog(null, "\nSem canais registrados.\n\nAdicionar?","TV",JOptionPane.YES_NO_OPTION) == 0 ) ...
c7df94b7-ceb8-4de6-83d9-375f1505962b
9
@Override public boolean equals(Object obj) { if (obj instanceof Map.Entry<?,?>) { Map.Entry<?,?> entry = (Map.Entry<?,?>)obj; if (!key.equals(entry.getKey())) { return false; } Object entryValue = entry.getValue(); ...
b9119291-b264-4da9-bd59-535623e4a5d5
9
public void mouseReleased (MouseEvent e){ Container parent = e.getComponent().getParent(); if(SwingUtilities.isLeftMouseButton(e) && dragging && parent != null){ Rectangle bounds = e.getComponent().getBounds(); boolean setBounds = false; for (int i = 25; ...
b17a4652-f23c-4aaf-8688-5a7bff40c734
7
private void checkDependency( final SystemObject systemObject, final SystemObject dependencyObject, ConfigurationAreaDependencyKind dependencyKind) { // Abhängigkeiten nur speichern, wenn mindestens Version 9 des Metamodells vorliegt if(!_storeDependencies) return; if(systemObject == null || dependencyObject ...
9c67ea28-79ba-4cd9-a626-2d024033ffc3
1
public void setProgressBar(JComponent cmpt) { if (cmpt instanceof JProgressBar) progressBar = (JProgressBar)cmpt; else throw new IllegalArgumentException("Provided component was not a JProgressBar!"); }
d92fcc92-d406-4e21-acad-32d9637ed095
9
@Override public SourceValue unaryOperation(final AbstractInsnNode insn, final SourceValue value) { int size; switch (insn.getOpcode()) { case LNEG: case DNEG: case I2L: case I2D: case L2D: case F2L: case F2D: case D2L: ...
2bee2a2f-5554-4ebf-ad3e-b8c476da33f9
5
@Override public void paint(Graphics g) { g.setColor(Color.WHITE); g.fillRect(0, 0, getWidthGraph(), getHeightGraph()); g.setColor(Color.GRAY); try { double xfactor = getWidthGraph() / (xdh - xdl), yfactor = getHeightGraph() / (ydh - ydl); //a normalization factor. alway...
3e4c311f-0230-4595-8fba-6ce1fd85412c
3
private void printIf(Node t, int n) { if (t.getCdr().isNull()) { t.getCar().print(n+4, false); System.out.println(); if (n > 0) { for (int i = 0; i < n; i++) System.out.print(" "); } t.getCdr(...
d5855e16-a4e0-435e-9e07-8c96147c225b
9
public void run(){ try{ Message assignCmd = new Message(msgType.COMMAND); assignCmd.setCommandId(CommandType.ASSIGNID); assignCmd.setWorkerID(workerId); sendToWorker(assignCmd); Message workerMessage; System.out.println("manage...
d86723ab-f0ee-4722-a803-c7ad41f34206
5
@Override public void keyPressed(KeyEvent e) { System.out.println(e.getKeyCode()); switch(e.getKeyCode()){ case 37://left //Point pL = new Point(entity.getLocation().x-1,entity.getLocation().y-1); //ArrayDeque<Point> left = new ArrayDeque<Point>(); //left.add(pL); //testCanvas.moveUnit(entity,left); ...
87433100-a20b-4f3f-b656-8b44918621a3
5
public void validateQueueHead(String queueHead) { if(queueHead.isEmpty()) { System.out.println("NOOOOOOOOOOOOOOOOOOOOOOOOO, Ladder can not be made"); userInter.optionSelect(); } //looks at word after . removes full stop from wordQueue and removes first from parentlist if(queueHead =="." && parentsList....
2c7ec680-8616-423d-b9aa-e9d804318fe3
9
private void awardBiggestArmy(){ Player playerHasBA = players[0]; boolean hasEnough = true; for (Player p : players){ if (p.getArmy() > playerHasBA.getArmy()) playerHasBA=p; else if (p.getArmy() == playerHasBA.getArmy() && p.getHasBiggestArmy()) playerHasBA=p; } if (playerHasBA.getArmy()<3) hasEnough =...
3d938eaf-3148-4f66-a128-be913af9ffc0
4
public static void main(String[] args) { long sum = 0; if(args.length == 0) { for(File file : Directory.walk(".").files) { System.out.print(file + ": "); System.out.println(file.length()); sum += file.length(); } } else { ...
8a457149-02bc-45a1-95e9-57cbccda99dc
5
private static Register.Width join(Register.Width lhs, Register.Width rhs) { if(lhs == rhs) { return lhs; } else if(lhs == Width.ScalarDouble) { return join(Width.Quad,rhs); } else if(lhs == Width.ScalarSingle) { return join(Width.Long,rhs); } else if(rhs == Width.ScalarDouble) { return join(lhs,Wi...
5871c89b-4584-481e-91b0-cbe699a2dc64
1
public String closeAlertAndGetItsText() { try { Alert alert = driver.switchTo().alert(); if (acceptNextAlert) { alert.accept(); } else { alert.dismiss(); } return alert.get...
6e7bbff4-090c-47a8-8c58-9322d9eab297
3
public ResultSet retrieveLoginPageData() throws SQLException{ try{ databaseConnector=myConnector.getConnection(); stmnt=(Statement)databaseConnector.createStatement(); SQLQuery="SELECT * FROM familydoctor.loginpage"; System.out.println(SQLQuery); ...
9847c235-ac38-4a5c-9a5f-fd09ad910263
4
@Override public Response list(ListRequest request) throws IOException { //STAGE3 Mac hmac=null; try { hmac = Mac.getInstance("HmacSHA256"); } catch (NoSuchAlgorithmException e) { System.err.println("NoSuchAlgorithmException (HmacSHA256 not valid): " + e.getMessage()); return new HmacErrorResponse("In...
01d3b685-a049-4758-8887-30591fb87e7a
2
public String getPIDByCoordinate(Statement statement,Double longitude,Double latitude)//根据坐标获取PID { String result = null; sql = "select PID from Park where longitude = '" + longitude +"' and latitude = '"+latitude+"'"; try { ResultSet rs = statement.executeQuery(sql); while (rs.next()) { result = rs...
ae85746a-4054-4b00-90f6-e4ab1074e5a7
7
public static Rectangle parseLoadRect(String data){ Rectangle rect = new Rectangle(); Point pt; boolean ptSet = false; boolean dimSet = false; for (String l : data.split("\n")){ if (l.matches("pt +\\([0-9]+, ?[0-9]+\\)")){ pt = parsePoint(l.substring(l.indexOf("("), l.indexOf(")")+1)); rect.setLoca...
0484dc9d-9fff-49ef-ae67-41d20c7c5ec0
8
@Override public void initialize(Problem P) { double [] opt_values = null; double opt_cost = Double.NaN; try { unknowns = P.get_unique_unknowns(); int num_unknowns = unknowns.size(); // Create a problem lp_solver = LpSolve.makeLp(0,num_unkn...
4bafb866-7265-469c-8d28-843a6f75094c
6
private DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir){ String currentDirectory; // try{ currentDirectory = destinationDir.getPath(); // }catch(IOException e){ // currentDirectory = "no such directory"; // } DefaultMutableTreeNode ...
90148af9-91c6-4f48-ac37-9d3ea5f6dba3
1
@Override public Collection<String> getThisPageFiles() { Collection <String> fileset = new LinkedList<String>(); try { fileset.add( getChildrenSaveTo() ); } catch (IOException e) { } return fileset; }
99e3056e-01fb-4967-a9f4-f36b309fe960
5
protected int findKey(int key, boolean include) { int index = 0; int size = getSize(); BufferView dataView = getDataView(); for(; index < size; index ++) { int current = dataView.getInt(8 * index); if((include && current >= key) || (!include && current > key)) { break; } } dataView.close(); r...
ea733e98-7d78-4ca9-ab46-0e4a3c21a5b0
0
public boolean getIsFaceUp() { return isFaceUp; //You may need to change this }
d0e352da-f7be-4ff3-afa7-443baba33301
2
public void Ringtone() { try { Synthesizer synthesizer = MidiSystem.getSynthesizer(); synthesizer.open(); MidiChannel[] channels = synthesizer.getChannels(); int one = 90; int two = 110; for(int i=0; i<100; i++) { channels[0].noteOn(one, one); Thread.sleep(50); channels[0].noteOn(two, tw...
fd6ad3b8-58e6-4832-b422-ea7f5dc5cd23
0
private void closeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeBtnActionPerformed this.dispose(); }//GEN-LAST:event_closeBtnActionPerformed
e03e2fc3-71dd-417e-84ec-3cc221f763dd
4
public boolean isQueryInformationValid(Server sv) { loadFromServer(server); String temp = ""; try { temp = queryServer(); if(temp == null || temp.isEmpty()) { return false; } } catch (IOException e) { e.printStackTrace(); } if (temp.contains("disconnected")) { return false; } return t...
4ce1047f-1c28-4576-bafb-71f6cd091265
7
public void syncSingleFile(String fileName, FileOperation fileOperation, TextProcessor textProcessor) { byte operation = fileOperation.operation; long fileLastModifiedTime = fileOperation.file.lastModified(); long fileSize = fileOperation.file.length(); boolean isDir = fileOperation.file...
8b920fd0-fa37-4ec9-86a0-a029530d6ddb
8
public void compExecTime() { double newExeTime; double newCost; dEval = 0; dTime = 0; dCost = 0; for (int i = 0; i < iClass; i++) { newExeTime = 0; System.out.print("Cost[" + i + "]"); for (int j = 0; j < iSite; j++) { if (dmAlloc[i][j] != -1) { if (dmAlloc[i][j] < 1) { newExeTime = ...
333c8fb3-fbd5-46e5-b887-11f098a7fdc5
2
public static void main(String s[]) { String X = "ABCABBA"; String Y = "CBABACA"; BULCS bu = new BULCS(X, Y); for (int i = 0; i < X.length(); i++) { for (int j = 0; j < Y.length(); j++) System.out.print(bu.getLength(i, j) + " "); System.out.println(); } /* * for (int i = 0; i < X.length(); ...
eb8fb0b7-1cc2-4245-b7e0-2ad5d9d6d97a
5
protected void startBroadMessage(){ while(noStopRequested){ try{ Response msg = broadMessages.take();//获取广播消息 Iterator<Client> it = this.clients.values().iterator(); boolean isCode = false; while(it.hasNext()){ //log.info(msg.getBody()); Client socketer = it.next(); if(!isCode){...
4e019d6c-12fe-40ee-8681-08074e52d007
3
private int getItemStackIndexBackwards(Item item) { int ID = item.getID(); ItemStack stack; for (int i = items.size() - 1; i >= 0; i--) { stack = items.get(i); if (stack.getItemInStackID() == ID && stack.getAmount() <= stack.getMaxStackSize()) return i; ...
4b5faab6-f80e-4c56-bff8-07a6dce755a3
1
public void stopMovement() { if (moving) { setXD(0); setYD(0); step = 0; moving = false; t.cancel(); t.purge(); timerStarted = false; } }
1039445c-a6bf-4360-9e3d-2f76feb648c4
2
protected void execute() { double left = Robot.driveTrain.getLeftDistance(), right = Robot.driveTrain.getRightDistance(); if(Math.abs(_goal-left) > Math.abs(_goal-right)) { _dist = left; } else { _dist = right; } ...
b65d226d-ee2a-4607-9ec7-1f01df630317
6
private void logicalOr(LogicalOr lop) { for(Predicate p : lop.getPredicates()) { if(p instanceof BinaryContains) { // ignore them for the time being } else if(p instanceof Contains) { this.addToCount(((Contains) p).getA().getName(), 1); return; } else if(p instanceof Exactly) { this.addToCoun...