method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
6b374b5f-5a6a-41f5-adcc-d0bd583df96a
9
private void loadInputData() { men = new ArrayList<Person>(); women = new ArrayList<Person>(); try { FileInputStream fstream = new FileInputStream("input-indifference.tsv"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String str...
762bb84d-e456-4ca4-be58-21db4b926c8e
1
public ClassInfo getSuperclass() { if ((status & HIERARCHY) == 0) loadInfo(HIERARCHY); return superclass; }
ec8dfff6-4d68-4385-b731-976a38c8d521
3
public Quaternion slerp(Quaternion dest, float lerpFactor, boolean shortest) { final float EPSILON = 1e3f; float cos = this.dot(dest); Quaternion correctedDest = dest; if (shortest && cos < 0) { cos = -cos; correctedDest = new Quaternion(-dest.getX(), -dest.getY(), -dest.getZ(), -dest.getW()); } if...
be2114fa-41e1-4266-a716-27a02ee7bf18
7
protected void loadDatabaseObjects() { String fileName = dirName + "DatabaseObject.txt"; if (verbose) Timer.showStdErr("Loading objects from '" + fileName + "'"); // Ensure capacity int numObjects = Gpr.countLines(fileName); if (verbose) Timer.showStdErr("Counting lines from '" + fileName + "'. Total lines: ...
2ec86585-494b-4aba-9613-db76effe1f62
4
private Token scanDirective () { forward(); String name = scanDirectiveName(); String value = null; if (name.equals("YAML")) value = scanYamlDirectiveValue(); else if (name.equals("TAG")) value = scanTagDirectiveValue(); else { StringBuilder buffer = new StringBuilder(); while (true) { char ...
da3f86ac-b221-43b6-8789-2aa4c6929031
9
public void commandLine() { while (true) { System.out.print(">"); command = userInput.nextLine().split(" "); //String junk = userInput.next(); if (command[0].equals("addplayer")) { comAddplayer(); } else if (command[0].equals("removeplayer")) { comRemoveplayer(); } else if (command[0].equals...
90beab24-c480-49f3-afc0-ef78f961b119
0
public Date getLastActiveDate() { return lastActiveDate; }
6c5c4564-54cb-471f-ad2b-a46845c9f979
5
public static void main(String[] args){ Die d = new Die(2,6); boolean rolledTwo = false; boolean rolledTwelve = false; int total = 0; int runs = 1000000; for(int i = 0; i < runs; i++){ int roll = d.roll(); total += roll; if(roll == 2){ rolledTwo = true; } if(roll == 12){ rolledTwelve ...
9714abda-5044-45c0-98b0-05cd10142c99
5
public byte[] read(long offset, VDKFilePattern pattern) { byte[] buffer = new byte[pattern.getLength()]; byte[] resultBuffer = new byte[pattern.getLength()]; int bytesRead; try { seek(offset + pattern.getOffset()); bytesRead = read(buffer); if (bytesRead != pattern.getLength()) { close()...
01706c26-0c4c-42a3-89e6-450bce6e9bb1
3
public static ArrayList getOpSerial(String arg_serial) throws SQLException, ClassNotFoundException { ArrayList sts = new ArrayList(); Connection conPol = conMgr.getConnection("PD"); ResultSet rs; if (conPol == null) { throw new SQLException("Numero Maximo de Conexoes Atingida...
ab7e0d69-dd3b-4c4c-a432-c9679d11aead
5
private void findTo() { possibleToEdges = guiM.findPossibleEdges(cgInstance.getTextFromToTextField()); if (possibleToEdges.size() > 1){ new ChooseFrame(this, false); } else if(possibleToEdges.size() == 1){ for(Entry<String, MyEdge> entry : possibleToEdges.entrySet()) { guiM.nodeToKDV = entry.getValue()....
9fde0850-ab93-436f-8474-9e6fdcaf9114
6
public static void main(String [] args) { try { VermilionCascadeNotebook vermilionCascadeNotebook = VermilionCascadeNotebook.getInstance(); vermilionCascadeNotebook.init(); Shell vcnShell = vermilionCascadeNotebook.getMainComposite().getShell(); vcnShell.open(); while (!vcnShell.isDisposed()) { t...
da548046-9146-47d0-88f5-9478bf1174d7
9
static int move(int[] array, int i) { if (array.length <= 1) { return -1; } while (array[i - 1] == array[i]) { i--; if (i == 0) { return -1; } } if (i == array.length - 1) { swap(array, i, i - 1); i--; if (i == 0) { return -1; } else { return i; } } while (array[i - ...
a46757a4-5986-40d5-93ca-43e0849bd40b
9
public int compareTo(PartialMove other) { if (this.equals(other)) { return 0; } if (this.color < other.color) { return -1; } else if (this.color > other.color) { return 1; } if (this.start < other.start) { return -1; ...
4a8656df-73dd-4cac-aa65-039a2a629ae4
7
static public void test_getElement103() throws Exception { int[] input = { 1, 6, 13, 8, 20 }; if( 1 != ArrayQuestions.getElement103( input, 1 ) ) throw new Exception( "Test failed." ); if( 6 != ArrayQuestions.getElement103( input, 2 ) ) throw new Exception( "Test...
cc70b953-16d6-4fc4-b582-d4d462a3bc5e
9
public Config getConfig () { out.println("[+++]\tReading Configuration File (Config.json)"); InputStream fileStream = FileReader.class.getResourceAsStream(config_file); if (fileStream == null) { err.println("[+++]\tError: " + config_file + " was not found"); Sy...
5ae9357e-6c21-4d04-8c3a-2b380ac3619a
7
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); int n = Integer.parseInt(in.readLine().trim()); for (int i = 0; i < n; i++) { int[] rc = readInts(in.readLine()); c = rc[0]; r =...
7a64439d-07a3-49e3-b9f1-c59b73d2c983
4
private Point getCoord(String token) // Token's format is <x>-<y>; return it as a Point object { int x = 0; int y = 0; String[] results = token.split("-"); if (results.length != 2) System.out.println("Incorrect coordinates in " + token); else { try { x = Integer.parseInt(results[0]); y = Integ...
a7e0ea7d-343d-47ab-9333-c06b114af706
4
public boolean canMove(Pos toDirection) { boolean retFlg = true; int moveX = this.getX() + toDirection.getX(); int moveY = this.getY() + toDirection.getY(); if (moveX < Common.X_MIN_LEN || moveX >= Common.X_MAX_LEN || moveY < Common.Y_MIN_LEN || moveY >= Common.Y_MAX_LEN) { retFlg = false; } return retFl...
d599c56c-140a-417e-ab57-7005ccd66eb7
1
public void addExp(int xp){ exp += xp; if(exp > maxExp){ levelUp(); } }
aee7ed15-2b1e-4e34-a39d-a1b6f4f886c4
7
static KnqAnimation createAnimation(){ KnqAnimation aAnimation; int aName; int Min = 1, Max = 7; aName = Min + (int)(Math.random() * ((Max - Min) + 1)); switch(aName){ case 1: aAnimation = new KnqAnimation("../img/bear/00", ".png", 45, 0, 0, "bear"); ...
45a4b8e2-a06c-4254-8984-f8f575e921ce
3
private void generateAlbumList(DefaultListModel model, JList list) { model.removeAllElements(); ArrayList<Album> albumslist = GuiView.control.listAlbums(); if (albumslist != null){ int count = 1; for (int y = 0; y < albumslist.size(); y++) { if (albumslist.get(y).getPhotoList().size() > 0) { model....
29e9e2df-d07d-42d7-9f42-ae381bdf1701
8
@Override protected void transformTheoryToRegularFormImpl() throws TheoryNormalizerException { List<Rule> rulesToAdd = new ArrayList<Rule>(); Set<String> rulesToDelete = new TreeSet<String>(); List<Literal> headLiterals = null; List<Literal> origHeadLiterals = null; Rule newRule1 = null; Rule newRule2 =...
06354b08-c708-411f-9d03-8c3dbad815bb
4
public void render(Transform transform) // Main Thread { Spritesheet.bind(); GL11.glDisable(GL11.GL_BLEND); for(int i = chunks.size() - 1; i > 0; i--) { if(!chunks.get(i).isCreated()) // Need to create in GL thread because we're uploading mesh data chunks.get(i).create(); chunks.get(i).render...
43f75409-9037-4c2f-923a-a482a9e17e18
3
public JPanel getGui() { if(state == State.Login) return (JPanel)login; if(state == State.Lobby) return (JPanel)lobby; if(state == State.Game) return (JPanel)game; ClientHelper.log(LogType.GUI, "Fehler im GuiManager: state ist "+state); ret...
e0a5e4f6-186f-4160-99a0-d2391dc3a70c
3
@Override public void deserialize(Buffer buf) { dungeonId = buf.readShort(); if (dungeonId < 0) throw new RuntimeException("Forbidden value on dungeonId = " + dungeonId + ", it doesn't respect the following condition : dungeonId < 0"); buddyId = buf.readInt(); if (buddyId...
461c3d63-43f3-4098-a540-1ca0a205dafc
6
private static void _init() throws ReaderException { logger.log("##############################################################################################", 1); logger.log("The user directory on this machine is: " + System.getProperty("user.dir") + ". Provide a relative path from this folder or an absolut...
05553f08-fd31-41af-a024-e15ff5480c5d
7
private static void warnAboutJar() { String userDir = System.getProperty("user.dir"); if (System.getProperty("os.name").startsWith("Windows")) userDir = userDir.replace('\\', '/'); // if mw.jar is in the root directory, userDir="C:/"; otherwise, userDir="C:/folder" // note the former has an extra '/' that th...
97e5362e-a580-434b-8143-6f789e69817e
6
public void setFramePartialTruth(TruthValue truthvalue, double posscore, double negscore, boolean ignorepolarityP) { { PartialMatchFrame self = this; { boolean flippolarityP = self.controlFrame.reversePolarityP && (!ignorepolarityP); if ((posscore == Stella.NULL_FLOAT) && (tr...
79ae4e1e-9626-43e1-a68a-96379bfa0ede
6
public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX); props.setLook(shell); setShellImage(shell, meta); ModifyListener lsMod = new ModifyListener() { public void modifyText(ModifyEvent e...
fd9bfcca-70e5-481e-81c5-4728a48fae85
0
protected AnnotatedHandlerBuilder<Class> handleType() { return wrapped.handleType(); }
cadc13e6-5ae8-4f00-bed3-0904e902a333
5
public void run() { running = true ; // Endlosschleife while (running) { JobContainer job = null ; // diesen Block komplett locken, damit zwischen get & if keine Unterbrechung // erfolgen kann synchronized (jobs) { job = jobs.getJob() ; // Kein Job vorhande...
b9ebf22a-1c89-4f4b-9257-5f2dccb24fd9
8
public void update(long deltaMs) { //System.out.println(currentState); // delete actors that were destroyd after the last update via events for(long a : toDelete) { deleteActor(a); } toDelete.clear(); for(GameActor a : created) { actors.put(a.getID...
4da2b5d7-85c1-4dcd-93ca-f2d57d8e6d16
3
public static byte renderTypeToByte(RenderType renderType) { switch(renderType) { case SOLID: return 0; case TEX: return 1; case ANIM: return 2; } return -1; }
cc68c5c5-efd3-4dd7-93e7-f1c213258e3b
6
public HouseLocation getHouseLocation() { switch (ctx.varpbits.varpbit(SETTING_HOUSE_LOCATION) & 7) { case 1: return HouseLocation.RIMMINGTON; case 2: return HouseLocation.TAVERLEY; case 3: return HouseLocation.POLLNIVNEACH; case 4: return HouseLocation.RELLEKKA; case 5: return Hous...
e4686649-47cc-4912-b93c-8c205d125c0d
6
private void loadInfo () { try { Document doc = AppUtils.downloadXML(new URL(DownloadUtils.getStaticCreeperhostLink("version.xml"))); Update upd = JsonFactory.getUpdate("net.ftb:launcher:beta@json", Locations.FTBMAVENFULL); if (upd.getPrimary().equals("beta")){ ...
eae7b925-ce29-4535-8b95-b3263f6995d1
7
public void giveBox(){ if(getAttachmentSize(CardboardBox.class) != 0) { removeAttachment(CardboardBox.class, true); EYESIGHT = Terrarium.MAX_X*Terrarium.MAX_Y; isBlind = false; if (rnd.nextBoolean()){ this.setMessage(this.getNameE() + " is blind!"); } else if (rnd.nextInt(1000) == 1){ this.setMessage...
97b72589-4c56-40f6-903e-f383399fb379
0
@Test public void testGetS1() { System.out.println("getS1"); Unmark instance = new Unmark(6, 9); int expResult = 9; int result = instance.getS1(); assertEquals(expResult, result); }
1191eba4-8bef-42ee-8e05-33185e7c169d
8
public void keyReleased(KeyEvent e){ switch(e.getKeyCode()){ case KeyEvent.VK_W : keyArray[2] = false; break; case KeyEvent.VK_A : keyArray[3] = false; break; case KeyEvent.VK_S : keyArray[4] = false; break; case KeyEvent.VK_D : keyArray[5] = false; break; case KeyEvent.VK_SHIFT : ...
4526d01b-ac39-4804-b6f5-2679ec94f798
1
public void unmake(Piece[][] board) { board[x1][y1] = Piece1; //System.out.println("Unmake: " + (Piece1.x == x2 && Piece1.y == y2)); if (Piece2 != null) { board[x2][y2] = Piece2; } else { board[x2][y2] = null; } ...
c1b5e7ae-0ce9-40be-a2aa-87c2bdd3dbac
6
AnimationLoader(GameMode class230, int i, IndexLoader animLoader, IndexLoader skeletonLoader, IndexLoader skinLoader) { try { animIndexLoader = animLoader; if (animIndexLoader != null) { int i_8_ = animIndexLoader.getAmountChildren() - 1; animIndexLoader.getAmountChildEntries(i_8_); } Clas...
c615fb62-2047-408d-bea2-0188ba1f7a7e
9
public SelectionOverlay(final WordFrame wordFrame) { selections = new ArrayList<>(); solutions = new ArrayList<>(); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { super.keyPressed(e); if (e.getKeyCode() == KeyEvent.VK_ESCAPE) System.exit(0); if (e.ge...
c7ea3455-8f4f-4719-a8d7-45f58fc674d9
4
public void checkCapacity(Booking b) throws MaxCapacityException { Calendar bookingDate = b.getDate(); Category studentCat = b.getStudent().getCategory(); int dHallMonitors = b.getDiningHall().getMonitors(); double cntChld = 0; double cntPrmy = 0; if (studentCat == Category.INFANTIL) cntChld++; else ...
2837a057-3d07-4da9-9454-25f45c0990ec
5
private void c_MTPage(){ c_MTPane = new JPanel(); c_MTPane.setBackground(SystemColor.activeCaption); c_MTPane.setLayout(null); MTT_treat.setText(""); MTT_fpp.setText(""); MTC_bp.setSelected(false); JLabel lbl_MedicalTreatment = new JLabel("Medical Treatment"); lbl_MedicalTreatment.setHorizontalAli...
a61581ac-af87-4813-acef-e3ab45af99ec
4
@Override public int compareTo(Vertex v) { if (this == v) return 0; if (this.x != v.x) return ((Double) this.x).compareTo(v.x); if (this.y != v.y) return ((Double) this.y).compareTo(v.y); if (this.ID != v.ID) return ((Integer) this.ID)...
fabbda83-897b-4e0e-b919-7118b6f7dc09
0
private void info(final String msg) { log("INFO", msg); }
834c0f72-c1fa-4767-8613-0b08cf58e975
5
public boolean isItem() { return this.type == Item.Type.ITEM || this.type == Item.Type.EXPMEMORY || this.type == Item.Type.HP_MEMORY || this.type == Item.Type.REGUP || this.type == Item.Type.SUBCHIP || this.type == Item.Type.SUBMEMORY; }
0c1de310-07e3-4926-8ac3-25f58b6d971a
5
public boolean commitTransaction() { depth--; if (depth < 0) { throw new PanicException("commitTransaction invoked when no transaction active."); } if (depth > 0) { throw new PanicException("commitTransaction invoked on nested transaction."); } if (depth == 0) { ...
2094dbd5-75dc-472e-9325-5f8db5995962
1
@Override public Object next() { if (this.hasNext()) { return array[index++]; } return null; }
62c1023a-9b5f-4007-8607-12c4187026de
8
private final void method3227(int i, ByteBuffer class348_sub49, int i_24_) { if ((i_24_ ^ 0xffffffff) != -2) { if ((i_24_ ^ 0xffffffff) == -3) { int i_25_ = class348_sub49.getUByte(); ((Class348_Sub42_Sub11) this).anIntArray9592 = new int[i_25_]; ((Class348_Sub42_Sub11) this).aCharArray9588 = new char...
b05f2a73-8881-4726-8436-8e5b02925d5c
1
public void setUsertileImageOverlay_Width(int width) { if (width <= 0) { this.usertileImageOverlay_Width = UISizeInits.USERTILE_IMAGEOVERLAY.getWidth(); } else { this.usertileImageOverlay_Width = width; } somethingChanged(); }
03653fa0-30db-44a7-9de5-8b3342430f71
6
public static OS getPlatform() { String osName = System.getProperty("os.name").toLowerCase(); if (osName.contains("win")) return OS.windows; if (osName.contains("mac")) return OS.macos; if (osName.contains("solaris")) return OS.solaris; if (osName.contains("sunos")) return OS.solaris; if (osName...
07c9f4ff-13da-45e7-ba3c-5d3a64e358e4
9
private HaploStruct[] patternsToGametes(HaploStruct[] patterns, int[] centro) throws Exception { //sort the patterns such that the four gametes //are based on the centromere alleles, in the order of centro: HaploStruct tmphs; for (int s=0; s<patterns.length-1; s++) { ...
70585bb3-02fb-4995-890e-b5ae8c304bd0
9
public void sendFrame(Frame frame) throws IOException { if (!open) { throw new SocketException("Socket is closed"); } boolean fin = true; byte opcode = (byte) frame.getOpCode(); boolean maskEnabled = false; byte data[] = frame.getPayload(); long len = data != null ? data.length : 0; byte firstlen ...
88ea80c8-079d-48aa-8d22-290936bebc7f
7
protected Object installView(byte[] buf, int offset, int length) { try { ViewData data=Util.streamableFromByteBuffer(ViewData.class, buf, offset, length); if(data.uuids != null) NameCache.add(data.uuids); remote_view=data.remote_view; if(global_vi...
f21c5a35-2c16-4e6b-9b27-7395c29df315
4
private void getData() throws ParseException { Session se = HibernateSessionFactory.getSession() ; staItem_list = new LinkedList<StaItemBean>() ; Criteria store_cri = se.createCriteria(Store.class) ; store_cri.add(Restrictions.and(Restrictions.ne("name", "superDepartment"), Restrictions.ne("name", "server"))) ;...
f649fd34-5f4e-46ff-9366-aa493c3b7a19
4
public ArrayList<String> fullJustify(String[] words, int L) { this.result = new ArrayList<String>(); this.L = L; this.line = new ArrayList<String>(); this.letterCount = 0; int count = -1; for (String word : words) { count = count + 1 + word.length(); ...
2b936ea2-63d8-4c48-afd3-b35063cc70eb
9
public void updateObject(Map<String, Integer> coeff) { if(null != object) { for(Map.Entry<String, Integer> mapEntry : coeff.entrySet()) { String key = mapEntry.getKey(); if("k".equals(key)) { k = mapEntry.get...
08d1c9ba-3064-4668-a89a-08c4494789c9
1
private void DoCaptureImage() { try { String type = System.getProperty("video.snapshot.encodings"); byte[] imageData = videoControl.getSnapshot("encoding=jpeg"); capturedImageBytes = imageData; capturedImage = Image.createImage(imageData, 0, imageData.length); ...
7a916f40-931b-4cd9-a0f8-d52211caae4b
3
private void playRound() { currentRound++; //Generate new m Random r = new Random(); currentM = r.nextInt(participants.size() * (participants.size() - 1) - 1) + 1; //Shuffle participants Collections.shuffle(participants); List<List<Moves>> players_decisions = n...
fb3b28c9-e05b-4752-80be-d4da86158756
7
private PojoTester(Mode mode) { this.mode = mode; FixtureDatumFactory<Boolean> booleanDatumFactory = new FixtureDatumFactory<Boolean>(Boolean.class) { public Boolean getNext() { return counter.getAndIncrement() == 0; } }; fixtureDataByType.put(boolean.class, booleanDatumFactory); fixtureDat...
fed836bd-16da-403f-ac28-4347a77f42e8
3
@Override public void updateLong() { super.updateLong(); if(generationTimerEnd == 0) { resetGenerationTimer(); } if(generationTimerEnd <= System.currentTimeMillis() && this.isActivated()) { placeableManager.playerAddItem("Gold", 1); ...
3386d469-6f17-4d56-9dc3-2a5387d5baf5
1
public final void endDocument() throws SAXException { try { os.write(toByteArray()); } catch (IOException ex) { throw new SAXException(ex.toString(), ex); } }
b33d00a6-7cbc-41d8-8054-580dcc5c22bb
4
private void smoothen() { for (int x = 1; x < width - 1; ++x) { for (int z = 1; z < depth - 1; ++z) { float total = 0.0f; for (int u = -1; u <= 1; u++) { for (int v = -1; v <= 1; v++) { total += map[(x + u) + (z + v) * depth...
b320a677-b653-4e6c-9633-c6f8cfb8bce6
2
public void excluir(int id){ dlo.excluir(id); for (int i = 0; i < secoes.size(); i++){ if (secoes.get(i).getId() == id){ secoes.remove(i); break; } } exibirMensagem("Seção excluída com sucesso"); }
61feb980-4a87-4add-9c45-f61c38227aa4
8
private boolean checkStop(double[] rst, double minDL, double dl){ if(dl > minDL+MAX_DL_SURPLUS){ if(m_Debug) System.err.println("DL too large: "+dl+" | "+minDL); return true; } else if(!Utils.gr(rst[2], 0.0)){// Covered positives if(m_Debug) System.err.println("Too few positives."); ...
96883453-53b0-431c-a08b-a7d84f3c0e14
4
private void predict(){ /* // calculate dy for (int i = 1; i < y.length; i++){ dy[i]= y[i]-y[i-1]; //System.out.println("dy" + i + " = " + dy[i]); } double a; double b; // prediction calculation for (int i=30; i<40; i++){ a = average(y, i-30, i-1); b = average(dy, i-30, i-1); ...
169411a9-0204-418c-9dcb-e355696e4fc3
4
public static void main (String Args[]){ Scanner sr = new Scanner(System.in); testcases = sr.nextInt(); while(testcases>0){ k = sr.nextInt(); while(k>0){ if(k>10000){ l = l*905611805; k=k-10000; }else{ l = l*2; k--; } if(l>mod){ l = l% mod; } ...
d9e50534-e4b9-46d9-8aa4-c2785074d136
0
public String toCsv() { List<String> values = Arrays.asList( this.id, this.postId, this.text.replace("\n", "").replace("\r", ""), this.creationDate, this.userId); return StringUtils.join(values, ';'); }
aef7f620-6347-48b7-984b-bd96ef40fb37
0
public LaenderGraph getGraph() { return laenderGraph; }
a1cd93b1-260f-40eb-82de-fa0233955906
9
public boolean doFindNext(JTextComponent target) { if (getPattern() == null) { return false; } SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(target); if (sDoc == null) { return false; } int start = target.getSelectionEnd(); if (target.getSelectionEnd() == target.getSelectionStart()) { // we...
5636e0c2-d63b-4db5-92f0-14f2abd054e2
6
@EventHandler public void CreeperHunger(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.getCreeperConfig().getDouble("Creeper.Hunge...
1172002d-b94d-40c4-8abe-ad24b0660882
9
public Order takeDecision(Game game) { Order order; ArrayList l = new ArrayList(); float cash; float energy; int nucl = 0, wind = 0, water = 0, sun = 0, charb = 0; Player us = game.getPlayers().get(0); for (Player p : game.getPlayers()) { if (p.getNam...
f203dc0f-15e2-4b60-861f-3fe339a3aa90
8
@Override public void removeProperty(String path) { if (path.startsWith(".")) path = path.substring(1); // VERY EXPENSIVE MemoryConfiguration temp = new MemoryConfiguration(); setOptions(temp); Map<String, Object> values = config.getValues(true); if (values.containsKey(path)) values.remove(path); else{ ...
9df774f9-ee84-4904-a4be-c0c1cb95a4df
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...
58d8c4a3-d717-46a0-9808-7df6b91cbf79
2
public String getLabelCode(){ String str = ""; if(statement.toString()!=null) str = statement.getLabelCode(); if(statements.toString()!=null){ str += statements.getLabelCode(); } return str; }
a9089c1f-e10b-405d-a631-0eaf5129e392
5
@Override public void actionPerformed(ActionEvent ae) { System.out.println("button " + ((JButton) ae.getSource()).getText()); switch (((JButton) ae.getSource()).getText()) { case "Start Game": mw.getMenuModel().play(); break; case "Sign Up": ...
b75b5862-6c88-43f7-89c1-a64c8d89b405
7
public Solucao TwoFlip(Solucao inicio){ this.solucoes.put(inicio.getCustototal(), inicio); for(int a = 0; a<=inicio.getColunas().size()-2; a++){ for(int b = a+1; b<=inicio.getColunas().size()-1;b++){ for(Integer entrada1 : inicio.getLinhasX().keySet()){ fo...
e55f3f78-3136-4200-9bb3-ca694f0bf2b3
7
@Override public void keyReleased (KeyEvent a) { input = a.getKeyChar(); if (!(a.getKeyCode() == KeyEvent.VK_BACK_SPACE)) { if (checkInput (input)) { int reply = JOptionPane.showConfirmDialog(null, "Confirm input of " + input + " ?"); if (reply == JOptionPane.YES_OPTION) { if ((AI.determineI...
2ea6090c-7cb2-4a9f-b5fb-2c879c27983a
8
public <T> Constructor<T> getConstructor( Class<T> targetClass, Class[] params ) throws ReflectorException { Map<String, Constructor<T>> constructorMap = getConstructorMap( targetClass ); StringBuilder key = new StringBuilder( 200 ); key.append( "(" ); for ( int i = 0, len...
3b361645-016c-4ac0-ba14-98a7382ba121
8
@Override public void wanderAway(MOB M, boolean mindPCs, boolean andGoHome) { if(M==null) return; final Room R=M.location(); if(R==null) return; int tries=0; while((M.location()==R)&&((++tries)<10)&&((!mindPCs)||(R.numPCInhabitants()>0))) beMobile(M,true,true,false,false,false,null,null); if(an...
60c8a555-9f53-4ab3-af68-9c6d0cb14625
6
public static int[] outerUnion(int[] firstArr, int[] secondArr) { if (firstArr == null || secondArr == null) { return new int[]{}; } int[] outerUnion; int[] innerUnion = innerUnion(firstArr, secondArr); int numberInnerElements = innerUnion.length; int numberO...
45694a34-fe41-428d-b046-52e2a018bfd7
2
private void getPathRecoursive(Node toNode) { if (toNode.equals(fromNode)) { route.add(toNode); } else if (!hasPathTo(toNode)) { return; } else { route.add(toNode); getPathRecoursive(getPrevious(toNode)); } }
4fae5dde-990a-4c25-93ba-1d8d41711e16
8
public void actionPerformed(ActionEvent e) { Object src = e.getSource(); Calendar c = new GregorianCalendar(); c.setTime(parent.getCalendar().getTime()); if (src instanceof JButton) { if (e.getSource() == premon) c.add(Calendar.MONTH, -1); else if (e.getSource() == nextmon) c.add(Calendar....
dcd191dd-5cac-4c62-bb41-c2e864b58f01
5
@Override public boolean equals( Object obj ){ if (this == obj){ return true; } if (obj == null){ return false; } if (obj instanceof Locomotive ){ Locomotive temp = (Locomotive) obj; return ( this.getComfortPercent() == temp.getComfortPercent())&& ( this.getHeight() == temp.getHeight() )&&...
b98523f8-0d4b-4e9d-a0b7-bbd10071d521
8
@Override public boolean isBookExisted(final Book book) { Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; boolean existed = false; try { conn = dataSource.getConnection(); stmt = conn.prepareStatement("SELECT COUNT(1) FROM ...
3ef677b9-38e0-4f16-89e6-4c1b564c45c1
8
public static char[] reverseWords(char [] input) { int len = input.length; int firstIndex = 0; int lastIndex = 0; while(firstIndex < len && lastIndex < len) { while(firstIndex < len && input[firstIndex] == ' ') { firstIndex ++; } lastIndex = firstIndex; while(lastIndex < len ) { if(input[...
ca8b1fa7-9ff4-4e1a-bead-e9497ccfdbdb
9
private void sendFile(String fileName, int startByte) throws FileNotFoundException, IOException, ClassNotFoundException, SQLException { // Sentinel set to false by default, only sets to true if client // can recieve the requested file Boolean cont = f...
babe33e3-6b9c-4322-9c81-ef7eb5421c3d
7
public void checkSideCollision(Rectangle rleft, Rectangle rright, Rectangle leftfoot, Rectangle rightfoot){ if(type != 5 && type != 2 && type != 0){ if(rleft.intersects(r)){ robot.setCenterX(tileX + 102); robot.setSpeedX(0); } else if (leftfoot.intersects(r)){ robot.setCenterX(tileX + 85); ...
693c19d1-6721-43f6-9bcf-9479fc48f1b5
3
* @param mergeSharedVersions apply to all versions sharing the same text * @return percentage of the new version that was unique, or 0 * if this was the first version */ public float update( short version, char[] data, boolean mergeSharedVersions ) throws Exception { // to do: if version already exis...
c5bfec03-6f05-4655-aaf0-5313ca4369be
2
public static ArrayList<Subcategorias> sqlSelectTodos(){ ArrayList<Subcategorias> subcat = new ArrayList(); if(!BD.getInstance().sqlSelect("SELECT * FROM subcategorias ORDER BY idsubcategorias DESC")){ return subcat; } while(BD.getInstance().sqlFetch()){ s...
9f8ea718-3d65-4d80-a41b-9574734af7d3
5
public static void main(String[] args) { Hash hash = new Hash(); JOptionPane.showMessageDialog(null, "Your are going to use Hash - Program \n" + "Chose, what action do you want to do and input a Key - number : \n" + "1 : add a new hash - element \n" + "2 :...
598bfc4f-ea19-40d8-bf0b-8fe25045d32a
8
@Override public double getRecall(String classValue) throws IllegalArgumentException { if( classValue == null) throw new IllegalArgumentException("Error: null class value"); if( this.valueToIndex.get(classValue) == null) throw new IllegalArgumentException("Error: state = " + classValue + " didn't found...
bda0e324-048c-43ff-a4e0-67acce803207
5
public static String calculateColorRatio(Deck deck) { int yellow = 0; int red = 0; int blue = 0; int green = 0; for (Card c: deck) { if (c.getColor().getType() == TypeC.YELLOW) yellow++; if (c.getColor().getType() == TypeC.RED) red++; if (c.getColor().getType() == TypeC.BLUE) blue++; ...
83449a58-d773-475d-afc3-3d696ff8d698
0
public String getOrgName() { return orgName; }
0ffffaac-3486-4a17-bda5-2a3b26ed0cd6
4
public JSONWriter key(String string) throws JSONException { if (string == null) { throw new JSONException("Null key."); } if (this.mode == 'k') { try { this.stack[this.top - 1].putOnce(string, Boolean.TRUE); if (this.comma) { ...
dd6bcbb1-1161-4637-a077-d81c583b7752
8
public static String getLyrics(String artist, String title) throws Exception { // Check if user has a correction saved String artistMatch = DataManager.getArtistCorrections().get(artist); // If no correction saved, we must try and find the artist on site if(artistMatch == null) artistMatch = validateArtis...
fc9189cd-627b-4eb1-b23f-9f3fb06b597e
9
protected boolean checkRequirementsValue(String validValue, String value) { if(validValue==null) return value != null; if(validValue.equalsIgnoreCase("integer")||validValue.equalsIgnoreCase("int")) return CMath.isMathExpression(value); else if(validValue.equalsIgnoreCase("double")||validValue.equalsIgnor...
d7658876-1b78-4610-846c-b1a1344d3a49
0
public Vector getNeighbours() { return neighbours; }
4085651e-c20c-4957-af1f-cc1a86c1adb3
3
final private Map<Property, PropertySearchResults> addThisResult( Map<Property, PropertySearchResults> results,List<Property> targetProperties) { if(results==null) { // first match, need to allocate a result set // guess what size map to create int expectedResults; if(targetProperties!=nul...