text
stringlengths
14
410k
label
int32
0
9
private String getDebugInfo(Game.CarInfo myCarInfo, Game game, double desiredSpeed, double throttle, AngleState as, double nextAngle) { GameInit.Race.Track.Piece piece = game.track.pieces[myCarInfo.pieceIndex]; double racc = myCarInfo.getRAcceleration(); double r = myCarInfo.getR(); if (...
6
public int getTurn() { int count = 0; for(int j = 0; j < takenSpaces.length; j++) { if(takenSpaces[j] != 0) { count++; } } if(count%2 == 0) { return 1; } else return 2; }
3
private void colorGrid() { m_layeredPane.resetColors(); int day = m_currentWeek.getDayOfWeek().getValue(); // 1-7 // plan before / after int startHour = m_appSettings.getStartPlanningTime().getHour(); int endHour = m_appSettings.getEndPlanningTime().getHour(); int startMinutes = m_appSettings.getStartPlanni...
6
public Command getCommand(char operator) { switch (operator) { case '>': return new GoToNextCell(); case '<': return new GotoPrevCell(); case '+': return new IncrementValue(); case '-': return new De...
6
private static int onkoMillainenPari(Sitsaaja sitsaaja) { if (sitsaaja.avecIsSet()) { if (sitsaaja.isMies() && sitsaaja.getAvec().isMies() == false) { return 1; } else if (sitsaaja.isMies() == false && sitsaaja.getAvec().isMies()) { return -1; ...
5
public static Bitmap[][] recolor(Bitmap[][] bitmaps, int a0, int b0, int a1, int b1) { for (int x = 0; x < bitmaps.length; x++) { for (int y = 0; y < bitmaps[x].length; y++) { Bitmap bm = bitmaps[x][y]; for (int i = 0; i < bm.pixels.length; i++) { if (bm.pixels[i] == a0) bm.pixels[i] = b0; if (bm...
5
public void move() { if (xcor >= framex) { xcor = -image.getWidth(null); } else if (xcor <= -image.getWidth(null)) { xcor = framex; } // Controls wrap around in the y-axis if (ycor >= framey) { ycor = -image....
4
public String toString(){ if (var!=null) return var.data; else if (list != null){ String res = "("; for (LISP_object it: list) res = res+it.toString()+" "; res = res+")"; return res; }else if (proc != null) return "FUNCTION"; else return ""...
4
public void countInitialFitnessAllPop() throws Exception { for (int i = 0; i < getSpecies().size(); i++) { for (int j = 0; j < getSpecies().get(i).getNumberOrganisms(); j++) { getSpecies().get(i).getOrganism(j).countFitnessOut(1); } } }
2
public void mousePressed(MouseEvent e) { // Stops any moves from being made once the puzzle is solved. if (isSolved()) return; // Gets the row and column of the clicked square int row = e.getY() / 100; int col = e.getX() / 100; // get coordinate of black square int[] blackSquare = adjacentBlackSquare...
4
public LinkedList<Point> getAdjacentPoints(int x, int y){ LinkedList<Point> adjacents = new LinkedList<Point>(); int cx,cy; for(int i = -1; i <= 1; i++){ for(int j = -1; j <= 1; j++){ cx = x + i; cy = y + j; if(cx >= 0 && cx < gridDims.width && cy >= 0 && cy < gridDims.height && !(i ==...
8
protected void buy(Player player, Game game) { Integer gold = player.getGold(); for (CardsToBuy couple : buyOrder) { if (couple.numberToBuy > 0 && couple.card.getCost() <= gold) { try { game.buy(couple.card, player); couple.numberToBuy--; break; } catch (BuyException e) { logger.error...
4
public void setFPS(int fps) { this.fps = fps; }
0
@Override public void manageInput(InputEvent e) { if (e.isKeyInput()) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) exitScreen(); } else { panel.manageInput(e); cancelButton.manageInput(e); } }
2
public ArrayList<Process> generateProcesses() { float arrivalTime; float expectedTime; int priority; generator = new Random(1); //paramater is seed used for random number generator for(int i = 0; i < numProcesses; i++){ //create random number for arrival time ...
4
@Override public String resaveFaction(Faction F) { if((F.factionID().length()>0) &&(CMLib.factions().getFaction(F.factionID())!=null)) { if(!CMath.bset(F.getInternalFlags(), Faction.IFLAG_NEVERSAVE)) { final StringBuffer buf = rebuildFactionProperties(F); String factionFilename = makeFactionFilena...
7
public void run() { System.out.println("Chef run"); try { while (!Thread.interrupted()) { restaurant.lock.lock(); try { if (restaurant.meal != null) restaurant.noMealCondition.await(); restaurant.meal = new Meal(0); System.out.println("Meal come"); restaurant.fullMealCondition.sign...
3
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!getClass().equals(obj.getClass())) return false; Device other = (Device) obj; return id == other.id && idComponent == other.idComponent && idPrev == other.idPrev && title.equals(other....
6
public void keyReleased(int k) { if(k == KeyEvent.VK_LEFT) player.setLeft(false); if(k == KeyEvent.VK_RIGHT) player.setRight(false); if(k == KeyEvent.VK_UP) player.setUp(false); if(k == KeyEvent.VK_DOWN) player.setDown(false); if(k == KeyEvent.VK_W) player.setJumping(false); }
5
public void set(int key, int value) { Node node = map.get(key); if (capacity == map.size()) { if (null == node) { Node rmn = dlist.removeEnd(); map.remove(rmn.key); Node n = new Node(key, value); dlist.add(n); map.put(key, n); } else { Node n = dlist.remov...
3
public static void arc(double x, double y, double r, double angle1, double angle2) { if (r < 0) throw new RuntimeException("arc radius can't be negative"); while (angle2 < angle1) angle2 += 360; double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*r); doubl...
4
@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> alread...
9
private final void step6() { j = k; if (b[k] == 'e') { int a = m(); if (a > 1 || a == 1 && !cvc(k-1)) k--; } if (b[k] == 'l' && doublec(k) && m() > 1) k--; }
7
private boolean checkScannedRobot(){ boolean scanned = false; for (int i = 0; i < Board.robots.size(); i++) { if(Board.robots.get(i) != this){ Point2D pfradar = this.movePoint(this.radar.x+18 , this.radar.y+20, this.radar.angle, 800); Line...
5
void setCellBackground () { if (!instance.startup) { textNode1.setBackground (1, cellBackgroundColor); imageNode1.setBackground (1, cellBackgroundColor); } /* Set the background color item's image to match the background color of the cell. */ Color color = cellBackgroundColor; if (color == null) color =...
3
@Basic @Column(name = "PRP_FECHA") public Integer getPrpFecha() { return prpFecha; }
0
private DbHelper() { try { Class.forName(driver); if (login.equals("")) { conn = DriverManager.getConnection(url); } else { conn = DriverManager.getConnection(url, login, password); } logger.info("Connection OK!"); ...
3
@Test public void test_twoParamComplexExtends() { TypeToken<?> token = new TypeToken<Map<String, Map<? super Integer, ? extends List<? extends Number>>>>() {}; doTest(token, "java.util.Map<java.lang.String, java.util.Map<" + "? super java.lang.Integer, ? extends java....
4
public static void main(String[] args) { double a, b; Func f = new Func(); ArrayList<String> al = new ArrayList<String>(); try(Scanner in = new Scanner(System.in)) { System.out.println("Enter operation:"); while(in.hasNext()) { al.clear(); String str = in.nextLine(); // read line from c...
9
private int getArgIndex(final int arg) { int index = (access & Opcodes.ACC_STATIC) == 0 ? 1 : 0; for (int i = 0; i < arg; i++) { index += argumentTypes[i].getSize(); } return index; }
2
public Circuit decoder(String endroit){ try { Circuit c = new Circuit(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(endroi...
5
private void paintInfoForCurrentObj(Graphics2D g2, Placeable obj) { if (obj != null && obj.isEnemy()) { paintInfoForCurrentEnemy(g2, (Enemy) obj); } else if (currentObject instanceof ShootableTower) { paintInfoForCurrentTower(g2, (ShootableTower) currentObject); } }
3
public void setFamily(Family family) { Person husband = family.getHusband(); Person wife = family.getWife(); lblCaption.setText((husband == null || husband.getName() == null ? "?" : husband.getName().getFamilyName()) + "/" + (wife == null || wife.getName() == null ? "?" : wife .getName().getFam...
7
public String getVis_matricule() { return vis_matricule; }
0
private void copyTo(MCHashEntry[] var1) { MCHashEntry[] var2 = this.slots; int var3 = var1.length; for(int var4 = 0; var4 < var2.length; ++var4) { MCHashEntry var5 = var2[var4]; if(var5 != null) { var2[var4] = null; MCHashEntry var6; do { ...
3
@EventHandler(priority = EventPriority.HIGH) public void onBlockPistonExtend(BlockPistonExtendEvent event) { if (event.isCancelled()) return; for (Block block : event.getBlocks()) if (new PartialCKDoor(block).isBlockPartOfCKDoor()) { //Make sure the door is one that needs to be protected if (DebugFiles....
7
private void findFrequencies() { for(int i = 0; i < modifiedSamples.length; i++){ int width = AudioData.WINDOW_SIZE; int result = autoCorrelation(i, width); if(result!= -1){//markFrequencyMethod //the autocorrelated max result minus the index starting point gives the width of the si...
8
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); ImageIcon color = (ImageIcon) value; setText("");...
0
public void setQuest(QuestPoint quest) { this.quest = quest; }
0
@Override public void doLoopAction() { if (hit) { super.doHit(); if (getGoinUp() == 20) { hit = false; setGoinUp(0); } } }
2
public static void transfer(InputStream in, OutputStream out, long len) throws IOException { byte[] buf = new byte[4096]; while (len != 0) { int count = len < 0 || buf.length < len ? buf.length : (int)len; count = in.read(buf, 0, count); if (count == -1) {...
6
private void executeOaiListAggregateSetRecords( String verb, HttpServletResponse response, boolean authenicate, String aggregateSetName, String metadataPrefix, boolean forceNewDate ) throws IOException { AggregateList aggregateSets = new AggregateList(); AggregateSet setToRetrieve = aggregateSets.getAggregateS...
7
public ShapeParcela(SimpleFeature f, String tipo) { super(f, tipo); shapeId = "PARCELA" + super.newShapeId(); // Para agrupar geometrias segun su codigo de masa codigoMasa = ((String) f.getAttribute("MASA")).replaceAll( "[^\\p{L}\\p{N}]", "") + "-"; this.poligons = new ArrayList<LineString>(); //...
7
public void add(String s){ if(s.equals("Head")){ m[size++] = "Head"; countHead(); }else if(s.equals("Tail")){ m[size++] = "Tail"; countTail(); } }
2
public void shutdown() { try { registry.unbind(bindingName); } catch (AccessException e) { logger.error("couldn't unbind the Registry"); } catch (RemoteException e) { logger.error("couldn't unbind the Registry"); } catch (NotBoundException e) { logger.error("couldn't unbind the Registry"); } try...
7
public Queens(final int size) { if (size > 0) { this.size = size; placementConstraints = new PlacementPart[size][size]; // build placement constraints for (int row = 0; row < size; ++row) { for (int col = 0; col < size; ++col) { placementConstraints[row][col] = new PlacementPart( this, ro...
7
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: try { String nome = jTextField1.getText(); long id = Long.parseLong(jTextField2.getText()); long tel = Long.parseLong(j...
3
private int computeLocalSize() { int size = (allocator.getRegNumber() + 2) * 4; // useless, just to make // code logic simple int maxReg = 0; for (int reg : regMap.values()) { if (maxReg < reg) { maxReg = reg; } } if (maxReg > allocator.getRegNumber() + 2) { size = maxReg * 4; } ...
5
public String getAllTriples(Model model) { StringBuffer dump = new StringBuffer(); StmtIterator statements = model.listStatements(); while (statements.hasNext()) { Statement statement = statements.nextStatement(); RDFNode object = statement.getObject(); dump.append(statement.getSubject().getLocalName())...
3
public int authorize(String user, String pass){ // go through all users, look for username User currentUser = null; for (User u : users){ if (u.username.equals(user)){ currentUser = u; break; } } // return 0 = invalid username if (currentUser == null) return 0; // determine type of ...
5
public static void appendToFile( String fileName, String content ) { File file = new File( fileName ); file = new File( file.getParent() ); if ( !file.exists() ) { file.mkdirs(); } FileWriter fw = null; try { fw = new FileWriter( fileName, tru...
2
public static boolean wordBreak(String s, Set<String> dict) { int len = s.length(); boolean[] iswordbreak = new boolean[len + 1]; iswordbreak[len] = true; for (int i = len - 1; i >= 0; i--) { for (int j = i; j < len; j++) { String word = s.substring(i, j + 1); if (iswordbreak[j +...
4
@Override public int hashCode() { int res = this.propertyId.intValue(); res+=this.propertyTableNameId; if(this.propertyClassNameId!=null) { res+=this.propertyClassNameId; } if(this.relationName!=null) { res+=this.relationName.hashCode(); } return res; }
2
public void update(FriendshPk pk, Friendsh dto) throws FriendshDaoException { long t1 = System.currentTimeMillis(); // declare variables final boolean isConnSupplied = (userConn != null); Connection conn = null; PreparedStatement stmt = null; try { // get the user-specified connection or get a connection fr...
9
public BinaryHeap() { heap = new DynamicArray(); heapSize = 0; }
0
public boolean find(String xmlPathQuery) { XmlPath xmlPath = XmlPathParser.parse(xmlPathQuery); XmlNode node; while((node = pullXmlNode()) != null) { if(node instanceof XmlStartElement) { XmlStartElement startElement = (XmlStartElement) node; Element ...
7
public void writeToFile(String outFileName) throws SoundException { /* get an audioInputStream that represents this sound. then, we will write from the stream to the file */ AudioInputStream audioInputStream = makeAIS(); AudioFileFormat.Type type = audioFileFormat.getType(); ...
7
public final static boolean finish() throws FatalError { try { // HTTP parameters stores header etc. HttpParams params = new BasicHttpParams(); params.setParameter("http.protocol.handle-redirects", false); HttpGet httpget = new HttpGet(Config.getHost() + "quests/start"); httpget.setParams(params); ...
7
*/ @Override public void paintComponent(Graphics g) { Object map = Toolkit.getDefaultToolkit().getDesktopProperty( "awt.font.desktophints"); //$NON-NLS-1$ if (map != null) { ((Graphics2D) g).addRenderingHints((Map<?, ?>) map); } Rectangle clip = g.getClipBounds(); // Fill backgro...
7
@Override public void run() { while(this.running) { switch(r.nextInt(6)+1) { case 1: this.lagermitarbeiter.addTeil(Lagermitarbeiter.ETeil.TEIL_ARM, this.pgnr("Arm")); logger.log(Level.INFO, "Neuer Arm wurde angeliefert!"); case 2: this.lagermitarbeiter.addTeil(Lagermitarbeiter...
8
private static Map<String, String[][]> parseStyle(String styleText) { String[] styleArray = styleText.split(","); Map<String, String[][]> styleMap = null; if (styleArray.length != 0) { styleMap = new HashMap<String, String[][]>(); String[][] styleContentArray = null; for (int i = 0; i < styleArray.length...
5
private void init(){ for(int i=1;i<=100000;++i){ aux[i-1]=num(i); } sum[0]=1; for(int i=1;i<100000;++i){ sum[i]=sum[i-1]+(aux[i]%2!=0?1:0); } }
3
@Override public int compareTo(UpcomingEventItem o) { if (getWhen() == null) return -1; if (getWhen().getTime() == null) return -1; if (o == null) return 1; if (o.getWhen() == null) return 1; if (o.getWhen().getTime() == null) return 1; if (getWhen().getTime().getTimeInMillis() < o.getWhen().getTime().getT...
7
public Encoder tableEncoder(String sql, String name) throws SQLiteException { /* * Pack peers table Table ::= SEQUENCE { name TableName, fields SEQUENCE * OF FieldName, fieldTypes SEQUENCE OF FieldType, rows SEQUENCE OF * SEQUENCE OF NULLOCTETSTRING } */ Database db = manager.getDB(); Table peer=db....
6
protected String validate(String zipCode) { Pattern REGEX = Pattern.compile("^\\d{5}(-\\d{4})?$"); if (zipCode == null) { throw new NullPointerException("Zip Code cannot be null!"); } if (!strictMode || REGEX.matcher(zipCode).matches()) { return zipCode; ...
3
private void impact(int range2, int speed2) { Point startPoint = new Point(Game.PLAYER.getX(), Game.PLAYER.getY()); Point endPoint = new Point(0, 0); for(double i = 0; i < 2*Math.PI-0.01; i+= 0.1){ endPoint = new Point(Game.PLAYER.getX() + (int) (Math.cos(i)*range),Game.PLAYER.getY() + (int) (Math.sin(i)*r...
1
public boolean warpPlayer(ProxiedPlayer player) throws IOException { ServerInfo CurrentServer = player.getServer().getInfo(); ServerInfo TargetServer = ProxyServer.getInstance().getServerInfo( wl.getServer()); if (CurrentServer.equals(TargetServer)) { ByteArrayOutputStream b = new ByteArrayOutputStream();...
2
public void testPropertySetSecond() { LocalDateTime test = new LocalDateTime(2005, 6, 9, 10, 20, 30, 40); LocalDateTime copy = test.secondOfMinute().setCopy(12); check(test, 2005, 6, 9, 10, 20, 30, 40); check(copy, 2005, 6, 9, 10, 20, 12, 40); try { test.seco...
2
public String decrypt(byte[] encondeMessage) { int[] intText = byte2int(encondeMessage); int sum, n, rounds, z, e, y, ind; n = blockSize; rounds = 6 + 52 / n; sum = rounds * delta; y = intText[0]; while (sum != 0) { e = (sum >> 2) & 3; for (ind = n - 1; ind > 0; ind--) { z = intText[ind - 1]; ...
2
void generateRandomNet(BayesNet bayesNet, Instances instances) { int nNodes = instances.numAttributes(); // clear network for (int iNode = 0; iNode < nNodes; iNode++) { ParentSet parentSet = bayesNet.getParentSet(iNode); while (parentSet.getNrOfParents() > 0) { parentSet.deleteLastParent(instances); ...
8
@Override protected void paintComponent ( Graphics arg0 ) { if ( this.board.isReady ) { for ( int i = 0 ; i < this.board.boardHeight ; i++ ) { for ( int j = 0 ; j < this.board.boardWidth ; j++ ) { this.grid[ i ][ j ].setChar ( this.board.charGrid[ i ][ j ] ) ; } } String ...
5
public void removeNode (Tree forRemove) { Tree parent = forRemove.getParent(); Tree leftChild = forRemove.getLeftChild(); Tree rightChild = forRemove.getRightChild(); // get highest child from removable tree Tree highestTree = getLeftHeight(forRemove) > getRightHeight(forRemove) ? leftChild : rightChild; ...
9
public static void sort(String f1, String f2) throws FileNotFoundException, IOException { RandomAccessFile a = new RandomAccessFile(f1, "r"); RandomAccessFile a2 = new RandomAccessFile(f1, "rw"); RandomAccessFile b = new RandomAccessFile(f2, "rw"); DataOutputStream dosb; DataOutputStream dosa; DataInputStre...
7
@Test public void getTwoUserByEmail() { // 7. partialEmail이 'user'인 CalendarUser가 2명임을 확인하는 테스크 코드 작성 // [주의] public List<CalendarUser> findUsersByEmail(String partialEmail)를 테스트 하는 코드 System.out.println("\n7.------------------------------------------------"); //findUsersByEmail 메소드로 user 메일에 user가 들어가는 모든 ...
3
private List<String> purseLine(final String line) { List<String> result = new ArrayList<String>(); if (StringUtility.isNotEmpty(line)) { StringBuilder sb = new StringBuilder(); boolean dblFlg = false; for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); if (dblFlg) { if ('"' == c...
8
public static void main(String[] args) { // Get command-line parameters int m = Integer.parseInt(args[0]); int d = Integer.parseInt(args[1]); // Print values System.out.println("Month: " + m); System.out.println("Day: " + d); // Is month and day in spring? ...
9
public static int[] translate(int[] pixs, int tx, int ty, int w, int h, int ow, int oh) { int u, v; int[] pix = new int[ow * oh]; for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { u = i + tx; v = j + ty; pix[v * ow + u] = pixs[j * w + i]; } } return pix; }
2
public void removeWar(String name) { GenericObject toRemove = null; for (GenericObject war : getWars()) { if (war.getString("name").equals(name)) { toRemove = war; break; } } if (toRemove != null) { toRemove.getParent()....
3
public static Update performCheck(Options rel, boolean requireRestart) { if (requireRestart && Game.isActive()) { int Confirmation = JOptionPane.showConfirmDialog(rel, "Some changes will not affect the current game.\n" + "Quit the current game and start a new one?\n" + "Clicking \"No\" will stil...
6
protected void header(String key, String value) { if(! statusSent) throw new IllegalStateException("Must send status " + "before headers"); if(headersSent) throw new IllegalStateException("Cannot send headers " + "after data"); key = key.substring(0, 1).toUpperCase() + key.substring(1); byte[] byt...
3
public Direction hitWall() { if (pos_x + v_x < 0) return Direction.LEFT; else if (pos_x + v_x > max_x) return Direction.RIGHT; if (pos_y + v_y < 0) return Direction.UP; else if (pos_y + v_y > max_y) return Direction.DOWN; else return null; }
4
private String sha(String text) { StringBuilder key = new StringBuilder(); try { MessageDigest md = MessageDigest.getInstance("sha1"); md.update(text.getBytes()); for (byte b : md.digest()) { key.append(Integer.toHexString((0xff & b) | 0xffffff00) .substring(6)); } } catch (Exception ex) { ...
2
@Override public boolean equals(Object obj) { if (obj == this) { // simple case return true; } // now try to reject equality... if (!super.equals(obj)) { return false; } if (!(obj instanceof XYDrawableAnnotation)) { return false; ...
9
protected boolean AddInventory(Inventory inventory) throws NullPointerException{ if (null == Inventory.libraryMaterials) { return false; } try{ if (Inventory.libraryMaterials.containsKey(Inventory.libraryMaterialID)) { return false; } ...
3
public void complexLoadFromTag(DataTag tag) { try { int size = tag.getInteger("Size", 0); for (int i = 0; i < size; i++) { DataTag t = tag.getTag("" + i); Class<?> c = Class.forName(t.getString("Class Name", null)); Sprite s = (Sprite) c.newInstance(); set(i, s); } } catch (Exceptio...
3
private ITrieNode[] getMaxChild(final HashMap<Integer,Integer> frontierMap) { // returns two largest weight nodes in order HashMap<Character, ITrieNode> availableChildren = getAvailableChildren(frontierMap); if (availableChildren == null) { return null; } ITrieNode re...
5
public void create(Comment comment) throws RollbackFailureException, Exception { EntityManager em = null; try { utx.begin(); em = getEntityManager(); Article newsID = comment.getNewsID(); if (newsID != null) { newsID = em.getReference(newsI...
5
private Entry<Point, Item> pickBestMove(Entry<Point, Item> itemA, Entry<Point, Item> itemB) { Entry<Point, Item> best = itemA; if (greenEnergy <= pinkEnergy) { if (itemB.getValue() != null) { best = itemA.getValue().greenGain * itemA.getValue().quantity > itemB.getValue().greenGain * itemB.getValue(...
5
public String[][] makeNewTableArray(ArrayList<HostRoom> L) { String[][] array = new String[L.size()][4]; for (int i = 0; i < array.length; i++) { array[i][0] = L.get(i).GameName; array[i][1] = Integer.toString(L.get(i).ClientCount) + "/" + Integer.toString(L.get(i).MaxSize); array[i][2] = L.get(i).Roo...
1
private boolean isRankConsistent(STNode<Key, Value> x) { for (int i = 0; i < size(x); i++) if (i != rank(select(i))) { return false; } for (Key key : keys()) if (key.compareTo(select(rank(key))) != 0) return false; return true; }
4
@Override public Account createAccount(Account account) { Connection cn = null; PreparedStatement ps = null; ResultSet rs = null; try { cn = ConnectionHelper.getConnection(); ps = cn.prepareStatement(QTPL_INSERT_ACCOUNT, new String[] { "account_id" }); ...
5
@Override public void paint(Graphics g) { // the healthbar g.setColor(Color.BLACK); g.drawRect(x + 3, y - 10, 20, 5); g.setColor(Color.RED); g.fillRect(x + 4, y - 9, 19, 4); g.setColor(Color.GREEN); g.fillRect(x + 4, y - 9, (int) (((enemy.getHP() * 1.0) / (enemy.defHP * 1.0)) * 20) - 1, 4); /...
9
public static void main(String[] args) { // Instantiate a Scanner object Scanner sc = new Scanner(System.in); String choice ="y"; System.out.println("Welcome to the Loan Calculator"); System.out.println(""); System.out.println("DATA ENT...
7
public Character shoot(Matrix matrix, Player player, int ns, int shootX, int shootY) { int nx = Math.round(shootX/ns); int ny = Math.round(shootY/ns); Node node = matrix.getNode(nx, ny); System.out.println("testing node at " + "(" + node.getX() + ":" + node.getY() + ")"); if (!(node instanceof Square)) { r...
5
@Override public Command receive() { // Process the history if (m_histo.size() != 0) { return m_histo.remove(0); } System.out.println("[CLIENT] Wait for some message ..."); try { // Parse the message ObjectMessage msg = (ObjectMessage) m_sub.receive(); if (msg.getObject() instanceof Command) ...
3
private void checkUpdate(boolean showNoUpdate) throws InterruptedException, ExecutionException, MalformedURLException{ ExecutorService executor = Executors.newSingleThreadExecutor(); Future<Boolean> task = null; task = executor.submit(new Updater(lastVersionURL)); if (task.get()) showMessage(("New version a...
2
public void endElement(String uri, String localName, String qName) throws SAXException { // sort out element name if (no) namespace in use String elementName = localName; if ("".equals(elementName)) { elementName = qName; } if (elementName.equals("book")) { bookList.addBook(currentBook); } else if(...
5
public void run() { try { m_visual.setAnimated(); m_Saver.setInstances(m_dataSet); if (m_logger != null) { m_logger.statusMessage(statusMessagePrefix() + "Saving " + m_dataSet.relationName() + "..."); } m_Saver.writeBatch(); ...
7
public boolean isValid() throws Exception { int virtualGraphs=0; int defaultGraphs=0; for (NamedGraph g:graphs){ if (g.getDepth()==-1){ virtualGraphs++; if (virtualGraphs>1){ throw new Exception("Multiple virtual graphs"); } } if (g.getName().length()==0){ defaultGraphs++; if (de...
6
public void add(PlanObject plan) { if (insertPointer == plans.length) { PlanObject[] help = plans; plans = new PlanObject[insertPointer + 1]; for (int i = 0; i < help.length; i++) { plans[i] = help[i]; } } plan.setPlanManager(this); plans[insertPointer] = plan; insertPointer++; }
2