text
stringlengths
14
410k
label
int32
0
9
public void normalizeSquared(int col) { double sqr = 0.0f; for(int j=0; j < nrows; j++) { double x = (double) getValue(j, col); sqr += x * x; } System.out.println("Normalize-squared: " + col + " sqr: " + sqr); float div = (float) Math.sqrt(sqr); S...
5
@Override public void actionPerformed(ActionEvent e) { OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched(); OutlinerCellRendererImpl textArea = doc.panel.layout.getUIComponent(doc.tree.getEditingNode()); if (textArea == null) { return; } Node node = textArea.n...
3
public String getId() { return id; }
0
@SuppressWarnings({ "unused", "unchecked" }) private HashMap<String, ActionPattern> buildActionPatterns(Agent agent, HashMap<String, Competence> competences2, HashMap<String, ActionPattern> actionPatterns2) { //HashMap<String, ActionPattern> returnActionPatterns = new HashMap<String, ActionPattern>(); Has...
9
double[] recPositions(int chrom) { //get all recPositions of the first haplotype: double[] recpos = new double[0]; for (int p=0; p<getPloidy(); p++) { ArrayList<Double> hrecs = haplostruct[chrom][p].getRecombPos(); int rp=0; //index to recpos for (int hp=0; hp...
9
public void writeVariant(Variant var) throws IOException { if (var.isStringType()) { writeString(var.getString()); } else if (var.isObjectType()) { out.append('{'); writeln(); boolean first = true; for (Map.Entry<String, Variant> e : var.varOb...
9
public static void update(GameContainer container, int delta) throws SlickException { if (isInputPressed(Controls.DEBUG)) { setDebug(!isDebug()); } if (transition != null) { transition.update(game, container, delta); ...
5
@Raw public World(double width, double height, boolean[][] passableMap, Random random) throws IllegalArgumentException { if (!isValidDimension(width, height)) throw new IllegalArgumentException("The dimension provided isn't a valid dimension for a World"); if(random == null) throw new IllegalArgumentExcep...
4
private String getTripText (Integer trip) { String s = "Gruppe: " + tripsOfDay.get(trip).getGroupNumber().toString(); s += " Fluss: " + tripsOfDay.get(trip).getRiver().getRiverName(); s += " WW" + tripsOfDay.get(trip).getRiver().getWwLevel() + "\n"; s += "Start: " + tripsOfDay.get(t...
2
private boolean jj_2_21(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_21(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(20, xla); } }
1
public void printTable() { Setup.println(" DISTANCE TABLE"); Setup.println("----------------------------------------------------------"); for (String n : dv.keySet()) { Setup.print("\t" + n); } Setup.println(); // print mine Setup....
5
protected void backfitHoldOutInstance(Instance inst, double weight, Tree parent) throws Exception { // Insert instance into hold-out class distribution if (inst.classAttribute().isNominal()) { // Nominal case if (m_ClassProbs == null) { m_ClassProbs = new double[inst.numClasses()]; } ...
9
public int getSearchArticleCount(String search,String val, int area) throws Exception{ Connection conn = null; PreparedStatement pstmt = null; Statement stmt = null; ResultSet rs = null; int x = 0; try{ conn = getConnection(); val = new String(val.getBytes("iso_8859-1"),"utf-8"); String sql = "sele...
8
@SuppressWarnings("unchecked") @PUT @Produces( { "application/json", "application/xml" }) @Path("/mood/title/{title}/{username}/{valence}/{arousal}") public void putMoodByName(@PathParam("title") String title, @PathParam("username") String username, @PathParam("valence") double valence, @PathParam("arousal") ...
5
@Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(jbEscolha)) { String strMsg = validaFormulario(); if (!strMsg.equals("")) { JOptionPane.showMessageDialog(rootPane, strMsg); } else { if (jrbDocAnalise.isSelect...
6
@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...
9
public boolean existII(char[][] board, String word) { if (board == null || board.length == 0 || word.length() > board.length * board[0].length) return false; char c = word.charAt(0); for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[i].length; j++) { if (c == board[i][j]) { boolean...
7
@EventHandler public void SilverfishNausea(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.getSilverfishConfig().getDouble("Silverf...
6
public boolean doHashCheck (DownloadInfo asset, final List<String> remoteHash) throws IOException { String hash = DownloadUtils.fileHash(asset.local, asset.hashType).toLowerCase(); List<String> assetHash = asset.hash; boolean good = false; if (asset.hash == null) { if (remote...
7
public static void main (String[] args) throws FileNotFoundException { Scanner key = new Scanner(System.in); // System.out.println("enter title name"); // String input = key.nextLine(); File htmlDir = new File("G:/Code/htmls/"); File[] htmls = htmlDir.listFiles(); ...
8
public void run(){ while(true){ try { try { Thread.sleep(1000); } catch (InterruptedException ex) {} System.err.println("Deamon"); Transporte tr = new Transporte(100); DatagramPacket p = tr.receberDatagramPacket(receiveSocket);...
5
public boolean isReady(){ return ( !resultReady && !isPlaceHolder(addr_comp[0]) && !isPlaceHolder(addr_comp[1]) && ( !is_store || (is_store && !isPlaceHolder(addr_comp[2])) ) ); // force store to wait for register value }
5
private static void diffDefaultValues(final PrintWriter writer, final PgView oldView, final PgView newView, final SearchPathHelper searchPathHelper) { final List<PgView.DefaultValue> oldValues = oldView.getDefaultValues(); final List<PgView.DefaultValue> newValues...
9
public static void M(Topic root) { ArrayList<SparseMatrix> edges = root.Get_edgeset(); float[][] eijk = root.clone2df(root.Get_edgeweight()); int ii = eijk.length; // number of edges int jj = eijk[0].length; // number of topics //float[] rho_z_M = root.clone1df(root.Get_rho_z()); float[] rho_z_M = ...
7
public void testThreadSafety() throws Exception { rnd = newRandom(); final int numThreads = 5; final int numDocs = 50; final ByteArrayPool pool = new ByteArrayPool(numThreads, 5); Directory dir = new RAMDirectory(); final IndexWriter writer = new IndexWriter(dir,...
7
public void close() { if(socket != null) { try{ socket.close(); ServerHelper.log(LogType.NETWORK, "ServerSocket geschlossen"); } catch(IOException e) { ServerHelper.log(LogType.ERROR, "Fehler beim Schließ...
2
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { if (dir.toString().equalsIgnoreCase(ROOTDIR)) return CONTINUE; String name = "" + dir; String[] comps = name.split("/"); String tmp = comps[comps.length - 1].toLowerCase(); if (related.length == 0) { ...
9
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); String line = ""; while ((line = in.readLine()) != null && line.length() != 0) { double xm = Double.parseDouble(line.trim()); doubl...
5
public static final int getDropRate(byte village) { switch (village) { case 0: return 20; case 1: return 10; case 2: return 10; case 3: return 30; case 4: return 10; ...
7
public void removeEdge(final GraphNode v, final GraphNode w) { final Block src = (Block) v; final Block dst = (Block) w; if (FlowGraph.DEBUG) { System.out.println(" REMOVING EDGE " + src + " -> " + dst); } super.removeEdge(src, dst); cleanupEdge(src, dst); }
1
public static Matrix getMatrix(int rows, int cols, DataType dataType) { Matrix matrix = null; switch (dataType) { case INTEGER: matrix = new MatrixInteger(rows, cols); break; case DOUBLE: matrix = new MatrixDouble(rows, cols); ...
3
public static void main(String[] args) throws NoSuchMethodException, IOException { ExpressionFactory factory = new ExpressionFactoryImpl(); SimpleContext context = new SimpleContext(); // variables e, pi context.setVariable("e", factory.createValueExpression(Math.E, double.class)); context.setVariable("pi",...
8
public double score(StringWrapper s,StringWrapper t) { computeTokenDistances(); BagOfTokens sBag = (BagOfTokens)s; BagOfTokens tBag = (BagOfTokens)t; double sim = 0.0; for (Iterator i = sBag.tokenIterator(); i.hasNext(); ) { Token tok = (Token)i.next(); double df = getDocumentFrequency(tok); if ...
5
public boolean checkForNewVersion(boolean notifyNoUpdate) { String currentVersion = versionManager.getVersion(); String newVersion = versionManager.checkForNewVersion(); boolean newVersionAvailable = false; if (newVersion != null && currentVersion != null) { if (Version.compare(newVersion, currentVersion) ...
8
public void editAcc() throws FileNotFoundException, IOException { System.out.println("Which Account do you want to edit? (Account Number)"); Scanner impor = new Scanner(System.in); String editLine = "hi"; int ach = impor.nextInt(); String path = accDir+ach+".txt"; String newline = System.getProp...
5
public static int discrete(double[] a) { double EPSILON = 1E-14; double sum = 0.0; for (int i = 0; i < a.length; i++) { if (a[i] < 0.0) throw new IllegalArgumentException("array entry " + i + " is negative: " + a[i]); sum = sum + a[i]; } if (sum > 1.0 + EP...
7
public boolean isLine(){ int countUnblocked=0; for(int i = 0; i < corridor.length; i++) { if(corridor[i].getWeight()==1){ countUnblocked++; } } if(countUnblocked == 2) { if(corridor[0].getWeight() == 1 && corridor[2].getWeight() == 1){ return true; } else if(corridor[1].getWeight() == 1 &...
7
private void drawTooltip() { if (menuActionCount < 2 && itemSelected == 0 && spellSelected == 0) { return; } String text; if (itemSelected == 1 && menuActionCount < 2) { text = "Use " + selectedItemName + " with..."; } else if (spellSelected == 1 && menuAc...
8
SortedSet<Dimension> read() throws CubeXmlFileNotExistsException, IOException, DocumentException { Configuration conf = CubeConfiguration.getConfiguration(); FileSystem hdfs = FileSystem.get(conf); Path dimensionXmlFile = new Path(PathConf.getDimensionXmlFilePath()); if (!hdf...
7
private int jjMoveStringLiteralDfa11_0(long old0, long active0) { if (((active0 &= old0)) == 0L) return jjStartNfa_0(9, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(10, active0); return 11; } switch(curChar) { case 10...
5
/* */ public void update(int time) /* */ { /* 58 */ if ((Math.abs(this.x - this.targetX) < 5.0F) && (Math.abs(this.y - this.targetY) < 5.0F)) { /* 59 */ this.speedX = 0.0F; /* 60 */ this.speedY = 0.0F; /* 61 */ this.active = true; /* */ } /* 63 */ this.x += this.speedX; /* 64 ...
4
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } RangeConstraint other = (RangeConstraint) obj; i...
9
private void updateViews() { if(!cardViews.isEmpty()) { for(CardView temCard : cardViews) { remove(temCard); } cardViews.clear(); } MouseListener mouseListener = new MouseListener(); List<Card> cards = player.getCardGroup().getCardList(); CardView cardView; for(Card card : cards) { cardVi...
4
public Rectangle getAbsoluteRect() { Rectangle absRect = new Rectangle(); int unitVal = unit.value; absRect.x = x * unitVal; absRect.y = y * unitVal; absRect.width = width * unitVal; absRect.height = height * unitVal; return absRect; }
0
public boolean setInputFormat(Instances instanceInfo) throws Exception { super.setInputFormat(instanceInfo); // Make the obfuscated header FastVector v = new FastVector(); for (int i = 0; i < instanceInfo.numAttributes(); i++) { Attribute oldAtt = instanceInfo.attribute(i); Attribute n...
7
public LogWindow() { super("Game History"); setLayout(new FlowLayout()); setSize(WIDTH, HEIGHT); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setResizable(false); list = new JList<String>(listModel); list.setLayoutOrientation(JList.VERTICAL); JScrollPane listScroller = new JScrollPane(l...
0
public static void main (String args[]) { System.out.println("HTTPServer.java"); ServerSocket Server = null; try { Server = new ServerSocket (5000, 10, InetAddress.getByName("192.168.43.247")); } catch (UnknownHostException e) { System.out.println("Unknown host"); } catch (IOException e) { ...
4
private Array createFixedWaysPath(Ways way, Array start, GameContainer container, StateBasedGame game) throws SlickException { Array currrentNode = start; Array newNeighboor = null; for (int i = 0; i < MIN_WAY_SIZE + (int) (Math.random() * MAX_WAY_SIZE); i++) { switch (way) { case NORTH: newNeighboor...
7
public boolean equals( Object o) { if ((o == null) || !(o instanceof DERUnknownTag)) { return false; } DERUnknownTag other = (DERUnknownTag)o; if(tag != other.tag) { return false; } if(data.length != other.data.length) { ret...
6
public AudioServer(String [] args) { isRunning = true; isPlaying = true; /* Check port exists */ if (args.length < 1) { System.out.println("Usage: ChatServerMain <port>"); System.exit(1); } /* Create the server socket */ try { serverS...
4
private void jButtonPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPesquisarActionPerformed Cidadao cidadao = new Cidadao(); Bairro bairro = new Bairro(); Cidade cidade = new Cidade(); Estado estado = new Estado(); cidade.setEstado(estado); ...
6
public void setCells(Object[] cells) { if (cells != null) { if (singleSelection) { cells = new Object[] { getFirstSelectableCell(cells) }; } List<Object> tmp = new ArrayList<Object>(cells.length); for (int i = 0; i < cells.length; i++) { if (graph.isCellSelectable(cells[i])) { ...
4
@Test public void testGetX() { System.out.println("getX"); assertEquals(1.0, new Orb(4,12,1,1).getX(), 0.00001); }
0
public static void disposeColors() { for (Color color : m_colorMap.values()) { color.dispose(); } m_colorMap.clear(); }
1
public static Equation parseEquation(String strEquation) throws InvalidEquationException{ //Create a list of expressions ArrayList<Expression> expressionList = new ArrayList<Expression>(); //Create a queue of integers LinkedList<Integer> digits = new LinkedList<Integer>(); //for each character in the answer ...
9
public Vector<BaseRace> getRankedRaces(int rank) { Vector<BaseRace> br = new Vector<>(); for (ClassMap item : _classMap) { if (item.getClassType().getName().equals(_class.getName())) { if (item.getAverage() == rank) { br.add(item.getRace()); ...
3
public static void main(String... args) throws IOException { ServerSocket serverSocket = new ServerSocket(13800); Socket socket = serverSocket.accept(); InputStream inputStream = socket.getInputStream(); Scanner scanner = new Scanner(inputStream); OutputStream outputStream = sock...
2
public static void main(String[] args) { try { File file = new File(Path); Scanner scanner = new Scanner(file); scanner.useDelimiter("#NEW RECORD\n"); int counter = 0; while (scanner.hasNext()){ String document = scanner.next(); ...
8
public void test_convertText() { BaseDateTimeField field = new MockBaseDateTimeField(); assertEquals(0, field.convertText("0", null)); assertEquals(29, field.convertText("29", null)); try { field.convertText("2A", null); fail(); } catch (IllegalArgumentExc...
2
private <T> StringConverter<T> findAnnotatedConverter(final Class<T> cls) { Method toString = findToStringMethod(cls); // checks superclasses if (toString == null) { return null; } MethodConstructorStringConverter<T> con = findFromStringConstructor(cls, toString); Me...
6
public void cargarProductos() { try { Connection conn = Conexion.GetConnection(); try { st = conn.createStatement(); pro = st.executeQuery("SELECT * FROM Productos"); } catch (SQLException e) { JOptionPane.showMessageDialog(this...
3
public static boolean isCyclicUndirected(mxAnalysisGraph aGraph) { mxGraph graph = aGraph.getGraph(); mxIGraphModel model = graph.getModel(); Object[] cells = model.cloneCells(aGraph.getChildCells(graph.getDefaultParent(), true, true), true); mxGraphModel modelCopy = new mxGraphModel(); mxGraph graphCopy = n...
3
public List<Tuple<Integer,Integer>> reconstructPath ( HashMap<Tuple<Integer,Integer>,Tuple<Integer,Integer>> cameFrom, Tuple<Integer,Integer> currentNode ) { int delayNearEndpoints = 3; int roomNearEndpoints = 3; //log.trace("reconstructPath: cameFrom size:" + cameFrom.size() ); List<Tuple<Integer,Integer>> ...
5
public void nextPermutation(int[] nums) { if(nums.length <= 1) { return; } int i = nums.length - 2; for(; i >= 0; i--) { if(nums[i+1] > nums[i]) { break; } } if(i == -1) { reverse(nums, 0, nums.length-1); ...
6
public final DirkExpParser.equalityExpr_return equalityExpr() throws RecognitionException { DirkExpParser.equalityExpr_return retval = new DirkExpParser.equalityExpr_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token set9=null; DirkExpParser.relationalExpr_re...
7
public static boolean check(Robot paramRobot) { return (robotContainsBeacon(paramRobot)) || (lostOnlyPart(paramRobot, new Hermes().getClass())) || (lostOnlyPart(paramRobot, new Launcher().getClass())) || (lostOnlyPart(paramRobot, new Arachnae().getClass())) || ( (noRobotsLeft()) && (cantMakeAC...
5
public List<String> getIP(String url) throws IOException{ URL u = new URL(url); BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream())); String s = ""; List<String> ipList = new ArrayList<String>(); String regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"; Pattern p = Pat...
2
public static void main(String[] args) { new Main(); }
0
public E element() { E rv; if((rv = peek()) == null) throw(new NoSuchElementException()); return(rv); }
1
public GUI() { try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exc...
4
public static Object nartSubstitute(Object cyclObject, CycAccess access) throws IOException { if (!DefaultCycObject.isCycLObject(cyclObject)) { throw new RuntimeException(DefaultCycObject.cyclify(cyclObject) + " is not a valid Cyc object."); } if (!(cyclObject instanceof CycObject)) { // @todo need ...
2
public Alphabet( String path, String texFile, String alphaFile, String mapFile, int numLines, int lineHigh ) { // Basic initialisation routine here. The list of individual characters // must be loaded first for comparison with scanned character blocks. int charMap[] = null ; final int m...
9
public void colorBiddableLand(Graphics g){ String player = Requests.teamName; String owner; Grid grid = request.operator.getGrid(); Point p; for(int i = 0; i < s; i++){ for(int j = 0; j < s; j++) { p = new Point(j,i); owner=grid.getOwner(p); if(!grid.exists(p)||owner==null){ //If no o...
8
@Test public void construction() { int size = 30; List<Calendar> dates = new ArrayList<>(30); for (int i = 0; i < size; i++) { dates.add(Calendar.getInstance()); } IntervalList list = new IntervalList(dates); assertEquals(size / 2, list.size()); }
1
public void maintenence()// well, kind of what it sounds like. Kings pieces, // checks for draws, etc... { for (int x = 0; x < 8; x++)// kinging. { if (theBoard[x][7].getPiece() == '@') { theBoard[x][7].king(); } else if (theBoard[x][0].getPie...
9
public static void main(String[] args) { int[] vals; Scanner scan = new Scanner(System.in); try { while (true) { try { System.out.print("How long would you like the array to be? "); int count = scan.nextInt(); ...
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...
7
public void testPropertySetDayOfWeek() { DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0); DateTime copy = test.dayOfWeek().setCopy(4); assertEquals("2004-06-09T00:00:00.000+01:00", test.toString()); assertEquals("2004-06-10T00:00:00.000+01:00", copy.toString()); try...
2
public static int[][] adjoint(int[][] matrix){ //preconditions if(matrix == null)throw new IllegalArgumentException("matrix must not be null"); for(int i = 0; i < matrix.length; i++){ if(matrix.length != matrix[i].length)throw new IllegalArgumentException("matrix must be square!"); } int[][] newMatrix =...
5
public String toString() { String strType; switch (type) { case _AVERAGE: strType = STR_AVERAGE; break; case _MIN: strType = STR_MIN; break; case _MAX: strType = STR_MAX; break; case _LAST: strType = STR_LAST; break; default : throw new RuntimeException("Thi...
4
public PolyEquationImpl(final BigInteger[] inCoeffs) { if (inCoeffs.length <= 0) { throw new SecretShareException("Must have at least 1 coefficient"); } coefficients = new BigInteger[inCoeffs.length]; for (int i = 0, n = inCoeffs.length; i < n ; i++) ...
5
public void addOpdrachtToList(Opdracht opdracht) { try { if (opdrachten.size() != 0) { if (!opdracht.equals(null) || !opdrachten.contains(opdracht)) { Opdracht o = opdrachten.get(opdrachten.size() - 1); opdracht.setId(o.getId() + 1); } } else { opdracht.setId(opdrachten.size() + 1); } ...
4
@SuppressWarnings("resource") public static void denyRdr() throws IOException{ if (!dnames.exists()){dnames.createNewFile();} BufferedReader rfile = new BufferedReader(new FileReader(dnames)); String nme=null; for (int i=0;i<6;i++){ nme=rfile.readLine(); if (nme!=null && !nme.isEmpty())...
4
public void finalizeMap(){ for (int i = 0; i < tiles.length; i++) { for (int j = 0; j < tiles.length; j++) { if (tiles[i][j] == 'S') { myX = 25 + i * 50; myY = 25 + j * 50 ; } if (tiles[i][j] == 'R') { mySecondX = 25 + i * 50; mysecondY = 25 + j * 50; } } } int count=0; ...
9
protected static int partition(double[] arrayToSort, double[] linkedArray, int l, int r) { double pivot = arrayToSort[(l + r) / 2]; double help; while (l < r) { while ((arrayToSort[l] < pivot) && (l < r)) { l++; } while ((arrayToSort[r] > pivot) && (l < r)) { r--; } ...
8
public void testPropertyCompareToYear() { YearMonth test1 = new YearMonth(TEST_TIME1); YearMonth test2 = new YearMonth(TEST_TIME2); assertEquals(true, test1.year().compareTo(test2) < 0); assertEquals(true, test2.year().compareTo(test1) > 0); assertEquals(true, test1.year().compar...
2
private boolean hasSerialArrayListFlavor(DataFlavor[] arrDfIn) { if (this.dfSerial == null) return false; for(int iCnt = 0; iCnt < arrDfIn.length; iCnt ++) { if (arrDfIn[iCnt].equals(this.dfSerial)) return true; } return false; }
3
public Berechtigung getBerechtigungzuidBerechtigung(int idBerechtigung) { Berechtigung rueckgabe = null; ResultSet resultSet; try { resultSet = db .executeQueryStatement("SELECT * FROM Berechtigungen WHERE idBerechtigung = '" + idBerechtigung + "'"); if(resultSet.next()) rueckgabe = new Berec...
2
public static int removeHandler(Board theBoard, Army army, String team) { int r, c; if(army.getCapacity() == army.getRemaining()) { System.out.println("No armies to remove."); return 0; } else { System.out.print("Enter row of piece to remove: "); r = Integer.parseInt(""+input.next().charAt...
8
public boolean actionBuild(Actor actor, Venue built) { // // Double the rate of repair again if you have proper tools and materials. final boolean salvage = built.structure.needsSalvage() ; final boolean free = GameSettings.buildFree ; int success = actor.traits.test(HARD_LABOUR, ROUTINE_DC, 1) ? 1...
8
public void attack(){ for(int i = 0; i<enemies.size(); i++){ if((Driver.player.getX() > enemies.get(i).getX()-enemies.get(i).getRange()) && (Driver.player.getX() < enemies.get(i).getX()+enemies.get(i).getRange()) && (enemies.get(i).getY() == Driver.player.getY())) enemies.get(i).attack(); } }
4
public void paint(Graphics g) { // clear previous image g.setColor(Color.WHITE); g.fillRect(0, 0, getWidth(), getHeight()); // draw grid BufferedImage myImage = null; try { java.net.URL myImageURL = TicTacToe.class .getResource("images/grid.png"); myImage = ImageIO.read(myImageURL); } catch (IO...
9
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { try { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "The server doesn't have a PIN!"); return true; } Player player = (Player)sender; if (HyperPVP.getStorage().readS...
4
public void svg2pngUsingInkscape(File svgFile, File pngFile) throws ConverterException { if(inkscapePath==null) throw new ConverterException("No runtime defined for Inkscape"); // inkscape classDiag.svg -e classDiag.png -d 200 ProcessBuilder pb = new ProcessBuilder( ...
3
@Override public void update(GameContainer container, StateBasedGame sbg, int delta) throws SlickException { xpos=container.getInput().getMouseX(); ypos=container.getInput().getMouseY(); bonusButton.update(delta); updateEntities(delta); if(time > 0){ time -= delta*1/1000f; if(time%10 == 0){ coun...
3
int putIndexed(int tag, Object obj1, int index1, int index2) { Key key = new Key(tag, obj1, index2); Integer indexObj = (Integer) entryToIndex.get(key); if (indexObj != null) { /* Maybe this was a reserved, but not filled entry */ int index = indexObj.intValue(); indices1[index] = index1; indices2[ind...
1
@Override public void init(boolean isServer) { timer = 0; tiles = new Tile[99][99]; for(int x = 0; x < tiles.length; x++) for(int y = 0; y < tiles[x].length; y++) tiles[x][y] = new Tile(this, x, y); entities = new ArrayList<Entity>(); //for(int i = 0; i < 7; i++) //entities.add(new RandomWalkEnti...
2
public void disconnect() { //windowController.getSendTextArea().setDisable(true); //windowController.getSubmitButton().setDisable(true); shutdownReconnectWorker(); if(connectionCheckTimer != null) { connectionCheckTimer.cancel(); } if(!echoSocket.isClosed()) { preDisconnect(); ...
4
private void pop(char c) throws JSONException { if (this.top <= 0) { throw new JSONException("Nesting error."); } char m = this.stack[this.top - 1] == null ? 'a' : 'k'; if (m != c) { throw new JSONException("Nesting error."); } this.top -= 1; ...
5
public static void main(String[] args) { Integer i = new Integer(253); if((i & 0x01) == 1){ System.out.println("CARRY"); } System.out.println(Integer.toBinaryString(i)); i = i >> 1; System.out.println(Integer.toBinaryString(i)); }
1