text
stringlengths
14
410k
label
int32
0
9
private static int merge(Comparable[] a, Comparable[] aux, int lo, int mid, int hi) { // i and j is used to point to the currently processing element in the // first and 2nd half respectively int i = lo, j = mid + 1; // number of array access int numAccess = 0; // Copy a[lo..hi] to aux[lo..hi]. 2 acce...
5
public UpgradeManager getUpgradeManager(){ return this.upgradeManager; }
0
public void run() { System.out.println("Movie: The Matrix"); System.out.println("Movie starts in: "); for(int countdown = 0; countdown > 0; countdown--) { System.out.println(countdown); try { Thread.sleep(1000); } catch (InterruptedException e) { System.err.println("Cant sleep! " + e.getLocali...
8
public <T> T unmarshal(int type) throws JAXBException { if (type == CLIENT || type == ADMIN) { String str = new String(buf.array()); str = str.replace("xmlns=\"jabber:client\"", ""); str = str.replace("xmlns='jabber:client'", ""); if(!str.contains("xmlns='jabber:server'") && !str.contains("xmlns=\"jabber...
6
public static Method getMostSpecificMethod(Method method, Class<?> targetClass) { Method specificMethod = null; if (method != null && isOverridable(method, targetClass) && targetClass != null && !targetClass.equals(method.getDeclaringClass())) { specificMethod = SpringReflectionUtils.findMethod(target...
6
public static void main(String[] args) { try { if(args.length > 1) { if(args.length < 6) { Monopoly m = new Monopoly(new Loader()); for(String name : args) { m.addPlayer(new Player(name, m.STARTMONEY)); } m.startMonopoly(); } else { throw new IllegalArgumentException("You c...
4
private int checkBlk(Map<Long, BlockChecksums> srcMap, int offset, List<DiffCheckItem> difList) { int start = offset; BlockChecksums bck = null; // 新老文件相同的块,老文件的 BlockChecksums blk = null; // 新文件取出的块 for (; start < updateFile.length(); start++) { blk = getNextBlock(start); if (srcMap.containsKey(blk.ge...
9
public void saveFile() throws IOException { Collections.sort(scorelist); Collections.reverse(scorelist); PrintWriter fileOut = new PrintWriter(new FileWriter(fileName)); for (int i = 0; i<5 && i<scorelist.size(); i++) { fileOut.println(scorelist.get(i)); ...
2
@Override public String toString() { return name; }
0
@Override public void run() { try { serverObject = new ServerClass(console); console.setCommandManager(config.commandManager); config.commandManager.setConsole(console); config.commandManager.setServerClass(serverObject); console.setServerClass(serverObject); Thread t = new Thread(serverObject); ...
5
@Override public ExecutionContext run(ExecutionContext context) throws InterpretationException { int x = context.ui.dw.turtle.getPosX(); int y = context.ui.dw.turtle.getPosY(); Value value = ((AbsValueNode) this.getChildAt(0)).evaluate(context); if (value.getType() == VariableType.N...
3
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Colore other = (Colore) obj; if (blue != other.blue) return false; if (green != other.green) return false; if (red != other.red) ret...
6
public void reloadPlugin(CommandSender sender, String args) { if (args.equalsIgnoreCase("Paypassage")) { plugin.getLoggerUtility().log((Player) sender, "Please wait: Reloading this plugin!", LoggerUtility.Level.WARNING); } if ("all".equalsIgnoreCase(args) || "*".equalsIgnoreCase(args...
9
protected int readHWReg(Size size, int addr) { int reg = addr - 0x2000; if (mmap[reg] == null) { //Log.err(String.format("Read Memory Mapped register 0x%04x not implemented.", addr)); if (Settings.get(Settings.MEM_THROW_INVALID_ADDR).equals("true")) throw new RuntimeException(String.format("Read Memory Ma...
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Identification that = (Identification) o; if (revision != that.revision) return false; if (!description.equals(that.description)) return false;...
9
protected void moveToPosition(Environment e, Point position) { if (e.canMove(position)) { //return if agent doesn't have energy to move if (pinkEnergy < MOVE_COST || greenEnergy < MOVE_COST) return; System.out.println(this + " moves to " + position.x + ", " + position.y); this.position = position; ...
3
private String unpackResult(String first) throws ApiConnectionException, ApiDataException { StringBuilder buf = new StringBuilder(first); line = null; while (hasNextLine()) { String peek = peekLine(); if (!(peek.startsWith("!") || peek.startsWith("=")...
4
public void update() { for(GuiButton button : buttons) { button.update(); } for(int i = 0; i < particles.size(); i++) { if(particles.get(i).update()) particles.remove(particles.get(i)); } repaint(); }
3
public boolean subrend(GOut g) { if (!loading) return (false); List<Resource.Image> images = new ArrayList<Resource.Image>(); loading = false; for (Indir<Resource> r : layers) { if (r.get() == null) loading = true; else ...
5
private Entry search_this_block(String myid) { ArrayList<Entry> block = st.peek(); for( Entry p : block) { if( p.getName().equals(myid) ) { return p; } } return null; }
2
public String getTypeName () { switch (type) { case 0: return "RST"; case 1: return "KEY"; case 2: return "REL"; case 3: return "ABS"; case 0x11: return "LED"; case 0x12: return "SND"; case 0x14: return "REP"; default: if (type > 0x1f) throw new IllegalStateException (); } ...
8
public int priseTerritoire(Territoire t, int nbUnite) { // Utilisation prioritaire des unités bonus if (this.nbUniteBonus >= nbUnite - 1) { this.nbUniteBonus -= nbUnite - 1; nbUnite = 1; } else { nbUnite -= this.nbUniteBonus; this.nbUniteBonus = 0; } this.nbUniteEnMain -= nbUnite; ...
2
@Override public boolean tick(Tickable ticking, int tickID) { if(!super.tick(ticking, tickID)) return false; final Physical affected=this.affected; if(affected instanceof MOB) { final MOB mob=(MOB)affected; if((mob.isInCombat()) ||(CMLib.flags().isFalling(affected)) ||(!CMLib.flags().isAliveAwa...
7
public void input( GameObject go ) { final float SPEED_MOD = 0.25f; final float SENSITIVITY = 0.0025f; float moveAmount = SPEED_MOD * ( float ) ( 100 * Time.GetDeltaTime( ) ); float scroll = Mouse.getDWheel( ); if( Input.GetKeyDown( Input.KEY_W ) || scroll > 0 ) { go.transform.move( go.transform.forward, ...
8
public static String bytesToHex(byte[] data) { if (data == null) { return null; } else { int len = data.length; String str = ""; for (int i = 0; i < len; i++) { if ((data[i] & 0xFF) < 16) str = str + "0" + java.lang.Integer.toHexString(data[i] & 0xFF); else str = str + java.lang...
3
void loadWorld() { try{ String inpath ="Data//save.txt"; try (FileInputStream fstream = new FileInputStream(inpath)) { DataInputStream in = new DataInputStream(fstream); List<String> worldLines; List<String> mapLines; ...
9
public TypePraticien() { }
0
public MultiValueMapAdapter(Map<K, List<V>> map) { Assert.notNull(map, "'map' must not be null"); this.map = map; }
0
final public void MulDiv_Op() throws ParseException {/*@bgen(jjtree) MulDiv_Op */ SimpleNode jjtn000 = (SimpleNode)SimpleNode.jjtCreate(this, JJTMULDIV_OP); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);Token t; try { switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case STAR:{ t = jj_con...
4
private int minMove(Board prev, int depth, int alpha, int beta) { moves++; if(depth >= maxDepth) return getCost(prev); // exceeded maximum depth int minScore = MAX_SCORE; Board b = new Board(prev); b.turn(); // min player's turn for(int j = 0; j < size; j++) { for(int i = 0; i < size;...
9
public Connection connectToDB() throws CustomerizedException{ if(this.DriverName != null && this.URL != null && this.UserName != null && this.PassWord != null && this.conn == null){ try { Class.forName(this.DriverName); this.conn = DriverManager.getConnection(this.URL,this.UserName,this.PassWor...
7
public void adjustBeginLineColumn(int newLine, int newCol) { int start = tokenBegin; int len; if (bufpos >= tokenBegin) { len = bufpos - tokenBegin + inBuf + 1; } else { len = bufsize - tokenBegin + bufpos + 1 + inBuf; } int i = 0, j = 0, k = 0; int nextColDiff = ...
6
public int getEvolutions() { return evolutions > -1 ? evolutions : (NumOfParams * 2 + 1); }
1
public static void defaultAction(NodeInfo node, ParameterSet parameters, ParameterSet tunnelParams, XPathContext context, int locationId) throws XPathException { sw...
9
public void DoTheOption(char key){ switch(key){ case 'z': String tmp = null; //pop current room //we need to pop one before last element to get to the previous room if (!history.IsEmpty()) { tmp =history.pop();} else { System.out.print("\nSorry, you are in the first room\n"); ...
8
public void set(TKey key, TValue value) { if (!enabled || maxCacheSize == 0) return; if (!useBuffer) { mainCache.put(key, value); Boolean reachedMax = (maxCacheSize > 0) && (mainCache.size() >= maxCacheSize); if (reachedMax) ...
6
@Override public void initWorld() { //this.getWorld().setPlayer(new Player(this,this.getStartLocation().getX(),this.getStartLocation().getY())); { for(int i = 0;i<50;i++) if(i%2==0) this.getWorld().addEntity(new Wall(32*i,50,2)); for(int i = 0;i<50;i++) if(!(i%2==0)) ...
8
private void drawMenu() { int i = menuOffsetX; int j = menuOffsetY; int k = menuWidth; int l = anInt952; int i1 = 0x5d5447; DrawingArea.drawPixels(l, j, i, i1, k); DrawingArea.drawPixels(16, j + 1, i + 1, 0, k - 2); DrawingArea.fillPixels(i + 1, k - 2, l - 19, 0, j + 18); chatTextDrawingArea.method38...
9
@Override public String toString() { String h = String.format("%+f", this.h); String k = String.format("%+f", this.k); return "[(x" + h + ")^2/" + this.a + "+(y" + k + ")^2/" + this.b + "=1" + "]"; }
0
public static void main(String[] args) { // Check to make sure that a file was entered as argument. if (args.length != 1) { System.err.println("Usage: java Reverse <filename>"); System.exit(0); } // Process the file. Scanner originalFile;...
4
public void actionPerformed(ActionEvent e) { if (e.getSource() == bt_open1) { //Do something //IJ.log("pushed open1"); this.watchpath = IJ.getDirectory(""); ; setWatchpath(this.watchpath); directory.setText(this.watchpath); } if (e.getSource() == bt_open2) { //Do something //IJ.log("pushed op...
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; LoginEntity that = (LoginEntity) o; if (iduser != that.iduser) return false; if (password != null ? !password.equals(that.password) : that.pass...
8
public static HttpURLConnection HTTPConnect(URL urlToConnect, String method, String jsonText) throws IOException{ HttpURLConnection conn = (HttpURLConnection) urlToConnect.openConnection(); //Set token for open connection to Openstack conn.addRequestProperty("X-Auth-Token", OpenstackNetProxyConstants.TOKEN); ...
5
private void writeBehavior(Behavior b, XMLStreamWriter w) throws XMLStreamException { if ("beat".equals(b.type())) { writeEmpty(w, "gesture", a("start", asSync(b.low())), a("lexeme", "BEAT")); } else if ("brows".equals(b.type())) { writeEmpty(w, "faceLexeme", a("start", asSync(b.low())), a("en...
8
private SavingTrustManager openSocketWithCert() throws IOException { try { // Load the default KeyStore or a saved one KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); File file = new File("certs/" + server + ".cert"); if (!file.exists() || !file.isFile()) file = new File(System.getPr...
3
@Test public void test() throws InterruptedException { for (int i = 0; i < 100; i++) { for (ChildData data : PathCacheFactory.getBabyDuncanPathData()) { System.out.println(data.getPath() + " = " + new String(data.getData())); } Thread.sleep(1000); ...
2
public void update() { //NOTE, X AND Y ARE NOT THE POSITIONS OF THESE ENTITIES //This is to check for movement requests from entities (to allow the player to move between levels) //TODO move this to a dedicated (maybe static?) class ArrayList<ArrayList<Entity>> entityarrays = new ArrayLi...
7
public boolean isForward() { return _limitSwitch.get(); }
0
public int getUnreadNews() { int i = 0; BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(new URL("http://launcher.promethea-ftb.com/newsupdate.php").openStream())); ArrayList<Long> timeStamps = new ArrayList<Long>(); String s = reader.readLine(); s = s.trim(); S...
6
public void run() { init(); this.requestFocus(); while (running) { t.setNewTime(); if (t.checkDelta()) { updateGame(); } renderGame(); t.incrementFrames(); } }
2
public void schemeEditorDelCircuit() { if(ce_circuit.getSelectionIndex() == -1) return; String circuitName = ce_circuit.getText(); ce_circuit.remove(circuitName); ce_circuit2.remove(circuitName); scheme.getCircuits().remove(circuitName); schemeEditorSche...
1
private static File convertGLFile(File originalFile) throws IOException { // Now translate the file; remove commas, then convert "::" delimiter to comma File resultFile = new File(new File(System.getProperty("java.io.tmpdir")), "ratings.txt"); if (resultFile.exists()) { resultFile.delete(); } ...
5
public void moveHead(String direction) { try { switch (direction.charAt(0)) { case 'L': tapeHead--; break; case 'R': tapeHead++; break; case 'S': break; default: throw new IllegalArgumentException("Bad tape direction " + direction); } } catch (IndexOutOfBoundsExceptio...
8
public void keyPressed(KeyEvent e) { switch(e.getKeyCode()) { case KeyEvent.VK_PLUS: plus = true; break; case KeyEvent.VK_MINUS: minus = true; break; case KeyEvent.VK_P: ...
5
@Override public ExecutionContext run(ExecutionContext context) throws InterpretationException { Value val = ((AbsValueNode) getChildAt(this.getChildCount() - 1)).evaluate(context); if (val.getType() == VariableType.NUMBER) { for (int i = 0; i < ((Number) val.getValue()).intValue(); i+...
3
public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(TITLE); int[] fibonacci = new int [FIBONACCI_SIZE]; int lo = 1; int hi = 1; fibonacci[0] = lo; for(int i=0; i<FIBONACCI_SIZE; i++){ if (hi < 50){ fibonacci[i] = hi; hi = lo + hi; ...
3
private static void closeWriter(Writer writer) { try { if (writer != null) { writer.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } }
2
private String extractCollName(Map<QName, String> otherAttributes) { for (QName name: otherAttributes.keySet()) { if (name.getLocalPart().equalsIgnoreCase("name")) { return otherAttributes.remove(name); } } return null; }
2
public void step(SimulationComponent mComp) { if(callStack == null) { if(!gMethodList.get(0).isFinished()) { gMethodList.get(0).step(mComp); } else { bFinished = true; } return; } if(!gStarted && callStack != null) { callStack.push(gMethodList.get(0)); gStarted = true; ...
7
@Override public boolean setUserOffline(String username, UUID uuid) { FileWriter writer = null; try { BufferedReader reader = new BufferedReader(new FileReader(new File(OnlineUsers.directory+OnlineUsers.flatfileData))); String line = ""; StringBuilder toSave = new StringBuilder(); while ((line = reader...
6
@SuppressWarnings("rawtypes") public static Class loadPrimitiveType(String name) { if (name.equals("byte")) return byte.class; if (name.equals("short")) return short.class; if (name.equals("int")) return int.class; if (name.equals("long")) return long.class; if (name.equals("char")) return char.class; ...
9
@Override public void run() { while(true) { if (playing && !gameOver){ try { Thread.sleep(1000/30); //sleep for 1/30 second //if (!gameOver) { moveBall(); movePaddle(); if (dx>0) checkForHit(); if(misses == 3){ gameOver = true; score = h...
8
public byte[] getArchive(String name) { try { int nameHash = 0; name = name.toUpperCase(); for(int j = 0; j < name.length(); j++) nameHash = (nameHash * 61 + name.charAt(j)) - 32; for(int i = 0; i < amountEntries; i++) { if(nameHash...
6
public void setUpFile() { removeAll(); m_fileChooser.setFileFilter(new FileFilter() { public boolean accept(File f) { return f.isDirectory(); } public String getDescription() { return "Directory"; } }); m_fileChooser.setAcceptAllFileFilterUsed(false); try{...
7
public int addToQueueAutoPriority(String channel, String message, int source) { return addToQueue(channel, message, source); //soon }
0
private boolean calcolaSpazio() { boolean tuttoBene = false; if ((velocita!=0)&&(tempo!=0)) // Calcola con la formula inversa della velocità { spazio = velocita*tempo; tuttoBene = true; } else if ((!tuttoBene)&&(massa!=0)&&(tempo!=0)) // Calcola con...
5
@Override public List<AuthorModel> getAuthorsByName(String name) throws WebshopAppException { if (name != null) { try (Connection conn = getConnection()) { String sql = "SELECT * FROM author WHERE lastname = ? or firstname = ?"; try (PreparedStatement pstmt = conn.prepareStatement(sql)) { setSt...
3
@EventHandler public void ZombieStrength(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.getZombieConfig().getDouble("Zombie.Streng...
6
private boolean matchesPhi(final Expr real, final Phi phi) { final Bool match = new Bool(); match.value = true; real.visitChildren(new TreeVisitor() { public void visitExpr(final Expr expr) { if (match.value) { expr.visitChildren(this); } } public void visitStoreExpr(final StoreExpr expr) ...
6
public void removeHeart(Heart h) { synchronized(hearts) { if (hearts.contains(h)) hearts.remove(h); } }
1
public void setManagerId(String managerId) { this.managerId = managerId; }
0
public void run() { try { this.MPrio.acquire(); this.MReading.acquire(); if(this.counter == 0) this.MWriting.acquire(); this.counter++; this.MReading.release(); System.out.println("Lecture"); Thread.sleep(100); this.MReading.acquire(); this.counter--; ...
3
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { panel = new javax.swing.JPanel(); progressBar = new javax.swing.JProgressBar(); labelProgress = new javax.swing.JLabel(); scro...
0
private void addTileBars() { int yOffset = 0; int firstButtonPosition = 127; int firstTileBarPosition = 25; int tileBarHeight = 100; int buttonHeight = 23; //Adds a line between bars. JPanel inititalDivider = new JPanel(); inititalDivider.setBounds(0, 0, 1600, 1); inititalDivider.setBackground(Colo...
7
public void SpecDamgNPC(int maxDamage) { if(server.npcHandler.npcs[attacknpc] != null) { if (server.npcHandler.npcs[attacknpc].IsDead == false) { int damage = misc.random(maxDamage); if (server.npcHandler.npcs[attacknpc].HP - hitDiff < 0) damage = server.npcHandler.npcs[attacknpc].HP; ...
3
public Notepad() { super("Secure Note");//name/heading on the window try//exception handling for the user interface look and feel option { javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName()); } catch(Exception ex) ...
6
public int[]OrdenInsercion(int arreglo[], String ordenamiento){ int i,j,temporal; int indice, indice2,auxiliar; for (indice = 0; indice< arreglo.length; indice++) { auxiliar=arreglo[indice]; for (indice2 = 0; indice2>= 0&&arreglo[indice]<auxiliar; indice2--) { ...
3
public static void start(InetAddress address, int port) { Setup.println("Forwarder iniciado en " + address.getHostAddress() + ":" + port); server = new ForwardingService(address, port); new Thread(server).start(); }
0
public DefaultComboBoxModel<String> buildList() { DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<String>(); switch(comboBox.getSelectedIndex()) { case(0): comboBoxModel.addElement("Buff Max"); comboBoxModel.addElement("Heal"); break; case(1): comboBoxModel.addElement("Buff Max...
4
public boolean retirar(float cantidad) { if(cantidad<=saldo){ saldo-=cantidad; return true; } else{ return false; } }
1
private String getVideoID(String message) { Matcher matcher = LONG_URL.matcher(message); if ( !matcher.find() ) { matcher = SHORT_URL.matcher(message); matcher.find(); } return matcher.group(1); }
1
public void setOrgUnit(String orgUnit) { orgUnit = orgUnit.trim(); if ( orgUnit.isEmpty() ) { throw new RuntimeException( "'organizational' unit should not be empty" ); } this.orgUnit = orgUnit; }
1
public double getVoltage() { double w = 2 * pi * (sim.getT() - freqTimeZero) * frequency + phaseShift; switch (waveform) { case WF_DC: return maxVoltage + bias; case WF_AC: return Math.sin(w) * maxVoltage + bias; case WF_SQUARE: ...
8
@Override protected void refreshDiffs() { super.refreshDiffs(); //Create custom diffs line ArrayList<Integer> lLines = new ArrayList<Integer>(), rLines = new ArrayList<Integer>(); System.out.println(Arrays.asList(diffs)); for( RangeDifference diff : diffs){ if( diff.kind() != RangeDifference.NOCH...
8
@Override public void actionPerformed(ActionEvent e) { String username = txfUser.getText().trim(), password = new String( pwfPassword.getPassword()).trim(); if (username.length() < 1) { JOptionPane.showMessageDialog(LoginFrame.this, "The user field must not be empty. ", "Input error", JOpti...
3
private void addNewTerm(String name, String document){ termIndex.add(document, name); }
0
private void freqUpdate(Status status) { //String hashtags = "";// HashtagEntity[] tags = status.getHashtagEntities(); for (HashtagEntity t: tags) { String hashtag = "#"+t.getText().toLowerCase(); int val = 1; if (Settings.TFHashtagFreq.containsKey(hashtag)) { val += Settings.TFHashtagFreq.get(ha...
2
public void testCompare (){ liMarq1 = ligne1.compare(ligne2); assertEquals(liMarq1, liMarq2); }
0
public static Action buildAction(Library library, Hashtable hashTable) { Name actionType = (Name) hashTable.get(Action.ACTION_TYPE_KEY); if (actionType != null) { if (actionType.equals(Action.ACTION_TYPE_GOTO)) { return new GoToAction(library, hashTable); } else i...
5
@Test public void lineOneTodayAdenExpl() { LinkedList<String> meals = new LinkedList<String>(); LinkedList<String> price = new LinkedList<String>(); Canteen curCanteen = new Canteen(new CanteenData(CanteenNames.ADENAUERRING, 0));// 0 for "today" for (MealData m : curCanteen.getCanteenData().getLines().get(0).g...
3
void checkTryCatchOrder() { /* * Check if try/catch ranges are okay. The following succeeds for all * classes generated by the sun java compiler, but hand optimized * classes (or generated by other compilers) will fail. */ Handler last = null; for (Iterator i = handlers.iterator(); i.hasNext();) { ...
8
public Error() {}
0
public void showHarrisPoints(int keepMax) { if(keepMax < 0) RHarris.display(); else { Data max = null; PortableMap image = null; try { max = RHarris.keepMax(keepMax); image = new PortableMap(portableMap); float min = max.getMinValue(); for(int i = 0; i < portableMap.getHeight(); ++i) f...
7
public void SetTimeCreated(int timeCreated) { this.timeCreated = timeCreated; }
0
@Test public void testCreateObject(){ calc = new DataCalc(inData, numberOfPoints); calc.createDataSet(0); outData = calc.getStructureIn(); Assert.assertNotNull(outData); }
0
public Message(boolean isLastMessage, COMMAND command, int dataLength, String filename, byte[][] data) throws IllegalArgumentException { this.isLastMessage = isLastMessage; this.command = command; this.dataLength = dataLength; this.filename = filename; this.data = data; if(dataLength > data.length ...
2
public void createGraph(){ Scanner console = new Scanner(System.in); String fileName; if (gSize != 0) clearGraph(); Scanner infile = null; try{ System.out.print("Enter input file name: "); fileName = console.nextLine(); System.o...
4
static public String doubleToString(double d) { if (Double.isInfinite(d) || Double.isNaN(d)) { return "null"; } // Shave off trailing zeros and decimal point, if possible. String s = Double.toString(d); if (s.indexOf('.') > 0 && s.indexOf('e') < 0 && s.indexOf('E') < 0) { ...
7
private void testMap(Map<Data, Data> data) { Assert.assertEquals(0, data.size()); for (int i = 0; i < 10; i++) { data.put(new Data(i), new Data(2 * i)); } Assert.assertEquals(10, data.size()); for (int i = 0; i < 10; i++) { Assert.assertEquals(new Data(2 * i), data.get(new Data(i))); ...
4
public void addRow(Object[] data){ int indice = 0, nbRow = this.getRowCount(), nbCol = this.getColumnCount(); Object temp[][] = this.data; this.data = new Object[nbRow+1][nbCol]; for(Object[] value : temp) this.data[indice++] = value; this....
1