method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0a7a9215-b7a8-4474-b2e0-9baffa3c877e
8
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Comment comment = (Comment) o; if (text != null ? !text.equals(comment.text) : comment.text != null) { ...
c726378f-bf7b-4138-a7b6-979f9729c7fc
9
public static String solve(String str) throws UnsupportedEncodingException{ StringBuffer sb = new StringBuffer(); StringBuffer sb2 = new StringBuffer(); System.out.println(str.length()); byte[] bytes = str.getBytes("UTF-8"); int blen = bytes.length; int slen = str.length(); printbyte(bytes); System.ou...
42aed8ee-c71a-4b82-ad44-7abae10241a1
1
private static final boolean isNonTerminal(int x) { return x >= FIRST_NON_TERMINAL && x < FIRST_SEMANTIC_ACTION; }
a7902d15-c6a8-4114-9e02-6e57d26a24e2
0
public MenuManager(ProBotGame game) { this.upgradeMenu = new UpgradeMenu(game); this.mainMenu = new MainMenu(game); this.pauseMenu = new PauseMenu(game); }
06c3640a-2433-49f5-b892-130ef2952150
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...
3c74bfaf-9634-44cd-a976-fc085916606d
4
protected final void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final HttpSession session = request.getSession(true); final User loggedUser = UserManagement.getCurrentlyLoggedInUser(session); if (loggedUser == null) { // Not logged...
2e3f18ef-c6f7-464b-a6d0-6fcbc25138e1
7
@Override public void render() { if(currentAchievement != null) { Textures.bind("/assets/textures/ui/compsTemplate.png"); Tessellator t = Tessellator.instance; int type = 0; float w = 300; float h = 80; x = Bloc...
b390b34c-6566-41b5-84b5-abe979ca8a0f
5
public boolean verificaCaminhos(Posicao posicaoInicial, Posicao posicaoFinal) { Peca peca = getCasas(posicaoInicial.getColuna(), posicaoInicial.getLinha()); switch (peca.toString()) { // verificacao do peao case "P": return verificaCaminhoPeao(po...
2b185478-51f1-4e5c-b3f6-45b7e4081d75
2
public static void main(String[] args) { try { List<Parking> parkings = new ParkingGenerator().generateParkingList(50, 10); ParkingList.getInstence().addParking(parkings); List<Car> cars = new CarGenerator().generateCars(3000); CarExecuter executer = new CarExecuter(); executer.execute(cars); } catch...
e3fa03f0-8b45-40f8-8cc7-df438e92d5eb
6
public Element getParameterElement(String xml,String attribute, String value) { if(xml==null){System.out.println("ERROR:SSAP_XMLTools:getParameterElement: XML message is null");return null;} Document doc=null; try { doc = builder.build(new ByteArrayInputStream(xml.getBytes())); } catch (Exception e) { /...
acad0ee1-c902-4ee9-a663-b8436a533e6e
8
@Override public void parseWearLocation(short[] layerAtt, short[] layers, long[] wornLoc, boolean[] logicalAnd, double[] hardBonus, String wearLocation) { if(layers != null) { layerAtt[0] = 0; layers[0] = 0; wearLocation=parseLayers(layerAtt,layers,wearLocation); } final double hardnessMultiplier = ...
de1d3489-6e9b-424c-a41e-5b8f96a71eff
4
public void setGoldOnPotionPurchase(int amount, int type){ if(type == 1){ int healthPotionCost = 10; int playerGold = this.getGold(); if(healthPotionCost * amount > this.getGold()){ System.out.println("You dont have enough!"); } else{ this.setGold(playerGold -= healthPotionCost * amount); } ...
0e1e1275-4211-49e4-9843-f7168aa5241c
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...
a0c7bb87-31fe-4af6-b9a0-699c15ab73b0
9
public boolean execute() { long time = peersim.core.CommonState.getTime(); if ((time % epoch) == 0) { initvar = -1.0; } /* Initialization */ final int len = Network.size(); IncrementalStats stats = new IncrementalStats(); /* Compute max, min, average */ for (int i=0; i < len; i++) { Node node = Network.g...
9ddc1fd0-1a93-494f-af1b-0a8eab6ef2df
0
public int getDlc() { return dlc; }
1c2cf2d4-dbe4-403f-88f8-d78f80efa377
9
public String[] insertionSort(String[] arreglo, String[] targets){ int aux, j; String aux2; int[] positions = new int[arreglo.length]; ArrayList<String> fill = new ArrayList<String>(1); // array of indexs for (int i=0; i<positions.length; i++) for (int k=0; k<targets.length; k++) if(arreglo[i].equa...
cbf0d2ee-9e51-44c2-8a92-9c71a21538a8
7
public boolean equals(Object _other) { if (_other == null) { return false; } if (_other == this) { return true; } if (!(_other instanceof GroupMembersPk)) { return false; } final GroupMembersPk _cast = (GroupMembersPk) _other; if (groupId != _cast.groupId) { return false; } ...
4952a656-7b3d-4a5c-b784-17063f2ad91f
8
public void run() { this.Sender_enabled = true; int l_tmp_error_count = 0; while( this.Sender_enabled ) { try { Send(); Thread.sleep( this.Sender_time_wait ); l_tmp_error_count = 0; } catch (SocketException e) { if(this.Sender_enabled) { l_tmp_error_count++; Logger....
dc8a8c31-f00d-4e1e-a7dc-1783602af17b
3
public static int findNumDays(String fileName) { int lineNumber = 0; String line; try { BufferedReader br = new BufferedReader( new FileReader(fileName)); while( (line = br.readLine()) != null) { lineNumber++; ...
59f0f3e7-36ea-4f83-9bf3-faafdfe12fd1
2
public void testGetFieldType() { TimeOfDay test = new TimeOfDay(COPTIC_PARIS); assertSame(DateTimeFieldType.hourOfDay(), test.getFieldType(0)); assertSame(DateTimeFieldType.minuteOfHour(), test.getFieldType(1)); assertSame(DateTimeFieldType.secondOfMinute(), test.getFieldType(2)); ...
1ed59eae-b2e7-422d-b535-3d1b825abc05
9
public void doStep() { boolean v1 = volts[0] > 2.5; boolean v2 = volts[1] > 2.5; if (v1 && !pins[0].value) { ff1 = true; } if (v2 && !pins[1].value) { ff2 = true; } if (ff1 && ff2) { ff1 = ff2 = false; } double o...
6bda7cf3-a0e6-43ec-9f76-55fe420d9d94
3
@Override public void onEnable() { updateConfigFile(); getBadWords(); migrateToUUID(); loadConfiguration(); loadIgnoredPlayers(); PluginManager pm = getServer().getPluginManager(); pm.registerEvents(playerChatListener, this); pm.registerEvents(playerJoinListener, this); getCommand("badw").setExecutor...
33a43fb9-a437-460d-b0af-d60bf98496fd
4
@EventHandler public void onSkeletonSpawnEvent(CreatureSpawnEvent e){ r = new Random(); Entity entity = e.getEntity(); if("SKELETON".equals(entity.getType().toString())){ Skeleton barbarianSkeleton = (Skeleton) e.getEntity(); Skeleton goldenSkeleton = (Skeleton) e.get...
c5c5951a-98a6-47bb-adce-858cdbdbe83c
1
public static long checksum(final byte[] data) { long sum = 0; for (int i = 0; i < data.length; i++) { final int lookupidx = ((int) sum ^ data[i]) & 0xff; sum = (sum >>> 8) ^ LOOKUPTABLE[lookupidx]; } return sum; }
f147696d-8d74-430a-9cfe-d04882646520
7
private static ArrayList<Configuration> sautRecursif(Configuration conf, byte[] triplet, byte typeSauteFirst, boolean noirEnPlayer){ ArrayList<Configuration> listeConf = new ArrayList<Configuration>(); byte caseDebut = triplet[0]; byte typeSaute = triplet[1]; byte caseFin = triplet[2]; byte newTurttle...
db9252db-68d8-4d16-b80c-45d54a3eb27f
4
public static void startpriv(InetAddress inetaddress) { threadliveid = (int) (Math.random() * 99999999D); if (active) { try { Thread.sleep(500L); } catch (Exception _ex) { } active = false; } socketreq = 0; threadreq = null; dnsreq = null; savereq = null; urlreq = null; socketip = inet...
290ca0c5-778e-445a-9658-8e0e60d331a7
1
public void setLoadingStatusAnimation(Animation animation) { if (animation == null) { this.loadingAnimation = UIAnimationInits.LOADINGSTATUS.getAnimation(); } else { this.loadingAnimation = animation; } somethingChanged(); }
6433465e-ec0f-4b5e-8613-010195af4c45
5
static void dedupWithDownsample() throws IOException{ dup=0; int memoryPolicy = 5; resultRecord.println("Total " + storageLoad() + " entries added into the index"); File[] incomingFile = null; incomingFile = new File(outputpath).listFiles(); int cacheSizeControl = 0; // int sampleNum = (int) ((Math.log(2)...
1f392ecf-afd7-49fb-8879-fff1d6ea2145
8
@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 AgendaPK)) { return false; } AgendaPK other = (AgendaPK) object; if ((this.dataHora == null && other.dataHora !...
e91557c2-924b-4841-a640-662b35577ec9
1
public boolean matches(Operator loadop) { return (loadop instanceof InvokeOperator || loadop instanceof GetFieldOperator); }
728d5825-6850-47f0-8585-90ae26d14c8a
3
@Override public List<T> doInCollection(DBCollection collection) { DBCursor cursor = collection.find(queryDbObject); if (skip != -1) { cursor.skip(skip); } if (limit != -1) { cursor.limit(limit); } if (sort != null) { cursor.sort(sort); } cursor.batchSize(batchSize); return mapperDBObjec...
165ef56e-c3b0-4614-9345-1a587aeb3b38
7
private void nearest_knn(KDNode node, double[] targetPoint) { tryToSave(node, targetPoint); int dMinus1 = node.d-1; if(dMinus1 < 0){ dMinus1 = dimensionCount - 1; } double perpendicularDistance = Math.abs(node.values[node.d] - targetPoint[dMinus1]); if (perpendicularDistance < resultKNN.maximum()....
91effef9-e16d-44da-bf45-bd8775707123
1
public Vector toVector() { Vector vec = new Vector(last.getIndex() + 1); LinkedElement<E> elem = first; for (int i = 0; i <= last.getIndex(); i++) { vec.addElement(elem); elem = elem.getNext(); } return vec; }
58a92225-805f-446a-96d7-18b722281172
3
public void depthFirstTraversal() { boolean[] visited; visited = new boolean[gSize]; for (int index = 0; index < gSize; index++) visited[index] = false; for (int index = 0; index < gSize; index++) if (!visited[index]) dft...
6b11072c-a3e3-4d48-abf0-b8a1eb13c66b
7
private final boolean cons(int i) { switch (b[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': return false; case 'y': return (i==0) ? true : !cons(i-1); default: return true; } }
fe4adb59-c478-46d7-9712-118b3f209a0b
4
public float[] getEquation(float p[][], int c[]) { float sum = 0; float avg; float[] esum = new float[c.length]; float temp = 0; for (int i = 0; i < c.length; i++) { if (c[i] < 2) esum[i] = 0; else { for (int j = 0; j < p[i].length; j++) sum = sum + p[i][j]; avg = sum / c[i]; for (...
5f9a7df5-c76f-4968-b0b9-b5aa2822dc7e
8
public static TruthValue weakenTruthValue(TruthValue tv1, TruthValue tv2) { if ((tv2 == Logic.UNKNOWN_TRUTH_VALUE) || (tv2 == null)) { return (Logic.UNKNOWN_TRUTH_VALUE); } else if ((tv2 == Logic.DEFAULT_TRUE_TRUTH_VALUE) || (tv2 == Logic.DEFAULT_FALSE_TRUTH_VALUE)) { if ((tv1 ==...
7641562b-dfaf-4a0a-a3f2-7bd78ebdb7f3
9
private int readHexDigit() throws PDFParseException { // read until we hit a non-whitespace character or the // end of the stream while (buf.remaining() > 0) { int c = (int) buf.get(); // see if we found a useful character if (!PDFFile.isWhiteSpac...
9ed8080a-73f3-4af7-960a-60e12eb9022b
2
public void stop() { try { safeClose(myServerSocket); closeAllConnections(); if (myThread != null) { myThread.join(); } } catch (Exception e) { e.printStackTrace(); } }
a4a3ec15-bf86-4c79-a860-d430bfad7525
9
public static boolean batch( WebSocketImpl ws, ByteChannel sockchannel ) throws IOException { ByteBuffer buffer = ws.outQueue.peek(); WrappedByteChannel c = null; if( buffer == null ) { if( sockchannel instanceof WrappedByteChannel ) { c = (WrappedByteChannel) sockchannel; if( c.isNeedWrite() ) { ...
f53b6e30-ee58-4c8a-b07a-b0be66325b73
7
private static void cleanUp() { try { if (hostServer != null) { hostServer.close(); hostServer = null; } } catch (IOException e) { hostServer = null; } try { if (socket != null) { socket.close(); socket = null; } } catch (IOException e) { socket = null; } try { if (i...
cf587238-b0db-4a58-9482-057ecd7d1e0b
1
void parseEnumeration() throws java.lang.Exception { char c; dataBufferAppend('('); // Read the first token. skipWhitespace(); dataBufferAppend(readNmtoken(true)); // Read the remaining tokens. skipWhitespace(); while (!tryRead(')')) { re...
03be7f42-adfa-4a43-a897-08cd2df710fc
8
private void createConnection(Node peer, DatagramSocket datagramSocket) { NodeList childNodes = peer.getChildNodes(); String ipAddress = null; String port = null; for (int i = 0; i < childNodes.getLength(); ++i) { Node node = childNodes.item(i); String nodeName = ...
da75db81-270a-4ecf-813d-90d44f632cba
7
public void eliminarAntesDeX(T x){ Nodo<T> nodoQ = null; Nodo<T> nodoT = null; Nodo<T> nodoR = null; boolean bandera = true; if(this.inicio == null){ }else{ if(this.inicio.getInfo() == x){ System.out.println("No existe elementos antes de X"); }else{ nodoQ = this.inicio; nodoT = this.in...
dc633ab5-7037-4f99-ac32-3ae1104b438c
1
private ActionListener makeSaveButtonListener() { return new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { programSettings.rootPathToTextDatabase = PATH_SOURCE.getText(); programSettings.rootPathToDownloads = PATH_DOWNLOADS.getText(); programSettings.autoLoadDataba...
22053eb1-61f4-4628-90a4-dd109b652c98
3
public int toLineNumber(int pc) { int n = tableLength(); int i = 0; for (; i < n; ++i) if (pc < startPc(i)) if (i == 0) return lineNumber(0); else break; return lineNumber(i - 1); }
0a828c90-f0bf-413c-a069-3ed717300129
4
public void removeBlockTileEntity(int var1, int var2, int var3) { TileEntity var4 = this.getBlockTileEntity(var1, var2, var3); if (var4 != null && this.scanningTileEntities) { var4.invalidate(); } else { if (var4 != null) { this.loadedTileEntityList.remove...
be2f3c98-da04-4259-8ed4-8fc696797aa6
0
public Bag() { first = null; N = 0; }
7858cf02-8cd3-48cf-8e2c-9cafa6842dd7
4
public static void maintainDirection(Entity snake){ switch(Movement.returnMovementDirection()){ case 0: snake.getPosition().updateYPosition(1); break; case 1: snake.getPosition().updateYPosition(-1); break; case ...
e7e1f9cf-1cef-449a-87b9-ea316f91b4df
4
protected static Ptg calcMMult( Ptg[] operands ) { if( operands.length != 2 ) { return PtgCalculator.getNAError(); } try { // error trap params: must be numeric arrays with no empty spaces double[][] a1 = PtgCalculator.getArray( operands[0] ); double[][] a2 = PtgCalculator.getArray( operands[1]...
7d7d81c6-f34d-4eed-b0fd-4dba5b04ce66
8
public static Field findNearestFreeField(Level level, Field from, List<Field> bannedFields, HashMap<Field, ArrayList<Object>> conflictingHashMap){ LinkedList<Field> frontier = new LinkedList<Field>(); frontier.add(from); HashSet<Field> closedSet = new HashSet<Field>(); Field currentField = frontier.po...
4d1f74b6-9639-4773-9544-669c8f32ff79
1
public void test_printParseLongNameWithLookup() { Map<String, DateTimeZone> lookup = new LinkedHashMap<String, DateTimeZone>(); lookup.put("Greenwich Mean Time", LONDON); lookup.put("British Summer Time", LONDON); DateTimeFormatterBuilder bld = new DateTimeFormatterBuilder() ...
72db1bd3-ac3c-4da7-bb8d-484a1cbd2c2e
9
public boolean attempt(long msecs) throws InterruptedException { // log.debug("attempt()::" + Thread.currentThread().toString()); if (Thread.interrupted()) { throw new InterruptedException(); } Thread caller = Thread.currentThread(); synchronized (this) { ...
4c124342-60c8-4653-99c8-264c66e93cab
0
public NodeGui(String name) { super(name); }
107b5e52-61a6-43d0-891c-9edae747340b
3
private Controller() { log.debug("Starting Controller()"); try { init(); // TimerBO timerBo = new TimerBO(timerPanel); Dao.getInstance().addObserver(timerBo); ActivityDao.getInstance().addObserver(timerBo); TimeDao.getInstance().addObserver(timerBo); // ActivityBO activityBo = new Ac...
135b418f-30da-4c78-81aa-f68466e59c98
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...
d47de420-41c1-4e8f-bf07-36cba27a1b50
9
private Scenery AStarAlgorithm(MovableEntity goal, List<Scenery> opened, List<Scenery> closed) { while (opened.size() > 0) { for (Scenery scenery : closed) { scenery.highLight(); } for (Scenery scenery : opened) { scenery.highLight2(); } // choose the best Scenery (base...
51da94b4-06b9-4320-acd1-092af651a350
3
public void appendConnected() { BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter("connectedfrom/"+playerName+".txt", true)); bw.write(connectedFrom); bw.newLine(); bw.flush(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { if (bw != null...
438b313e-629d-4709-8dd6-f888fc72dc05
8
public String makeMap(int x, int y, int numPits, int numBats){ int size = x * y; if(size <= 0){ return "error :("; } String[][] map = new String[x][y]; littleRoom[][] rooms = new littleRoom[x][y]; for(int i = 0; i < x; i++){ for(int...
f042f4c0-170f-4b27-83e2-ac176a0ae424
8
public boolean equals(Object obj) { if(obj instanceof Write) { Write new_w = (Write) obj; if((new_w.csn == this.csn) && (new_w.sID == this.sID) && (new_w.acceptStamp == this.acceptStamp) && ((new_w.command).equals(this.command)) && ((new_w.song).equals(this.song)) && ((new_w.URL).equals...
88085bd8-1a31-43e9-8318-0c277c15d968
1
double[] VectorSub(double[] a, double[] b) { double sum[] = new double[a.length]; for (int i = 0; i < a.length; i++) { sum[i] = a[i] - b[i]; } return sum; }
fc35a342-a84c-4ae8-85fa-19f7a00fb51c
2
public static String eliminarComillas(String s){ String ret = new String(); for (int x = 0; x < s.length(); x++) if (s.charAt(x) != '"') ret += s.charAt(x); return ret; }
d2914218-1556-4188-ae10-97dd28d21a98
1
public static Set getCompleteUsefulVariableSet(Grammar grammar) { Set set = getNewUsefulVariableSet(); while (areMoreVariablesThatBelongInUsefulVariableSet(grammar, set)) { String variable = getVariableThatBelongsInUsefulVariableSet( grammar, set); addToUsefulVariableSet(variable, set); } return set;...
878aef23-19f1-476a-8767-e6e72659ba5b
1
private String makeBoardMove(CardGame game) { if (topRow) { return game.moveCardOntoTopRowFromBoard(toMoveTop, boardIndexFrom, boardIndexTo); } else { //Need this in case we undo to see how many we moved easily (or at all?). //If size = 6 and toMoveTop = 5, we moved ...
09c8e357-3572-4ac5-b6b9-1a3ca20960f7
2
public static void CountItems(int Room) { ItemCount = 0; for(int i=0; i<Items.roomItems[Room-1].length; i++) { if(Items.roomItems[Room-1][i] != 0) { ItemCount++; } } }
709633b4-1e04-49ce-98ee-a9e26a2dab0d
2
public boolean isReference() { return type != null && (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY); }
6489069a-ba28-4683-82ac-fdccd9e9bd18
6
final NpcDefinition method794(ConfigHandler interface17, int i) { anInt1394++; int i_2_ = i; if (anInt1368 == -1) { if (anInt1354 != -1) i_2_ = interface17.getRawConfig(anInt1354); } else i_2_ = interface17.getSetting(anInt1368); if (i_2_ < 0 || ((i_2_ ^ 0xffffffff) <= (-1 + ((NpcDefinition) thi...
49bb4627-8e9c-4d1e-90fa-20b3db9638a2
6
public boolean canRotate(){ int i,j; Tetrimino r= new Tetrimino(); r.setMatrix(t.getMatrix()); r.setMatrix(r.rotateLeft(r.getMatrix(), 4, 4)); for(j=0;j<t.getySize();j++){ for(i=0;i<t.getxSize();i++){ if((!r.isEmpty(i, j) && !p.isEmpty(i+t.getPosX(), j+t.getPosY())) || ((!r.isEmpty(i, j) &&...
8749001d-4c32-4a73-8438-cf5a5948731f
4
private boolean continueDividing() { // out of pizels if(intensities.length < 4) return false; if(depth > 6) return false; int tot = 0; for(int i = 0; i < intensities.length; i++){ tot += intensities[i]; } if(tot/intensities.length > 20){ return true; } else{ return false; } }
3cd99268-33f7-44f8-8799-2c4cd0408300
6
protected void loadComplex2HasComponent() { String fileName = dirName + "Complex_2_hasComponent.txt"; if (verbose) Timer.showStdErr("Loading Complex_2_hasComponent from '" + fileName + "'"); int i = 1; for (String line : Gpr.readFile(fileName).split("\n")) { // Parse line String rec[] = line.split("\t");...
3ef962fc-2060-40a8-ab89-f400f7be8a76
8
public static Parameter.Direction randomDir() { Parameter.Direction dir = Parameter.Direction.STOP; switch((int)Math.floor(8*Math.random())) { case 0 : dir = Parameter.Direction.U; break; case 1 : dir = Parameter.Direction.D; break; case 2 : dir = Parameter.Direction.L; break; case 3 : ...
7da8343c-73a1-4eb4-9579-60426b207957
0
private void returnToHomePage() { driver.findElement(By.linkText("home page")).click(); }
357ca554-8859-48e4-b42e-4d637386fa41
1
public int newPassword(User userToUpdate) { try { // Erforderlicher SQL-Befehl String sqlStatement = "UPDATE bookworm_database.users SET username = '" + userToUpdate.getUserName() + "', userpassword = md5('" + userToUpdate.getUserPassword() + "')" + ", userrole = '" + userToUpdate...
79160d1d-bdb3-45a6-88cc-d5e31d360ab3
4
public void setText (String value) { checkWidget (); if (value == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); if (value.equals (super.getText ())) return; /* same value */ super.setText (value); GC gc = new GC (parent); computeDisplayText (gc); gc.dispose (); if (parent.drawCount <= 0 && parent.getHeaderVisi...
232578b7-4e16-450b-90ed-7a318280f4c4
5
public void update() { xa = ya = 0; counter++; counter2++; if(counter > 60) { shoot(); counter = 0; } if(counter2 > 3) { positioning(); counter2 = 0; } if(xa != 0 || ya != 0) { move (xa, ya); walking = true; } else { walking = false; } if(health <= 0) { rem...
2b3faf62-4b57-4d50-b522-cec730dba880
4
public static void main(String[] args) { // TODO Auto-generated method stub VirtualChess object = new VirtualChess(); // Create a new object AbstractPiece [][] x = object.board(); String user_input = " "; i...
c16b8593-2a14-4977-a23a-b56807aa71b6
8
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> <S-IS...
c9fc3057-f86d-43e2-b625-d0de76e4d9b7
0
@Override public void documentAdded(DocumentRepositoryEvent e) {}
d3cdc718-efae-416d-950a-df2187df24d2
9
private Object readResolve() throws ObjectStreamException { if (this.equals(TextBlockAnchor.TOP_CENTER)) { return TextBlockAnchor.TOP_CENTER; } else if (this.equals(TextBlockAnchor.TOP_LEFT)) { return TextBlockAnchor.TOP_LEFT; } else if (this.equals(TextBl...
85beb4aa-5590-45ce-8c7d-67c215c3ad92
5
protected void insererNoeudAB(NoeudArbre<E> noeud) { boolean stop = false; NoeudArbre<E> pivot = root; NoeudArbre<E> pivotPere = NIL; // l'arbre est il vide ? if (root == NIL) { root = noeud; } else { // tant qu'on a pas atteint une feuille, on che...
f8d41f2e-f9d4-46e6-a9ae-4e4469383e2d
1
public static JList<String> getJListString(ArrayList<String> list) { int size = list.size(); final DefaultListModel<String> model = new DefaultListModel<String>(); for (int i = 0; i < size; i++) { model.addElement(list.get(i)); } return new JList<String>(model); }
96f44a51-3d5b-48d7-9885-42ef373828f6
8
private void readData(File dataFile) { Scanner s = makeScanner(dataFile); try { // in case the input doesn't match the specification while (s.hasNextDouble()) { // while there is another row of // values Double[] values = new Double[NumChannels]; for (int channel = 0; channel < NumChannel...
40faaae7-bbe8-4fdf-b6ae-222469319ecf
4
public static void main(String[] args) { try { URL url = new URL( "http://localhost:8080/com.powershare.rest/rest/json/metallica/get"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); if (con...
73975d23-3cdb-49d2-8ee8-7975feaadeda
1
@DELETE @Path("/v2.0/subnets/{subnetId}") public Response deleteSubnet(@PathParam("subnetId") String subnetId) throws MalformedURLException, IOException{ //Send the HTTP request to the REST service HttpURLConnection conn=HTTPConnector.HTTPConnect(new URL(this.URLpath+"/"+subnetId), OpenstackNetProxyConstants.HTTP...
d8f65982-f2fd-4cd8-8f3d-397ebfc93fb8
8
protected boolean handleOutgoingEvent(ChannelEvent event) throws Exception { if( !(event instanceof ChannelStateEvent) ) return false; ChannelStateEvent stateEvent = (ChannelStateEvent) event; switch(stateEvent.getState()) { case CLOSE: close0(); break; case CONNECT: if( stateEvent.getV...
e4051ce1-b4ba-4e39-b838-832be9d727f2
5
public static void main(String[] args) { if (args.length == 3) { int row = 0; int column = 0; int victory = 0; boolean good = true; try { row = Integer.parseInt(args[0]); column = Integer.parseInt(args[1]); victory = Integer.parseInt(args[2]); } catch(NumberFormatException e)...
2d365871-8507-45c6-abf2-fc94c6a0a4f5
5
@Override public void actionPerformed(ActionEvent event) { synchronized (var.monitor) { var.monitor.notify(); } int x = ((Button)event.getSource()).geTx(); int y = ((Button)event.getSource()).geTy(); if (!var.exit) { if (Engine.field.isCellEmpty(x,y))...
90ba02cb-d789-4e3e-8fe0-ce4d730c7171
1
public void testCompareTo() { Instant test1 = new Instant(TEST_TIME1); Instant test1a = new Instant(TEST_TIME1); assertEquals(0, test1.compareTo(test1a)); assertEquals(0, test1a.compareTo(test1)); assertEquals(0, test1.compareTo(test1)); assertEquals(0, test1a.compareTo(t...
94dd8385-c233-41c4-ac90-6322f9deee39
6
public static void UpdatePlaytable() { for(int i = 0; i < mo.users.size(); i++){ if(mo.users.get(i).getUser_ID() == client_ID){ Login.playtable.myRank = i; System.arraycopy(mo.users.get(i).getHand(),0, Playtable.handcopy,0,13); System.arraycopy(mo.users.get(i).getHand(),0, Playtable.newhand,0,13); ...
d5590f3c-82f6-4503-af40-71b326a75f8c
4
@Override public PlayerAction chooseAction(State state, IPlayer player) { lastAction = new PlayerAction(); lastAction.oldStake = player.getCurrentBet(); PlayerAction.ACTION[] actionArray = PlayerAction.ACTION.values(); lastAction.action = actionArray[generator.nextInt(actionArray.length)]; if(state.getBig...
989dfcf7-7d91-4f1f-b1b7-b6dccc6c7a56
7
public boolean canPassHere(Physical affected) { if(affected instanceof MOB) { final MOB M=(MOB)affected; final Room R=M.location(); if(R!=null) { switch(R.domainType()) { case Room.DOMAIN_OUTDOORS_CITY: case Room.DOMAIN_OUTDOORS_SPACEPORT: case Room.DOMAIN_OUTDOORS_UNDERWATER: c...
53e8f441-7797-497d-988f-047930fd5748
3
public void handleGuiKeyInput() { if(KeyHandler.isPressed(KeyHandler.ESCAPE)){ world.displayGui(null); } if(KeyHandler.isPressed(KeyHandler.ESCAPE2) && XboxController.controller != null){ world.displayGui(null); } }
af9afbe7-aeb4-4e75-9f7f-0aa3e1d0600b
2
public String toString() { String s = "{"; for (Location loc : getOccupiedLocations()) { if (s.length() > 1) s += ", "; s += loc + "=" + get(loc); } return s + "}"; }
4097d41e-b9f5-4a03-94e5-75efd9791120
8
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub response.setContentType("text/html"); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); if (session == null || session.getA...
9825abe2-a795-4781-bc0d-b3417956cdeb
9
private double checkRow(int rowC, int rowZeroC, int playerID, int column, int row, int[][] gameBoard) { // The amount of pieces needed to get 4 in a row int need = 4 - rowZeroC - rowC - 1; // The amount of pieces needed to get 4 in a row, updated throughout the method int left = need; // Check the field to t...
e1cb8a16-dd02-49e1-8ccd-cef1666d5fdb
8
public String toString() { String format = ""; if(this.a == 0) if(this.b == -1) return "-i"; else if(this.b == 0) return "0"; else if(this.b == 1) return "i"; else return String.format("%di", this.b); else if(this.b == -1) return String.format("%d-i", this.a); else if(this.b =...
e0d89a4c-5fc6-4cc4-a2ae-5a5c6bb8a9e6
9
public boolean[][] fillIn(int[] order, boolean[][] bAdjacencyMatrix) { int nNodes = bAdjacencyMatrix.length; int[] inverseOrder = new int[nNodes]; for (int iNode = 0; iNode < nNodes; iNode++) { inverseOrder[order[iNode]] = iNode; } // consult nodes in reverse order for (int i = nNodes - 1; i >= 0; i--) {...
38c57b6b-034b-4d53-b899-d776d4104c63
8
public Colour(int alphaComponent, int redComponent, int greenComponent, int blueComponent){ if(alphaComponent > 255 || alphaComponent < 0){ throw new Error("Alpha Component has an invalid value."); } if(redComponent > 255 || redComponent < 0){ throw new Error("Red Component has an invalid value."); } ...
c40dd173-b558-4a16-8c12-8066cffd20a0
9
public void merge(int A[], int m, int B[], int n){ if (n == 0) return; if (m == 0){ for (int i = 0; i < n; i++) A[i] = B[i]; return; } int l = m + n; for (int i = m - 1, j = n - 1; i >= 0 || j >= 0; ){ int valA = i >= 0 ? A[i] : Integer.MIN_VALUE; int valB ...
8c1b0090-ded8-4b54-ba48-ab6e6e370352
6
public void checkForAllCollisions(Collection<Entity> entities) { for (Entity e1 : entities) { for (Entity e2 : entities) { if (!(e1.type == EntityType.ENTITY_WALL && e2.type == EntityType.ENTITY_WALL) && !e1.equals(e2)) { if (existsACollisionBetween(e1, e2)) { ...