text
stringlengths
14
410k
label
int32
0
9
@Override public boolean update(Particulier x) { Statement stm = null; try { String req = "UPDATE particulier SET \n" + "email=\""+x.getEmail()+"\",\n" + "motdepasse=\""+x.getMotDePasse()+"\",\n" + "nom=\""+x.getNom()+"\",\...
4
public void level() { level++; System.out.println("You are now level " + level + "!"); String choice = ""; while (!choice.equals("intelligence") && !choice.equals("strength")) { System.out.println("Increase intelligence or strength: "); choice = input.next().toLowerCase(); } System.out.println("Pick ...
3
private double calculateWavedX(double x1, double x2, double x3, double f1, double f2, double f3) throws ArithmeticException{ double r23 = Math.pow(x2, 2) - Math.pow(x3, 2), r31 = Math.pow(x3, 2) - Math.pow(x1, 2), r12 = Math.pow(x1, 2) - Math.pow(x2, 2), ...
1
@Override public DataTable generateDataTable (Query query, HttpServletRequest request) throws DataSourceException { DataTable dataTable = null; try (final Reader reader = new FilterCsv (new BufferedReader (new InputStreamReader (new URL (this.urlYahoo).openStream())))) { TableRow row = new TableRow (); ...
5
static public void main(String args[]) { String[] argv; long start = System.currentTimeMillis(); int argc = args.length + 1; argv = new String[argc]; argv[0] = "jlc"; for(int i=0;i<args.length;i++) argv[i+1] = args[i]; jlcArgs ma = new jlcArgs(); if (!ma.processArgs(argv)) System.exit(1); Con...
4
private static ClassSignature parseSig(String sig) throws BadBytecode, IndexOutOfBoundsException { Cursor cur = new Cursor(); TypeParameter[] tp = parseTypeParams(sig, cur); ClassType superClass = parseClassType(sig, cur); int sigLen = sig.length(); ArrayList ifArray ...
2
private boolean r_perfective_gerund() { int among_var; int v_1; // (, line 71 // [, line 72 ket = cursor; // substring, line 72 among_var = find_among_b(a_0, 9); if (among_var ...
8
public void generate(){ }
0
@SuppressWarnings("StringConcatenationMissingWhitespace") private void writeObjectToStream(Object obj, Types t, String name, DataOutputStream os) throws IOException { //Write Name os.writeUTF(name); //Write Type os.writeInt(t.ordinal()); //Write Value switch(t) { case OBJECT_ARRAY: case ISAVEABLE: {...
2
public static void Edmonds(Graph input) { input.setState(States.ARR_ADJ); Log.print(Log.system, "Edmonds algorithm:"); // init... n = input.getVertexCount(); used = new boolean[n]; blossom = new boolean[n]; mt = new int[n]; p = new int[n]; q = new int[n]; base = new int[n]; Arrays.fill(mt, -1); ...
6
public void createMaze(String filePath) { try { reader = new BufferedReader(new FileReader(filePath)); int i = 0; while ((line = reader.readLine()) != null) { parts = line.split("\\s"); for (int j = 0; j < MicromouseRun.BOARD_MAX; j++) { ...
5
public BubbleSorter() { // TODO Auto-generated constructor stub }
0
public JPanel getBrandingMenu() { if (!isInitialized()) { IllegalStateException e = new IllegalStateException("Call init first!"); throw e; } return this.brandingMenu; }
1
public ComparisonResult findGenes(Chromosome other) { ComparisonResult comparisonResult = new ComparisonResult(); // знаю имя координаты нужного гена, найти нужный домен comparisonResult.sizeGenes = other.intervals.size(); System.out.println(other.intervals.size()); for (Interval domain:...
8
@SuppressWarnings("CallToThreadDumpStack") private ArrayList<FieldCandidate> split_line(ArrayList<FieldCandidate> candidates, int start, int maxFields) { ArrayList<FieldCandidate> selectedCandidates = new ArrayList<>(); try { for (int posList = start; posList < candidates.size(); posLi...
7
private void startGame() { Timer.getInstance().start(); SoundManager.getInstance().playStartSound(); }
0
public static List<ClienteDTO> convertToDTOList(List<Cliente> lsClientes){ if(lsClientes == null){ return new ArrayList<ClienteDTO>(); } List<ClienteDTO> lsClientesDTO = new ArrayList<ClienteDTO>(); for(Cliente cliente : lsClientes){ lsClientesDTO.add(convertToClienteDTO(cliente)); } return l...
2
public void setSkill(int skill, String name, int value, int cost, String description) { assert numOfSkills > skill; this.skillNames[skill] = name; this.skillValues[skill] = value; this.skillCosts[skill] = cost; this.skillDescriptions[skill] = description; }
0
@Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((firstName == null) ? 0 : firstName.hashCode()); result = PRIME * result + ((id == null) ? 0 : id.hashCode()); result = PRIME * result + ((lastName == null) ? 0 : lastName.hashCode()); return result; ...
3
public String tileIDToStr(int tileid) { if (tileid==0) return ""; StringBuffer tilestr = new StringBuffer(""+(char)(tileid&255)); if (tileid >= 0x100) tilestr.append( (char)((tileid/0x100)&255)); if (tileid >= 0x10000) tilestr.append( (char)((tileid/0x10000)&255)); if (tileid>=0x1000000) tilestr.append( (char...
4
public List<Interval> merge(List<Interval> intervals) { if (intervals == null || intervals.size() < 2) return intervals; // First need to sort all the intervals based on the start time. // Sort with comparable. Collections.sort(intervals, new Comparator<Interval>() { @Override public int compare(Interv...
9
public int maxProfit(int[] prices) { int length = prices.length; if(length == 0) return 0; int[] history = new int[length]; int[] furture = new int[length]; int maxProfit=0; int valley = prices[0]; int peak = prices[length-1]; for(int i =0 ; i<...
5
public LockEventListener(LockManager manager){ this.manager = manager; }
0
private java.util.ArrayList<Binding> getBindings(String PortBinding){ NodeList Definitions, ChildNodes; NamedNodeMap attr; String BindingName, BindingType, BindingStyle, BindingTransport; Binding Binding = null; java.util.ArrayList<Binding> arrBindings ...
9
public static boolean Refill(PatientProfilePage pProfileP) { prescIDL=new JLabel("Prescription ID"); prescID = new JTextField(10); MyPanel = new JPanel(); MyPanel.add(prescIDL); MyPanel.add(prescID); int n = JOptionPane.showConfirmDialog( null,MyPanel, ...
1
@Override public JTable search(String searchTerm) { displaysearch = new String[result.length][result.length]; int n = 0; for(int i = 0; i < result.length; i++){ for(int j = 0; j < result[i].length; j++){ if((result[i][j].toLowerCase()).contains(searchTerm)){ displaysearch[n]= result[i]; ...
5
protected static boolean buscarPalabraDescripcion(String buscar){ boolean aux=false; //buca en cada linea del fichero si en la "casilla " descripcion hay la cadena que se esta buscando //si encuentra alguna coincidencia imprimira toda la linea try{ BufferedReader stdin=Files.newBufferedReader(path,java.n...
3
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = "", data[]; StringBuilder out = new StringBuilder(); while ((line = in.readLine()) != null && line.length() != 0) { int test = Integer.parseInt(line.trim()); ...
7
private boolean checkColumns(Player player) { boolean isWinner = false; if ((board[0][0].equals(player.getMark()) && board[0][1].equals(player.getMark()) && board[0][2].equals(player.getMark()))) { winnerCombination[0] = "0 0"; winnerCombination[1]...
9
public int candy(int[] ratings) { assert (ratings != null) : "Please input ratings!"; int len = ratings.length; if (len == 0 || len == 1) return len; int[] dp = new int[len]; // left -> right for (int i = 1; i < len; i++) { if (ratings[i] > ratings[i - 1]) { dp[i] = dp[i - 1] + 1; } } /...
8
public int numDecodings(String s) { if (s == null || s.length() == 0) { return 0; } int[] nums = new int[s.length() + 1]; nums[0] = 1; nums[1] = s.charAt(0) != '0' ? 1 : 0; for (int i = 2; i <= s.length(); i++) { if (s.charAt(i - 1) != '0') { nums[i] = nums[i - 1]; } int twoDigits = (s.char...
7
@SuppressWarnings("unchecked") private void parseQuery(String query, Map<String, Object> parameters) throws UnsupportedEncodingException { if (query != null) { String pairs[] = query.split("[&]"); for (String pair : pairs) { String param[] = pair.split("[=]"); String key = null; String value ...
8
public int largestRectangleArea(int[] height) { if (height.length == 0) return 0; int max = 0; int[] f,g; f= new int[height.length]; g= new int[height.length]; f[0] = -1; g[height.length-1] = height.length; for (int i = 1;i< height.length;i++) { ...
9
public void updatePosition() { if (xPos < xDestination) xPos++; else if (xPos > xDestination) xPos--; if (yPos < yDestination) yPos++; else if (yPos > yDestination) yPos--; if (xPos == xDestination && yPos == yDestination && isMoving==...
8
public static void main(String[] args) { Display display = Display.getDefault(); Shell shlCmss = new Shell(); shlCmss.setSize(562, 236); shlCmss.setText("CMSS"); Group group = new Group(shlCmss, SWT.NONE); group.setText("Current crisis"); group.setBounds(10, 10, 544, 194); Button button = new B...
2
@Override public double getHig() { return hight; }
0
Xpp3Dom createResult(final TestState testState) { return createElementWithText("result", testState.getState()); }
0
public static String writeObj(final Object object) { String result = null; if (object instanceof Long) { Long longObj = (Long) object; result = writeInt(longObj); } else if (object instanceof Integer) { Integer intObj = (Integer) object; result = w...
8
private OutputStream getOutputStream(final String s) { return new OutputStream() { StringBuffer o = new StringBuffer(); boolean done = false; @Override public void write(int b) throws IOException { if (b == '\n' && !sync) { sy...
4
public void testConstructorEx9_TypeArray_intArray() throws Throwable { int[] values = new int[] {3, 0}; DateTimeFieldType[] types = new DateTimeFieldType[] { DateTimeFieldType.dayOfMonth(), DateTimeFieldType.dayOfWeek()}; try { new Partial(types, values); fail...
1
@Override public void visitTypeInsn(final int opcode, final String type) { Item i = cw.newClassItem(type); // Label currentBlock = this.currentBlock; if (currentBlock != null) { if (compute == FRAMES) { currentBlock.frame.execute(opcode, code.length, cw, i); ...
4
public void addContestant(Contestant c) throws InvalidFieldException { if (allContestants.size() == numInitialContestants) { System.out.println("Too many contestants."); return; } if (isContestantIDInUse(c.getID())) { throw new InvalidFieldException( InvalidFieldException.Field.CONT_ID_DUP, "C...
2
public void addToggleButtonListener(ActionListener listener){ toggleBtn.addActionListener(listener); if(disableAction != null) disableAction.addActionListener(listener); }
1
@Test public void runTestActivityCommunication1() throws IOException { InfoflowResults res = analyzeAPKFile("InterAppCommunication_ActivityCommunication1.apk"); Assert.assertEquals(1, res.size()); }
0
public void setState(String state) { this.state = state; }
0
public void setStoredValueAsString(String storedValueAsString) { this.storedValueAsString = storedValueAsString == null ? "" : storedValueAsString; }
1
public Type getCanonic() { int types = possTypes; int i = 0; while ((types >>= 1) != 0) { i++; } return simpleTypes[i]; }
1
public Term getTerm() { return term; }
0
public Point getSideLocation(TileColor face) { Point offset = new Point(150, -25); if (face.equals(TileColor.orange)) return new Point(offset.x, frameSize.height / 2 - squareSize / 2 + offset.y); else if (face.equals(TileColor.white)) return new Point(offset.x + squareSize, frameSize.height / 2 - squareSize...
6
public String getIpaddress() { return ipaddress; }
0
public void addAll(Profile[] p, byte gameID){ Game g = GameFactory.getGameFromID(gameID); for(int i=0; i<p.length; i++){ if(profiles.length == size) profiles = Arrays.copyOf(profiles, size+3); // Check if the profile is already in use ...
7
public void refineTree() throws Exception { int nniCount = 0; switch( ntype ) { case OLS: if ( btype != balance.OLS ) T.assignAllSizeFields(); T.makeOLSAveragesTable(D,A); nniCount = T.NNI(A,nniCount); T.assignOLSWeights(A); break; case BAL: ...
9
public static <T> boolean binarySearch(ArrayList<T> list, T item, Comparator<? super T> cmp) { int comparison= cmp.compare(list.get(list.size()/2), item); if(comparison != 0) { //If we go to the bottom of the tree and there is like roots that are unequal then its not in the list. if(list.size() <= 1) ...
4
@Override public boolean nextKeyValue() throws IOException, InterruptedException { if (fsin.getPos() < end) { if (readUntilMatch(startTag, false)) { try { buffer.write(startTag); if (readUntilMatch(endTag, true)) { value.set(buffer....
3
public void setRight(PExp node) { if(this._right_ != null) { this._right_.parent(null); } if(node != null) { if(node.parent() != null) { node.parent().removeChild(node); } node.parent(this); ...
3
public T getSecond() { return second; }
0
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: List<String> pelaajat = new ArrayList<String>(); if(!jTextField2.getText().isEmpty()) { pelaajat.add(jTextField2.getText()); } ...
4
@Override public boolean setFromString(String value) { this.strings=value.split("\\x00"); if(strings.length==0) { this.strings=null; } return true; }
1
public void testInvariants() { assertTrue(!(moteur.estFini() && !((moteur.combat().alex().estVaincu() && moteur .combat().ryan().estVaincu()) || moteur.combat().slick() .estVaincu()))); assertTrue(!(moteur.resulatFinal() == Resultat.GAGNEE && !(moteur .combat().slick().estVaincu() && (!moteur.combat().a...
8
public boolean fill() { Random rand = new Random(); boolean modified = false; for (int i = 0; i < height; i++) { for (int j = width - 1; j >= 0; j--) { if (contentGrid[i][j] instanceof EmptyCase) { if (j == 0) { contentGrid[i][j] = listOfContents.get(rand .nextInt(listOfContents.size()))...
4
public int getResponseCode() throws IOException { int code = 0; try { code = con.getResponseCode(); } catch (FileNotFoundException fnfex) { code = HttpConnection.HTTP_NOT_FOUND; } catch (IOException ioex) { if (ioex.getMessage().starts...
3
public boolean birthChecker() { switch (state) { case NONE: // If leftHand is below leftElbow which is below leftShoulder (or right) if (GestureInfo.gesturePieces[GestureInfo.LEFT_HAND_DOWN] && GestureInfo.gesturePieces[GestureInfo.RIGHT_HAND_D...
9
@Override public void mouseClicked(MouseEvent arg0) { PictureLabel label = (PictureLabel) arg0.getSource(); if (SwingUtilities.isLeftMouseButton(arg0)) { switch (label.getText()) { case "Quest": for(int i = 0; i < Main.begin.getSize(); i++){ Main.begin.getCards()[i].getName(); Main.be...
8
public void setSocketListen(ServerSocket socketListen) { this.socketListen = socketListen; }
0
public static void asm_rlf(Integer befehl, Prozessor cpu) { // TODO Integer f = getOpcodeFromToBit(befehl, 0, 6); Integer d = getOpcodeFromToBit(befehl, 7, 7); Integer result = cpu.getSpeicherzellenWert(f); result = result << 1; if(result > 255) { result -= 256; if(cpu.getStatus().getBit(bits.C)) { ...
3
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) { Type type = typeToken.getType(); Class<? super T> rawType = typeToken.getRawType(); if (!Map.class.isAssignableFrom(rawType)) { return null; } Class<?> rawTypeOfSrc = $Gson$Types.getRawType(type); Type[] keyAndValueTyp...
5
public Object clone()throws CloneNotSupportedException { throw new CloneNotSupportedException(); }
0
private void closeOpenReport() throws Exception { LedgerOverview ledgerOverview = getLedgerOverview(); if (ledgerOverview == null) { throw new Exception("Could not find ledger overview."); } String ledgerUri = null; for (String uri : ledgerOverview.uris) { ...
9
public void mouseMoved(MouseEvent e) { MouseCoords = Board.fromScreenSpace(e.getPoint()); if (engine != null) engine.mouseChanged(); if (!editable) return; if (!boardBox.contains(e.getPoint())) return; Rectangle2D testPt = new Rectangle2D.Double(e.getX() - 5, e.getY() - 5, 8, 8); boolean hit = ...
6
public static String remove(String s, char c) { //Quick corner case maybe not needed if(s.length() == 0) { return s; } StringBuilder sb = new StringBuilder(); for(int i=0; i< s.length(); i++) { if (s.charAt(i)!= c) { sb.append(s.charAt(i)); } } return sb.toString(); }
3
public void buyPickaxe() { if (this.game.chestOpen && this.chestWood >= 10) { // unlock stone this.pickaxe = true; this.chestWood -= 10; } }
2
public Class<?> getReturnType() { return this.returnParam; }
1
public static String fastaSimpleRead(String fastaFile) { StringBuilder sb = new StringBuilder(); BufferedReader inFile; try { // Open file (either 'regular' or gzipped) inFile = Gpr.reader(fastaFile); if (inFile == null) return ""; // Error opening file String line = inFile.readLine(); // Discard fi...
3
public void testConstructor_8int__PeriodType3() throws Throwable { try { new Period(1, 2, 3, 4, 5, 6, 7, 8, PeriodType.dayTime()); fail(); } catch (IllegalArgumentException ex) {} }
1
public boolean removeGeneric(String generic_name){ Generic sgl; boolean item_found = false; for(int i=0;i<generics.size();i++){ sgl = (Generic) generics.get(i); if (sgl.name.equals(generic_name)){ item_found = generics.remove(i) != null; break; } } return item_found; }
2
public static NotificationType get(int typeID) { for (NotificationType notificationType : values()) { if (notificationType.getId() == typeID) return notificationType; } return UNKNOWN; }
2
public void genera() { iDir = ((int) (Math.random() * 5 + 1)); Objeto objFire = new Objeto(0,0,imaFire11); switch (iDir) { case 1: //Fire1 objFire.setX(400); objFire.setY(550); objFire.setImagen(imaFire11); b...
5
public void run() { try { while (true) { monitorThreadPool(); Thread.sleep(monitoringPeriod * 1000); } } catch (Exception e) { log.error(e.getMessage()); } }
2
public void reinforce() { }
0
public void readPic(int width, int height, int startFrame, int framesToBeCoded, ArrayList<Picture> picList) { int widthC = width >> 1; int heightC = height >> 1; for (int framesNo = startFrame; framesNo < startFrame + framesToBeCoded; framesNo++) { Picture picTemp; if (startFr...
2
public static void setMaxAge(int max_age) { if (max_age >= 1) Grass.max_age = max_age; }
1
public static void main(String[] args) { LOG.log(Level.FINE, "start aplikacji"); List<Klient> klienci = load(); Scanner sc = new Scanner(System.in); while(true) { pokazMenu(); int i = czytajLiczbeZKlawiatury(sc); ...
6
private HashSet<Integer> calcTargets(int start, int steps, HashSet<Integer> targets, HashSet<Integer> visited) { // This is our recursive function that creates the targets list. steps = steps - 1; visited.add(start); if(getCellAt(start).isDoorway()) { targets.add(start); } else if(steps == 0) { targets....
4
@Override public void paint(Graphics g) { super.paint(g); for (Entry<State, Point> node : statePositionList.entrySet()) { for (State followingState : node.getKey().getFollowingStates()) { Point followingPosition = statePositionList.get(followingState); g.setColor(Color.BLACK); drawArrow(g, calcula...
6
@Override public void OnTimerTick(Room Room, RoomUser PetUser) { int timenow = Room.Environment.GetTimestamp(); if(timenow < NextThink) return; int r = Room.Environment.GetRandomNumber(1, 35); if(r == 1) { PetUser.MoveTo(Room.Environment.GetRandomNumber(1, Ro...
5
public SimpleStringProperty addressTypeProperty() { return addressType; }
0
public String _toString () { org.omg.CORBA.portable.InputStream $in = null; try { org.omg.CORBA.portable.OutputStream $out = _request ("toString", true); $in = _invoke ($out); String $result = $in.read_string (); return $result; ...
2
public String getTypeString(Type type) { if (type instanceof ArrayType) return getTypeString(((ArrayType) type).getElementType()) + "[]"; else if (type instanceof ClassInterfacesType) return getClassString(((ClassInterfacesType) type).getClassInfo()); else if (type instanceof NullType) return "Object"; ...
3
@Override public boolean okMessage(final Environmental myHost, final CMMsg msg) { if(!(affected instanceof MOB)) return super.okMessage(myHost,msg); final MOB mob=(MOB)affected; if((msg.amITarget(mob)) &&(CMath.bset(msg.targetMajor(),CMMsg.MASK_MALICIOUS)) &&(msg.targetMinor()==CMMsg.TYP_CAST_SPELL) &...
9
private int[] generateRow(int[] input) { LinkedList<Integer> checkList = new LinkedList<Integer>(); Random r = new Random(); int row[] = new int[9]; for(int i=1; i<10; i++) checkList.add(i); for(int i=0; i<9; i++){ int num = Math.abs(input[i]); if(num>9||num==0) row[i]=0; else{ row[...
7
public static void main(String[] args) { Scanner in = new Scanner(System.in); char grade = in.next().charAt(0); switch (grade) { case 'A': System.out.println("Excellent"); break; case 'B': System.out.println("Good");...
5
public void renderLights(){ for(LightSource source : lightSources){ calculateShadows(source); } for(Player e : players){ if(e.light != null) calculateShadows(e.light); } for(Mob e : mobs){ if(e.light != null) calculateShadows(e.light); } }
5
@Override public String toString() { return this.file + "" + this.rank; }
0
private static GridResourceWithFailure createGridResource(String name, double baud_rate, double delay, int MTU, int totalPE, int totalMachine, int rating, String sched_alg) { // Here are the steps needed to create a Grid resource: // 1. We need to crea...
4
public boolean hasNext() throws Exception { if (!tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(reader.readLine().trim()); return hasNext(); } return true; }
1
@Override protected boolean execute(Widget widget, MouseEvent event) { final Widget c = parent != null ? parent : widget; switch (event.getID()) { case MouseEvent.MOUSE_EXITED: case MouseEvent.MOUSE_RELEASED: pressedPoint = null; initialXOffset...
8
public Tablero(){ super(); setBackground(new Color(0,0,0)); tortuga =new Tortuga(); liebre = new Liebre(); pista = new Pista(); setLayout(null); ltortuga=new JLabel(""); ltortuga.setForeground(new Color(126,176,175)); ltortuga.setLocation(30,100); ltortuga.setSize(400, 25); lliebre=new JLabel("...
3
public void reset(){ Object[] data; try { data = Parser.parse(Constants.LEVEL_FILENAME); world = new World((List<Entity>)data[0], (List<Tile>)data[1], (List<PickUpObject>)data[2], (Player)data[3]); player = (Player)data[3]; lastJump = 0; lastRedraw = 0; cam = new Camera(); hud = new HUD(); w...
1
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); double totaal = 0; if (session != null) { @SuppressWarnings("unchecked") Map<Integer, Integer> mandje = (HashMap<Integer, Integer>) session....
3
private void resetTargetsIfNeeded() { if(runawayTarget[0] == x && runawayTarget[1] ==y){ runawayTarget[0] = -1; runawayTarget[1] = -1; } if(foodTarget[0] == x && foodTarget[1] == y){ foodTarget[0] = -1; foodTarget[1] = -1; randomTarget[0] = -1; randomTarget[1] = -1; } if(foodTarget[0]>0 && f...
9