method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
2d219d9d-643c-4df4-9b79-d0c028184e3d
7
@Override public void paintComponent(Graphics g){ Graphics2D g2 = (Graphics2D) g; drawBackground(g2); for(Sprite sprite : sprites) if(sprite.isLayered()) sprite.draw(g2); for(Sprite sprite : sprites) if(!sprite.isLayered())sprite.draw(g2); for(Sprite s...
6cca83d8-b58b-44b9-8fa9-41751b668d87
7
public void visitIfCmpStmt(final IfCmpStmt stmt) { print("if ("); stmt.left().visit(this); print(" "); switch (stmt.comparison()) { case IfStmt.EQ: print("=="); break; case IfStmt.NE: print("!="); break; case IfStmt.GT: print(">"); break; case IfStmt.GE: print(">="); break; ca...
74d01981-5d2d-4945-afef-49cd15c9f3b0
1
public static BoardLoader getInstance() { if (instance == null) { instance = new BoardLoader(); } return instance; }
d66cf7db-c365-4451-8385-cd26c5352e37
7
public void isPossible(final int[] code) { // Creates a new thread thread = new Thread(new Runnable() { @Override public void run() { // Checks if there are no Inputs. if (mastermind.getRowSize() == 0) { ...
6e372cc0-fecb-4bcf-954d-80c54fc568cd
8
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (! request.getParameterMap().isEmpty()) { List<String> fouten = new ArrayList<>(); BigDecimal van = null; try { van = new BigDecimal(request.getParameter("van")); } catch (Numbe...
0522b455-728b-45a1-aa2d-f83229b6e347
0
public static NamesManager getInstance() { return instance; }
7ce8012b-aebb-482a-a0fa-faad6aca4d56
5
private void setCurrentElement(PhysicsElement e) { if (currentElement != null) { currentElement.setReleased(); currentElement = null; } if (e != null) { currentElement = e; currentElement.setSelected(); if (currentElement instanceof Ball) { ...
242f696c-229f-4cb0-b24f-16675edbf3dd
2
public void play() { try { if (clip != null) { new Thread() { public void run() { synchronized (clip) { clip.stop(); clip.setFramePosition(0); clip.start(); } } }.start(); } } catch (Exception e) { System.out.println(e); } }
91f8ca3a-d1ee-40b6-a4e7-5352eaa51903
8
private static String trimSpacesAndNulls(String value) { int len = value.length(); int st = 0; while ((st < len) && (value.charAt(st) == ' ' || value.charAt(st) == 0 )) { st++; } while ((st < len) && (value.charAt(len - 1) == ' ' || value.charAt(len - 1) == 0)) { ...
f5a87839-1b71-47e9-9d13-95a0d9da12c3
5
@Override public void updateInputMap() { System.out.println("Uppdaterar Inputs"); final Action menuUp = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (currentOption > 0) currentOption--; } }; final Action menuDown = new AbstractAction() { @Override pub...
5cc9132f-e402-4260-841f-539a37f13206
5
public final void setOnline(final int cid, final boolean online, final int channel) { boolean bBroadcast = true; for (final MapleGuildCharacter mgc : members) { if (mgc.getId() == cid) { if (mgc.isOnline() && online) { bBroadcast = false; } mgc.setOnline(online); mgc.setChannel((byte) channel); ...
36dd5075-0237-4574-80dd-a7e579a7ad5e
4
private int hasInfo() { if (strings == null) { return 1; //return this.size(); } int infos = 0; for (String value : strings) { if (value != null && !value.matches(spaceRegex)) infos++; } return infos; }
ede5113c-9042-4385-8a9a-47b60fde493b
8
private void dhcpResponse(){ int responseTime = -1; // create request packet LOG.info("create request packet"); byte[] requestMessage = createRequestMessage(); DatagramPacket requestPacket = null; try { requestPacket = new DatagramPacket(requestMessage, ...
870438b3-738d-49e4-b336-13fe43e966d6
0
public static void expandEverything(JoeTree tree) { tree.getRootNode().ExpandAllSubheads(); tree.getDocument().panel.layout.redraw(); return; }
4e689953-a9c9-4efa-876a-be0ee1503b18
8
public void setActivePanel(final PanelType type) { if (this.frame != null) { this.frame.dispose(); } switch (type) { case START: this.frame = new PlainPanel(this.sfb, SWT.FILL, CompositeBrick.DEFAULT); break; case CLUBS: this.frame = new ClubPanel(this.sfb, SWT.FILL, CompositeBrick.DEFAULT); ...
5f4da03f-9f72-4ce6-8b2e-6e740333d225
6
private final void setLeaves() { if (daughterNodes.size() > 0) for (Node n : daughterNodes) n.setLeaves(); else { isLeaf = true; for (Point p : leafLocations) if (p.x == (int) x && p.y == (int) y) isLeaf = false; if ...
b10248cf-b0ca-4788-b6bd-de06600089bb
9
public MethodHelper(Class<?> clazz) { Method[] methods = clazz.getMethods(); for(Method method : methods) { if(method.getParameterTypes().length != 0) continue; if(method.getReturnType().equals(Void.TYPE)) continue; if(method.getDeclaringClass().equals(Object.class)) continue; String property = keyForMe...
32f9f781-417c-46a9-83a9-e5ef2e8c38ac
9
private void discoverAndIntimateForClassAnnotations (ClassFile classFile, boolean visible, boolean invisible) { Set<Annotation> annotations = new HashSet<Annotation>(); if (visible) { AnnotationsAttribute visibleA = (AnnotationsAttribute) classFile.getAttribute(AnnotationsAttribute.visibleT...
02cdea92-2149-417b-b58a-ed64bc28a210
3
private final void copy() { final int length = length(); if (this.tail < this.head) { System.arraycopy(this.content[this.cIdx], this.head, this.content[this.cIdxNext], StringBuilder.PATTERN_SIZE, length - this.tail); System.arraycopy(this.content[this.cIdx], 0, this.content[this.cIdxNext], (len...
6fa53a30-d252-4336-9883-aaa2762486b9
4
public boolean isOrInheritsFrom(String parent_id) { if(id.equals(parent_id)) return true; else if(parents.size() != 0) { for(int i = 0; i < parents.size(); ++i) { if(parents.get(i).isOrInheritsFrom(parent_id)) return true; } return false; } else return false; }
98586c38-7194-4ea7-bb32-11af276346fe
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 Answer)) { return false; } Answer other = (Answer) object; if ((this.idAnswer == null && other.idAnswer != null...
026224e3-48c0-4659-a82f-6fc1517c705c
8
public void stop() { // Pass on to upstream beans if (m_trainingProvider != null && m_trainingProvider instanceof BeanCommon) { ((BeanCommon)m_trainingProvider).stop(); } if (m_testProvider != null && m_testProvider instanceof BeanCommon) { ((BeanCommon)m_testProvider).stop(); } ...
e3d7089f-bbe8-4a5f-9550-147b6ddbba63
2
public Set<Vehicule> getVehiculesDisponibles(){ System.out.println("ModeleLocations::getVehiculesDisponibles()") ; Set<Vehicule> vehiculesDisponibles = new HashSet<Vehicule>() ; for(Vehicule vehicule : this.vehicules){ if(vehicule.estDisponible()){ vehiculesDisponibles.add(vehicule) ; } } return veh...
7cda2ff7-b465-49a7-9263-65c8836ca808
8
public static void main(String[] args) { int n = scn.nextInt(); int tc = 0; while (n != 0) { // Create the nodes and put them in the map Point[] points = new Point[n + 1]; for (int i = 1; i <= n; i++) { points[i] = new Point(i); } // The starting point int s = sc...
69392623-5f57-4efb-8750-fcf5cdaab1e3
1
public void testToStandardMinutes() { Weeks test = Weeks.weeks(2); Minutes expected = Minutes.minutes(2 * 7 * 24 * 60); assertEquals(expected, test.toStandardMinutes()); try { Weeks.MAX_VALUE.toStandardMinutes(); fail(); } catch (ArithmeticExcepti...
b9181c4e-eb23-47d4-89d3-6e9d94e9990d
0
public static void main(String[] args) { float float_pi = 3.145926535897896F; double double_pi = 3.145926535897896D; System.out.println(float_pi); // 3.1459265 System.out.println(double_pi); // 3.145926535897896 }
343895ec-b8ca-4506-9029-054f6dd31f06
3
private void showTrigDialog(Account acc) { Account selectedAccount = acc; TriggerDialog diag = new TriggerDialog(shell, shell.getStyle(), acc, mySelf); shell.setEnabled(false); diag.open(); // Check if the account still exists Boolean deleted = true; for (Account a : FkManager.getInstance().getList(...
1e1bd73d-0772-497b-8101-0e4e2155ef17
5
@Override public void update(Observable o, Object arg) { String sender = o.getClass().getName(); System.out.println("Board received ["+ arg +"] from ["+ sender +"]"); if (sender.equals("Core.List")) { String message = (String) arg; // On transmet la notification pour les plugins // Seulement si le ...
425d05cc-63b3-49d6-b4ca-1bcfc3620ce4
6
public static void close(Connection conn,Statement statement,ResultSet reSet){ if(reSet!=null){ try { reSet.close(); } catch (Exception e) { e.printStackTrace(); }finally{ /* 手动将其引用指向null,java的内存清理机制最终会对其清除 */ reSet = null; } } if(statement!=null){ try { statement.close();...
4fae25d2-5029-48dd-b4a7-2dec263e5f23
5
synchronized public static void write() { FileOutputStream fosTmp = null; Properties props = new Properties(); try { for(Field fld: EzimConf.class.getFields()) { EzimSetting setting = fld.getAnnotation(EzimSetting.class); if (null == setting) continue; props.setProperty(setting.name(), fl...
0e1eafa8-c251-4b52-a490-d74bfe278f3a
5
private boolean isHexDigit() { return current >= '0' && current <= '9' || current >= 'a' && current <= 'f' || current >= 'A' && current <= 'F'; }
b7d70a0c-0416-4ef2-849b-cf1599e0c03c
4
public Tower getTower(){ int ID = (id-1) / 3; int level = (id-1) % 3 + 1; Tower t; if (ID == 0){ //air t = new AirTower(); }else if (ID == 1){ //water t = new WaterTower(); }else if (ID == 2){ //fire t = new FireTower(...
e9689487-9622-4bf0-9244-b2c89cf3d564
9
public TileMap createExampleMap() { int size = Configuration.getInstance().getValueAsInt("mapSize"); TileMap tileMap = new TileMap(size, size); FloorCellFactory floorCellFactory = GameFactories.getInstance().getFloorCellFactory(); FloorCell earth = floorCellFactory.getFloorCell("earth"); FloorCell grass = fl...
f7c67e0a-0690-489b-ab57-dbc5785c5bb2
3
private boolean hasLocalArrayListFlavor(DataFlavor[] arrDfIn) { if (this.dfLocal == null) return false; for(int iCnt = 0; iCnt < arrDfIn.length; iCnt ++) { if (arrDfIn[iCnt].equals(this.dfLocal)) return true; } return false; }
aaf4382d-aa3b-42d9-92c9-52fd92945a94
9
public int newLocal(final Type type) { Object t; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: t = Opcodes.INTEGER; break; case Type.FLOAT: t = Opcodes.FLOAT...
f2df25b8-5cc4-4e02-b019-ab9f6d5dadf8
1
public static void main(String[] args) { server1.start(); server2.start(); HB.start(); try {filerdr();} catch (IOException e) {e.printStackTrace();} }
f354c62e-f4cc-42cc-8022-096fc9cc9946
8
private boolean rotation(int rotation) { boolean colision = false; Vecteur<Integer> temp = new Vecteur(); if (rotation != 0) { if (rotation == -1) { courante.rotCW(); } else if (rotation == 1) { courante.rotACW(); } ...
4547de2f-9439-4cd6-85f5-551e3ccda430
7
public static void writeMap(Map paramMap, OutputStream paramOutputStream) throws IOException { Dimension localDimension = paramMap.getSize(); ObjectOutputStream localObjectOutputStream; if ((paramOutputStream instanceof ObjectOutput)) localObjectOutputStream = (ObjectOutputStream)paramOutputStream; ...
3ec3df9c-7c6e-4286-b4ad-c1ea51767d0a
2
public boolean charsAtEqual(ArrayList<String> file, int index, int num, String[] chars) { for (int j=0; j<chars.length; ++j){ if(charAtEquals(file, index, num, chars[j])) { return true; } // end if } // end for return false; }
d31f0d58-5ba4-4498-a09e-f70eb17dc576
4
@Override public boolean click(int mx, int my, boolean click) { if (mouseIn(mx, my)) { if(click) { if(preClick) { if (!clicked) { clicked = true; return true; } clicked = true; return false; } return false; } preClick = true; mouseOver = true; ...
d029a87f-63b9-406a-99a6-2984f6dee025
3
private void distribute(Msg msg_, int flags_) { // If there are no matching pipes available, simply drop the message. if (matching == 0) { return; } for (int i = 0; i < matching; ++i) if(!write (pipes.get(i), msg_)) --i; // Retry last wr...
3cd5e338-d88d-4455-bbd8-1ee0091aa707
7
private int writeBankJumpPointer(BufferedWriter bw, int curAddress, int end) throws Throwable { for(;rom.type[curAddress] == ROM.DATA_BANKJUMPPOINTER && curAddress < end;curAddress+=3) { addLabel(bw, curAddress); String bankString = "$"+Integer.toHexString(rom.data[curAddress] & 0xFF); String da...
428d7d24-2116-468d-be9c-199b9c1cf003
4
public static double calculateCosineSimilarity(Double[] ratingsOne, Double[] ratingsTwo) { double enumerator = 0, denominatorOne = 0, denominatorTwo = 0; for (int i = 0; i < ratingsOne.length; i++) { enumerator += ratingsOne[i] * ratingsTwo[i]; denominatorOne += Math.pow(ratingsOne[i], 2); denominatorTwo ...
6e575e90-6b1c-4d10-bacb-36a1016f4b62
8
public void renderSprite(double x, double y, double z, double yOff, int[] pix) { int spriteSize = h / 2; double upco = -0.125; double rightco = 0.125; double forwardco = 0.125; double walkco = 0.0625; double xc = ((x / 2) - (right * rightco)) * 2 + 0.5; double yc ...
b2236b20-d752-4029-b434-a920362207ea
4
public void updateStatus() { try { if (_leftFrontMotor != null) { SmartDashboard.putNumber("Left Front Jaguar", _leftFrontMotor.getOutputVoltage()); SmartDashboard.putNumber("Left Front Current", _leftFrontMotor.getOutputCurrent()); } ...
b24e5f7b-64f1-4793-b19f-6d72f98d9ad6
3
private void encrypt(String pass) { try { byte[] utf8 = pass.getBytes("UTF8"); byte[] enc = this.encrypter.doFinal(utf8); this.setEncryptedPass(Base64.encode(enc)); } catch (javax.crypto.BadPaddingException e) { } catch (IllegalBlockSizeException e) { } catch (UnsupportedEncodingException e) { } }
db6983e8-74a1-48df-afad-dfcb4e38d4ac
9
private boolean checkCreditsInputs() { //first check if the user has entered text to be overlaid if (creditText.getText().equals("")) { JOptionPane.showMessageDialog(null, "Please enter text to overlay on video", "Missing Input", JOptionPane.WARNING_MESSAGE); //otherwise if text has been entered, continue...
49776330-b429-4df1-9390-c0c2fb47f2f1
3
@Override protected Class<?> loadClass(String name, boolean resolve) { try { if ("fruit.sim.Player".equals(name)) return parent.loadClass(name); else return super.loadClass(name, resolve); } catch (ClassNotFoundException e) { re...
ce06ae6b-e71b-4859-98cc-f63555277e2f
2
public void crearBD(String nombreBD) { try { // Abre la base de datos para realizar operaciones en ella this.bd = SqlJetDb.open(new File(nombreBD), true); this.bd.getOptions().setAutovacuum(true); // Esta función hace que las operaciones a realizar se...
9e8ea43a-1fef-44ae-a533-c8c931e2ef2a
0
public CGIExecute(String binPath) { cgiApp = new ProcessBuilder(binPath); }
e41d77a4-ec1b-4527-94d4-2fe33d5eb79c
5
private static boolean[] primeBoolArray(int limit) { boolean[] nums = new boolean[limit]; for (int i = 2; i < nums.length; i++) nums[i] = true; int nextPrime = 2; while (nextPrime < nums.length / 2) { int i = nextPrime; for (; i < nums.length; i += nextPrime) nums[i] = false; nums[nextPrime] = t...
2d46bd3f-d93e-4a0d-9837-e4ba53c31a9b
7
@Override public void paintRow(Graphics2D g2d, int row, int firstCol, int lastCol, int x, int y, int cellWidth, int rowHeight) { Sequence seq = currentSG.get(row); setCellSize(cellWidth, rowHeight); g2d.setFont(font); List<SequenceAnnotation> orfs = seq.getAnnotationsByType(Simpl...
1c4a80a3-f760-4e93-a2e4-607ceb5ad5db
8
private String getText(BufferedReader reader) { String finishedText = ""; String s = ""; StringBuilder sb = new StringBuilder(); while (s != null && !s.contains("<div class=\"csc-textpic-text\">")) { //go to the text passage in the html-code try { s = reader....
b642e9c1-9378-48ec-8e45-61f1f3a529c2
9
private static void debugInfo() { String cv = "kFold: " + cf.getInt("num.kfold") + (cf.isOn("is.parallel.folds") ? " [Parallel]" : " [Singleton]"); float ratio = (float) cf.getDouble("val.ratio"); int givenN = cf.getInt("num.given.n"); float givenRatio = cf.getFloat("val.given.ratio"); String cvInfo = c...
fee352c5-dadc-432e-ae1a-3bba30743dee
6
public static Matrice createSubMatrix(Matrice matrix, int excluding_row, int excluding_col) { Matrice mat; if(excluding_row==-1) mat = new Matrice(matrix.getNbLines(), matrix.getNbColumns()-1); else if(excluding_col==-1) mat = new Matrice(matr...
596f02af-d1de-418c-9320-f59cb6a8a06a
0
public void setPreference(Preference pref) { this.pref = pref; }
31f0ab61-fe55-444a-8174-a8baab6c7fad
1
public void printOverzicht(){ int i = 1; for (Huisdier dier : lijst){ System.out.println("Naam dier" + i + ": " + dier.getNaam()); i ++; } }
fd0a9c47-e457-45c0-8c57-f672ffb6cd31
9
public static void test3(){ try { InputStream returnStream = null; HttpsURLConnection conn = null; int connectTimeout=15000; int readTimeout=30000; String requestMethod="GET"; String charEncode="utf-8"; String url="https...
275ed65b-dd2d-4e65-a6cb-1e9680433f53
2
@RequestMapping(value = {"/SucursalesBancarias"}, method = RequestMethod.GET) public void readAll(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse) { try { ObjectMapper jackson = new ObjectMapper(); String json = jackson.writeValueAsString(sucursalBancariaDAO.f...
5f5f681a-cc2b-49e6-b26a-cd6186d7b95d
4
@Test public void testProfileCrudUsingCard() throws BeanstreamApiException { String profileId = null; try { Address billing = getTestCardValidAddress(); Card card = getTestCard(); // test create profile ProfileResponse createdProfile = beanstream.profiles() .createProfile(card, billing); profil...
9ec3c4e8-c1ac-4de9-a6b0-aaa529989c13
9
private boolean check(FlowNetwork G, int s, int t) { // check that flow is feasible if (!isFeasible(G, s, t)) { System.err.println("Flow is infeasible"); return false; } // check that s is on the source side of min cut and that t is not on // source side...
c3a47330-cd83-4e33-a8a6-884472a851d4
7
public Integer getInf( int field, Boolean net ) { try { switch ( field) { case ALLOCATED: if ( net ) { return (int) (mInflation * mNetAllocated); } else { return (int) (mInflation * mGrossAllocated); } case REVISED: if ( net ) { return (int) (mInflation * mNetRevised); } els...
19a1ce63-3873-4442-9b6b-ec91daec9664
0
public int GetSequenceNumber() { return sequence; }
a8341d09-3b65-45d3-a363-ad27b2dcea06
2
@Test public void testBuyDevCard() { //me BuyDevCardRequest request=new BuyDevCardRequest(0); ServerModel aGame=gamesList.get(2); cookie=new CookieParams("Bobby", "bobby", 0, 2); int playerNewCards=aGame.getPlayers().get(0).getNewDevCards().getTotalDevCardCount(); int playerOldCards=aGame.getPlayers().get(...
69728148-7ab9-4923-8eab-d1185b437fdd
1
private void deletePlaylist() { try { int id; System.out.println("Enter id: "); showPlaylists(); id = Keyboard.readInt(); BEPlaylist aPlaylist = new BEPlaylist(id); BLLPlaylist ds = new BLLPlaylist(); ds.deletePlaylist(aPlay...
142ae5e2-a814-4126-9872-04065bbbadd3
0
public Problem getProblem() { return problem; }
7ace88fc-1d04-43ae-8944-8ffc8e40a68c
9
public List<Token> postProcess(List<Token> tokens) { if (tokens.size() == 0) { return tokens; } List<Token> newTokens = new ArrayList<Token>(); Token prevToken = null; Rule currentRule = null; outer_loop: for (int i = 0; i < tokens.size(); i++) { Token token = tokens.get(i); if (currentRule != nu...
8d606089-f7e1-431d-ab3e-0855acd18c4f
6
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { config = plugin.getConfig(); if (args.length == 1 ){ if (sender instanceof Player) { if (sender.hasPermission("darkcommand.kiss")){ if (commandLabel.equalsIgnoreCase("kiss")){ Player player = (Player)...
9ecb1a3c-2c18-4dde-a8cc-3777007defc4
4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AbstractComponent other = (AbstractComponent) obj; if (type != other.type) return false; return true; }
c17beb74-4288-4e33-a41a-303b0524e963
7
@Override public Bean parse(String filename) { Bean newBean = new Bean(); String[] splited; // lecture du fichier texte try { InputStream ips = new FileInputStream(filename); InputStreamReader ipsr = new InputStreamReader(ips); BufferedReader br = new BufferedReader(ipsr); String ligne; int i =...
6a4458b7-81a4-4275-b28f-357ad951db0c
8
public static boolean updateList() { // Download mod list if (modList.exists()) { System.out.print("Backing up mod List\n"); try { if (oldList.exists()) { FileManager.deleteFile(FileManager.updaterDir, "/...
72a11ef2-eb08-499c-8f46-62e2d876aab9
1
@Override public void update() { super.update(); if (jumpCounter > 0) { dy = -3; --jumpCounter; } }
ece53c9c-de9a-4827-9be3-74e048312edb
1
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { ManagerReport frame = new ManagerReport(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
abe15549-d062-44ac-9783-e068bab3ecf7
4
@Override public IEmailKontakt first() throws NoEmailKontaktFoundException { System.out.println("Display first contact..."); Connection con = null; try { con = initDBConnection(); } catch (SQLException e) { e.printStackTrace(); } ResultSet rs = null; Statement stmt = null; EmailKontakt ek = new E...
c00e1959-b0f9-4b84-a643-7f51a6077c13
0
public ControleurDeuxJoueurs(ModeleDeuxJoueurs _plateaux) { super(_plateaux.getPlateau1()); plateau2 = _plateaux.getPlateau2(); }
9847bf98-2e19-4add-9b79-497df900a10c
0
private void init() { input.clear(); cache.clear(); ; }
47928a36-061c-4649-9136-d2f9f63458ee
2
public IOClient(Socket client, PacketManager pm) { if (client == null) return; this.client = client; this.pm = pm; try { writer = new PrintStream(client.getOutputStream()); //writer.flush(); reader = new DataInputStream(client.getInputStream()); } catch (IOException e) { pm.server.Log("Error");...
2ada44cb-cf56-4f35-b53a-5cc2c916b021
1
public void advancePlayer(){ this.currentPlayer.setSelected(false); //if the list is at the end, reset if(list.lastIndexOf(currentPlayer) == list.size() - 1){ this.currentPlayer = list.get(0); //otherwise, go forward } else { this.currentPlayer = list.g...
8f8cd6fe-60f3-4978-a2a0-5aafc067d5f1
9
public static String rot13(String input) { StringBuilder output = new StringBuilder(); for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c >= 'a' && c <= 'm') { c += 13; } else if (c >= 'A' && c <= 'M') { c += 13;...
ca5c37c1-e11c-4171-a9e7-6be2a4d7e79e
0
@Test public void testInvokeZeroArgMethod() { Bean bean = new Bean(); Assert.assertNull(ReflectUtils.invokeZeroArgMethod(bean, "voidMethod")); Assert.assertEquals( "public", ReflectUtils.invokeZeroArgMethod(bean, "publicMethod") ); Assert....
c017f4bc-af26-4d16-8fd0-a8872fa72e08
1
@Test public void testNextGreaterPowerOf2() { logger.info("nextGreaterPowerOf2"); int[] number = {0, 1,2, 3,4, 5,6,7,8, 9,10,11,12,13,14,15,16,17,18,19,20}; int[] expResult = {1, 1,2, 4,4, 8,8,8,8, 16,16,16,16,16,16,16,16,32,32,32,32}; for (int i = 0; i < number.lengt...
a8074f26-2d18-4155-bdb6-213fea076bc8
5
public void getData( Config config ) { try { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); saveData.dataInfo.encode = "UTF-8"; saveData.dataInfo.language = "中文"; saveData.dataInfo.crawlDate = dateFormat.format(new Date()); for (Rea...
6cb350f4-559e-493b-97a7-8c3d5538432f
0
public CoffeescriptPartitionScanner() { IToken commentToken = new Token(COMMENT); IToken stringToken = new Token(STRING); List<IPredicateRule> rules = new ArrayList<IPredicateRule>(); rules.add( new MultiLineRule("###", "###", commentToken) ); rules.add( new EndOfLineRule("#" , commentToken) ); ...
15a71a3f-a609-43b3-be61-6639b8f0b743
4
@Test /** * D'après les resultats obtenus, on peut affirmer que l'alea mis en place est correct. */ public void testDistribution() { double[] matrix; int size = 100000; int taille = 8; double[] somme = new double[taille]; for (int i = 0; i < taille; i++) { ...
583b5c3f-7224-46ba-8723-e8be1865bce4
8
public static void loadUnitPropetries(JsonReader reader, Unit unit) throws IOException { while (reader.peek() == JsonToken.NAME) { String name = reader.nextName(); if ("i".equals(name)) unit.i = reader.nextInt(); else if ("j".equals(name)) unit.j = reader.nextInt(); else if ("health".equals(nam...
2a9ce7d3-893e-4141-bef5-f84f4745f638
8
public boolean userExists(String userName) { // inserted this pseudo-condition for testing purposes. if(true) return false; checkUserExistsSql = String.format(checkUserExistsSql, userName); Connection conn = null; Statement stmt = null; ResultSet rs = nul...
064de118-1c08-424c-97b6-b3d45c97493f
6
public void play_opponents() { Suit round = null; Submission temp; for ( Player player : players_ ) { if ( !player.is_human() ) { // Player will draw a card from the draw pile if (game_.turn_.draw()) { player.take_card(deck_.draw())...
025580c9-3e62-4e8e-95aa-a12c5b31df0e
2
private double innerProduct(Instance instance) { double sum = 0; for (int index : linearParam.getVector().keySet()) { if (instance.getFeatureVector().getVector().containsKey(index)) { sum += instance.getFeatureVector().get(index) * linearParam.get(index); } } return sum; }
78d9ed33-3edd-4a1b-9f84-7c437cc7d053
0
public Hero getHero(Player p) { return getheroesplugin().getCharacterManager().getHero(p); }
a5d3d0a7-bc69-4142-bb44-ea19f8f570aa
9
public HostMenuPanel(final MainFrame frame) { final JLabel error = new JLabel();; this.addLabel(frame, "PortLabel"); final JTextArea port = new JTextArea(1, 30); this.addComponent(port); ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { i...
b9c020a7-5c73-4cb1-aa97-10800e5b58bc
1
public String getCourseName(int courseId) throws SQLException { NoteDatabaseManager dm = new NoteDatabaseManager(); String s_courseId = Integer.toString(courseId); String sql = "select course_name from course where course_id = " + s_courseId + ";"; ResultSet rs = dm.sqlQuery(sql); String courseName = null...
3b8f797b-a6b1-40d8-8113-00f1bf0b15a1
0
public static void main(String[] args) throws Exception { new ParallaxMapping().loop(); }
dfba64af-08bc-4178-8070-3a7fdbed5a54
7
public static Double idealGasLaw(Double p, Double v, Double n, Double t) { boolean[] nulls = new boolean[4]; nulls[0] = (p == null); nulls[1] = (v == null); nulls[2] = (n == null); nulls[3] = (t == null); int nullCount = 0; for(int k = 0; k < nulls.length; k++) { if(nulls[k]) nullCount++; }...
da585dc5-a2bb-4071-8dfd-8ae9d2de9bd5
4
public boolean connect(String remoteHost) { try { // Connect to the server m_skServer = new Socket(remoteHost, Utils.PORT_NUM); // Get the output stream object m_stOutput = new ObjectOutputStream(m_skServer.getOutputStream()); m_stInput = new ObjectInputStream(m_skServer.getInputStream()); ...
7859ec60-5b10-40ad-bc2a-e2347d8d248b
0
public Main() { }
74880708-596e-4fc8-b39e-b30073a1e0fe
2
private void jTxtFldFindClienteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtFldFindClienteKeyTyped // TODO add your handling code here: try { clearClientes(); String sql = "SELECT * FROM clientes WHERE email LIKE ? "; Connection conn = Conexion.GetConn...
f14f8ff9-43f0-4f4c-b749-ed834c5a7889
3
public List<String> getMostFrequentWords(List<List<Object>> sequenceList, int highestCount) { List<String> frequentWordList = new ArrayList(); for (int i = 0; i < sequenceList.size(); i++) { List<Object> countAndSequenceList = sequenceList.get(i); //only get the most frequent wor...
cc1bd4c7-aa25-4326-975e-8ea0aad346c2
0
@XmlAttribute public void setId(int id) { this.id = id; }
65a311b4-f6eb-4d64-9bbc-aea3e9c631fc
0
@Override public void warning(SAXParseException e) { System.out.println("SAXParserException Warning: " + e.getMessage()); this.errorOccurred = true; }
6f8dd083-58d4-40c6-9ce5-3749f1d6927e
1
public final void redirect(String target, String... patterns) { for (String path : patterns) { pages.redirect(target, path); } }