method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
350b658e-dbaa-41ef-8960-b564f8d04416
2
public final static GameFrame getInstance(){ if (GameFrame.gameFrame==null){ synchronized(GameFrame.class){ if(GameFrame.gameFrame==null) { GameFrame.gameFrame= new GameFrame(); } } } return GameFrame.gameFrame; }
1c91f203-f261-4075-9607-1ee5a23aab94
8
public boolean isFour() { boolean retBoo = false; if (isTrip()) { for (int i = 0; i < _cards.size()-3; i++) { for (int x = (i+1); x < _cards.size()-2; x++) { if (_cards.get(i).compareTo(_cards.get(x)) == 0) { for (int p = (x+1); p < _cards.size()-1; p++) { if (_cards.get(i).compareTo(_cards.get(p)) == 0) { for (int q = (p+1); q < _cards.size(); q++) { if (_cards.get(i).compareTo(_cards.get(q)) == 0) retBoo = true; } } } } } } } return retBoo; }
2da562ed-e66c-4ae0-95e9-6fc82f75782b
0
@Test public void runTestObfuscation1() throws IOException { InfoflowResults res = analyzeAPKFile("AndroidSpecific_Obfuscation1.apk"); Assert.assertEquals(1, res.size()); }
faa639a9-422b-4f46-ba62-a214ef97095a
5
private void layoutTabComponents() { if (JTattooUtilities.getJavaVersion() >= 1.6) { if (tabContainer == null) { return; } Rectangle rect = new Rectangle(); Point delta = new Point(-tabContainer.getX(), -tabContainer.getY()); if (scrollableTabLayoutEnabled()) { translatePointToTabPanel(0, 0, delta); } for (int i = 0; i < tabPane.getTabCount(); i++) { Component tabComponent = getTabComponentAt(i); if (tabComponent == null) { continue; } getTabBounds(i, rect); Dimension preferredSize = tabComponent.getPreferredSize(); Insets insets = getTabInsets(tabPane.getTabPlacement(), i); int outerX = rect.x + insets.left + delta.x; int outerY = rect.y + insets.top + delta.y; int outerWidth = rect.width - insets.left - insets.right; int outerHeight = rect.height - insets.top - insets.bottom; //centralize component int x = outerX + (outerWidth - preferredSize.width) / 2; int y = outerY + (outerHeight - preferredSize.height) / 2; int tabPlacement = tabPane.getTabPlacement(); boolean isSeleceted = i == tabPane.getSelectedIndex(); tabComponent.setBounds(x + getTabLabelShiftX(tabPlacement, i, isSeleceted), y + getTabLabelShiftY(tabPlacement, i, isSeleceted), preferredSize.width, preferredSize.height); } } }
bfcc7341-d0c9-4a59-a418-79048a4e6d16
3
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { AGPlayer agp = pH.getAGPlayer(event.getPlayer().getName()); if(agp == null) return; if(agp.isPraying() && ConfigHandler.disableChatAndCommands) { Messenger.sendMessage(event.getPlayer(), Message.cantDoThat); event.setCancelled(true); } }
2fca1c32-2d31-4775-abc8-d7359c935ba0
5
@Override public ArrayList<String> getNames(char firstLetter, String session, boolean indexPeople) { //create list to store the names ArrayList<String> speakerList = new ArrayList<>(); //loop through each member of specified session for (int i = firstLetter; i <= 'z'; i++) { try { //connect to the page of names for the given letter Document letterIndex = Jsoup.connect(firstMemberURL + session + lastMemberURL + (char) i).get(); //get all the names Elements speakers = letterIndex.select("dd"); //extract the names and store int the array for (Element speaker : speakers) { String name = speaker.text(); //format the name name = name.toUpperCase(); //if there are parens at end of name, remove them if (name.indexOf("(") > 0) { name = name.substring(0, name.indexOf("(")); } speakerList.add(name); if (indexPeople) { //create a new Person and add the list for later use Speaker newSpeaker = new Speaker(name); //set the speaker's url newSpeaker.setURL(domain + speaker.select("a").attr("href")); //add to the list searchedSpeakers.put(name, newSpeaker); } } } catch (IOException ex) { System.out.println(firstMemberURL + session + lastMemberURL + (char) i); System.out.println("Error on letter index"); } } return speakerList; }
90a8a6ca-eb43-4dad-ba44-2bc8f25a3dd1
8
public static String SentenceTrim(String sentence){ String temp[]; if(sentence.indexOf("null")>-1){ temp=sentence.split("null"); sentence=""; for(int i=0;i<temp.length;i++){ sentence=sentence+temp[i]; } } if(sentence.indexOf("</p>")>-1){ temp=sentence.split("</p>"); sentence=""; for(int i=0;i<temp.length;i++){ sentence=sentence+temp[i]; } } if(sentence.indexOf("<p>")>-1){ temp=sentence.split("<p>"); sentence=""; for(int i=0;i<temp.length;i++){ sentence=sentence+temp[i]; } } if(sentence.indexOf("<p class=\"\">")>-1){ temp=sentence.split("<p class=\"\">"); sentence=""; for(int i=0;i<temp.length;i++){ sentence=sentence+temp[i]; } } return sentence; }
3e411b2c-609c-4532-85c3-dc7b995b55fd
4
private GraphListener graphListener() { return new GraphListener() { private UmlDiagramListener[] listeners() { return umlDiagramListeners.toArray( new UmlDiagramListener[umlDiagramListeners.size()] ); } @Override public void itemRemoved( Graph source, GraphItem graphItem ) { if( graphItem instanceof Item ) { Item item = (Item) graphItem; for( UmlDiagramListener listener : listeners() ) { listener.itemRemoved( DefaultUmlDiagram.this, item ); } } } @Override public void itemAdded( Graph source, GraphItem graphItem ) { if( graphItem instanceof Item ) { Item item = (Item) graphItem; for( UmlDiagramListener listener : listeners() ) { listener.itemAdded( DefaultUmlDiagram.this, item ); } } } }; }
d2f7266a-5a81-4180-9a26-d1fc93fba469
2
public static ServerSocket ramdomAvailableSocket() { Random ran = new Random(); boolean accept = false; ServerSocket socket = null; while (!accept) { int x = ran.nextInt(9999); try { socket = new ServerSocket(x); accept = true; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); accept = false; } } return socket; }
eb3af69f-432d-4fd0-85d0-d7ff94642e4b
0
public void ResetPlayer() { raceWin = false; crashed = false; //place the car on the canvas x = random.nextInt(Framework.frameWidth - carImgWidth); y = (int) (Framework.frameHeight * 0.70); speedX = 0; speedY = 0; }
11e25b9e-9aa7-404f-91c9-3767bca68bb8
0
public static java.sql.Date utilDateToSqlDate(java.util.Date uneDate) { return (new java.sql.Date(uneDate.getTime())); }
8115c04a-03c5-43d8-a422-f5695b72df0d
8
@Override public void create(Object obj) throws OperacionInvalidaException { if (obj instanceof Vendedor) { Vendedor v = (Vendedor) obj; v.setIdentificacion(vendedores.size() + 1); vendedores.add(v); } else if (obj instanceof Mueble) { Mueble m = (Mueble) obj; m.setReferencia(muebles.size() + 1); muebles.add(m); } else if (obj instanceof Usuario) { Usuario m = (Usuario) obj; for (Usuario us : usuarios) { if (us.getLogin().equals(m.getLogin())) { throw new OperacionInvalidaException("El usuario '" + m.getLogin() + "' ya ha sido registrado en el sistema"); } if (us.getDocumento() == m.getDocumento() && us.getTipoDocumento().equals(m.getTipoDocumento())) { throw new OperacionInvalidaException("El usuario con documento '" + m.getDocumento() + "' ya ha sido registrado en el sistema"); } } usuarios.add(m); } else if (obj instanceof RegistroVenta) { registrosVentas.add((RegistroVenta) obj); } }
ab951264-9618-4350-8b1b-d80509669c88
6
public void init(){ generator = new Random(); playerList = new ArrayList<Entity>(); chargeTime = new double[10]; chargeCanceled = new boolean[10]; pushDelay = new double[10]; /*build trigonometry tables*/ double toRadian = Math.PI/(180*trigScale); //sine sin = new float[(90*trigScale) + 1]; for(int i=0;i<sin.length;i++){ sin[i] = ((float)Math.sin(((double)i) * toRadian)); } //cosine cos = new float[(90*trigScale) + 1]; for(int i=0;i<cos.length;i++){ cos[i] = ((float)Math.cos(((double)i) * toRadian)); } //tangent tan = new float[(90*trigScale) + 1]; for(int i=0;i<tan.length;i++){ tan[i] = sin[i]/cos[i]; } corner = new Polygon[4]; //ordered counter-clockwise, starting from top-right int[][] cornerPointsX = {{7000,7000,6200},{-200,-1000,-1000},{-1000,-1000,-200},{6200,7000,7000}}; int[][] cornerPointsY = {{4920,5720,5720},{5720,5720,4920},{1080,280,280},{280,280,1080}}; for(int i=0;i<4;i++){ corner[i] = new Polygon(); corner[i].npoints = 3; corner[i].xpoints = cornerPointsX[i]; corner[i].ypoints = cornerPointsY[i]; } final int BOUNDARY_SIZE = Entity.PLAYER_SIZE + 50; int pushCosOffset = (int) (BOUNDARY_SIZE*cos[67]); int pushSinOffset = (int) (BOUNDARY_SIZE*sin[67]); int[] pointsX = {cornerPointsX[0][0]-pushSinOffset,cornerPointsX[0][2]-pushCosOffset,cornerPointsX[1][0]+pushCosOffset,cornerPointsX[1][2]+pushSinOffset,cornerPointsX[2][0]+pushSinOffset,cornerPointsX[2][2]+pushCosOffset,cornerPointsX[3][0]-pushCosOffset,cornerPointsX[3][2]-pushSinOffset}; int[] pointsY = {cornerPointsY[0][0]-pushCosOffset,cornerPointsY[0][2]-pushSinOffset,cornerPointsY[1][0]-pushSinOffset,cornerPointsY[1][2]-pushCosOffset,cornerPointsY[2][0]+pushCosOffset,cornerPointsY[2][2]+pushSinOffset,cornerPointsY[3][0]+pushSinOffset,cornerPointsY[3][2]+pushCosOffset}; pushOffBoundary = new Polygon(); pushOffBoundary.npoints=pointsX.length; pushOffBoundary.xpoints=pointsX; pushOffBoundary.ypoints=pointsY; //player init for(int i=0; i<10; i++){ Entity player = new Entity(); //team specific init if(i<5){ player.x = playerStartX[i]; player.y = playerStartY[i]; } else { player.x = 6000 - playerStartX[i - 5]; player.y = playerStartY[i - 5]; } //general init playerList.add(player); player.playerInit(); } //ball init ball = new Entity(); ball.x = 3000; ball.y = 3010; ball.ballInit(); //goalie init blueGoalie = new Goalie(true/*isBlue*/, new Point(-1440, 3010)); redGoalie = new Goalie(false, new Point(7420, 3010)); GameState.state=GameState.GAME_RUN; GameState.period=1; GameState.periodLength=600; GameState.numOfPeriods=3; GameState.randomPlayerPositions = true; GameState.time=GameState.periodLength;//CRITICAL. SETS TIME TO PERIOD LENGTH BEFORE STARTING GAME }//end initialization
c78ab6ce-206c-45ba-a4ea-2598925d828c
9
protected void loadFields(com.sforce.ws.parser.XmlInputStream __in, com.sforce.ws.bind.TypeMapper __typeMapper) throws java.io.IOException, com.sforce.ws.ConnectionException { super.loadFields(__in, __typeMapper); __in.peekTag(); if (__typeMapper.isElement(__in, CreatedBy__typeInfo)) { setCreatedBy((com.sforce.soap.enterprise.sobject.User)__typeMapper.readObject(__in, CreatedBy__typeInfo, com.sforce.soap.enterprise.sobject.User.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, CreatedById__typeInfo)) { setCreatedById(__typeMapper.readString(__in, CreatedById__typeInfo, java.lang.String.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, CreatedDate__typeInfo)) { setCreatedDate((java.util.Calendar)__typeMapper.readObject(__in, CreatedDate__typeInfo, java.util.Calendar.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, DataCategoryGroupName__typeInfo)) { setDataCategoryGroupName(__typeMapper.readString(__in, DataCategoryGroupName__typeInfo, java.lang.String.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, DataCategoryName__typeInfo)) { setDataCategoryName(__typeMapper.readString(__in, DataCategoryName__typeInfo, java.lang.String.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, IsDeleted__typeInfo)) { setIsDeleted((java.lang.Boolean)__typeMapper.readObject(__in, IsDeleted__typeInfo, java.lang.Boolean.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, Parent__typeInfo)) { setParent((com.sforce.soap.enterprise.sobject.FAQ__kav)__typeMapper.readObject(__in, Parent__typeInfo, com.sforce.soap.enterprise.sobject.FAQ__kav.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, ParentId__typeInfo)) { setParentId(__typeMapper.readString(__in, ParentId__typeInfo, java.lang.String.class)); } __in.peekTag(); if (__typeMapper.isElement(__in, SystemModstamp__typeInfo)) { setSystemModstamp((java.util.Calendar)__typeMapper.readObject(__in, SystemModstamp__typeInfo, java.util.Calendar.class)); } }
cc672763-ee02-49c7-82f1-c7945cddafde
1
float[] getBandFactors() { float[] factors = new float[BANDS]; for (int i=0, maxCount=BANDS; i<maxCount; i++) { factors[i] = getBandFactor(settings[i]); } return factors; }
7193b6f1-84c4-42e9-bde1-81ecad5facc7
7
public static void createTaxonomySpanningTree(TaxonomyGraph graph, TaxonomyNode node) { if (node.label != Stella.NULL_INTEGER) { return; } node.label = Stella.MARKER_LABEL; { TaxonomyNode maxparent = null; int maxparentvalue = Stella.NULL_INTEGER; { TaxonomyNode parent = null; Cons iter000 = node.parents; for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) { parent = ((TaxonomyNode)(iter000.value)); if ((maxparentvalue == Stella.NULL_INTEGER) || (parent.totalAncestors > maxparentvalue)) { maxparent = parent; maxparentvalue = parent.totalAncestors; } } } { TaxonomyNode parent = null; Cons iter001 = node.parents; for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) { parent = ((TaxonomyNode)(iter001.value)); if (parent == maxparent) { parent.treeChildren = Cons.cons(node, parent.treeChildren); } else { graph.brokenLinks.push(Cons.cons(parent, Cons.cons(node, Stella.NIL))); } } } { TaxonomyNode child = null; Cons iter002 = node.children; for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) { child = ((TaxonomyNode)(iter002.value)); TaxonomyGraph.createTaxonomySpanningTree(graph, child); } } } }
531d07aa-5760-4bd2-9047-438ecf289041
9
public void paintComponent(Graphics g) { super.paintComponent(g); if (!gameRunning && !deathScreen) { Main.background.paintComponent(g); Main.menu.paintComponent(g); } if (gameRunning && deathScreen) { g.setColor(Color.red); g.setFont(new Font("TimesRoman", Font.PLAIN, 40)); g.drawImage(Main.background.gameOver, Main.mainFrame.getWidth() / 2 - 200, Main.mainFrame.getHeight() / 2 - 200, 400, 400, null); g.drawString("Score: " + String.valueOf(Main.score), Main.mainFrame.getWidth() / 2 - 200, Main.mainFrame.getHeight() / 2 + 250); if (gameOverTimer >= 200) { soundOfDeath.stop(); Main.sound.loop(); Main.score = 0; Main.player.disabled = true; Main.menu.init(Main.mainFrame.getWidth() / 2 - 50, Main.mainFrame.getHeight() / 2, Main.mainFrame.getHeight() / 2 + 60); gameRunning = false; Main.player = new Player(); Main.player.setY(Main.mainFrame.getHeight() / 2); Main.enemies = new ArrayList<Enemy>(); Main.bonuses = new ArrayList<Bonus>(); Main.background.init(Main.mainFrame.getWidth(), Main.mainFrame.getHeight()); Main.background.paintComponent(g); Main.menu.paintComponent(g); deathScreen = false; gameOverTimer = 0; } } if (gameRunning && !deathScreen) { Main.background.paintComponent(g); Main.player.paintComponent(g); g.setColor(Color.red); g.setFont(new Font("TimesRoman", Font.PLAIN, 40)); for (int i = 0; i < Main.enemies.size(); i++) { Main.enemies.get(i).paintComponent(g); } for (int i = 0; i < Main.bonuses.size(); i++) { Main.bonuses.get(i).paintComponent(g); } g.drawString("Score: " + String.valueOf(Main.score), 10, 50); } }
2b43ee7b-4021-4231-965e-6a314c99f80d
8
final public void nestedSentence() throws ParseException { /*@bgen(jjtree) nestedSentence */ SimpleNode jjtn000 = new SimpleNode(JJTNESTEDSENTENCE); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { jj_consume_token(LPAREN); booleanSentence(); jj_consume_token(RPAREN); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0)); } } }
e7af9f7b-5da2-42f5-b3b1-0765f1758d58
0
public MeasureKitString(DataStructures inData) { this.inData = inData; outData = new DataArrays<Integer[]>(); }
4e2ae122-1728-4565-bb84-888e5996dd04
9
@Override public void handleInput() { if(Keys.isDown(Keys.W)) rect.getPosition().thisAdd(0,-1); if(Keys.isDown(Keys.S)) rect.getPosition().thisAdd(0,1); if(Keys.isDown(Keys.A)) rect.getPosition().thisAdd(-1,0); if(Keys.isDown(Keys.D)) rect.getPosition().thisAdd(1,0); if(Keys.isDown(Keys.UP)) rect.setRotation(rect.getRotation()+(float)Math.toRadians(1)); if(Keys.isDown(Keys.DOWN)) rect.setRotation(rect.getRotation()-(float)Math.toRadians(1)); if(Keys.isDown(Keys.R)) rect.setPosition(new Vector2D(0,0)); if(Keys.isDown(Keys.F)) {cam.zoomInc(0.1f);} if(Keys.isDown(Keys.G)) {cam.zoomInc(-0.1f);} }
bcb5ab58-e0a3-48bb-8735-a252979ce2f4
0
@Override public boolean equals(Object obj){ return this.toString().equals(((Fraction)obj).toString()); }
6154d9cb-cb5a-454e-9adf-65aa534c2028
5
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String args[]) { if (args.length == 0) args = new String[]{"help"}; outer: for (BaseCommand command : plugin.commands.toArray(new BaseCommand[0])) { String[] cmds = command.name.split(" "); for (int i = 0; i < cmds.length; i++) if (i >= args.length || !cmds[i].equalsIgnoreCase(args[i])) continue outer; return command.run(plugin, sender, commandLabel, args); } return true; }
72faab41-9654-4980-a30f-694f7df9861d
6
public void playGame() throws Exception { Position updatedCell; while (!boardState.isGameOver()) { if (boardState.getTurn() == TicTacToeBoard.PLAYER_X) { updatedCell = playerX.getNextMove(boardState); if (isLegalPosition(updatedCell)) { boardState.setState(updatedCell.row, updatedCell.col, TicTacToeBoard.X); cellGrid[updatedCell.row*TicTacToeBoard.SIZE+updatedCell.col].setChosen(true); } else { throw new Exception("Illegal board position returned"); } boardState.setTurn(TicTacToeBoard.PLAYER_O); } else { updatedCell = playerO.getNextMove(boardState); if (isLegalPosition(updatedCell)) { boardState.setState(updatedCell.row, updatedCell.col, TicTacToeBoard.O); cellGrid[updatedCell.row*TicTacToeBoard.SIZE+updatedCell.col].setChosen(true); } else { throw new Exception("Illegal board position returned"); } boardState.setTurn(TicTacToeBoard.PLAYER_X); } displayBoard(boardState); turnLabel.setText(turnString[boardState.getTurn()]); } if (boardState.isWin(TicTacToeBoard.PLAYER_X)) { turnLabel.setText("Player X won"); } else if (boardState.isWin(TicTacToeBoard.PLAYER_O)) { turnLabel.setText("Player O won"); } else { // Draw turnLabel.setText("Draw"); } }
19f2bb2e-e684-4668-ae41-5fe60d2589f3
0
public int getPort() { return _port; }
5849922a-8f61-4b20-804c-bc451f9ddcf2
4
public static Direction getDirectionByLeeter(final char letter) throws NotValidDirectionException{ switch(letter){ case 'N' : return NORTH ; case 'E' : return EAST ; case 'W' : return WEST ; case 'S' : return SOUTH ; default : throw new NotValidDirectionException();//no valid direction } }
7795fd07-7d1f-45e8-878b-d23e1898f083
2
public void addParticleSprite(String spriteName, BufferedImage spriteImage) { if (spriteName == null || spriteImage == null) { throw new IllegalArgumentException("Cannot add a null sprite!"); } particleSprites.put(spriteName, spriteImage); }
83958867-b9f0-4722-a7a9-d7e7f9d48640
5
public int compareTo(Gleitpunktzahl r) { if (this.vorzeichen == false && r.vorzeichen == true) return 1; if (this.vorzeichen == true && r.vorzeichen == false) return -1; int compabs = compareAbsTo(r); if (!this.vorzeichen) return compabs; else return -compabs; }
0cbce617-576e-4897-8c56-45efcfa8997b
5
private void insertion(String value, String[] oldNode, Node root){ if(oldNode.length > 2){ if(oldNode[2].equals(root.getValue())){ List<Node> children = root.getChildren(); if(oldNode[0].equals(children.get(1).getValue()) && oldNode[1].equals(children.get(0).getValue()) ){ root.setValue(value); root.setChildren(new ArrayList<Node>()); } } } for(Node n : root.getChildren()){ insertion(value, oldNode, n); } }
a6aac3aa-13aa-4bae-b5f0-edfcb3d3d916
8
public void rotate(RotationState state) { if (state != RotationState.TurningLeftDrifting && state != RotationState.TurningRightDrifting) { angularVelocity += angleIcrement * .1; if (angularVelocity > maxAngularVel) { angularVelocity = maxAngularVel; } else if (angularVelocity < -maxAngularVel) { angularVelocity = -maxAngularVel; } if ((angularVelocity < .01 && angularVelocity > 0) || (angularVelocity > -.01 && angularVelocity < 0)) { angularVelocity = 0; rotationState = RotationState.Idle; } } else { angularVelocity *= .90; // causes acceleration } updateAngle(state); }
f3402c14-657a-4a6e-931e-d357f227a40f
7
float clutching(SensorModel sensors, float clutch) { float maxClutch = clutchMax; // Check if the current situation is the race start if (sensors.getCurrentLapTime()<clutchDeltaTime && getStage()==Stage.RACE && sensors.getDistanceRaced()<clutchDeltaRaced) clutch = maxClutch; // Adjust the current value of the clutch if(clutch > 0) { double delta = clutchDelta; if (sensors.getGear() < 2) { // Apply a stronger clutch output when the gear is one and the race is just started delta /= 2; maxClutch *= clutchMaxModifier; if (sensors.getCurrentLapTime() < clutchMaxTime) clutch = maxClutch; } // check clutch is not bigger than maximum values clutch = Math.min(maxClutch,clutch); // if clutch is not at max value decrease it quite quickly if (clutch!=maxClutch) { clutch -= delta; clutch = Math.max((float) 0.0,clutch); } // if clutch is at max value decrease it very slowly else clutch -= clutchDec; } return clutch; }
6dfe29ff-79ea-4828-bbfb-65c228651c86
1
static Map<String, Object> convert(Map<String, Object> m) { LinkedHashMap<String, Object> hm = new LinkedHashMap<String, Object>(); Set<Entry<String, Object>> entrySet = m.entrySet(); for (Entry<String, Object> entry : entrySet) { String key = entry.getKey(); key = key.replace('.', '_'); Object value = entry.getValue(); hm.put(key, value); } return hm; }
6833971b-2f1f-41f6-a227-7694fbcb31f4
0
public int getClaveles() { return claveles; }
a565e332-8c9d-442d-bc10-9889d724fed8
9
private static boolean createImageFile(BufferedImage image) { String name = JOptionPane.showInputDialog("please enter file name."); File f = new File(filesys.getHomeDirectory() + "/Desktop/" + name); if (name == null) return false; if (!f.exists() && name != null) try { ImageIO.write(image, "jpg", f); return true; } catch (IOException e1) { e1.printStackTrace(); } else { while (f.exists() && name != null) { name = JOptionPane .showInputDialog("file of the same name exists in the same directory.\nplease enter file name."); f = new File(filesys.getHomeDirectory() + "/Desktop/" + name); } if (!f.exists() && name != null) try { ImageIO.write(image, "jpg", f); return true; } catch (IOException e) { e.printStackTrace(); } } return false; }
9fb2fbbb-b889-4594-8a51-7fb2a3968cef
6
public void step() { boolean[][] newGrid = new boolean[height][width]; // Iterate through all cells for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // Implement rules boolean cell = grid[y][x]; int aliveNeighbours = getAliveNeighbours(x, y); if (cell) { if (aliveNeighbours < 2 || aliveNeighbours > 3) newGrid[y][x] = DEAD; else newGrid[y][x] = ALIVE; } else if (aliveNeighbours == 3) newGrid[y][x] = ALIVE; } } grid = newGrid; }
c3b16cc2-5961-4d5f-91f3-578f619ab043
8
private void getTextFromFields(){ for(int j = 0;j < repository.size();j++){ redQueryList.get(j).clear(); greenQueryList.get(j).clear(); blueQueryList.get(j).clear(); redQueryStrings.get(j).clear(); greenQueryStrings.get(j).clear(); blueQueryStrings.get(j).clear(); } for(int i = 0;i < repository.size();i++){ String redQuery = redSearchQuery.getText(); String greenQuery = greenSearchQuery.getText(); String blueQuery = blueSearchQuery.getText(); StringTokenizer redQuerySplit = new StringTokenizer(redQuery, ","); StringTokenizer greenQuerySplit = new StringTokenizer(greenQuery, ","); StringTokenizer blueQuerySplit = new StringTokenizer(blueQuery, ","); Term redTerms; Term greenTerms; Term blueTerms; while(redQuerySplit.hasMoreTokens()){ redQuery = redQuerySplit.nextToken(); redQuery = redQuery.trim(); redQueryStrings.get(i).add(redQuery); redTerms = repository.get(i).queryForTerm(redQuery); if(redTerms == null){ System.out.println(redQuery+" not found."); } else { redQueryList.get(i).add(redTerms); } } while(greenQuerySplit.hasMoreTokens()){ greenQuery = greenQuerySplit.nextToken(); greenQuery = greenQuery.trim(); greenQueryStrings.get(i).add(greenQuery); greenTerms = repository.get(i).queryForTerm(greenQuery); if(greenTerms == null){ System.out.println(greenQuery+" not found."); } else { greenQueryList.get(i).add(greenTerms); } } while(blueQuerySplit.hasMoreTokens()){ blueQuery = blueQuerySplit.nextToken(); blueQuery = blueQuery.trim(); blueQueryStrings.get(i).add(blueQuery); blueTerms = repository.get(i).queryForTerm(blueQuery); if(blueTerms == null){ System.out.println(blueQuery+" not found."); } else { blueQueryList.get(i).add(blueTerms); } } } }
d2c28ef8-75c8-4a48-9a69-12c6da0b5df1
4
public static void main(String[] args) throws Exception { String inputPath = "./data/training.txt"; if(args.length > 0){ inputPath = args[0]; } List<String> lines = FileUtils.readLines(new File(inputPath)); long start = System.currentTimeMillis(); for (int i = 0; i+3 < lines.size(); i+=4) { Query view = new Query(lines.get(i+1).getBytes()); Query query = new Query(lines.get(i+2).getBytes()); ContainmentProblem problem = new ContainmentProblem(query, view, lines.get(i+3)); if(problem.shouldMatch != -1){ boolean expectedResult = problem.shouldMatch == 0; System.out.println(lines.get(i)); boolean result = problem.containsNaive(); if(result != expectedResult ){ System.out.println(String.format("view %s\nquery %s\nexpected %s got %s",view, query,expectedResult, result)); } } else { // System.out.println(lines.get(i)); System.out.println(problem.containsNaive()); } } System.out.println((System.currentTimeMillis()-start)+" ms"); }
a5de8191-f133-400c-ac42-d6144037e7cd
6
public static void main(String[] args) { System.out.print("Enter the number of lines: "); Scanner scan = new Scanner(System.in); int num = scan.nextInt(); int noOfGap = num - 1; int index = 1; for (int hrLine = 1; hrLine <= num - 1; hrLine++) { for (int gap = 0; gap < noOfGap; gap++) { System.out.print(" "); } noOfGap--; for (int vrLine = 0; vrLine < index; vrLine++) { if (vrLine == 0 || vrLine == index - 1) { System.out.print(num); } else { System.out.print(0); } } index = index + 2; System.out.println(); } for (int lastRow = 0; lastRow < index; lastRow++) { System.out.print(num); } }
699c9248-af40-476c-bda9-37ca4b484fdc
9
public static String drawRequirementElement(RequirementElement target, RequirementElement reference, String direction) throws ScriptException { // customized parameters String layer = target.getLayer(); double x = 0, y = 0; String position = ""; if (direction.equals("up")) { x = reference.origin_x; y = reference.origin_y - 200; } else if (direction.equals("down")) { x = reference.origin_x; y = reference.origin_y + 200; } else if (direction.equals("left")) { x = reference.origin_x - 200; y = reference.origin_y; } else if (direction.equals("right")) { x = reference.origin_x + 200; y = reference.origin_y; } else { } position = "{"+ x +","+ y +"}"; // assign the position information to the target element target.origin_x=x; target.origin_y=y; String shape = InfoEnum.reverse_req_elem_type_map.get(target.getType()); String corner_radius = "0"; String name = target.getName(); if (target.getType().equals(InfoEnum.RequirementElementType.DOMAIN_ASSUMPTION.name())) { corner_radius = "5"; } else if (target.getType().equals(InfoEnum.RequirementElementType.SECURITY_GOAL.name())) { name = "(S)\n" + name; } else if (target.getType().equals(InfoEnum.RequirementElementType.SECURITY_MECHANISM.name())) { name = "(S)\n" + name; } int size_type = 0; if(target.getType().equals(InfoEnum.RequirementElementType.ACTOR.name())){ size_type = InfoEnum.ACTOR_SIZE; } else if (target.getType().equals(InfoEnum.RequirementElementType.MIDDLE_POINT.name())){ size_type = InfoEnum.POINT_SIZE; } // return drawReferredRequirementElement(reference_id, InfoEnum.REQ_TARGET_CANVAS, layer, offset, shape, size, corner_radius, name); return drawArbitraryRequirementElement(InfoEnum.REQ_TARGET_CANVAS, layer, shape, size_type, position, corner_radius, name); }
50e7a40a-04c2-457f-bca9-b82e7106db77
8
public int func_27371_a(StatCrafting par1StatCrafting, StatCrafting par2StatCrafting) { int var3 = par1StatCrafting.getItemID(); int var4 = par2StatCrafting.getItemID(); StatBase var5 = null; StatBase var6 = null; if (this.slotStatsItemGUI.field_27271_e == 0) { var5 = StatList.objectBreakStats[var3]; var6 = StatList.objectBreakStats[var4]; } else if (this.slotStatsItemGUI.field_27271_e == 1) { var5 = StatList.objectCraftStats[var3]; var6 = StatList.objectCraftStats[var4]; } else if (this.slotStatsItemGUI.field_27271_e == 2) { var5 = StatList.objectUseStats[var3]; var6 = StatList.objectUseStats[var4]; } if (var5 != null || var6 != null) { if (var5 == null) { return 1; } if (var6 == null) { return -1; } int var7 = GuiStats.getStatsFileWriter(this.slotStatsItemGUI.field_27275_a).writeStat(var5); int var8 = GuiStats.getStatsFileWriter(this.slotStatsItemGUI.field_27275_a).writeStat(var6); if (var7 != var8) { return (var7 - var8) * this.slotStatsItemGUI.field_27270_f; } } return var3 - var4; }
32fe860f-8f28-4566-8f82-67d8a67ef310
7
private static void findC(int[][] points, int start, int end) { int firstQ = 0, secondQ = 0, thirdQ = 0, fourthQ = 0; for (int i = start; i <= end; i++) { boolean posX, posY; posX = numChangesX[i]; posY = numChangesY[i]; if (posX && posY) firstQ++; else if (!posX && posY) secondQ++; else if (!posX && !posY) thirdQ++; else fourthQ++; } System.out.println(String.format("%d %d %d %d", firstQ, secondQ, thirdQ, fourthQ)); }
e7cbabc6-20fc-4bf6-a3ec-42dfaa50ed69
0
public SaveGraphPNGAction(Environment environment, JMenu menu) { super("Save Graph as PNG", null); this.environment = environment; this.myMenu = menu; }
d81f861c-7a5e-4376-b8b6-794da48dae12
6
public void actualizarListaProd() { abrirBase(); tablaProd.setRowCount(0); prodlista = Articulo.where("codigo like ? or descripcion like ?", "%" + textCodProd.getText() + "%", "%" + textCodProd.getText() + "%"); Iterator<Articulo> it = prodlista.iterator(); while (it.hasNext()) { Articulo a = it.next(); String rowArray[] = new String[4]; rowArray[0] = a.getId().toString(); rowArray[1] = a.getString("codigo"); rowArray[2] = a.getString("marca"); rowArray[3] = a.getString("descripcion"); tablaProd.addRow(rowArray); } Articulo a = Articulo.findFirst("codigo = ?", textCodProd.getText()); if (a != null) { String fram = a.getString("equivalencia_fram"); if (!(fram.equals(""))) { prodlista = busqueda.filtroProducto2(fram); it = prodlista.iterator(); while (it.hasNext()) { Articulo b = it.next(); if (!(b.getInteger("id").equals(a.getInteger("id")))) { String rowArray[] = new String[4]; rowArray[0] = b.getId().toString(); rowArray[1] = b.getString("codigo"); rowArray[2] = b.getString("marca"); rowArray[3] = b.getString("descripcion"); tablaProd.addRow(rowArray); { } } } } } if (Base.hasConnection()) { Base.close(); } }
3aee2381-b840-484a-8e85-8da1b0341c8b
4
List<List<Integer>> traverse(Graph g) { int startVertex = 0; List<List<Integer>> connectedComponents = new ArrayList<List<Integer>>(); while(startVertex != ALL_VISITED) { PriorityQueue<Integer> queue = new PriorityQueue<Integer>(g.vcount()); queue.add(startVertex); List<Integer> connectedGraph = new ArrayList<Integer>(); connectedGraph.add(startVertex); g.setMark(startVertex, VISITED_VERTEX); while(queue.size() > 0) { int vertex = queue.poll(); for(int neighbor = g.first(vertex); neighbor < g.vcount(); neighbor = g.next(vertex, neighbor)) { if(g.getMark(neighbor) == UNVISITED_VERTEX) { g.setMark(neighbor, VISITED_VERTEX); queue.add(neighbor); connectedGraph.add(neighbor); } } } connectedComponents.add(connectedGraph); startVertex = findUnvisitedVertex(g); } return connectedComponents; }
db634377-cb38-4319-bf8b-8cf9583c0997
5
public void process(ShipGame game) { Ship enemy = new Ship(); enemy.name = "Enemy"; while(enemy.hp > 0 && ship.hp > 0){ int enemyAtt = game.random.nextInt(35); int playerAtt = game.random.nextInt(30); int enemyDef = game.random.nextInt(10); int playerDef = game.random.nextInt(15); int enemyDamage = enemyAtt - playerDef; int playerDamage = playerAtt - enemyDef; if (playerDamage > 0){ enemy.hp = enemy.hp - playerDamage; System.out.println("Ship " + enemy.name + " takes " + playerDamage + " Damage!"); } if (enemyDamage > 0){ ship.hp = ship.hp - enemyDamage; System.out.println("Ship " + ship.name + " takes " + enemyDamage + " Damage!"); } } if (ship.hp > 0){ int booty = game.random.nextInt(enemy.value); int profit = game.random.nextInt(ship.value + booty); ship.value += profit / 5; game.money += profit; System.out.println("Ship " + ship.name + " has returned with " + ship.hp + " health!"); System.out.println("Profit: " + profit); game.dock.add(ship); } else{game.queue.add(new DestroyedEvent(ship, 3));} }
c1007212-4483-4a9d-b6f1-9cbb2296c889
8
public void turn() { if(x > goalX && dir != Direction.WEST) { this.setDirection(Direction.WEST); }else if(x < goalX && dir != Direction.EAST) { this.setDirection(Direction.EAST); }else if(y > goalY && dir != Direction.NORTH) { this.setDirection(Direction.NORTH); }else if(y < goalY && dir != Direction.SOUTH) { this.setDirection(Direction.SOUTH); } }
e47e8229-d340-4517-994b-b56016c0268f
1
public void colorChanged(WorldMapObject o, Color c) { core.Point pos = p2o.get(o); System.out.println("color changed: "+o+", "+c.name+", "+pos); //if (ready) { try { mapWidget.objectAt(pos.y, pos.x).setLayer(0, new gui.WidgetImage(c.mfFile)); } catch (java.lang.NullPointerException e) {} //} }
f5f3554a-bfc3-4f11-b72e-bee069a64ea4
0
public void setjSeparator1(JSeparator jSeparator1) { this.jSeparator1 = jSeparator1; }
5eb7e97d-fe9e-44a7-b460-7b080b6fd42f
2
public void randomCoords(){ Random rnd = new Random(); // Find a random starting y coordinate int x = rnd.nextInt(660); x += 20; this.yCoord = x; // Find a random speed x = rnd.nextInt(5); x += 1; this.speed = x; // randomize which image to use x = rnd.nextInt(2); if(x == 1){ setImageIcon(image); } else if(x == 0){ setImageIcon(smallCloud); } }
3bd829b5-7774-4477-a430-fd54e469ac8f
0
private VariablePrecisionTime getVorbisReleaseDate() { return vorbisDate(false); }
b7cdf388-072f-4798-b703-02e584c64de4
7
private static boolean matchesAttribute( final boolean html, final SelectorElementBuffer elementBuffer, final String attrName, final MarkupSelectorItem.AttributeCondition.Operator attrOperator, final String attrValue) { boolean found = false; for (int i = 0; i < elementBuffer.attributeCount; i++) { if (!TextUtil.equals( !html, attrName, 0, attrName.length(), elementBuffer.attributeBuffers[i], 0, elementBuffer.attributeNameLens[i])) { continue; } // Even if both HTML and XML forbid duplicated attributes, we are going to anyway going to allow // them and not consider an attribute "not-matched" just because it doesn't match in one of its // instances. found = true; if (html && "class".equals(attrName)) { // The attribute we are comparing is actually the "class" attribute, which requires an special treatment // if we are in HTML mode. if (matchesClassAttributeValue( attrOperator, attrValue, elementBuffer.attributeBuffers[i], elementBuffer.attributeValueContentOffsets[i], elementBuffer.attributeValueContentLens[i])) { return true; } } else { if (matchesAttributeValue( attrOperator, attrValue, elementBuffer.attributeBuffers[i], elementBuffer.attributeValueContentOffsets[i], elementBuffer.attributeValueContentLens[i])) { return true; } } } if (found) { // The attribute existed, but it didn't match - we just checked until the end in case there were duplicates return false; } // Attribute was not found in element, so we will consider it a match if the operator is NOT_EXISTS return MarkupSelectorItem.AttributeCondition.Operator.NOT_EXISTS.equals(attrOperator); }
eabf5d33-e199-4b22-bd3a-772421394f10
0
public void setDocument(IDocument document) { fDocument = document; }
a209ccfc-995e-4c29-a4ea-1265fba5b853
1
public void testToStandardDays_overflow() { Duration test = new Duration((((long) Integer.MAX_VALUE) + 1) * 24L * 60L * 60000L); try { test.toStandardDays(); fail(); } catch (ArithmeticException ex) { // expected } }
3f94281f-80cc-47a7-a31a-b248d544ad03
0
public void setTemp(long t) { sa.temps[sa.stable][indexI][indexJ] = t; sa.temps[sa.updating][indexI][indexJ] = t; }
6b01f6e7-5400-4f17-80d1-4f55c430f923
0
public static void main(String[] args) { new Menu(); }
1c5baff8-8017-4e34-a9a8-129dae7e472d
3
public void updateSeekMax(Track t) { String lengthString = (String) t.get("length"); if(lengthString != null && lengthString instanceof String) { try { double length = Double.parseDouble(lengthString); seek_slider.setMax(length); seek_slider.setDisable(false); } catch (NumberFormatException e) { seek_slider.setDisable(true); } } }
d96d8953-01ef-4481-bb71-f30f61e56f3e
7
public static String getTableNameBySql(Cg cg){ String tableName = null; String tableSql = formartSql(cg.getTableSql()); if(tableSql!=null && tableSql.trim().length()>0){ try{ // tableSql=tableSql.replaceAll("--.*\r\n","\r\n"); String[] strs = tableSql.split("\r\n"); if(strs!=null && strs.length>0){ for(int i=0;i<strs.length;i++){ if(strs[i].trim().toLowerCase().startsWith("create table")){ Pattern p = Pattern.compile("create table\\s+`([^`]*)`.*"); Matcher m = p.matcher(strs[i].trim().toLowerCase()); m.matches(); tableName=m.group(1); break; } } } }catch(Exception e){ System.out.println("匹配表名出错,请检查sql是否按标准格式提交..."); e.printStackTrace(); } } return tableName; }
c6cea5a0-ff13-492d-8521-844789a93ded
5
private void recursiveScanDir(String relativePath, File dirOrFile, List<LessFileStatus> lstAddedLfs) { if (dirOrFile.isDirectory()) { File[] subf = dirOrFile.listFiles(); if (subf != null) { for (File current : subf) { String subRelPath = relativePath.isEmpty() ? current.getName() : relativePath + '/' + current.getName(); recursiveScanDir(subRelPath, current, lstAddedLfs); } } } else if (dirOrFile.isFile()) scanFile(relativePath, dirOrFile, lstAddedLfs); }
69e9b562-a679-4d96-9b4f-56cd1a1f3da9
0
@Override public void annulerTransaction() throws SQLException { getConnexion().rollback(); // getConnexion().setAutoCommit(true); }
87137b15-10ff-4b46-acdc-8bf80c46d599
6
static public BigDecimal calculateMultiItemPrice(Class<? extends Item> genericItem) { BigDecimal price = BigDecimal.ZERO; Item item = getItem(genericItem); if (item.isMultiItem()) { Map<Class<? extends Item>, BigDecimal> prices = new HashMap<Class<? extends Item>, BigDecimal>(); for (Class<? extends Item> genericResource : item.getActualItems()) { prices.put(genericResource, calculateItemPrice(genericResource)); } price = price.add(prices.get(getCheapest(prices))); } return price; }
15493540-ab1f-4582-ab13-af04e6b7b7f8
5
public void endMove(int column, int row) { if (checkWin(playingField, column, row)) { VierGewinntAi.mainGUI.showWinMessage(); gameEnd = true; return; } if (checkFull()) { VierGewinntAi.mainGUI.showFullMessage(); gameEnd = true; return; } if(gameEnd){ return; } if (playerTurn == 1) { playerTurn = 2; } else { playerTurn = 1; } VierGewinntAi.mainGUI.showPlayerTurnMessage(); if (!playerHuman[playerTurn - 1]) { startAi(); } else { lock = false; } }
7e6c24d6-bb41-4692-b9e6-bb6e1f5fc612
5
@Override public boolean equals(Object object) { if (!(object instanceof DescricaoPreco)) { return false; } DescricaoPreco other = (DescricaoPreco) object; if ((this.getCodigo() == null && other.getCodigo() != null) || (this.getCodigo() != null && !this.getCodigo().equals(other.getCodigo()))) { return false; } return true; }
d303a68b-19ab-47a0-9732-b5600db52c31
8
public void SendFileCommand() { if(running==false || paused==true || fileOpened==false || isConfirmed==false || linesProcessed>=linesTotal) return; String line; do { // are there any more commands? line=gcode.get((int)linesProcessed++).trim(); //previewPane.setLinesProcessed(linesProcessed); //statusBar.SetProgress(linesProcessed, linesTotal); // loop until we find a line that gets sent to the robot, at which point we'll // pause for the robot to respond. Also stop at end of file. } while(!SendLineToRobot(line) && linesProcessed<linesTotal); if(linesProcessed==linesTotal) { // end of file Halt(); } }
5cfdf882-32f1-4fc4-9fa3-5aca11cdd7c7
2
public String toString() { if (this.title != null && this.year != null) { return String.format("%s (%s)", this.title, this.year); } else { return ""; } }
d450e637-4d9e-44ee-a6bb-cff233dab92b
8
public String getSql() { StringBuffer sbSql = new StringBuffer(); if (tableName != null && tableName.length() > 0) { sbSql.append(" " + tableName); if (tableNode != null) { switch (joinOperate) { case LeftJoin: sbSql.append(" left join "); break; case RightJoin: sbSql.append(" right join "); break; case CrossJoin: sbSql.append(" cross join "); break; case InnerJoin: sbSql.append(" inner join "); break; } sbSql.append(tableNode.getSql()); if (onConditions != null) { sbSql.append(" on " + onConditions.getSql()); } } } return sbSql.toString(); }
e894babd-b2f8-4b3d-8ff5-ca318dd95c8f
0
public void setDollar(Dollar dollar) { this.dollar = dollar; }
00b3bbad-6472-41d0-ae59-7cbabfd345ef
6
protected void splitNextLargeSublist() { if (smallSublistCount < sublists.size()) { if (sublists.isFull()) { sublists = copyTo(sublists, new FixedListInternal<CircularListInternal<T>>( sublists.capacity() << 1)); } int firstLargeSublistIndex = smallSublistCount; boolean isHeadList = firstLargeSublistIndex <= headSublistIndex; boolean isTailList = firstLargeSublistIndex >= tailSublistIndex; CircularListInternal<T> large = sublists.get(firstLargeSublistIndex); assert large.capacity() == (1 << largeSublistSizeExp); CircularListInternal<T> small1 = new CircularListInternal<T>( large.capacity() >>> 1); CircularListInternal<T> small2 = new CircularListInternal<T>( large.capacity() >>> 1); split(large, small1, small2, isHeadList); if (isHeadList) { sublists.set(firstLargeSublistIndex, small2); sublists.add(firstLargeSublistIndex, small1); smallSublistCount += 2; if (small1.isEmpty()) { headSublistIndex += 1; } tailSublistIndex += 1; } else if (isTailList) { sublists.set(firstLargeSublistIndex, small1); sublists.add(firstLargeSublistIndex + 1, small2); smallSublistCount += 2; if (!small2.isEmpty()) { tailSublistIndex += 1; } } else { sublists.set(firstLargeSublistIndex, small2); sublists.add(firstLargeSublistIndex, small1); smallSublistCount += 2; tailSublistIndex += 1; } } }
a8b428f8-7482-4777-87ac-b4d6ba2bfb11
3
void setCellFont () { if (!instance.startup) { textNode1.setFont (1, cellFont); imageNode1.setFont (1, cellFont); } /* Set the font item's image to match the font of the item. */ Font ft = cellFont; if (ft == null) ft = textNode1.getFont (1); TableItem item = colorAndFontTable.getItem(CELL_FONT); Image oldImage = item.getImage(); if (oldImage != null) oldImage.dispose(); item.setImage (fontImage(ft)); item.setFont(ft); colorAndFontTable.layout (); }
5af9650f-662c-48db-bea1-23a1fa7ddb5b
4
private void close(Connection conn, Statement stmt, ResultSet rs) { try { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { System.out.println("Erro ao fechar conexao."); e.printStackTrace(); } }
2f3cbcc2-ca9a-4755-9043-58bc11fae9a4
7
public static void main(String[] args) { //Define spaceing int space = 21; int leftSpace = 0; //define starting numbers int left = 1; int right = 1; //first loop for top of the x while (space >= 0) { //Printing out the correct amount of leftspace for (int i = 1; i <= leftSpace; i++) { System.out.print(" "); } //outputting the number for the line on the left System.out.print(format.format(left)); //incrementing the left number for the next line left++; //printing out the correct amount of space inbetween numbers for (int i = 1; i <= space; i++) { System.out.print(" "); } //output the nuber for the line on the right System.out.println(format.format(right)); //incrementing the right number for the next line right++; //changing spacing for next line space -= 2; leftSpace++; } //loop for spacing for center number for (int i = 1; i <= leftSpace; i++) { System.out.print(" "); } //output center number System.out.println(format.format(left)); left++; right++; //redefine spacing leftSpace = 10; space = 1; //loop for bottom while (leftSpace >= 0) { //loop for left space for (int i = 1; i <= leftSpace; i++) { System.out.print(" "); } //number output System.out.print(format.format(right)); //incrementing right++; //outputting space for (int i = 1; i <= space; i++) { System.out.print(" "); } //outputting line number System.out.println(format.format(left)); //incrementing left++; space += 2; leftSpace--; } BlockLetters.TONY_PAPPAS.outputBlockName(); }
dac65d04-978d-43e1-8672-8b0d3faf2f51
0
public SetupApplication(String androidJar, String apkFileLocation) { this.androidJar = androidJar; this.apkFileLocation = apkFileLocation; }
f4c3b429-5518-491e-95de-b0021f0b3916
7
public String salvarTicket() { Ticket ticket = new Ticket(); ticket.setIdTicket(idTicket); ticket.setTitulo(titulo); ticket.setSistema(sistema); ticket.setComponente(componente); ticket.setDescricao(descricao); ticket.setOperador(operador); ticket.setStatus(Ticket.Status.ABERTO); request.put("ticket", ticket); Componente componenteSelecionado = FabricaDAO.getComponenteDAO().getComponente(componente); if(titulo.length() == 0) { addFieldError("titulo", getText("erro.titulo.obrigatorio")); } if(sistema <= 0) { addFieldError("sistema", getText("erro.sistema.obrigatorio")); } if(componente <= 0) { addFieldError("componente", getText("erro.componente.obrigatorio")); } else if(componenteSelecionado.getSistema() != sistema) { addFieldError("componente", getText("erro.componente.sistemaIncorreto")); } if(operador.equals("-1")) { addFieldError("operador", getText("erro.operador.obrigatorio")); } if(hasErrors()) { return INPUT; } if(ticket.getIdTicket() <= 0) { FabricaDAO.getTicketDAO().insere(ticket); } else { FabricaDAO.getTicketDAO().atualiza(ticket); } return SUCCESS; }
2b909c90-cb08-46c1-a389-d080d0946e0c
9
public long getRandom() { final Random r=new Random(); final int roomCount=size(); if(roomCount<=0) return -1; final int which=r.nextInt(roomCount); long count=0; for(int i=0;i<intArray.length;i++) { if((intArray[i]&NEXT_FLAG)>0) count=count+1+(intArray[i+1]-(intArray[i]&INT_BITS)); else count++; if(which<count) { if((intArray[i]&NEXT_FLAG)>0) return (intArray[i+1]-(count-which))+1; return intArray[i]&INT_BITS; } } for(int i=0;i<longArray.length;i++) { if((longArray[i]&NEXT_FLAGL)>0) count=count+1+(int)(longArray[i+1]-(longArray[i]&LONG_BITS)); else count++; if(which<count) { if((longArray[i]&NEXT_FLAGL)>0) return (longArray[i+1]-(count-which))+1; return longArray[i]&LONG_BITS; } } return -1; }
5ffaf5e6-47c7-4aa6-8bca-e5163e38c3e9
5
List<Score> matchCoupleChainFind(Map<Person, List<Score>> table, Person start, int limit){ if (!table.containsKey(start)) { return Collections.EMPTY_LIST; } List<Score> path = new LinkedList<>(); HashSet<Person> set = new HashSet<>(); Person next = start; while (next != null && set.add(next)) { List<Score> ls = table.get(next); if (ls.size() < 0) break; Score s = ls.get(0); path.add(s); next = s.target; } //path.size + 1 >= limit if (path.size() + 1 < limit) { return Collections.EMPTY_LIST; } return path; }
e454267f-0d3d-4ee8-8976-d07f0b7213b3
1
private static synchronized DateFormat getDf() { if (df == null) { df = new SimpleDateFormat("HH:mm:ss.SSS"); } return df; }
71da5dd9-0f42-43bc-bae2-363eb5f55745
2
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/alumno/list.jsp"); try { AlumnoDao oAlumnoDao = new AlumnoDao(oContexto.getEnumTipoConexion()); Integer intPages = oAlumnoDao.getPages(oContexto.getNrpp(), oContexto.getAlFilter(), oContexto.getHmOrder()); Integer intRegisters = oAlumnoDao.getCount(oContexto.getAlFilter()); if (oContexto.getPage() >= intPages) { oContexto.setPage(intPages); } ArrayList<AlumnoBean> listado = (ArrayList<AlumnoBean>) oAlumnoDao.getPage(oContexto.getNrpp(), oContexto.getPage(), oContexto.getAlFilter(), oContexto.getHmOrder()); String strUrl = "<a href=\"Controller?" + oContexto.getSerializedParamsExceptPage() + "&page="; ArrayList<String> botonera = Pagination.getButtonPad(strUrl, oContexto.getPage(), intPages, 2); ArrayList<Object> a = new ArrayList<>(); a.add(listado); a.add(botonera); a.add(intRegisters); return a; } catch (Exception e) { throw new ServletException("AlumnoList1: View Error: " + e.getMessage()); } }
d6b9addf-64db-4510-a79f-b3cbdfcb4b0c
5
public static void main(String[] args) { String t = ""; int ejercicio = 0; BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); while (true) { try { System.out.println("Introduce el numero de ejercicio que quieras comprobar. [1 - 2]. 0 para salir"); t = s.readLine(); ejercicio = Integer.parseInt(t); } catch (Exception e) { System.out.println("No has introducido un numero del 1 al 2"); continue; } switch (ejercicio) { case 1: PruebaArboles.EX1(); break; case 2: PruebaFormas.EX2(); break; case 0: System.out.println("Fin del test"); return; default: break; } } }
86987c62-8b55-4e27-bec1-58c8b314ba34
9
public static void main(String[] args) { Scanner scn = new Scanner(System.in); int q = scn.nextInt(); for (int i = 1; i <= q; i++) { int a = scn.nextInt(); int b = scn.nextInt(); int c = scn.nextInt(); System.out.println("Case " + i + ": " + ((b < a && a < c) || (c < a && a < b) ? a : ((a < b && b < c) || (c < b && b < a) ? b : c))); } }
7598d044-7834-46ce-88bb-66b5a5a7a022
9
void parsePCData() throws java.lang.Exception { char c; // Start with a little cheat -- in most // cases, the entire sequence of // character data will already be in // the readBuffer; if not, fall through to // the normal approach. if (USE_CHEATS) { int lineAugment = 0; int columnAugment = 0; loop: for (int i = readBufferPos; i < readBufferLength; i++) { switch (readBuffer[i]) { case '\n': lineAugment++; columnAugment = 0; break; case '&': case '<': int start = readBufferPos; columnAugment++; readBufferPos = i; if (lineAugment > 0) { line += lineAugment; column = columnAugment; } else { column += columnAugment; } dataBufferAppend(readBuffer, start, i - start); return; default: columnAugment++; } } } // OK, the cheat didn't work; start over // and do it by the book. while (true) { c = readCh(); switch (c) { case '<': case '&': unread(c); return; default: dataBufferAppend(c); break; } } }
f466c411-b689-4c88-bdf1-afbe353f53ad
3
public void randAlgo(){ int cnt = 0; Random rand = new Random(); while(cnt < 25){ int a = rand.nextInt(100); if(cnt == 0){ randlist[cnt] = a; cnt++; } else{ if(isExist(a, cnt)){ randlist[cnt] = a; cnt++; } } } }
f2ccfb75-5930-4161-86c9-57adb4fac454
2
private void delete(User user){ for (int i = 0; i < userList.size(); i++){ if (userList.get(i).getName().equals(user.getName())){ userList.remove(i); } } }
052ea83f-f7ab-4019-8e1d-763631b61cf0
2
protected void clearTile(Tile t){ for (Item i : t.getInventory()){ t.removeItem(i); } if (t.removeCharacter() instanceof Player){ playerTile = null; } }
2cd57a7c-f15a-41c7-a2a6-d6f8d5f4d776
5
@FXML private void jacobiResultClick(MouseEvent me) { int curMethod = 1; if (me.getButton().equals(MouseButton.PRIMARY)) { if (coef == null || free == null || results[curMethod] == null) { return; } if (curMode[curMethod]) { curMode[curMethod] = false; jacobiResult.setText(VECTOR + results[curMethod]); } else { curMode[curMethod] = true; jacobiResult.setText(CHECK + Checker.getResult(coef, free, results[curMethod])); } } }
913931ff-a70a-42b2-93ed-177623fa3915
4
public void renderEntities() { Entity entity; for (int i = 0; i < this.theWorld.loadedEntityList.size(); i++) { entity = this.theWorld.loadedEntityList.get(i); if (!entity.getEntityName().equals("Player")) { if (RenderHelper.isOnScreen(entity)) { if (entity.hasAnimatedTexture()) { this.entityRenderer.renderAnimatedEntity(entity); } else { //this.entityRenderer.renderEntityUsingDrawElements(entity); this.entityRenderer.renderEntity(entity); } } } } this.entityRenderer.renderPlayer(this.theGame.thePlayer); }
5bb11c88-f68f-4812-8b53-64dde0981ea7
8
public void modifyProfile(Line profile) { DataLine rq = new DataLine(); rq.setAPI("user.modify_profile"); try { if (profile.getString("name") != null) rq.set("name", profile.getString("name")); if (profile.getString("twitter") != null) rq.set("twitter", profile.getString("twitter")); if (profile.getString("facebook") != null) rq.set("facebook", profile.getString("facebook")); if (profile.getString("website") != null) rq.set("website", profile.getString("website")); if (profile.getString("about") != null) rq.set("about", profile.getString("about")); if (profile.getString("topartists") != null) rq.set("topartists", profile.getString("topartists")); if (profile.getString("hangout") != null) rq.set("hangout", profile.getString("hangout")); } catch (Exception ex) { ex.printStackTrace(); } this._send(rq, null); }
d7138b1a-402f-43d0-8feb-c04d7957bef1
5
public static void main(String[] args) throws Exception { File uniDir = new File(args[args.length - 7]); File triDir = new File(args[args.length - 6]); File s1Uni = new File(args[args.length - 5]); File s1Tri = new File(args[args.length - 4]); File s2Uni = new File(args[args.length - 3]); File s2Tri = new File(args[args.length - 2]); File pairFile = new File(args[args.length - 1]); System.out.println("================================== Test start =================================="); System.out.println(); System.out.println("Arguments:"); System.out.println("\tRaw Unigram directory: " + uniDir.getPath()); System.out.println("\tRaw Trigram directory: " + triDir.getPath()); System.out.println("\tStage1 Unigram : " + s1Uni.getPath()); System.out.println("\tStage1 Trigram : " + s1Tri.getPath()); System.out.println("\tStage2 Unigram : " + s2Uni.getPath()); System.out.println("\tStage2 Trigram : " + s2Tri.getPath()); System.out.println("\tPair file: " + pairFile.getPath()); System.out.println(); if (TEST_STAGE1) { System.out.println("Stage 1 Approaches:"); for (Class<? extends gtm.test.stage1.Approach> app : STAGE1_APPROACHES) System.out.println('\t' + app.getSimpleName()); } System.out.println(); // Test two stages. if (TEST_STAGE1) testStage1(uniDir, triDir, s1Uni, s1Tri, pairFile); if (TEST_STAGE2) testStage2(s2Uni, s2Tri, pairFile); System.out.println("=================================== Test end ==================================="); }
14fb837a-3492-46cc-a579-639c0b76b1cb
3
private int getFailPosition(Pattern pattern, String input) { for (int i = 0; i <= input.length(); i++) { Matcher matcher = pattern.matcher(input.substring(0, i)); if (!matcher.matches() && !matcher.hitEnd()) { return i - 1; } } return input.length(); }
32292c45-0fb8-4cf9-96d6-c8fdf0bcd6a9
3
@RequestMapping(value = "updateRoleAuth", method = RequestMethod.POST) @ResponseBody public Object updateRoleAuth( @RequestParam int roleId, @RequestParam int[] menuIds ) { Map<String, Object> map = new HashMap<>(); Role role = roleService.getById(roleId); List<Menu> menus = new ArrayList<>(); if (role == null) { map.put("success", false); map.put("msg", "角色不存在!"); return map; } for (int menuId : menuIds) { if (menuId == 0) { continue; } menus.add(menuService.getById(menuId)); } roleService.updateRoleAuth(role, menus); map.put("success", true); map.put("msg", "修改权限成功!"); return map; }
9fba1008-b691-437e-bb18-654423a4a8ed
8
public void merge(int A[], int m, int B[], int n) { int a = m - 1; int b = n - 1; for(int i = m + n -1; i >= 0; i--){ if(a >= 0 && b < 0) break; if(a < 0 && b >= 0){ A[i] = B[b--]; continue; } if(a >= 0 && b >= 0){ if(A[a] > B[b]) A[i] = A[a--]; else A[i] = B[b--]; } } }
fef15cb5-fc83-4b87-9101-254169669ba7
9
private void updateCurrentLogFile() { // get the log file name from the file system File logFolder = new File(slateComponent.getLogDirectoryName()); File[] listOfLogFiles = logFolder.listFiles(); numLogFiles = listOfLogFiles.length; if (numLogFiles == 0) { return; } if ((RotationParadigm.Bounded.equals(slateComponent.getSlateSettings().getRotationParadigm()) && (currentLogFileCounter < 0)) || (RotationParadigm.Continuous.equals(slateComponent.getSlateSettings().getRotationParadigm()) && (currentLogFileCounter >= numLogFiles))) { currentLogFileCounter = 0; } if ((RotationParadigm.Bounded.equals(slateComponent.getSlateSettings().getRotationParadigm()) && (currentLogFileCounter >= numLogFiles)) || (RotationParadigm.Continuous.equals(slateComponent.getSlateSettings().getRotationParadigm()) && (currentLogFileCounter < 0))) { currentLogFileCounter = numLogFiles - 1; } // Now, get the log file currentLogFile = listOfLogFiles[currentLogFileCounter]; }
c3e5a755-8162-41e1-8479-d48f4fd4330f
7
private static void testInvalidNode(ListNode p) { System.out.println("p.isValidNode() should be false: " + p.isValidNode()); try { p.item(); System.out.println("p.item() should throw an exception, but didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.item() should throw an exception, and did."); } try { p.setItem(new Integer(0)); System.out.println("p.setItem() should throw an exception, but didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.setItem() should throw an exception, and did."); } try { p.next(); System.out.println("p.next() should throw an exception, but didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.next() should throw an exception, and did."); } try { p.prev(); System.out.println("p.prev() should throw an exception, but didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.prev() should throw an exception, and did."); } try { p.insertBefore(new Integer(1)); System.out.println("p.insertBefore() should throw an exception, but " + "didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.insertBefore() should throw an exception, and did." ); } try { p.insertAfter(new Integer(1)); System.out.println("p.insertAfter() should throw an exception, but " + "didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.insertAfter() should throw an exception, and did." ); } try { p.remove(); System.out.println("p.remove() should throw an exception, but didn't."); } catch (InvalidNodeException lbe) { System.out.println("p.remove() should throw an exception, and did."); } }
2300d5e8-18cd-4bc2-9b70-329e9ffd42a2
7
public void update() { if(!active) { if(Math.abs(player.getX() - x) < GamePanel.WIDTH) active = true; return; } // check if done flinching if(flinching) { flinchTimer++; if(flinchTimer == 6) flinching = false; } getNextPosition(); checkTileMapCollision(); calculateCorners(x, ydest + 1); if(!bottomLeft) { left = false; right = facingRight = true; } if(!bottomRight) { left = true; right = facingRight = false; } setPosition(xtemp, ytemp); if(dx == 0) { left = !left; right = !right; facingRight = !facingRight; } // update animation animation.update(); }
75c252b2-63c3-4e75-b584-01054de439af
2
public boolean Benutzernameaendern(String betroffenerBenutzer, String neuerBenutzername) { Benutzer benutzer = dbZugriff.getBenutzervonBenutzername(betroffenerBenutzer); if (benutzer != null){ try{ benutzer.setBenutzername(neuerBenutzername); return true; } catch (SQLException e){ System.out.println(e); } } return false; }
1494ad65-0556-4d0e-a96a-d04f1e1ebfef
0
public JPanel getjPanelTitre() { return jPanelTitre; }
3bdfb79b-f51d-4d2c-9d2e-fc6fea010499
7
public void tick() { if ((this.runOnTick) && (isVisible())) { ImageComponent[] arrayOfImageComponent = getImageComponents(); int i = 0; int j = 0; for (int k = 0; k < arrayOfImageComponent.length; k++) { if (!(arrayOfImageComponent[k] instanceof AnimationComponent)) continue; i++; if (!((AnimationComponent)arrayOfImageComponent[k]).nextImage()) { j++; } } if ((j == i) && (i != 0)) { getEnvironment().removeObject(this); } } }
b4364575-aba7-4227-9a04-0ff2fb92f946
2
@Test public void testLoadGame() { //There MUST be a "testsave.xml" file in the saves/ folder for this to pass. try { int id = games.loadGame("testsave"); boolean condition = false; if(id == games.listGames().size()-1){ condition = true; } else condition = false; assertTrue("Loaded game correctly and was suppose to.", condition); } catch (IOException e) { assertTrue("Game did not load correctly and was suppose to.", false); } }
387781fd-c43b-48a7-b6ae-68033d723ace
8
@SuppressWarnings({ "rawtypes", "unchecked" }) public Newlevel() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } setTitle("New Level"); setBounds(100, 100, 321, 309); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[]{232, 226, 0}; gbl_contentPanel.rowHeights = new int[]{32, 31, 42, 0, 0}; gbl_contentPanel.columnWeights = new double[]{1.0, 1.0, Double.MIN_VALUE}; gbl_contentPanel.rowWeights = new double[]{1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE}; contentPanel.setLayout(gbl_contentPanel); { JLabel lblName = new JLabel("Name:"); GridBagConstraints gbc_lblName = new GridBagConstraints(); gbc_lblName.anchor = GridBagConstraints.EAST; gbc_lblName.insets = new Insets(0, 0, 5, 5); gbc_lblName.gridx = 0; gbc_lblName.gridy = 0; contentPanel.add(lblName, gbc_lblName); } { Name = new JFormattedTextField(); Name.setText("Unnamed"); GridBagConstraints gbc_Name = new GridBagConstraints(); gbc_Name.insets = new Insets(0, 0, 5, 0); gbc_Name.fill = GridBagConstraints.HORIZONTAL; gbc_Name.gridx = 1; gbc_Name.gridy = 0; contentPanel.add(Name, gbc_Name); } { JLabel lblHeight = new JLabel("Height:"); GridBagConstraints gbc_lblHeight = new GridBagConstraints(); gbc_lblHeight.anchor = GridBagConstraints.EAST; gbc_lblHeight.insets = new Insets(0, 0, 5, 5); gbc_lblHeight.gridx = 0; gbc_lblHeight.gridy = 1; contentPanel.add(lblHeight, gbc_lblHeight); } { height = new JFormattedTextField(); height.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if(!Character.isDigit(e.getKeyChar()) || Character.isSpaceChar(e.getKeyChar()) || Character.isWhitespace(e.getKeyChar())) { e.consume(); } } }); height.setText("64"); GridBagConstraints gbc_height = new GridBagConstraints(); gbc_height.insets = new Insets(0, 0, 5, 0); gbc_height.fill = GridBagConstraints.HORIZONTAL; gbc_height.gridx = 1; gbc_height.gridy = 1; contentPanel.add(height, gbc_height); } { JLabel lblNewLabel = new JLabel("Width:"); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.anchor = GridBagConstraints.EAST; gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 2; contentPanel.add(lblNewLabel, gbc_lblNewLabel); } { width = new JFormattedTextField(); width.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if(!Character.isDigit(e.getKeyChar()) || Character.isSpaceChar(e.getKeyChar()) || Character.isWhitespace(e.getKeyChar())) { e.consume(); } } }); width.setText("64"); GridBagConstraints gbc_width = new GridBagConstraints(); gbc_width.insets = new Insets(0, 0, 5, 0); gbc_width.fill = GridBagConstraints.HORIZONTAL; gbc_width.gridx = 1; gbc_width.gridy = 2; contentPanel.add(width, gbc_width); } { JLabel lblCollisiontype = new JLabel("CollisionType:"); GridBagConstraints gbc_lblCollisiontype = new GridBagConstraints(); gbc_lblCollisiontype.anchor = GridBagConstraints.EAST; gbc_lblCollisiontype.insets = new Insets(0, 0, 0, 5); gbc_lblCollisiontype.gridx = 0; gbc_lblCollisiontype.gridy = 3; contentPanel.add(lblCollisiontype, gbc_lblCollisiontype); } { collTypebox = new JComboBox(); GridBagConstraints gbc_collTypebox = new GridBagConstraints(); gbc_collTypebox.fill = GridBagConstraints.HORIZONTAL; gbc_collTypebox.gridx = 1; gbc_collTypebox.gridy = 3; contentPanel.add(collTypebox, gbc_collTypebox); for(CollisionType colltype: CollisionType.values()) { collTypebox.addItem(colltype); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); { okButton = new JButton("OK"); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
df587ed0-46ac-491f-8c73-a6f3bb6d60ae
2
private void drawHand() { // the x and z offset from the center-top point of the palm of the hand float[][] fingers = new float[][] { { -2*(this.hand[Y]/3), this.hand[Z]/1.5f }, // pinky :D { -this.hand[Y]/4.5F, this.hand[Z]/8f }, // ring finger { this.hand[Y]/4.5F, this.hand[Z]/8f }, // middle finger { 2*(this.hand[Y]/3), this.hand[Z]/2f } }; // index finger // translate to the middle of the palm gl.glPushMatrix(); //gl.glRotatef(90, 0f, 1f, 0f); //gl.glRotatef(-90, 1f, 0f, 0f); gl.glScalef(this.hand[X], this.hand[Y], this.hand[Z]); //glut.glutSolidSphere(1f, 16, 16); this.drawSphere(1F, 128, 128); gl.glScalef(1/this.hand[X], 1/this.hand[Y], 1/this.hand[Z]); //gl.glRotatef(-90, 0f, 1f, 0f); gl.glPushMatrix(); // Thumb code { gl.glTranslatef(0F, this.hand[Y]/1.5F, this.hand[Z]/4F); gl.glRotatef(90, 0f, 0f, 1f); gl.glRotatef(-40, 0f, 1f, 0f); fingerpart(); gl.glTranslatef(0f, 0f, -this.hand[Z]/3F); gl.glRotatef(15, 0f, 1f, 0f); fingerpart(); gl.glTranslatef(0f, 0f, -this.hand[Z]/3F); gl.glRotatef(5, 0f, 1f, 0f); fingerpart(); } gl.glPopMatrix(); // Back to where we were and draw 4 fingers gl.glRotatef(90, 0F, 0F, 1F); gl.glTranslatef(0f, 0f, -this.hand[Z]); for (float[] finger : fingers) { gl.glPushMatrix(); { gl.glTranslatef(finger[0], 0f, finger[1]); for (int i = 0; i < 3; i++) { fingerpart(); gl.glTranslatef(0f, 0f, -this.hand[Z]/3F); } } gl.glPopMatrix(); //gl.glTranslatef(0.05f, 0f, finger[1]); } gl.glPopMatrix(); }
9dfb27c2-67c8-4b48-bc12-406ff83b0392
2
public boolean globtype(char ch, java.awt.event.KeyEvent ev) { if (ch == '\n') { wdgmsg("make", ui.modctrl ? 1 : 0); return (true); } return (super.globtype(ch, ev)); }
0f722b70-be48-4a32-9e70-4b9d49805df9
1
public Muodostelma kloonaa(){ ArrayList<Palikka> kloonipalikat = new ArrayList<Palikka>(); for (int i = 0; i < this.palikat.size(); i++){ kloonipalikat.add(palikat.get(i).kloonaa()); } return new Muodostelma(this.muoto, this.peli, kloonipalikat); }
b0680443-45b7-45ea-aa0a-5b77b4477835
4
public static void initializeDB(Library myLibrary){ Statement statement; PreparedStatement pStatement; String query; try { Connection conn = getConnection(); conn.setAutoCommit(false); query = "TRUNCATE TABLE item"; statement = conn.createStatement(); statement.execute(query); close(statement); query = "INSERT INTO item VALUES (?,?,?,?,?)"; pStatement = conn.prepareStatement(query); for (int i = 0; i < myLibrary.getLibraryItems().size(); i++) { pStatement.setString(1, myLibrary.getLibraryItems().get(i).getReference()); pStatement.setInt(2, myLibrary.getLibraryItems().get(i).getType().equals("Book") ? 1 : 0); pStatement.setString(3, myLibrary.getLibraryItems().get(i).getName()); pStatement.setString(4, myLibrary.getLibraryItems().get(i).getCreator()); pStatement.setInt(5, myLibrary.getLibraryItems().get(i).getInLibrary() ? 1 : 0); pStatement.addBatch(); } pStatement.executeBatch(); conn.commit(); close(pStatement); } catch (SQLException e) { e.printStackTrace(); } finally { } }