text
stringlengths
14
410k
label
int32
0
9
public void func_48708_d() { this.blockRefCount = 0; this.tickRefCount = 0; for (int var1 = 0; var1 < 16; ++var1) { for (int var2 = 0; var2 < 16; ++var2) { for (int var3 = 0; var3 < 16; ++var3) { int var4 = ...
7
public static ArrayList<MstxInfo> getMstxRecommend() { ArrayList<MstxInfo> result = new ArrayList<MstxInfo>(); Connection con = DBUtil.getConnection(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con .prepareStatement("select info_title,info_dis,info_lon,info_lat,a.info_time,a.u...
8
public void setFile(String file) { this.file = file; this.path = assemblePath(this.path_list); }
0
public void keyReleased(KeyEvent e){ // int key = e.getKeyCode(); if (key == KeyEvent.VK_RIGHT || key == KeyEvent.VK_LEFT){ acceleration = 0; stance = Stance.forward; img = imgForward; } if (speed == 0){ stance = Stance.nomove; img = imgForward; } if (key == KeyEvent.VK_UP || key == Ke...
5
public GMLTokenMarker() { super(); schemes.add(new BlockDescriptor(S_DOC_COMMENT, "/\\*(?=\\*)", "\\*/", profile)); //$NON-NLS-1$ //$NON-NLS-2$ schemes.add(new BlockDescriptor(S_BLOCK_COMMENT, "/(?=\\*)", "\\*/", profile)); //$NON-NLS-1$ //$NON-NLS-2$ schemes.add(new BlockDescriptor(S_DOC_LINE_COMMENT, ...
6
public void load(String file) throws UnknownHostException, PersistencyException, FileNotFoundException { RoutingTable routingTable = new RoutingTable(); PersistencyDelegate bootstrapService = new XMLPersistencyService(); bootstrapService.load(file, routingTable); context_.setRoutingTabl...
2
public int indexOf(int[] array, int x){ for (int i =0 ; i < array.length ;i++ ) { if(array[i] == x) return i; } return -1; }
2
public static void main(String[] args) { System.out.print("Enter the array's length\n"); int userNumber = sc.nextInt(); int[] array = new int[userNumber]; for (int i = 0; i < userNumber; i++){ array[i] = r.nextInt(100); } Syst...
6
private void setup() { try { bom = BookingOptionsManager.getInstance(); } catch (IOException ex) { Logger.getLogger(OptionsGui.class.getName()).log(Level.SEVERE, null, ex); } try { options = bom.getAll(); } ...
5
private CubeSerializable getPlayerTeamArea(DodgeballPlayer p) { if(p.getTeam() == TEAM_1) { return TEAM_1_AREA; } else { return TEAM_2_AREA; } }
1
public static void update() { for (int i = 0; i < NUM_KEYS; i++) { prevKeyState[i] = keyState[i]; } }
1
public void clear(int v) { // Remove v from the list of vertices if (startVertex == v) { startVertex = vertices[v]; } else { int i = startVertex; while (vertices[i] != v) { i = vertices[i]; if (i == -1) { return; } } vertices[i] = vertices[v]; } vertices[v] = -1; numVertices-...
9
public static JSONObject JSONObjectOfGenomeFromId(JSONArray organizedJson, int id){ int len = organizedJson.length(); int i,j,k,l; JSONObject json = new JSONObject(); boolean ok = false; for(i = 0; i < len && !ok; i++) { JSONArray groups = organizedJson.getJSONObject(i).getJSONArray("groups"); int le...
9
private void comandoSenao() { //<senao> ::= “senao” “{“ <lista_comandos> “}” “;” System.out.println("To no Senão"); if (tipoDoToken[1].equals(" senao")) { if (!acabouListaTokens()) { nextToken(); if (tipoDoToken[1].equals(" {")) { i...
7
public static void closeQuietly(Closeable closeable) { try { if (closeable != null) { closeable.close(); } } catch (IOException ioe) { // ignore } }
2
public Color(double iR, double iG, double iB) { R = iR < 0 ? 0 : iR > 1 ? 1 : iR; G = iG < 0 ? 0 : iG > 1 ? 1 : iG; B = iB < 0 ? 0 : iB > 1 ? 1 : iB; }
6
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void handleHangingEntities(HangingBreakByEntityEvent event) { if (!(event.getRemover() instanceof Player)) return; Player player = (Player) event.getRemover(); User user = EdgeCoreAPI.userAPI().getUser(player.getName()); ...
7
@Override public void displayHistory(List<PlayerAction> AllActions, List<PlayerAction> ReleventActions) { final String newline = "<br>"; String HistoryText = "<html>"; for(PlayerAction Action : ReleventActions){ HistoryText += Action.print() + newline; } HistoryText += "</html>"; String CompleteTex...
2
public static void main(String[] args) { // Working with Stacks Stack<String> pez = new Stack<String>(); pez.push("Candy 1"); pez.push("Candy 2"); pez.push("Candy 3"); pez.push("Candy 4"); String candy4 = pez.pop(); String candy3 = pez.pop(); System.out.println(candy4); System.out.printl...
0
private void capture( Unit unit, State state ){ state.setProvLoyalty(unit.getLoyalty()); state.setInCapture(true); Turn.addEvent(new com.nasser.poulet.conquest.model.Event(1, state.getProductivity() , state, new Callback<State>(){ public void methodCallback(State state) { ...
4
@Override public void onMessage(String channel, String sender, String login, String hostname, String message) { for ( IRCMsgResponse response : mResponses ) { if ( response.canHandleMessage(sender, message) ) { response.handleMessage(sender, message); List<String> replies = response.getReplies(...
6
public static String doubleToString(double d) { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String string = Double.toString(d); if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && ...
7
public void DBWrite(String[] insert) { try { Date d1 = null; Date d2 = null; d1 = form.parse(insert[5]); d2 = form.parse(insert[4]); long t = d1.getTime() - d2.getTime(); Date dt = new Date(); dt.setTime(t); //System...
1
private boolean promptSaveState() { DisplayState state = this.constructDisplayState(); if(state.equals(study.getDisplayState())) // Don't warn if nothing to save. return true; //Custom button text Object[] options = {"Yes", "No", ...
3
public void setMovie(Movie movie) { if (movie == null) { throw new NullObjectInsertionException(); } this.movie = movie; }
1
public static Map initMap(Map newPopMap){ Map newMap = null; for(int i=0; i<=newPopMap.populationDensity; i++){ newMap = populateMap(newPopMap); } for(int i = 0; i<= newMap.tileMap[0].length-1; i++){ for(int c = 0; c<= newMap.tileMap.length-1; c++){ if(newMap.tileMap[c][i] == null){ newMap...
4
private static void findEnemyFlag(Board b) { int row, col; row = enemyHQL.getRow(); col = enemyHQL.getCol(); // if it is certain that enemy flag is on the left if (b.getPiece(row, col).getRank().equals(Rank.Flag) && !b.getPiece(row, col).getOurSide()) { ene...
5
public static int parseTime(String format) { // Parses XhYm format and turns it into seconds int total = 0; if (!format.matches("[0-9]*h?[0-9]*m?")) return -1; if (format.matches("[0-9]+")) return (Integer.parseInt(format)) * 60; if (format.matches("[0-9]+m")) return (Integer.parseInt(f...
5
private List<SplitCell> detectPotentialSplit(double[][] costs, int[] assigns, SegmentedImage A, SegmentedImage B, double ep){ List<SplitCell> result = new ArrayList<SplitCell>(); for(int i = 0; i < costs.length; i++){ List<ProcessedCell> temp = new ArrayList<ProcessedCell>(); if(assigns[i] == -1) continue; ...
5
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!sender.hasPermission("under50.teleport")) { sender.sendMessage(ChatColor.RED + "No access"); return true; } Player who, toWhom; if (args.length == 1 &...
6
public static final void charSelected(final SeekableLittleEndianAccessor slea, final MapleClient c) { final int charId = slea.readInt(); final String macs = slea.readMapleAsciiString(); if (loginFailCount(c) || !c.login_Auth(charId)) { c.getSession().close(); return; ...
6
public static void print_array (int n, int[] Arr_1, int[] Arr_2) { if ( n < 6 ) { for (int i = 0; i<n; i++) { System.out.println (Arr_1[i] + " " + Arr_2[i]); } } if ( n >= 6 && n != 10) { for (int i = 0; i<5; i++) { System.out.println (Arr_1[i] + " " + Arr_2[i]); ...
9
@Override public Object getValueAt(int rowIndex, int columnIndex) { switch (columnIndex) { case 0: return ((Invoice) data.values().toArray()[rowIndex]).getNumber(); case 1: return ((Invoice) data.values().toArray()[rowIndex]).getClient().getSortKey(); ...
5
private byte[] checkUserPassword( byte[] userPassword, byte[] firstDocIdValue, int keyBitLength, int revision, byte[] oValue, byte[] uValue, int pValue, boolean encryptMetadata) throws GeneralSecurityException, EncryptionUnsupportedByProductExcepti...
4
protected String getStatus() { StringBuilder buf = new StringBuilder(); buf.append("Turns left: ").append(turns).append("\n"); for (int i = 0; i < map.length; i++) { for (int j = 0; j < map[i].length; j++) { buf.append(map[i][j].toString()); } ...
4
public void waitForClientToStart() throws IOException { while (true) { String msg = inStream.readLine(); if ("START".equals(msg)) { break; } } }
2
public void syncDatabase(int syncType, String syncData, HttpServletResponse response) { try { if(syncType == SyncTypes.SYNC_TRANSACTION) { // IF TRANSACTION IS SYNCED THEN RUN THE DATA QUERY IN THE SERVER TABLES new WriteBase().execute(syncData, new Object[]{}); sendResponse(response, Boolean.TRU...
9
public String getPasswordByUID(Statement statement,String phonenumber)//根据用户名获取密码 { String result = null; sql = "select password from Users where phonenumber = '" + phonenumber +"'"; try { ResultSet rs = statement.executeQuery(sql); while (rs.next()) { result = rs.getString("password"); } } ...
2
public static String doubleToString(double d) { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String string = Double.toString(d); if (string.indexOf('.') > 0 && string.indexOf('e') < 0 ...
7
public void incrementRound(Player roundWinner) throws IOException{ // Round complete, add a score to the winner clock.stop(); roundWinner.setScore(roundWinner.getScore() + 1); if(roundWinner.getScore() < maxScore){ // continue playing roundCount++; set...
1
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Cell) { Cell<?> other = (Cell<?>) obj; return getRow() == other.getRow() && getColumn() == other.getColumn() && Objects.equal(getValue(),...
6
@Override public void run() { Elevator elevator = null; while (elevator == null) { if (this.currentFloor > this.requestedFloor){ elevator = this.building.CallDown(currentFloor); } if (this.currentFloor < this.requestedFloor){ elevator = this.building.CallUp(currentFloor); } } synchronized(...
7
private static void offerAction() { println( "Now, choose what to do." ); println( "(d)isplay all urinals, (o)ccupy urinal, (s)hake at urinal, (q)uit game: " ); while( true ) { print( "Action: " ); String input = scanner.next(); if( input.equalsIgnoreCase( "d" ) ) { displayAllUrinals(); } else if(...
6
private void doSend(final CEMILData f, final KNXnetIPConnection.BlockingMode m, final boolean positiveConfirmation) throws KNXTimeoutException, KNXConnectionClosedException { l.received = null; t.send(f, m); if (m == noblock) { while (t.getState() == ConnectionBase.ACK_PENDING) try { Thread.sleep...
7
public int getLargestSequence(int[] input) { int sum = 0; int maxSum = 0; for (int i = 0; i < input.length; i++) { sum += input[i]; if (maxSum < sum) { maxSum = sum; } if (sum < 0) { sum = 0; } } return maxSum; }
3
public String getMyUsername() { return ClientFinder.getInstance().getUsername(); }
0
private void loadPropFile() { try { BufferedReader br = new BufferedReader(new FileReader(pf)); for (String s = ""; (s = br.readLine()) != null;) { String[] p = s.split(":"); if (p[0].equals("name")) { name = p[1]; ServerGame.logger.info("Name set to " + name); } else if (p[0].equals("por...
5
public void init() { if (inited) { return; } Log.info("Initialising sounds.."); inited = true; AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { AL.create(); soundWorks = true; sounds = true; music = true; Log.info("- Sound works"...
8
public void setStandardDeviation(int standardDeviation) { this.standardDeviation = standardDeviation; }
0
public static void doSearch(final Environment env, final String outFileName, final long endTime) { // Create a new search and attempt to do our setup Search search = new Search(env, endTime); search.setup(); if (search.getSolveable()) { // If we haven't already exceeded the time limit... if (System.c...
5
public void setCle(String s){ cle = s.toLowerCase(); for(int i=0 ; i<cle.length() ; i++) if(((int)cle.charAt(i) < 97 || (int)cle.charAt(i) > 122) || (cle.indexOf(cle.charAt(i)) != cle.lastIndexOf(cle.charAt(i)))) cle = ""; if(!s.equals("")){ for(int i=0 ; i<cle.length() ; i++) referenceCle[i] = cle...
8
private JPanel createGeneralSettingsPanel() { JPanel jp = new JPanel(); jp.setBorder(default_border); BoxLayout bl = new BoxLayout(jp, BoxLayout.PAGE_AXIS); jp.setLayout(bl); JPanel ip; // inner panel used for layout. ip = new JPanel(); ip.add(new JLabel("Font Smoothing")); ...
1
@Override public void commit() { for(Entity entity: entities.keySet()) { switch(entity.getState()) { case Changed: entities.get(entity).persistUpdate(entity); break; case Deleted: entities.get(entity).persistDelete(entity); break; case New: entities.get(entity).persistAdd(e...
6
public static BufferedImage loadSplashImage(String path) { BufferedImage splashImage = null; try { splashImage = ImageIO.read(new File(path)); } catch (IllegalArgumentException e) { // TODO if no file found e.printStackTrace(); } catch (IOException e) { // TODO other problems e.printStackTrace();...
2
public String getName() { return this.name; }
0
public void setWidth(double width) { this.width = width; }
0
public float getCurrentLevel() { switch (state) { case ATTACKING: lerpProgression = (System.currentTimeMillis() - triggerTime) / (float) attackDuration; if (lerpProgression >= 1) { state = ADSRStates.DECAYING; triggerTime = Syst...
7
public static void main(String[] args) throws Exception { //System.err.println("ARGS:"+Arrays.toString(args)); for (String key : System.getenv().keySet()) { System.out.println(key + " " + System.getenv(key)); } Map<String, List<String>> argsMap = prepareArgs(args); if...
5
private String resolve(String str) { if (str != null && str.contains("${")) { Matcher ma = null; while ((ma = varPattern.matcher(str)).find()) { String key = ma.group(1); String val = get(key); if (val == null) { ...
4
@Override public void run() { while (true) { try { Thread.sleep(300); } catch (InterruptedException e) { LOG.info(this.toString() + " was interrupted"); } Integer smallestValue = philosophers.get(0).getMealsAmount(); for (Philosopher p : philosophers) { if(p.getMealsAmount() < smallestVal...
6
@Override public String toString() { return "Skill [skillName=" + skillName + ", skillId=" + skillId + "]"; }
0
protected static boolean isOurCanvas(String name) { return name.equals("draw.Canvas") || name.equals("idraw.Canvas") || name.equals("adraw.Canvas") || name.equals("funworld.Canvas") || name.equals("impworld.Canvas") || name.equals("appletworld.Canvas") || name.equals("javalib.worldcanvas.WorldCanvas") ...
9
public int getIdDetalle() { return idDetalle; }
0
@Override public Color[][] getColors(double[][] heightmap, boolean[][] watermap) { Color[][] c = new Color[calc.length][calc.length]; for (int x = 0; x < heightmap.length; x++) for (int y = 0; y < heightmap[x].length; y++) if (watermap[x][y]) if (calc[x][y] <= 0.1) c[x][y] = Color.cyan; else...
5
public static byte[] gzip(String input) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null; try { gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8")); } catch (IOException e) { e.printStackTrace...
3
public static void countRight2(ArrayList<Integer> list, TreeNode node, String s){ if(node == null ) return; StringBuilder sb = new StringBuilder(); sb.append(s); while(node != null){ sb.append(String.valueOf(node.val)); if(node.right == null && node.left == null){ list.add(I...
5
private void configureSpawnRequest(GameObjectSpawnRequest spawnRequest) { int uid = 0; int id = -1; int type = 0; int face = 0; if (spawnRequest.objectType == 0) uid = worldController.getWallObjectHash(spawnRequest.x, spawnRequest.y, spawnRequest.z); if (spawnRequest.objectType == 1) uid = worldC...
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Estado other = (Estado) obj; if (estFinal != other.estFinal) return false; if (inicial != other.inicial) return false; if (nome == null...
8
private int wordstart(int from) { while((from > 0) && !wordchar(line.charAt(from - 1))) from--; while((from > 0) && wordchar(line.charAt(from - 1))) from--; return(from); }
4
boolean contains(float inX, float inY) { float frontFace; if (face == FACE_CURVY) frontFace = 2; else frontFace = 1; if (orientation == Orientation.X) { return (inY >= y0 - frontFace && inY <= y0 + 1 && inX > x0 && inX < x0 + 2 + spineLength); } e...
8
@Override protected void done() { NameData[] nd = null; try { nd = this.get(); } catch(Exception e) { ptm.updateStatus(spContainer, "Data Error!"); } if(nd != null && nd.length > 0) { ptm.updateStatus(spContainer, "Ready!"); fc.addResult(nd[0].getMediaName(), nd, crawledData); } el...
3
public static Entry wrapSrampArtifact(BaseArtifactType artifact) throws URISyntaxException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { // TODO leverage the artifact->entry visitors here Entry entry = new Entry(); if (artifact.getUu...
6
public JSONWriter key(String string) throws JSONException { if (string == null) { throw new JSONException("Null key."); } if (this.mode == 'k') { try { stack[top - 1].putOnce(string, Boolean.TRUE); if (this.comma) { this...
4
@Override public void run() { ++elapseTime; if (state == EnumStopWatchState.RUNNING) { ++tick; } log.info("stopwatch state:" + state + ", elapseTime:" + elapseTime); if (listener != null) { if (date == null) { date = new Date(); } date.setTime(System.currentTimeMillis()); listener.countdow...
3
public static void printCompanyDataToFile(String file, Company company) { BufferedWriter output; FileWriter streamFiles; try { streamFiles = new FileWriter(file, true); output = new BufferedWriter(streamFiles); if(ReadFromFile.getNumberFromFile(file) < 2) { for(int i = 0; i < 9; i++) { if(i!= 8)...
7
public static boolean isSorted(double[] input) { for (int i = 1; i < input.length; i++) { if (input[i-1] > input[i]) { return false; } } return true; }
2
public List<Seance> getSeances() { List<Seance> seances = new ArrayList<Seance>(); Seance tempSeance; int tempIndex; for (Ticket ticket : tickets) { tempSeance = ticket.getSeance(); tempIndex = seances.indexOf(tempSeance); if (tempIndex == -1) { seances.add(tempSeance); }...
2
public void printTop(String type) { if(type.equals("blank")) { System.out.println(); System.out.println("Type 'get help' for help and instructions."); System.out.println(); } if(type.equals("help")) printHelp(); if(type.equals("win")) { System.out.println(); ...
5
@Override public void mouseReleased(MouseEvent e) { if (graphComponent.isEnabled() && isEnabled()) { Iterator<mxCellHandler> it = handlers.values().iterator(); while (it.hasNext() && !e.isConsumed()) { it.next().mouseReleased(e); } } reset(); }
4
public static String matchMovieFromRT(String jsonResponse, Movie movie) throws JSONException { JSONObject jsonObject = new JSONObject(jsonResponse); JSONArray jsonArray = jsonObject.getJSONArray("movies"); for (int i = 0; i < jsonArray.length(); i++) { JSONObj...
5
public static boolean isConflict(ConclusionType ct1, ConclusionType ct2) { if (DEFINITE_PROVABLE.equals(ct1) && DEFINITE_NOT_PROVABLE.equals(ct2)) return true; if (DEFINITE_NOT_PROVABLE.equals(ct1) && DEFINITE_PROVABLE.equals(ct2)) return true; if (DEFEASIBLY_PROVABLE.equals(ct1) && DEFEASIBLY_NOT_PROVABLE.equals...
8
public Method getBestMethod(Object receiver, String methodName, Class<?>[] parameterTypes) { Class<? extends Object> c = receiver.getClass(); while (c != null) { try { return c.getDeclaredMethod(methodName, parameterTypes); } catch (NoSuchMethodException e) { } catch (SecurityException e) { } ...
5
private static double removeCommonDigit(int numerator, int denominator) { int numDig1 = numerator / 10; int numDig2 = numerator % 10; int denDig1 = denominator / 10; int denDig2 = denominator % 10; if (numDig2 == 0 && denDig2 == 0) return -1; if (numDig1 == denDig1) return ((double) numDig2) / denDig2...
6
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed if(!cdb.getText().isEmpty()){ Administrador.Buscar adbc = new Administrador.Buscar(); adbc.setVisible(true); } else{ if(!idb.getText().isEmpty()...
2
public String poprawOsobe(){ return "dodaj"; }
0
int checkHours(RoomScheme chromo, int code){ int counter=0; int auxCounter=0; for(int a=0; a<5; a++){ for(int b=0; b<6; b++){ if(chromo.rooms[a][b].getCode() == code){ auxCounter++; if(auxCounter > 2){ counter--; } ...
4
public static int getInt(CSProperties p, String key) throws ParseException { String val = p.get(key).toString(); if (val == null) { throw new IllegalArgumentException(key); } return Integer.parseInt(val); }
1
public static float[][] getFirstCenter(float[][][] p, int cluster, int min, int max) { int k = max - min + 1; float temp[][] = new float[k][p[0][1].length + 1]; // cluster centroid,the first dimension is index float dis[][] = new float[p.length][p.length];// distance of samples float maxdis = 0;// maximum di...
7
private void create(String initialValue, Color bg, String title, boolean addTransparentBtn) { setPreferredSize(this.preferredDim); if (title != null) { setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title), BorderFactory.createEmptyBorder(5,...
2
public static void main(String[] args) throws JDOMException, IOException { SAXBuilder saxBuilder = new SAXBuilder(); File file = new File("D:\\Java SE\\src\\xml\\jdom\\file.xml"); Document document = (Document)saxBuilder.build(file); Element node = document.getRootElement(); Lis...
1
private static HashMap<Integer, Integer> generateListOfPrimes(Integer NumberofPrimes) { HashMap<Integer, Integer> HashMapofPrimes = new HashMap<Integer,Integer>(); HashMapofPrimes.put(1,2); HashMapofPrimes.put(2,3); for (int i = 4; i < NumberofPrimes; i++) { setDividibleBySomething(false); primInteger = i...
4
@Override public int[] sort(int[] target, boolean asc) { int length = target.length; int gap = length / 2; if (asc) { do { for (int i = 0; (i + gap) < length; i++) { int tmp = target[i + gap]; if (target[i] > tmp) { target[i + gap] = target[i]; target[i] = tmp; } } gap...
7
@Override public void run() { try { System.out.println( "Client has connected" ); if( client_num == FIRST_CLIENT ) { serverLock.lock(); try { while(...
8
public JView getViewByTitle(String title) { if (title == null || title.trim().length() == 0) return null; load(); if (views.size() == 0) return null; for (JView view : views) { if (title.trim().equalsIgnoreCase(view.getDisplayName())) return view; } return nul...
5
public void luoKaydytRuudut(JPanel paneeli, Labyrintti l, Pino polku) { for (int j=0; j<this.koko; ++j) { for (int i=0; i<this.koko; ++i) { boolean lahto = false; boolean maali = false; boolean kayty = false; boolean path = false; ...
9
public void setDestination(Teleporter destination) { if (destination == null || destination.position.equals(position)) throw new IllegalArgumentException("The given Teleporter is invalid!"); if (this.destination != null) throw new IllegalStateException("Destination is already set!"); this.destination ...
3
public void terminal() { try { run(); InputStreamReader isReader = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isReader); System.out.print(">> "); String command = br.readLine(); while (true) { if (command.startsWith("detect ")) { St...
8
public <V> Adapter.Setter<V> makeSetter(String methodName, Class<V> _class) { try { final Method method = version.getClass().getMethod(methodName, _class); return new Adapter.Setter<V>() { public void call(V value) { try { Transaction me = Thread.getTransaction(); ...
7
public double getValue(double x) { if (len.length == 0) { return Double.NaN; } if (len.length == 1) { if (len[0] == x) { return pos1D[0]; } else { return Double.NaN; } } int index = Arrays.binarySearch(len, x); if (index > 0) { return pos1D[index]; } index = - (...
5
private int num(int n){ if(n==1) return 1; int cnt=0; int max=n; for(int i=1;i<max/2;++i){ if(n%i==0){ cnt+=2; max=n/i; } } return cnt; }
3