text
stringlengths
14
410k
label
int32
0
9
public int getSecondOrderClassification(GraphPoint p) { List<GraphPoint> neighbourhood = new ArrayList<GraphPoint>(); for(GraphPoint neighbour: p.getEdges()) { if(neighbour.getClassification() == p.getClassification()) { for(GraphPoint edge: neighbour.getEdges()) { if(edge != neighbour && !nei...
5
private static void test_onesCount(TestCase t) { // Print the name of the function to the log pw.printf("\nTesting %s:\n", t.name); // Run each test for this test case int score = 0; for (int i = 0; i < t.tests.length; i += 2) { int bits = (Integer) t.tests[i]; int exp = (Integer) t.tests[i + 1]; t...
3
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initPageRender() { try { Element root = configXml.getDocumentElement(); NodeList nodeList = root.getElementsByTagName("pageRender"); if (nodeList.getLength() == 0) {// 如果没有配置则默认是freemarker渲染 RenderFactory.setPageRender(new FreemarkerRender()); ...
8
public static Pet randomPet() { return creator.randomPet(); }
0
public void activePlayerEndTurn(){ int lastIndexOfActivePlayer = getPlayerNumber(getActivePlayer()); lastIndexOfActivePlayer++; if (lastIndexOfActivePlayer >= players.size()){ lastIndexOfActivePlayer = 0; } setActivePlayer(players.get(lastIndexOfActivePlayer)); getActivePlayer().incrementTurnsWithThree(...
1
public void handleKeyStroke(KeyEvent evt) { switch (evt.getKeyCode()) { case KeyEvent.VK_SPACE: if (!inGame) { this.startSnake(); } break; case KeyEvent.VK_UP: snake.setCurrentDirection(Direction.UPARROW)...
9
public static void closeStatement(Statement stmt) { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { throw new RuntimeException(e.getSQLState() + "\nCaused by\n" + e.getCause(), e); } } }
2
public static long findMaxPrime(long value){ //long bigValue = value; //save the factor which have try long factor = 1; //save the max factor long lastFactor = 1; //remove the only one even factor if(value%2==0){ lastFactor=2; factor = 2; value = value/2; whil...
7
private static String LetterOrNumber(String string) { final String works = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; String finals = ""; boolean change = true; for (char c : string.toCharArray()) { for (char x : works.toCharArray()) { if (x == c) { change = false; break;...
4
public boolean canHaveAsCreditLimit(BigInteger creditLimit) { return (creditLimit != null) && (creditLimit.compareTo(BigInteger.ZERO) <= 0); }
1
public int hashCode() { return super.hashCode() ^ myUnprocessedInput.hashCode() ^ myOutput.hashCode(); }
0
public long[] next() { if (!hasNext()) { throw new NoSuchElementException(); } // save current long current[] = new long[numberOfLevels]; for (int i = 0; i < numberOfLevels; i += 1) { current[i] = axisWithoutMeaning[i]; ...
6
private void processScreenBlt(RdpPacket_Localised data, ScreenBltOrder screenblt, int present, boolean delta) { if ((present & 0x01) != 0) screenblt.setX(setCoordinate(data, screenblt.getX(), delta)); if ((present & 0x02) != 0) screenblt.setY(setCoordinate(data, scree...
7
@EventHandler public void IronGolemMiningFatigue(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.getIronGolemConfig().getDouble("Ir...
6
public void mainMenu() { System.out.println("Welcome grand overlord, What is your bidding?"); System.out.println("1:Print monthly sales"); System.out.println("2:Change Status"); System.out.println("3:Make Replenishment Order"); System.out.println("4:Delete Unneeded Sales"); System.out.println("5:Change Pri...
7
private static Node add(Node node, Argument left, Argument right) { if (left.getType() == String.class || right.getType() == String.class || left.getType() == Character.class || right.getType() == Character.class) { String ls = left.asString(); String rs = right.asString(); return new StringArgument(no...
8
public ShopConfigurationPanel() { super(); setLayout(new BorderLayout()); contents = new ShopData(); PropertySet ps = new PropertySet(); final FileProperty fpShopBackground = new FileProperty( "Shop background image (160 \u00d7 120)", null); final FileProperty fpShopButtonImage = new FileProperty( ...
5
public void setEmass(String emass) { // 精密質量設定 this.emass = emass; // 精密質量からソート用精密質量設定 if (!emass.equals("") && emass.length() != 0) { this.sortEmass = Float.parseFloat(emass); } // 精密質量から表示用精密質量設定 StringBuffer dispEmass = new StringBuffer(); if (!emass.equals("") && emass.length() != 0) { ...
7
public static void UnloadWorld(String name, Boolean save) { if (Core.getPlugin().getServer().getWorld(name) != null) { Core.getPlugin().getServer().unloadWorld(name, save); } }
1
private void animate(Entity entity, int delta) { combinedDelta += delta; if(previousDir != dir){ if(previousDir == Direction.RIGHT && dir == Direction.LEFT || previousDir == Direction.LEFT && dir == Direction.RIGHT){ entity.flip(); previousDir = dir; } } if(combinedDelta > 140){ nextFrame(...
6
public Query setParamsToQuery(Query query) { if (params != null) { for (int i = 0; i < params.size(); i++) { if (types.get(i) == null) { query.setParameter(params.get(i), values.get(i)); } else { query.setParameter(params.get(i), values.get(i), types.get(i)); } } } ...
9
public void checkCollisionWithWeapons() { for (int i = 0; i < weaponList.size(); i++) { for (int j = 0; j < boardSpawn.getEnemies().size(); j++) { if (weaponList.get(i).getShape().intersects(boardSpawn.getEnemies().get(j).getShape())) { if (weaponList.get(i) instanceof Star) { weaponList.remove(i); ...
8
static void checkMethodDesc(final String desc) { if (desc == null || desc.length() == 0) { throw new IllegalArgumentException( "Invalid method descriptor (must not be null or empty)"); } if (desc.charAt(0) != '(' || desc.length() < 3) { throw new Illeg...
9
private Command parse(String userInput) { if (userInput == null) { return null; } StringTokenizer tokenizer = new StringTokenizer(userInput); if (tokenizer.countTokens() == 0) { return null; } CommandName commandName = null; String userName = null; float amount = 0; int userInputTokenNo = 1; ...
8
@Override public Node parse(Token token) throws IOException { AttrNode node = null; if (ExpressionParser.START.contains(token.type())) { node = new AttrNode(startLine()); token = tokenizer().peek(); Token var = tokenizer().current(); if (ATTR.contains(token.type())) { boolean first = true; whil...
9
@SuppressWarnings("deprecation") private boolean setAirIfAllowed(World world, int x, int y, int z, boolean dungeonGen) { if(canSetAir(world, x, y, z, dungeonGen)) { setBlock(world, x, y, z, 0); int id = getBlock(world, x, y+1, z); if(id == Material.SNOW.getId() || id == Material.YELLOW_FLOWER.getId...
7
public void propertyChange(PropertyChangeEvent e) { String propertyName = e.getPropertyName(); // Make sure we are responding to the right event. if (propertyName.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { File selection = (File)e.getNewValue(); String name; ...
7
private static void method501(char arg0[]) { char ac1[] = arg0.clone(); char ac2[] = { '(', 'a', ')' }; Censor.method509(null, ac1, ac2); char ac3[] = arg0.clone(); char ac4[] = { 'd', 'o', 't' }; Censor.method509(null, ac3, ac4); for (int i = Censor.aCharArrayArray623.length - 1; i >= 0; i--) { Censor...
1
@Override public void paint(Graphics2D g) { if (drawAll && StateHandler.instance.getCurrentState() == State.PLAYING) { for (int i = 0; i < rectangles.size(); i++) { g.setColor(ColorUtils.getAlpha(BOX_COLOR, 150)); g.fillRoundRect(rectangles.get(i).x, rectangles.get(i).y, rectangles.get(i).width, rec...
7
public void registerStopWatchListener(StopWatchListener listener) { this.listener = listener; }
0
public static void main(String[] args) throws NumberFormatException, IOException{ BufferedReader strin; boolean choice = true; int gameNum = 0; int win = 0; int lose = 0; while (choice){ Random random = new Random(); int n = rando...
6
public synchronized void addUnsearchList(String url){ this.unsearchSitesList.add(url); }
0
@Override public FSMNode<EventType> nodeToTransitTo(StateMachineEvent<EventType> event) throws InvalidEventException { if (aspects != null && !aspects.onTransitionStart(event)) return null; try { FSMNode<EventType> target = delegate.nodeToTransitTo(event); if (tar...
8
public OnlineSearch(Settings settings) { SEARCH_JUMPLENGTH = settings.getSearchJumpLength(); SEARCH_SENTENCELENGTH = settings.getCompareSentenceLength(); MAX_URLS = settings.getSearchNumLinks(); URL = settings.getSearchURL(); URL_ARGS = settings.getSearchURLArgs(); URL_ARG_AUTH = settings.getSearchAuthArg(...
0
public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_CONTROL) { pressed = true; } if (pressed && e.getKeyCode() == KeyEvent.VK_V) { adaptee.pasteClipboard(); } }
3
public void writeExternalWithoutImages(ObjectOutput paramObjectOutput) throws IOException { paramObjectOutput.writeObject(this.location); paramObjectOutput.writeObject(this.LastPosition); paramObjectOutput.writeObject(this.LastCell); boolean[][] arrayOfBoolean = new boolean[this.shape.length][this.sha...
3
public static int getGreatestProdDownColumns(int[][] arr, int maxDigits, int columns, int rows) { int sum = 0; for(int i = 0; i < rows; i++) { int prod = 0; while((prod) < (columns-(maxDigits-1))) { int tmpProd = 1; int curr = prod; for(int it = 0; it < maxDigits; it++) { tmpProd = tmpProd * ...
4
public Symbol debug_parse() throws java.lang.Exception { /* the current action code */ int act; /* the Symbol/stack element returned by a reduce */ Symbol lhs_sym = null; /* information about production being reduced with */ short handle_size, lhs_sym_num; /* set up ...
7
@Override public void scoreRound(boolean won, int score) { if (TRAIN_score && old_score != null){ //Final target value is the final score old_score.output = score / max_points; //old_score.output = won ? 1 : 0; train_data.add(old_score); //Train the network //Give higher learning rate to more rece...
4
@Override public void deserialize(Buffer buf) { super.deserialize(buf); maxPods = buf.readShort(); if (maxPods < 0) throw new RuntimeException("Forbidden value on maxPods = " + maxPods + ", it doesn't respect the following condition : maxPods < 0"); prospecting = buf.read...
8
private static void compare(List<String> urlsOrFiles, String[] testSetIdArr) throws Exception { List<TestResultData> testNgResultData = parseTestNgResultFromFilesOrUrls(urlsOrFiles); List<String> testNgTests = (List<String>) CollectionUtils .collect(testNgResultDa...
4
public SetupHeader(VorbisStream vorbis, BitInputStream source) throws VorbisFormatException, IOException { if (source.getLong(48) != HEADER) { throw new VorbisFormatException("The setup header has an illegal leading."); } // read code books int codeBookCount = ...
9
private void listen() { ListenThread thread = new ListenThread(); thread.start(); }
0
private void cleaningText() { int latinCount = 0, nonLatinCount = 0; for(int i = 0; i < text.length(); ++i) { char c = text.charAt(i); if (c <= 'z' && c >= 'A') { ++latinCount; } else if (c >= '\u0300' && UnicodeBlock.of(c) != UnicodeBlock.LATIN_EXTEND...
9
private void solve() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); skill = new int[n]; gender = new char[n]; out = new boolean[n]; prev = new int[n]; next = new int[n]; prev[0] = 0; next[0] = 1; prev[n-1] = n...
7
public int compareTo(FolderWatcherQueue t1) { { if (date.before(t1.getDate())) { return -1; } if (date.after(t1.getDate())) { return 1; } return 0; } }
2
public void establishInitialConnection() throws FileNotFoundException , IOException{ String line_in_file, full_html = ""; FileReader html_file = new FileReader("page.html"); //FileWriter temp = new FileWriter("tmp.abc") BufferedReader html_file_br = new BufferedReader(html_file); while( (line_in_file=html_f...
7
@Override public void startSetup(Attributes atts) { super.startSetup(atts); addActionListener(this); Outliner.documents.addTreeSelectionListener(this); setEnabled(false); }
0
public static int getItemBurnTime(ItemStack par1ItemStack) { if (par1ItemStack == null) { return 0; } else { int var1 = par1ItemStack.getItem().shiftedIndex; if (var1 < 256 && Block.blocksList[var1].blockMaterial == Material.wood) return 30...
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; PacketEntry other = (PacketEntry) obj; if (underlyingPacket == null) { if (other.underlyingPacket != null) return false; } e...
6
protected Class<? extends AnnotatedElement> getAnnotatedElementType() { return this.annotatedElementType; }
1
private final void enableDeviceSpecificEvents (boolean b) { enableMotorVelocityChangeEvents (b && motorVelocityChangeListeners.size () > 0); enableCurrentChangeEvents (b && currentChangeListeners.size () > 0); enableCurrentUpdateEvents (b && currentUpdateListeners.size () > 0); enableInputChangeEvents (b && in...
8
@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 = this.getVisibleRect(); // line numbering is alway...
6
public void nettavisen(URL uri, String url) { try { HttpURLConnection web = (HttpURLConnection) uri.openConnection(); web.setRequestMethod("GET"); web.connect(); int code = web.getResponseCode(); if (code == HttpURLConnection.HTTP_OK) { BufferedReader in = new BufferedReader(new InputStreamReader...
8
public void restoreScreen() { Window window = device.getFullScreenWindow(); if(window != null) { window.dispose(); } device.setFullScreenWindow(null); }
1
public static Node followXpath (Node start, String Xpath) throws DOMException { StringTokenizer tokenizer = new StringTokenizer(Xpath, "/"); if (tokenizer.countTokens() == 0) { String invalidXpath = Xpath + " is an invalid Xpath!"; throw new DOMException(DOMException.SYNTAX_ERR,...
2
public void run() { Vector<Long> historyBytes = new Vector<Long>(); int maxSize = 20; while (true) { long timeInit = System.currentTimeMillis(); if (!copier.getPause()){ historyBytes.add(0,copier.readAndInitBytesCounter()); if (historyBytes.size() > maxSize) historyBytes.removeElementAt(h...
9
public Item(String name, String catagoryStr, String type) throws SalesTaxApplicationException { super(); if (name != null && name.length() > 0) { this.name = name; } else { throw new SalesTaxApplicationException("No item name specified !"); } if (catagoryStr.equals("FOOD")) this.catagory = Catagory...
7
public void initControllers() throws SlickException { if (controllersInited) { return; } controllersInited = true; try { Controllers.create(); int count = Controllers.getControllerCount(); for (int i = 0; i < count; i++) { Controller controller = Controllers.getController(i); if ((co...
8
public static boolean isSupport(ABObject o2, ABObject o1) { if (o2.x == o1.x && o2.y == o1.y && o2.width == o1.width && o2.height == o1.height) return false; int ex_o1 = o1.x + o1.width; int ex_o2 = o2.x + o2.width; int ey_o2 = o2.y + o2.height; if ((Math.abs(ey_o2 - o1.y) < gap) && !(o2.x - ex_o...
7
public static Input readInput(File file) throws InputException { if ((file != null) && (file.canRead())) { try { Input input = readInputFromFile(file); verifyInput(input); return input; } catch (InputException exception) { throw exception; } catch (IOException e) { throw new Inp...
4
public synchronized int getNextIndex() { int i, count = dataListModel.getSize(); if (nextIndex == -1) { switch(playMode) { case 1: break; //不改变 case 3: curIndex = (int)(Math.random()*count); break; //任意的 default: curIndex = (curIndex + 1 == count) ? 0 : curIndex + 1; break; } } else { cur...
9
public final URL getDownloadUrl() { return downloadUrl; }
0
@SuppressWarnings("unchecked") <T> T convertInternal(Object value, Type type) throws JSONException { if (type instanceof TypeReference<?>) { type = ((TypeReference<?>)type).getType(); } Class<?> cls = ClassUtil.getRawType(type); T result = null; try { enter('$', null); result = (T)p...
7
@Override public BufferedImage generate() { BufferedImage completePic = new BufferedImage(xSize, ySize, BufferedImage.TYPE_INT_RGB); // initialises to false completedPixels = new boolean[xSize][ySize]; for (int i = 0; i < xSize; i++) { for (int j = 0; j < ySize; j++) { // spots() may have got here f...
3
public boolean eventGeneratable(String eventName) { if (eventName.equals("configuration") && m_Filter != null) { return true; } // can't generate the named even if we are not receiving it as an // input! if (!m_listenees.containsKey(eventName)) { return false; } Object ...
7
public void renderSprites(Bitmap bm) { boolean visible = true; TreeSet<Sprite> sortedSprites = new TreeSet<Sprite>(spriteComparator); for (Sprite s : entities) { if (visible) sortedSprites.add(s); } for (Sprite s : particles) { if (visible) sortedSprites.add(s); } sortedSprites.addAll(mapSprites); ...
5
public Scene(Ticker ticker, GameWorld gameWorld) { buffer = new FrameBuffer(1024, 768, FrameBuffer.SAMPLINGMODE_NORMAL); buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE); buffer.enableRenderer(IRenderer.RENDERER_OPENGL); this.gameWorld = gameWorld; camera = new Camer...
0
public static List<TreeWorker> getsavedTrees() { if(savedTreeWorker==null)savedTreeWorker=new ArrayList<TreeWorker>(); return savedTreeWorker; }
1
void bounce(Dimension size) { if ((position.x <= 0 & xOffset < 0) || (position.x >= size.width & xOffset > 0)) { xOffset *= -1; } if ((position.y <= 0 & yOffset < 0) || (position.y >= size.height & yOffset > 0)) { yOffset *= -1; } }
4
public static void main(String[] args) throws InterruptedException { JFrame view = initWindow(); Supervisor.registerFrame(view); Stats constStatsInit = new HashMapStats(); constStatsInit.put(new Stat(StatType.C_CREATURE_CLASS, 1.0)); constStatsInit.put(new Stat(StatType.C_ATTAC...
3
public static int colisamax_f77 (int n, double x[][], int incx, int begin, int j) { double xmax; int isamax,i,ix; if (n < 1) { isamax = 0; } else if (n == 1) { isamax = 1; } else if (incx == 1) { isamax = 1; ix...
7
public void disconnectFromURL() { connected=false; try { if(out!=null) { out.write(new byte[]{(byte)255,(byte)253,18}); //iac, iacdo, logout out.flush(); } } catch(final Exception e) { } try { if((in!=null)&&(in[0]!=null)) in[0].close(); } catch(final Exception e) { } try ...
9
private void moveBodyAndSetSprites() { Vector2D currentBodyPos = new Vector2D(lastHeadPos.x(), lastHeadPos.y()); Vector2D lastBodyPos = new Vector2D(0, 0); for(int i = 1; i < snake.size(); i++) { lastBodyPos.setCoords(bodyPartPos.get(i).x(), bodyPartPos.get(i).y()); bodyPartPos.get(i).setCoord...
5
@Override public boolean isOpen() { return inputStream != null && outputStream != null && serialPort != null; }
2
@Override public List<Role> findRoleAll() { List<Role> list = new ArrayList<Role>(); Connection cn = null; PreparedStatement ps = null; ResultSet rs = null; try { cn = ConnectionHelper.getConnection(); ps = cn.prepareStatement(QTPL_SELECT_ALL); ...
5
private void preencheTabela(List<Venda> lista){ this.modelo = new DefaultTableModel(); modelo.addColumn("Id"); modelo.addColumn("Cliente"); modelo.addColumn("Usuario"); modelo.addColumn("Horario"); modelo.addColumn("Forma de Pagamento"); modelo.addColumn("Valor To...
1
public void actualizar(float tpf, float speed) { time += tpf / speed; if (time > 1f && state == 0){ flash.emitAllParticles(); spark.emitAllParticles(); smoketrail.emitAllParticles(); debris.emitAllParticles(); shockwave.emitAllParticles(); ...
6
public void update() { moveCamera(); movePlayer(); }
0
@Test public void testConcurrency1() { final int clientThreadCount = 5; final int machineId = 1; int total = 0; int count = 0; for (int i = 0; i < mServerCount; i++) { try { mDhtClientArray[i].purge(); } catch (RemoteException e) { ...
8
public Boolean getValid() { boolean test = false; if (test || m_test) { System.out.println("Loader :: loadAll() BEGIN"); } if (test || m_test) { System.out.println("Loader :: loadAll() END"); } return m_allValid; }
4
public static boolean parseAccessTokenAndOpenId(String responseData, OAuthV2 oAuth) { if (!QStrOperate.hasValue(responseData)) { return false; } oAuth.setMsg(responseData); String[] tokenArray = responseData.split("&"); log.info("parseToken response=>> tokenArray.le...
9
public PixImage boxBlur(int numIterations) { // Replace the following line with your solution. PixImage blur = new PixImage(this.pixWidth, this.pixHeight); if(numIterations < 1){ return this; } else{ for(int x = 0; x<blur.pixWidth; x++){ for(int y = 0; y<blur.pixHeight;y++...
8
public void moveRow(int start, int end, int to) { if (start < 0) { String message = "Start index must be positive: " + start; throw new IllegalArgumentException( message ); } if (end > getRowCount() - 1) { String message = "End index must be less than total rows: " + end; throw new IllegalArgume...
7
public void basicSetMeteo(Meteo myMeteo) { if (this.meteo != myMeteo) { if (myMeteo != null) { if (this.meteo != myMeteo) { Meteo oldmeteo = this.meteo; this.meteo = myMeteo; if (oldmeteo != null) oldmeteo.removeWorkout(this); } } } }
4
private void fillDocumentPositions(BooleanQuery boolQuery) throws IOException, XMLStreamException{ for(BooleanImpl clause: boolQuery.getBooleanClauses()) { if (clause instanceof BooleanClause) clause.getDocPositionST().addAll((this.getDocumentPositions((BooleanClause)clause))); if (clause instanceof Phr...
7
public void begin() { int numberOfCases = Integer.parseInt(readLine( 100 )); readLine( 100 ); // blank line for( int cases = 0 ; cases < numberOfCases; cases++ ){ Map<String,String> registers = new HashMap<String,String>(10); for( int inx = 0 ; inx < 10 ; inx++ ){ registers...
8
@Override public int getWidth() { return width; }
0
public String getVis_matricule() { return vis_matricule; }
0
public boolean getBoolean(int index) throws JSONException { Object object = this.get(index); if (object.equals(Boolean.FALSE) || (object instanceof String && ((String) object) .equalsIgnoreCase("false"))) { return false; } else if (object.equal...
6
public boolean frogIsOnLog(Rectangle log){ boolean collision = log.contains(leftHalf) || log.contains(rightHalf) || log.contains(backHalf) || log.contains(frontHalf); if(collision){ return true; }else{ return false; } }
4
protected void addColumnHeaders(Worksheet worksheet) { List<String[]> rawColumnHeadersList = worksheet.getRowsByRegex("^Druh kriminality.*"); Helper.isTrue(rawColumnHeadersList.size()==1,"Nemozno urcit na ktorom riadku su nazvy stlpcov"); String[] rawColumnHeaders = rawColumnHeadersList.get(0); List<String> col...
7
@Override public void setLock(String resource, String transaction, LockType requestType) { if (requestType != LockType.READ && requestType != LockType.WRITE) { System.err .println("error: site.ImpLockManager.setLock\n invalid coming request " ...
8
public Bipartite(Graph<?> g) { this.marked = new ListOrderedMap<>(); this.color = new ListOrderedMap<>(); this.isBipartite = true; for (Object x : g.getAllVertices()) { this.marked.put(x, false); this.color.put(x, false); } for (Object x : g.ge...
5
public void actionPerformed(ActionEvent e) { // get the button that was pressed JButton b = (JButton)e.getSource(); // fire appropriate event if (b.getText().equals("Normal Setup")) { // set up for normal simulation fireSimulationEvent(SimulationEvent.NORMAL_SETUP_EVENT); } el...
7
@Override public void mark(int boardPosition, Cell[] cellBoard, int rows, int columns) throws IllegalMark { //Find the column. int boardPositionColumn = boardPosition % columns; if (boardPositionColumn > 0){ //It's not the first column. int oneLe...
1
private static int checkAck(InputStream in) throws IOException { int b = in.read(); // b may be 0 for success, // 1 for error, // 2 for fatal error, // -1 if (b == 0) return b; if (b == -1) return b; if (b == 1 || b == 2) { StringBuffer sb = new StringBuffer(); int c; do { c = in.rea...
7
public void draw() { // draw board drawBoard(); // draw pieces double x = 0; double y = 0; for (int i = 1; i <= model.getPoints().size(); i++) { drawPoint(i); } // draw rails // player 2 on top, player 1 on bottom x = WIDTH/2; y = HEIGHT/2; StdDraw.setPenColor(StdDraw.WHITE); StdDraw.text(...
5
public boolean boundingBoxContains( double x, double y, double z ) { return x >= x0 && x <= x1 && y >= y0 && y <= y1 && z >= z0 && z <= z1; }
5
@EventHandler public void PigZombieNightVision(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.getPigZombieConfig().getDouble("PigZ...
6