method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
1875b7c8-0c11-4161-9449-341c2204dcbf
8
static void draw_sprites(osd_bitmap bitmap) { /* sprite information is scattered through memory */ /* and uses a portion of the text layer memory (outside the visible area) */ UBytePtr spriteram_area1 = new UBytePtr(spriteram, 0x28); UBytePtr spriteram_area2 = new UBytePtr(spriteram_2, 0...
efcedb08-029c-4921-a064-e37284b79b58
4
private void saveMoveHistory(boolean won){ //Disregard games that didn't have any moves if (moves_in_round == 0) return; //Score how well the AI did this round //double fac = scoreMetric() - initialScore; //double rate = LEARN_RATE * fac; double rate = 0.01; if (rate > .0001){ //System.out.pri...
201ad536-27be-498b-b90d-08a1a716f93e
5
public static void main(String[] args) throws IOException { // write your code here int menu; do { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("1 - Create Author(s)\n2 - Create Publisher(s)\n3 - Quit"); try { ...
b7749b9f-822e-4c23-b319-540f84205ae4
6
public static JEditTextArea getTextArea(EventObject evt) { if(evt != null) { Object o = evt.getSource(); if(o instanceof Component) { // find the parent text area Component c = (Component)o; for(;;) { if(c instanceof JEditTextArea) return (JEditTextArea)c; else if(c == null...
0c7b12ab-bb3d-47e8-84da-5dd9afb1e984
4
static boolean isThereAFour(Hand hand) { for (int z =0; z < hand.size();z++) {int count = 0; for(int y=0;y < hand.size();y++) { if (hand.get(z).getValue() == hand.get(y).getValue()) count++; if (count == 4) return true; // ...
9fd9242d-f65a-4a75-b85d-051bff4d95d1
1
public int read() throws IOException { if (closed) { return 0; } else { return inputStream.read(); } }
28949912-50fd-4a36-a716-9eb45f1c5f4d
9
void parseTargetStatistics(Element el) { this.targetStatistics = new ArrayList<Statistic>(); NodeList paramList = el.getElementsByTagName("targetStatistic"); // for each parameter for (int j = 0; j < paramList.getLength(); j++) { Node node = paramList.item(j); String name = ((Element)node).getAtt...
d837c6df-78c6-4105-8da2-7f674e331f7c
6
public void fire(){ Bullet bullet = new Bullet(this) ; if( this.direction == Tank.direction_up){ bullet.setLocation_x(this.location_x + this.width/2 - bullet.getWidth()/2 - 1); bullet.setLocation_y(this.location_y); }else if(this.direction == Tank.direction_down){ bullet.setLocation_x(this.location_x ...
98562f09-ac33-4b7d-9a0a-dbe246950f31
7
private void prepareSpawn(){ if (time % spawnRate == 0){ if (maxSpawnCount > spawnCount){ spawn(mobsToSpawn); spawnCount++; wp.setLeft (maxSpawnCount - spawnCount); } } if (level % 10 == 0){ s.stopAmbient(); ...
61f5ed1f-b4a5-48d4-a9f5-435716cbb834
6
public void drawRaster(int[] p, int w, int h, int x, int y) { // Finds the bounds (in world space) of the pixels that are visible and are on the tile map final int startX = (x < 0) ? 0 : x; final int endX = (x + w > imageWidth) ? imageWidth : w + x; final int startY = (y < 0) ? 0 : y; final int endY = (y + h...
83cb1fac-cf3f-4ac3-a9b1-c977a54e45c5
1
private void loadPerson() { // TODO Auto-generated method stub Pendinng = Satisfied.getInstanceSatisfied().getPendingCompanyApplication(); fila = new Object[5]; for (int i = 0, j=1; i <Satisfied.getInstanceSatisfied().getPendingCompanyApplication().getCompanyApplications().size(); i++,j++) { fila[0] = i+1; fila[1] = Sa...
224a9836-76c5-4d52-a18d-6f72cf45ec49
3
@Override public String action() { StringBuilder builder = new StringBuilder(); builder.append(ZapporRestUtils.SEARCH_ACTION); builder.append("?term="); if (term != null) { builder.append(term); } builder.append("&filters="); StringBuilder value = new StringBuilder(); value.append("{\"price\":"); ...
4f495255-7e9d-45cc-8cfb-f109582e5c26
8
private static <V> V findAbbreviatedValue(Map<? extends IKey, V> map, IKey name, boolean caseSensitive) { String string = name.getName(); Map<String, V> results = Maps.newHashMap(); for (IKey c : map.keySet()) { String n = c.getName(); boolean match = (caseSensitive && n.startsWith(string)) || ((!caseSen...
0b748fda-92a2-4ea4-b153-afad9227d2a6
1
@Override public synchronized void execute(final Runnable command) { tasks.offer(new Runnable() { public void run() { try { command.run(); } finally { scheduleNext(); } } });//insert one t...
17519b07-f0ff-4f46-a304-4e16304f639f
9
public boolean endTurn(Integer activePlayerId) { // Cooldowns for (Attack a : this.getAttacks()) { if (a.getCooldownRemaining() < 0) { a.setCooldownRemaining(0); } else if (a.getCooldownRemaining() > 0) { a.setCooldownRemaining(a.getCooldownRemaining() - 1); } } // TODO: Regen // Update Mo...
d24ad3cb-09c5-475f-8a91-d66fccf44cab
4
SimulatedIVPump2(Spawner spawn, InitialJFrame app) { super("Gamma Infusion Pump"); title = new JLabel(" Gamma Infusion Pump"); title.setFont(new Font("Arial", Font.PLAIN, 32)); title.setForeground(Color.WHITE); title.setBackground(Color.BLACK); setSize(defaultWidth, defaultHeight); getContentPane().set...
35685ce5-6942-4d28-ab0d-b30a656eabb2
7
public static void exportReestr(List <Reception> receptions) { List<ReestrColumn> reestrColumns = ReestrColumns.getInstance().getActiveColumns(); // List<Reception> receptions = ReceptionsModel.getInstance().getFilteredReceptions(); SXSSFWorkbook wb = new SXSSFWorkbook(100); Sheet sh = wb.createSheet(); ...
47f1d80e-083d-4b51-afbb-87d81989e6f1
5
@Override public Matrix<Double> value(final Matrix<Double> firstInput, final Matrix<Double> secondInput) { if (firstInput.getFirstColumn() != secondInput.getFirstRow()) throw new ArithmeticException("The matrices are not " + "conforming in dimensions: First colum...
8e869716-6ea9-4a04-a9f0-d3d15432e114
7
public void setDstType(String type) { if ("string".equalsIgnoreCase(type)){ this.dstType = DstColumnType.STRING; } else if ("integer".equalsIgnoreCase(type)){ this.dstType = DstColumnType.INTEGER; } else if ("blob".equalsIgnoreCase(type)){ this.dstType = DstColumnType.BLOB; } else if ("list".equalsIgno...
b7acc451-bf56-4cca-97df-e5e5b9b9d382
8
public SteganoDialog(Controller controller) { super(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); bundle = Application.getResourceBundle(); setTitle("Steganography"); // Closing the window is equal to pressing the Abort-Button WindowListener windowListener = (new WindowAdapte...
9b77e146-df10-4cde-9353-b2ef28583ac8
4
private static boolean getPersonGender() { Scanner keyboard2 = new Scanner(System.in); String gender; do { System.out.print("Gender?:"); gender = keyboard2.nextLine().toLowerCase(); if (!(gender.matches("f(emale)?") || gender.matches("m(ale)?"))) { System.out.println("The gender must be F,Female,M or...
d634124d-f847-4cba-8d1e-2f94139afa7d
0
public static void main(String[] args) { StockStrategy stockStrategy=new StockStrategy(); int[] arr={6,1,3,2,4,7}; System.out.println(stockStrategy.maxProfit(arr)); }
c8415356-94fc-49dd-b52d-14cecf225d2b
2
public void bytesRead(int bytes, int clientId) { if (this.clientId == clientId) { for (Iterator i = observers.iterator(); i.hasNext();) { ObservableStreamListener listener = (ObservableStreamListener) i .next(); listener.bytesRead(bytes, clientId); } } }
3e594a2b-3cb2-489e-828a-a1cb4c6f1765
6
private void load() { assets = new AssetManager(); assets.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver())); assets.setLoader(Script.class, new ScriptLoader(new InternalFileHandleResolver())); assets.setLoader(EntityList.class, new EntityLoader(new InternalFileHandleResolver())); a...
c6c39181-985f-4351-8680-fae29742b3f0
8
public byte[] handle(ConnectionDetails connectionDetails, byte[] buffer, int bytesRead) throws java.io.IOException { final StringBuffer stringBuffer = new StringBuffer(); boolean inHex = false; for(int i=0; i<bytesRead; i++) { final int value = (buffer[i] & 0xFF); // If it's ASCII, print i...
2fd4e43f-914f-42fa-9857-4f9ae52a114d
8
private void setPrev(Vector<vslIndexView<D>> prevVec) throws vslInputException { if (record instanceof vslIndexUpdateRecord) { vslIndexUpdateRecord update = (vslIndexUpdateRecord) record; if (update.prev == null) { Vector<vslRecKey> prevKeys = new Vector<vslRecKey>(); for (vslIndexView<D> prev: prev...
4730bf30-d5c5-464b-9617-2eff6622baf4
6
public static void main(String args[]) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); ...
70ffff11-4961-4942-8331-1e7d0431f6ea
6
private Format getFileFormat(File file) { BufferedReader br; String line; String [] parts; Scanner scanner = new Scanner(""); try { br = new BufferedReader(new FileReader(file)); // Skip the lines that don't contain data (comments and such) while((line = br.readLine()) != null) { scanner =...
a265d7c0-3bbd-4301-8560-73c5d4b1e3ab
0
@Override public void componentHidden(ComponentEvent e) { }
caed1af3-1dfa-45b7-94ef-3c756590004d
7
public static synchronized Response connect(Request request) throws IOException{ Response response = null; ObjectOutputStream oos = null; ObjectInputStream ois = null; try { socket = new Socket("localhost", 4444); oos = new ObjectOutputStream(new BufferedOutputS...
75606129-ff4a-4904-9ca0-d406ade24e62
1
public static int howMuchDigits(int number) { int count = 1; while (number / 10 != 0) { count++; number /= 10; } return count; }
19cca2a5-478a-419d-b893-281ae596726f
9
private static int parseChanges(int index, List<Word> wordList, List<Change> changes, String comma) throws SQLCompilerException { while (index < wordList.size()) { ParseExpressionResult result = ExpressionParser.parse(index, wordList); if (result.getIndex() <= index) { break; } else { Express...
e780193b-5617-4acb-a696-71b4735d937c
0
public MessagePost (String username, String message){ super(username); this.message = message; }
b72ce2b8-58c0-43b3-b29c-bdd9c4280655
5
public void connect() throws JSchException{ try{ Session _session=getSession(); if(!_session.isConnected()){ throw new JSchException("session is down"); } if(io.in!=null){ thread=new Thread(this); thread.setName("DirectTCPIP thread "+_session.getHost()); if(_...
6607244e-2b0b-4aa0-8759-ab11fa1a348d
6
private void removed (DeviceImpl dev) { if (MacOSX.trace) System.err.println ("notify bus->removed(dev): " + dev.getPath()); // call synch'd on devices try { dev.close (); } catch (IOException e) { // normally ignore if (MacOSX.debug) ...
f516ee9e-c071-474d-bbd8-75d8fec14727
7
public static BufferedImage cellImage(PixelType type){ if(type == PixelType.NOFILL){ return getImage(101, false); }else if(type == PixelType.FILL){ return getImage(102, false); }else if(type == PixelType.CROSS){ return getImage(103, false); }else if(type == PixelType.GUESS_NOFILL...
5216f53c-80be-44ef-92fc-d39258f42f08
7
private static Structure parseHeader(CallParser parser) { ParseError.validate(parser.size() > 2, parser.firstCall().lineN, "Malformed callable header"); ParseError.validate(parser.get(0).qualifiesAsKeyword(), parser.firstCall().lineN, "Malformed callable header"); ParseError.validate(parser.get(1).qualifiesAsKeyw...
f3a19cfd-176a-4f21-aba0-aeab26b6deb5
5
void run() { try { // 1. creating a server socket providerSocket = new ServerSocket(2004, 10); // 2. Wait for connection System.out.println("Waiting for connection"); connection = providerSocket.accept(); System.out.println("Connection received from " + connection.getInetAddress().getHostNa...
6ea0b081-5afc-4892-8b8f-746796812aeb
3
public EU2Country getOwner() { int id = getId(); String sid = go.getString("id"); if (!scenario.provCanHaveOwner(id)) return null; for (GenericObject c : scenario.countries) if (c.getChild("ownedprovinces").contains(sid)) return s...
6c5c6899-bce7-4e32-8509-e745f328dba2
8
protected int computeState(int neighbors[]){ int numberOfLiveNeighbors = 0; for(int i = 1; i < neighbors.length; i++){ if(neighbors[i] != CellularAutomatonConstants.NO_VALUE){ if(neighbors[i] == GameOfLifeAutomaton.CELL_LIVE){ numberOfLiveNeighbors++; } } } if(neighbors[0] == GameOfLifeAutom...
0c1d3fe8-59da-48f9-b19a-6b40fba447a9
9
final public List<Literal> literals() throws ParseException { List<Literal> literals=new ArrayList<Literal>(); String literalFunction=null; Literal literal=null; if (jj_2_48(7)) { literalFunction = literalFunction(); } else if (jj_2_49(7)) { literal = literal(); } else { jj_consume_tok...
c9672cae-5ee6-4410-bbc3-b16612d44db9
0
public void removeNeighbour(Agent a) { neighbours.remove(a); }
d5112bab-68c0-4117-8f2a-7ed5f700ec79
5
public TrackingAndRecognitionMenu() { super("Tracking & Recognition"); setEnabled(true); JMenuItem imageTracking = new JMenuItem("Image"); imageTracking.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Panel panel = (((Window) getTopLevelAncestor()).getPanel()); ...
f52689b3-f670-4995-b658-ef50f11548b9
7
public Keygen(HtmlMidNode parent, HtmlAttributeToken[] attrs){ super(parent, attrs); for(HtmlAttributeToken attr:attrs){ String v = attr.getAttrValue(); switch(attr.getAttrName()){ case "autofocus": autofocus = Autofocus.parse(this, v); break; case "challenge": challenge = Challenge.pa...
c75727ce-5b9a-4127-b7b0-d94b17a2484e
1
public boolean followUrl(final Url url) { if (visitedUrls.get(url) != null) { return false; } visitedUrls.put(url, ""); return visitor.followUrl(url); }
9ac2f622-83ba-44f4-b00e-76bbd0a2beed
4
public Weapon(int x, int y, String name) { this.x = x << 4; this.y = y << 4; type = Type.WEAPON; ammotype = Ammotype.BULLET; if (name == "Pistol") { up = new AnimatedSprite(SpriteSheet.player_pistol_up, 32, 32, 3, 10); down = new AnimatedSprite(SpriteSheet.player_pistol_down, 32, 32, 3, 10); left = ...
f4d59a58-543a-4e39-8f80-d5eebf65b052
1
public static void update(){ if (draw != null) { draw.repaint(); } }
9f812e63-6c9a-4859-9a07-6f0f91a5d926
2
public int getWallObjectUid(int z, int x, int y) { GroundTile groundTile = groundTiles[z][x][y]; if (groundTile == null || groundTile.wallObject == null) { return 0; } else { return groundTile.wallObject.uid; } }
0b190510-6ca5-4c01-9d52-8d635a990605
2
public static ArrayList<Productos> sqlSelectAtributos(Productos pro){ ArrayList<Productos> prod = new ArrayList(); String sql = "SELECT de.nombre, at.atributo " + "FROM atributos at " + "INNER JOIN cat_subcat_tit_attr_descr pr ON at.idatributos = pr.atribu...
fbb03911-398c-4795-b568-67600d6bde4f
1
public Class<?> getTargetType() { return this.targetType; }
32dd1044-2e95-48b1-b3ca-6ead5f273340
9
public boolean isContained(char axis) { switch (axis) { case 'x': if (getMinX() < -0.5f * model.getLength() || getMaxX() > 0.5f * model.getLength()) return false; break; case 'y': if (getMinY() < -0.5f * model.getWidth() || getMaxY() > 0.5f * model.getWidth()) return false; break; case 'z': ...
8bdff284-2283-468e-b3ca-af0e80189a2b
7
public static void leptet( int[][] tabla ) { b = 1; jatekos = 0; while( !Ellenor.jatekVege(tabla) ) { AktualisRajzol.rajzol(tabla); jatekos = Jatek.melyJatekosKovetkezik(b, jatekos, 1); sor = sc.nextLine(); String splitSor[] = sor.split(" "); if( splitSor.length != 2 ) { System.out....
8f4b7e61-93a0-4fbd-b6bf-85fbddcf991d
4
private String readFile(File file) { StringBuilder stringBuffer = new StringBuilder(); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new FileReader(file)); String text; while ((text = bufferedReader.readLine()) != null) { ...
e30fe2c1-dc4f-4688-a5de-2a9a6163fa20
1
public synchronized List<Long> getWaysIds(int pos) { if (nodes.size()>pos) return ways.get(pos); else return new ArrayList<Long>(); }
6770bdaa-c591-48cd-8955-d21143d56352
6
public static void putLongNullable(ByteBuffer out, Long x) { if (x == null) { out.put( NULL ); } else { long value = (x < 0 ? -x : x); int sign = (x < 0 ? BYTE_SIGN_NEG : BYTE_SIGN_POS); long a = (value & 0x1F); int...
e31c969a-5e88-4b66-bfad-4fa1a1ba0bc8
5
@Override public void controlObject(GObject target, Context context) { if (tick > duration) { // We've been reused. Get out. return; } // Is this our first run? if (tick == 0) { // We may have other tweens that should be run at the same time. for (TweenController tween : with) { // Add the con...
03fd7f6a-a073-4d6c-9b2b-25b81a6796cb
0
public Object clone() { return new LRParseTable(this); }
36ecdf17-e9f9-4107-b66a-b45082623e76
7
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; CovingtonConfig that = (CovingtonConfig)obj; if (input.size() != that.getInput().size()) return false; if (dependencyGraph.nEdges() != that.getDepen...
5c012141-9c57-4229-b517-ef97e22e2fc7
5
public static List<String> getChildren(URL url) { List<String> result = new ArrayList<String>(); if ("file".equals(url.getProtocol())) { File file = new File(url.getPath()); if (!file.isDirectory()) { file = file.getParentFile(); } addFiles(file, result, file); } else if ("jar".equals(url.getProto...
f8df038b-6047-4064-879f-677ef410da98
2
private PlayerPawn findPlayerPawnById(int id){ for (int i = 0; i < playerPawns.size(); i++) { if (playerPawns.get(i).getId() == id) { return playerPawns.get(i); } } return null; }
2be88d64-2967-437f-9863-ee2d3e31ca49
7
@Override public void delBehavior(Behavior to) { if(behaviors==null) return; if(behaviors.remove(to)) { if(behaviors.isEmpty()) behaviors=new SVector<Behavior>(1); if(((behaviors==null)||(behaviors.isEmpty()))&&((scripts==null)||(scripts.isEmpty()))) CMLib.threads().deleteTick(this,Tickable.TIC...
6355b597-e983-4fe5-afeb-ba5d53cfe3ab
9
@Test(dataProvider="createTimer") public void testSchedulingTasksThenCancellingEverySecondTask(TimeScheduler timer) { final int NUM=20; Future<?>[] futures=new Future<?>[NUM]; try { for(int i=0; i < NUM; i++) { futures[i]=timer.schedule(new MyRunnable(i), 1000, ...
85793d6f-8224-44c0-a23e-c5a0aa03f325
3
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final MappingProduct other = (MappingProduct) obj; if (!Objects.equals(this.pcodeScylla, other.pcodeScylla)) { ...
d1b74203-de3e-499e-b805-18426cae4427
4
@Override public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) { try { if(args.length < 1) { throw new IllegalArgumentException("must be more than one"); } PluginCommand pluginCmd = Bukkit.getServer().getPluginCommand(cmdLabel + " " + args[0]); if(!pluginCmd.te...
395bb146-e516-4788-af82-1386e9ed272a
3
public int getValueAsInt() throws IllegalArgumentException { if (!isOptionAsInt(code)) { throw new IllegalArgumentException("DHCP option type (" + this.code + ") is not int"); } if (this.value == null) { throw new IllegalStateException("value is null"); } if (th...
05a50376-5764-433b-ad02-4e8f3ed4a524
8
public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); for (int x = 0; x < n; x++) { String[] in = br.readLine().split(" "); int row = Integer.parseInt(in[0]); int col = Integer.parseIn...
ed40019c-90bd-4b0e-9102-66860262b2b9
5
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { EmployeeManager mgr = new EmployeeManager(); boolean success = false; //COLLECT ALL THE VARIOUS PARAMETERS String firstName = req.getParameter("firstName"); String lastName = req.getParameter("...
e402c91f-4622-4914-83e4-0ec73cc64717
4
private void loopCycle() { // Logic processHits(); while(Keyboard.next()) { // Only listen to events where the key was pressed (down event) if (!Keyboard.getEventKeyState()) continue; // Switch textures depending on the key released switch (Keyboard.getEventKey()) { case Keyboard.KEY_1: tex...
ff7090d8-1500-4c08-8131-f3bc0445225a
9
@Override public void execute() throws MojoExecutionException, MojoFailureException { if(skipTests || mavenTestSkip) { getLog().info("Skipping all Octave tests, because 'skipTests' is set to true."); } else { getLog().info("running Octave tests @" + url); try { ...
b05ac842-4691-4604-bf18-f55bf766cf78
0
public static void main(String[] args) { new Cli(); }
985869cf-e8d7-45c1-991f-f659b7e49674
3
public static String readLog(String name) { String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "DarkIRC"; if (!(new File(tmpDir)).exists()) { (new File(tmpDir)).mkdirs(); } String text = ""; try...
0e20ac6d-4803-4187-80b4-976d7da6ed31
3
public void setSourceItem( DefaultBox<?> sourceItem ) { if( this.sourceItem != null ) { this.sourceItem.removeDependent( this ); } this.sourceItem = sourceItem; if( this.sourceItem != null ) { this.sourceItem.addDependent( this ); } }
56f51f4f-1258-4a3b-a00a-9af27e156e65
6
@Override public boolean equals(Object o) { if (!(o instanceof User)) return false; User user = (User) o; return this.login == user.login && this.password == user.password && this.firstName == user.firstName && this.lastName == user.lastName && this.birthDate == u...
23a5b578-6396-4d95-a790-bb9ad8c787de
8
private void analyzeForLinking(ResultSet rs, String cmd) throws SQLException { if (rs == null) { return; } Statement stmt = rs.getStatement(); if (stmt == null) { return; } Connection conn = stmt.getConnection(); if (conn == null) { ...
f42ee4a1-bcb8-4211-9d09-a501e2043290
1
private String display() { String displayString = ""; if (this.address == -1) { return displayString; //If address line holds -1, signifies transfer from memory to MBR (no address). } displayString += this.address; return displayString; }
7d6964b2-c309-4bfa-80e6-00c265d404f7
1
public static boolean isZero(int x, int y, int[][] sea) { return (isTile(x, y, sea) && sea[x][y] == 0); }
b1f265fb-0b4e-482c-ba64-de77529904c3
8
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { Player player = null; if (sender instanceof Player) { player = (Player) sender; } /* * ゲームモードを変更する * * @gm [0,1,2] * 0 = Survival * 1 = Cr...
9cb83e70-1f3d-4cd7-b92f-ff14693c1b00
8
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String questionType = request.getParameter("newQuestionType"); if(questionType.equals("")){ RequestDispatcher dispatch = request.getRequestDispatcher("createQuiz/chooseQuestionType.jsp"); ...
c78518b5-1328-4fa3-b803-c78144b73f4e
1
public int setErrorHandler (PdbErrorHandler anErrorHandler) { // we don't accept null handlers if (anErrorHandler == null) { return NULL_OBJECT_REFERENCE ; } // end if // set it, return in triumph ourErrorHandler = anErrorHandler ; return SUCCESS ; } // end method setErrorHandler
91fd3fb5-59e2-43c6-8044-661d84fbe33d
7
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
dd104f79-df9d-4823-b3f1-762a02e7c7f6
0
public boolean getAcceptByFinalState(){ return turingAcceptByFinalState; }
12a53abb-db19-4b8e-9b8a-a53ea482ef44
2
public void addOnlyInstrumentReg(String arg) { String patternString = arg.substring(ONLY_INSTRUMENT_REG_PREFIX.length()); if (patternString.startsWith("/")) patternString = patternString.substring(1); defaultSkip = true; try { patternMatchers.add(PatternMatcherReg...
85572960-80f0-4240-8209-c076bc85471f
1
private void bla() throws Exception { if(0==0) throw new Exception("bla"); }
614d56c3-a1f8-4c56-88b0-82353dc90711
2
public void printJobRequiresAttention(PrintJobEvent pje) { System.out.println("Job requires attention"); PrinterStateReasons psr = pje.getPrintJob().getPrintService().getAttribute(PrinterStateReasons.class); if (psr != null) { Set<PrinterStateReason> errors = psr.printerStateReasonSe...
61341c8a-244a-4797-a9a4-bbff1b13d5b3
1
private static String getFileContents(String filename) throws IOException, FileNotFoundException { File file = new File(filename); StringBuilder contents = new StringBuilder(); BufferedReader input = new BufferedReader(new FileReader(file)); try { String line = ...
e581bf08-90dd-469c-a287-89e10764b324
8
@Override public boolean keyup(KeyEvent ev) { if (ev.getKeyCode() == KeyEvent.VK_UP) APXUtils.wPressed = false; if (ev.getKeyCode() == KeyEvent.VK_LEFT) APXUtils.aPressed = false; if (ev.getKeyCode() == KeyEvent.VK_DOWN) APXUtils.sPressed = false; if (ev.getKeyCode() == KeyEvent.VK_RIGHT) APXUtils....
6e2bae6f-4b35-44c9-ba2f-ef6cc9fcb6e6
9
public Location getAdjacentLocation(int direction) { // reduce mod 360 and round to closest multiple of 45 int adjustedDirection = (direction + HALF_RIGHT / 2) % FULL_CIRCLE; if (adjustedDirection < 0) adjustedDirection += FULL_CIRCLE; adjustedDirection = (adjustedDirect...
8f85d69a-eebd-47ce-a787-cee1e7c10fca
3
private void returnBook(String bookTitle) { for (Book currBook : list) { if (currBook.getTitle().equals(bookTitle)) { if (currBook.isBorrowed()) { currBook.returned(); System.out.println("You successfully returned " + currBook.getTitle()); return; } } } System.out.println("This...
dbf806ff-59af-4788-b0fc-49d998e4bfde
8
public void actionPerformed(ActionEvent e) { Object obj; if ((obj = e.getSource()) == bFile) { JFileChooser filechooser = new JFileChooser(new File("./")); int selected = filechooser.showOpenDialog(this); if (selected == JFileChooser.APPROVE_OPTION) { ...
4f046970-72af-49ce-a728-f640a3aade9e
7
private String IaddINode(String resource_id, String inode_id) { String node_id = null; String resource_node_id = null; OrientGraph graph = null; try { node_id = getINodeId(resource_id,inode_id); if(node_id != null) { //Syst...
cea4d455-d91c-4eb5-96e6-196f71af8445
3
@Override public void update(Observable arg0, Object arg1) { if (presenter.getState().isInAnyPlayingState()) { getPointsView().setPoints(presenter.getClientModel().getServerModel().getPlayers().get(presenter.getPlayerInfo().getIndex()).getVictoryPoints()); if (presenter.getClientModel().getServerModel().getWin...
3e779c1b-9fa4-4776-97ca-831cb2aa5b63
7
public static void main(String[] args) throws Exception { if(args.length < 2) { System.out.println("Usage: java JGrep (file or directory) regex"); System.exit(0); } Pattern p = Pattern.compile(args[1]); if(!(findDir(args[0], p) || findFile(args[0], p))) { ...
a39f453d-33bb-4c28-b6ff-44d12abe2c2c
1
public int calculateTotal() { total = 0; for (int i = 0; i < hand.size(); i++) { total += hand.get(i).getValue(); } return total; }
ac6c5478-d8ac-485c-ae57-e9e87182b4c4
8
@Override public void mousePressed(MouseEvent evt) { int x = evt.getX(); int y = evt.getY(); if ((evt.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) { if (pd == PD.RightMouseB) { Dimension d = getSize(); jumpX = x; jumpY = y; // Draw distribution only insi...
cf2413a5-daeb-4b7d-baa1-153a4c9e39d1
7
public void build() { for (int i = 1; i <= graph.V(); i++) { KK<Integer> next = new KK<>(graph); next.add(i); clusters.add(next); } List<WeightedGraph.Edge> edges = graph.edges(); Collections.sort(edges); int k = clusters.size(); int i = 0; while (k != K) { System.err.println("------------ "...
8d7bb8bd-f59d-4911-a924-81dd2adeb2a9
5
private void initValues() { try { enableFrameSkip.setSelected(Settings.get(Settings.AUTO_FRAME_SKIP).equals("true")?true:false); } catch (NullPointerException e) { enableFrameSkip.setSelected(false); } try { limitGameSpeed.setSelected(Settings.get(Settings.CPU_LIMIT_SPEED).equals("true")?tr...
0c68dda3-2685-4927-904f-ef5b0864da7b
4
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Een dispatcher verkrijgen van de request en er een JSP mee associeren RequestDispatcher dispatcher = request.getRequestDispatcher(VIEW); // Een simpele dynamische boodschap genereren ...
1668fb8e-afaa-4aaa-9bf8-6d904ceec990
4
private void downdatePosition() { if (direction == 1) { pos_y++; } if (direction == 2) { pos_x++; } if (direction == 3) { pos_y--; } if (direction == 4) { pos_x--; } System.out.println(name + ": new position (down) " + pos_x + " " + pos_y); }
f3fd91fe-d951-432d-87e7-78af5cf0c0d2
5
private Entry<K,V> successor(Entry<K,V> t) { if (t == null) return null; else if (t.right != null) { Entry<K,V> p = t.right; while (p.left != null) p = p.left; return p; } else { Entry<K,V> p = t.parent; Entr...
d17b30c9-ff85-47e3-a2ca-79cc35c07400
3
@Override public void actionPerformed(ActionEvent e) { // File Menu if (e.getActionCommand().equals(OK)) { main_ok(); } else if (e.getActionCommand().equals(APPLY)) { main_apply(); } else if (e.getActionCommand().equals(CANCEL)) { main_cancel(); } }