text
stringlengths
14
410k
label
int32
0
9
public int getDoneSymbols() { return completedSymbols; }
0
private void verifBouton() { if ((!nomProjet.getText().isEmpty() && !dateFinPrevue.getText().isEmpty() && !dureeProjet.getText().isEmpty() && !prixJournee.getText().isEmpty() && !clientSelectionne.getText().isEmpty())) { validerNouvProjet.setEnabled(true); } ...
5
public void grille(){ for(int y = 0; y<env.taille_envi;y++){ for(int x = 0; x<env.taille_envi;x++){ if(env.grille[x][y]!=null){ Graphics g = agent[x][y].getGraphics(); g.setColor(((Particule)env.grille[x][y]).color); g.fillOval(0, 0, agent[x][y].getHeight(), agent[x][y].g...
3
protected String RemoveNonNumbers(String input) { String temp = ""; for (int i = 0; i < input.length(); i++) { int c = (int)input.charAt(i); if ((c >= 48 && c <= 57) || c == 10 || c == 46) { temp += (char)c; } } return temp; }
5
@Override public void deserialize(Buffer buf) { super.deserialize(buf); firstNameId = buf.readShort(); if (firstNameId < 0) throw new RuntimeException("Forbidden value on firstNameId = " + firstNameId + ", it doesn't respect the following condition : firstNameId < 0"); la...
4
public void uimsg(String msg, Object... args) { if (msg == "sz") { isz = (Coord) args[0]; recalcsz(); } }
1
public static void makeAllPieces() { // Make an image showing all the pieces in all postions BufferedImage icons = new BufferedImage(9*56,12*56,BufferedImage.TYPE_INT_RGB); Graphics g = icons.getGraphics(); g.setColor(Color.white); g.fillRect(0,0,9*56,12*56); g.setColor(Color.black); ...
6
public void scanColumn(int columnPoint) { HashMap<Integer, SpanInfo> rowMap = new HashMap<Integer, SpanInfo>(); SpanInfo si = new SpanInfo(); si.name = originTable[0][columnPoint]; si.row = 0; si.num = 0; rowMap.put(0, si); for (int i = 0; i < originTable.length; i++) { if (si.name.equals(originTable[i...
7
public GetQuestionsFromSqliteDatabase() { }
0
protected Long coerceToLong(Object value) { if (value == null || "".equals(value)) { return Long.valueOf(0l); } if (value instanceof Long) { return (Long)value; } if (value instanceof Number) { return Long.valueOf(((Number)value).longValue()); } if (value instanceof String) { try { return ...
7
@FXML protected void doubleClickPlaySelectedSong(MouseEvent mouseEvent) throws Exception { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { playSong(); } } }
2
public EditorController getLevel(File file) throws LevelMisconfigurationException { // loads just the level itself from the xml Level level = XmlService.getInstance().getLevelFromFile(file); EditorController controller = new EditorController(); int col = XmlService.getInstance().getMaxColumnCount(level.getRo...
2
public static String sample(String srcfile,int sampleN,int N) throws IOException{ String output = srcfile.substring(0, srcfile.indexOf(".")) + "_sample.txt"; File fout = new File(output); if (fout.exists()) { fout.delete(); } ArrayList<Integer> trainIndices = new ArrayList<Integer>(sampleN); BootStrapSa...
8
public boolean equals(ChessPiece p) { if (p.TYPE != TYPE || p.COLOR != COLOR || p.RANGE != RANGE || p.ATTACK_SLOPES.length != ATTACK_SLOPES.length || p.hasMoved != hasMoved) { return false; } for (int i = 0;i < ATTACK_SLOPES.le...
7
public void pushOperand(double operand){ operandStack.push(operand); }
0
public void setVitality(double vitality) { this.vitality = vitality; }
0
public Upgrade(UpgradeType type, String name, Ability additionalAbility) { this.type = type; this.name = name; this.additionalAbility = additionalAbility; }
0
public ImageData getImageData() { Point size = getSize(); /* Create a 24 bit image data with alpha channel */ imageData = new ImageData(size.x, size.y, 24, new PaletteData(0xFF, 0xFF00, 0xFF0000)); imageData.alphaData = new byte[imageData.width * imageData.height]; drawCompositeImage(size.x, size.y); ...
9
public Forwarder() throws JSchException { worker = new Thread(new Runnable() { @Override public void run() { while (!Thread.interrupted()) { lock.lock(); try { if (init) { try { inits(); } catch (JSchException e) { // TODO Auto-generated catch block e....
5
public void set(String[] command) { int idIn = Integer.parseInt(command[0]); int noIn = Integer.parseInt(command[1]); int idOut = Integer.parseInt(command[2]); int noOut = Integer.parseInt(command[3]); CompuertaLogica compIn = null; CompuertaLogica compOut = null; ...
7
private boolean addStack(Stack stack, LinkedHashMap<Integer,Stack> destinationStack) { if ((null == stack) || (null == destinationStack)) return false; Integer subStackKey = Integer.valueOf(stack.stackID()); // When the stack ID is zero, the keys in the sub-stack map are // set incr...
9
public void doAlignment(String sq1, String sq2) { super.prepareAlignment(sq1, sq2); int n = this.n, m = this.m; float[][] score = sub.score; start = new TracebackSimple[2][sq2.length() + 1]; char[] s1 = sq1.toCharArray(); char[] s2 = sq2.toCharArray(); ...
8
@Override public void actionPerformed(ActionEvent e) { visibleScreen.getFrame().getContentPane().removeAll(); visibleScreen.getSetup().getRound().getPlayerInTurn().clearListOfLastCheckedCards(); visibleScreen.getSetup().getRound().playTurn(); if (visibleScreen.getSetup().getRound(...
6
@Override public int hashCode() { int hash = 0; hash += (idPerfil != null ? idPerfil.hashCode() : 0); return hash; }
1
public void addExpressionListener(ExpressionChangeListener listener) { listeners.add(listener); }
0
public List<T> findAll() { javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); cq.select(cq.from(entityClass)); return getEntityManager().createQuery(cq).getResultList(); }
0
private String checkValidArguments(String operation, String[] arguments) { //Checks if actual operation if(!operationArgs.containsKey(operation)) { return "The operation you requested could not be found: " + operation; } //TODO Consolidate this and make it more efficient //Checks number of arguments. ...
9
private boolean isValidEmpNum(){ boolean isValid = false; if(employeeNumber.length() != 5){ return false; }else{ if(employeeNumber.charAt(3) != '-') return false; else{ if((employeeNumber.charAt(4) >= 'A' && em...
6
private static int cyclesHeight(int n) { int height = 1; for (int i = 0; i < n; i++) { if (i % 2 == 0) { height *= 2; } else { height++; } } return height; }
2
private boolean calculate(Double number) { LOG.debug("START_METHOD calculate()."); boolean ret = true; switch ( operation ) { case OPERATION_ADD: { result += number; LOG.info("Execute operation ADD for number < " + number + " >. Result operation is " + result); break; } ...
6
public int threeSumClosest(int[] num, int target) { // similar to threeSum; keep track of the min_diff if (num.length < 3) { return Integer.MAX_VALUE; } int diff = Integer.MAX_VALUE; int result = 0; int[] r = new int[3]; Arrays.sort(num); for (...
9
private void create(int[] init, Color bg, String fieldTitle) { setPreferredSize(new Dimension(GUIConstants.DEFAULT_FIELD_WIDTH, FIELDHEIGHT)); setBackground(bg); setBorder(BorderFactory.createTitledBorder(fieldTitle)); setLayout(new VerticalLayout(0, VerticalLayout.CENTER)); setT...
5
public void setEmployeeName(String employeeName) { this.employeeName = employeeName; }
0
public void setRealname(String realname) { this.realname = realname; }
0
public void process() throws IOException { T incomingMessage= _tokenizer.getMessage(_in); while ((!_serverStop.getValue()) && (!_protocol.isEnd(incomingMessage))){ String response = _protocol.processMessage(incomingMessage); if (response != null){ addToOutBuffer(response); } incomingMessage= _tokeni...
5
public static void main(String[] args) { LogManager.getLogger(Lab5Test.class).log(Level.INFO, "TEST START"); final Scheduler scheduer = new Scheduler(); Runnable generatorRunnable = new Runnable() { @Override public void run() { Proxy proxy = scheduer.getProxy(); Random rand = new Random(System....
7
private String map () { if (mapType == 0) map ="roadmap"; else if (mapType == 1) map = "terrain"; else if (mapType == 2) map = "satellite"; else if (mapType == 3) map = "hybrid"; return (map); }
4
private synchronized void savePage(Page page) { FileWriter writer = null; try { writer = new FileWriter("page" + page.getPageId()); writer.write("LSN:" + Integer.toString(page.getLsn()) + "|"); writer.write("taId:" + Integer.toString(page.getTa().getTaId()) + "|"); writer.write("data:" + page.getDa...
3
public int connect() { System.out.println("Connecting to the database..."); int errorCode = 0; // load MySQL driver // --- 1) get the Class object for the driver try { Class.forName ("com.mysql.jdbc.Driver"); System.out.println("Found/loaded MySQL Connector JDBC driver"); } c...
2
public void run() { // システム情報取得 String str = System.getProperty("os.name"); mOSName = str; str = System.getProperty("os.arch"); mOSArch = str; str = System.getProperty("os.version"); mOSVersion = str; str = System.getProperty("user.name"); mUserName = str; DebugLog("user name:" + str); DebugLo...
7
private int[] initRandomArray(int i) { Random r = new Random(); int[] array = new int[i]; for (int j = 0; j < array.length; j++) { array[j] = j; } /** * for i from n − 1 downto 1 do * j ← random integer with 0 ≤ j ≤ i * exchange a[j] and a[i...
2
protected void initFromModel() { Random rand = new Random(); for (int x = 0; x <= 3; ++x) { int maxY = 3 - x; for (int y = -3; y <= maxY; ++y) { int r = rand.nextInt(HexType.values().length); HexType hexType = HexType.values()[r]; HexLocation hexLoc = new HexLocation(x, y); getView...
4
final int[][] method3047(int i, int i_0_) { if (i_0_ != -1564599039) return null; anInt9356++; int[][] is = ((Class348_Sub40) this).aClass322_7033.method2557(-90, i); if (((Class322) ((Class348_Sub40) this).aClass322_7033).aBoolean4035) { int[] is_1_ = this.method3048(i, i_0_ + -2096661920, 2); int[]...
5
public void run() { try { Socket socket = new Socket(this.hostName, this.portNumber); ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream()); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String fromServer = ""; ...
7
public BufferedImage read() throws IOException { if (!sourceFile.exists()) { throw new FileNotFoundException( "Could not find file: " + sourceFile.getAbsolutePath() ); } /* TODO refactor. * The following code has been adapted from the * StreamThumbnailTask.read method. */ ImageInputStr...
9
public void move() { Direction direction = DirectionMove.selectDirection(); switch (direction) { case LEFT: moveOnAxisX(direction); break; case RIGHT: moveOnAxisX(direction); break; case DOWN_LEFT: ...
6
public Collection<V> values() { Set<Map.Entry<K, CachedValue<V>>> entrySet = cache.entrySet(); List<K> expiredKeys = new ArrayList<K>(128); Collection<V> result = new ArrayList<V>(entrySet.size()); for (Map.Entry<K, CachedValue<V>> entry : entrySet) { CachedValue<V> cachedVal = entry.getValue(); ...
3
public static void rsaCrypterFile(CryptobyConsole console) { scanner = new Scanner(System.in); do { System.out.println("\n"); System.out.println("RSA File Cryption"); System.out.println("-----------------\n"); System.out.println("1 - Encryption and genera...
7
public ArrayList<HiloBean> getPage(int intRegsPerPag, int intPage, ArrayList<FilterBean> alFilter, HashMap<String, String> hmOrder) throws Exception { ArrayList<Integer> arrId; ArrayList<HiloBean> arrHilo = new ArrayList<>(); try { oMysql.conexion(enumTipoConexion); arrId...
2
public void weeklyBonus(Player player) { if (color == player.getColor()) { for (Artifact a: active.values()) { a.weeklyBonus(player); } } }
2
public boolean mouseup(Coord c, int button) { for (Widget wdg = lchild; wdg != null; wdg = wdg.prev) { if (!wdg.visible) continue; Coord cc = xlate(wdg.c, true); if (c.isect(cc, (wdg.hsz == null) ? wdg.sz : wdg.hsz)) { if (wdg.mouseup(c.add(cc.inv()), button)) { return (true); } } } r...
5
public synchronized void setRun(int state) throws InvalidArgumentException { if (state == NEW || state == RUNNING || state == ERROR || state == PAUSED || state == DISCONNECT || state == CLOSED) { this.state = state; } else { throw new InvalidArgumentException("State must equal NE...
6
@Override public boolean perform(final Context context) { // Example: /<command> format set[ <Player>] <Format> if (context.arguments.size() < 3) return false; OfflinePlayer target = Parser.parsePlayer(context, 2); if (target == null && context.sender instanceof OfflinePlayer) targe...
9
public void drawLoadGraph(Graph graph){ if (graph==null) return ; controller.setModel(graph); this.diagramPanel = new DiagramPanel(graph); this.setPopMenu(new PopUpMenu(getDiagramPanel())); diagramScrollPane.setViewportView(this.getDiagramPanel()); int x = 0; int ...
5
@Override public void addResult(String key, Result r) { if(results.containsKey(key) && results.get(key) != null){ results.get(key).add(r); } else{ ArrayList<Result> list = new ArrayList<Result>(); list.add(r); results.put(key, list); } }
2
public static void evaluateEquivalentProposition(Proposition self) { { Vector arguments = self.arguments; Stella_Object firstarg = Logic.innermostOf((arguments.theArray)[0]); Stella_Object secondarg = Logic.innermostOf((arguments.theArray)[1]); if (Proposition.trueP(self)) { if (Propositi...
9
@Override public P<NeuronStorage, List<Integer>> processAlg(Void _v) { Main.print("VectorQuantizer start " + new Date()); List<Integer> indexes = new ArrayList<Integer>(); for (int i = 0; i < blocks.size(); i++) { ColoredBlock cb = blocks.get(i); NeuronSeq history = new NeuronSeq(); for (int j = 0; j <...
9
public ArrayList<LinkedHashMap<Path, Patch>> listFilesDiffsFromSourcewToTarget() throws IOException{ ArrayList<LinkedHashMap<Path, Patch>> patches = new ArrayList<LinkedHashMap<Path,Patch>>(); for(int i=0;i<targetDirs.size();i++) patches.add(getFileDiffsOfDirectories(sourceDir,targetDirs.get(i))); re...
1
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub out.println("Please enter the maze you would like to run:"); String input = "src/MazeReadIn/trickySearch";//console().readLine(); String output = input+"Solution"; Maze myMaze = ReadMaze.parseMaze(input); // classNa...
4
public CompanyPendingApplication() { setIconImage(Toolkit.getDefaultToolkit().getImage(CompanyPendingApplication.class.getResource("/InterfazGrafica/Images/pendientes.png"))); getContentPane().setBackground(new Color(248, 248, 255)); setBounds(10, 50, 836, 758); getContentPane().setLayout(null); contentPanel.setBackgro...
0
public Location getPlayerSpawnLocation(Player player, Location location){ Location location_new = location; String worldName = location.getWorld().getName(); for (String worldN : plugin.mainWorlds){ if (worldName.startsWith(worldN + "_")){ //World is a copy world String playerName = player.getName()...
9
public void createNewPerson(Person person, String name, String email, String contactNumber, String address, int accessLevel, String password, String vatNumber, String contactName ){ if (person instanceof Customer){ customerList.add( new Customer(name, email, contactNumber, address)); } else if(person instanceo...
2
public boolean isSameTree(TreeNode p, TreeNode q) { if (p ==null&&q ==null){ return true; } if (p ==null||q == null){ return false; } if (isSameTree(p.left,q.left)&&isSameTree(p.right,q.right)&&p.val == q.val){ return true; } el...
7
public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); if (e.VK_LEFT == code) { desiredVelX = -1; desiredVelY = 0; } if (e.VK_RIGHT == code) { desiredVelX = 1; desiredVelY = 0; } if (e.VK_UP == code) { d...
6
@EventHandler public void SilverfishMiningFatigue(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("...
6
public void scrollCellToView(JTable table, int rowIndex, int vColIndex) { if (!(table.getParent() instanceof JViewport)) { return; } JViewport viewport = (JViewport) table.getParent(); Rectangle rect = table.getCellRect(rowIndex, vColIndex, true); Rectangle viewRect =...
9
private TreeMap<Float, Point2D.Float> pairPriceWithMarketByDate( TreeMap<Float, float[]> technicals, int idPt) { TreeMap<Float, Point2D.Float> pricePoints = new TreeMap<Float, Point2D.Float>(); for (Entry<Float, float[]> ent : technicals.entrySet()) { try{ Point2D.Float priceMatch = new Point2D.Float(ent.g...
2
public void merge(Cluster cluster) { for (int i = 0; i < cluster.size(); i++) this.addInstance(cluster.get(i)); }
1
public static void setPageMargins(PrintService service, PrintRequestAttributeSet set, double[] margins, LengthUnits units) { PageOrientation orientation = getPageOrientation(service, set); if (orientation == PageOrientation.LANDSCAPE) { setPaperMargins(service, set, new double[] { margins[3], margins[0], margin...
3
public boolean start() { synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; } // Is metrics already running? if (task != null) { return true; } // Begin hitting the s...
7
@Override public void run() { InputStream is; try { is = client.getInputStream(); DataInputStream dis = new DataInputStream(is); Date d = new Date(dis.readLong()); System.out.println("Client " + d + " socket: " + client.toString()); client.close(); } catch (IOException e) { // T...
1
public static void main(String[] args){ for(int i=1;true;i++){ int tri = getTri(i); if(numOfFactors(tri)>500){ System.out.println(tri); break; } } }
2
public static void main(String[] args) throws IOException{ Board board = new Board(); BoardGUI boardGUIStart = new BoardGUI(board); JFrame frame = addToFrame(boardGUIStart); List<Move> moves = new ArrayList<Move> (); try { Move move1 = new Move(new Coordinate("E2"), new Coordinate("E4")); Move move2 ...
3
public void updateTotal(int col) { int totalHours = 0; int totalMinutes = 0; int currentRow = 0; while(currentRow < tableRows-1 && tableData[currentRow][col] != null && tableData[currentRow+1][col] != null) { //Elaborated for visibility purposes int hourIn = timeToCode(tableData[curren...
6
public void ProcessInput(int key) { if(Keyboard.KEY_W == key) { if(holder != null) holder.Step(Directions.NORTH); } if(Keyboard.KEY_D == key) { if(holder != null) holder.Step(Directions.EAST); } if(Keyboard.KEY_A == key) { if(holder != null) holder.Step(Directions.WEST); } if(K...
8
public static AABB createMeshAABB( Mesh mesh ) { Vector3f min = new Vector3f( 0, 0, 0 ); Vector3f max = new Vector3f( 0, 0, 0 ); for ( Triangle triangle : mesh.getTriangles() ) { for ( int i = 0; i < 3; i++ ) { Vector3f vector = triangle.getPoint( i + 1 ); float posX = vector.getX(); float po...
8
public static void saveHighScores(){ //Erase and recreate save file try{ Game.file.delete(); }catch(Exception e){ e.printStackTrace(); } try{ if (!Game.file.exists()) { Game.file.createNewFile(); } }catch(IOException e){ e.printStackTrace(); } long winnerTime = (Game.stopTime-Game.st...
9
public void setOptions(String[] options) throws Exception { String mString = Utils.getOption('P', options); if (mString.length() != 0) { setPercent((double) Double.parseDouble(mString)); //setNumberOfAttributes((int) Integer.parseInt(mString)); } else { setPercent(0); mString = Utils.getOption('...
8
@Override public boolean activate() { if(Tabs.getCurrent() != Tabs.INVENTORY && hasSpinTicket()) { return false; } return hasSpinTicket(); }
2
public void loadTable() { if(isTableLoaded()) return; table = new double[350][23]; BufferedReader br = null; String line = null; StringTokenizer tok = null; int y = 0, x= 0; try { br = new BufferedReader(new InputStre...
7
private void stopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopButtonActionPerformed if (task == null || !task.isAlive()) { return; } task.interrupt(); setEnableControls(true); setRunningIndicator(false); sout.println("\n\nSTOPPE...
2
protected String getStandardHitWordInternal(int type, int damnCode) { damnCode++; // always add 1 because index into hitwords is type=0, annoy=1; final Object[][][] hitWords = CMProps.getListFileGrid(CMProps.ListFile.DAMAGE_WORDS); if(hitWords != hitWordsChanged) { hitWordsChanged=hitWords; hitWordIndex=...
9
Class226(int i, IndexLoader class45, IndexLoader class45_3_) { do { try { aClass45_2961 = class45; aClass45_2965 = class45_3_; if (aClass45_2961 != null) aClass45_2961.getAmountChildEntries(0); if (aClass45_2965 == null) break; aClass45_2965.getAmountChildEntries(0); } catch (RuntimeExc...
6
public void resetGame(int sx,int sy)//清空地圖、隨機地圖、重設按鈕文字 { gameOver = false; aroundBombNum = new int[mapHeight][mapWidth];//清空地圖 map = new boolean[mapHeight][mapWidth]; isPressed = new boolean[mapHeight][mapWidth]; isTurned = new boolean[mapHeight][mapWidth]; i...
9
public void toggleClick() { if (this.isSelected == false) { this.isSelected = true; } else { this.isSelected = false; } repaint(); }
1
public int getRowCount() { return data.size(); }
0
public int getOpcode(final int opcode) { if (opcode == Opcodes.IALOAD || opcode == Opcodes.IASTORE) { // the offset for IALOAD or IASTORE is in byte 1 of 'off' for // primitive types (buf == null) return opcode + (buf == null ? (off & 0xFF00) >> 8 : 4); } else { ...
4
private void notifyListeners() { for (AnswerSideListener listener : listeners) listener.onAnswerSideChanged(answerSide); }
1
private void processFilterFiles(Sim_event ev) { if (ev == null) { return; } Object[] data = (Object[]) ev.get_data(); if (data == null) { return; } Filter f = (Filter) data[0]; int destination = ((Integer) data[1]).intValue(); ...
4
private boolean isBlocked(float x, float y) { boolean blocked = false; float tweakedX = x + 4; float tweakedY = y + 8; beeBoundingRect.setLocation(tweakedX,tweakedY); for(int i = 0; i < map.length; i++){ if(beeBoundingRect.intersects(map[i])){ if(map[i].type !=...
3
*/ private void updateMouseAutoScroll(Point point) { // FIXME: This entire thing is some huge pile of fail. // It scrolls too slowly and causes viewport issues. if (!(getParent() instanceof JViewport)) { return; } JViewport p = ((JViewport) getParent()); Rectangle vr = p.getViewRect(); ...
7
private void addProperty(PropertyDescriptor propertyDescriptor, JComponent editor, GridBagLayout grid) { String text = propertyDescriptor.getDisplayName(); String newText = ""; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (((c >= 'A'...
5
static void RunMessagesOption(Client client, Scanner scanner) throws UnspecifiedErrorException, IOException, InvalidHeaderException { MessagesOptionShell.in = scanner; MessagesOptionShell.client = client; StringBuilder builder = new StringBuilder(String.format("\n%s > %s\n\n", SHELL_TITLE, Options.MESSAGES...
9
public NodeFoldingComponent(NodeView view) { super(); if (logger == null) { logger = freemind.main.Resources.getInstance().getLogger( this.getClass().getName()); } this.nodeView = view; setModel(new DefaultButtonModel()); init(null, null); ...
7
public void update() { if (timer >= frames.get(frameNum).duration) { timer = 0; if (++frameNum >= frames.size()) { frameNum = 0; } } else { timer++; } }
2
@Override public void setCorrectAnswer() { for (int i=1; i<=col1Choices.size(); i++){ int choice = InputHandler.getInt("Which item in column 2 matches item "+i+" from column 1?"); answer.put(i, choice); } }
1
public int volumnwithwater(int[] A) { int[] Av = new int[A.length]; int volumn = 0; int lmax = 0; while (lmax < A.length) { int p = lmax; while (p < A.length && A[p] <= A[lmax]) p += 1; if (p < A.length) { volumn += (p-lmax...
9
private char scanCells(Direction direction) { final boolean isHorizontal = direction == Direction.Horizontal; for (int i = 0; i < _board.length; ++i) { final char startToken = _board[isHorizontal ? i : 0][isHorizontal ? 0 : i]; boolean foundWinner = true; for (int j = 1; j < _board.length; ++j) { ...
8
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof DenseGrid) { DenseGrid<?> other = (DenseGrid<?>) obj; return Arrays.equals(values, other.values); } return super.equals(obj); }
4
private String contohex (int num) { String test = ""; for (int i = 16; i >= 1; i = i / 16) { if (num / i < 10) test += num / i; else if (num / i == 10) test += "A"; else if (num / i == 11) test += "B"; else if (num / i == 12) test += "C"; else if (num / i == 13) test += "D"; else if (num / i == 14...
8