method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
8a1c45da-996a-4eda-86b6-1574bd558ca4 | 0 | public final boolean isPruned() { return pruned; } |
0548bc7b-4745-4555-b79c-c7ba041a0eee | 3 | public static void main(String[] args){
int primeCount =0;
int i = 0;
while(true){
if(isPrime(i)){
primeCount++;
if(primeCount ==10001){
break;
}
}
i++;
}
System.out.println(i);
} |
44b2854f-761e-45da-b61c-bd91bb0e97b3 | 8 | public void start_run_single(int n){
Random ran = new Random();
jade.math.ExponentialDistribution disp = new jade.math.ExponentialDistribution();
disp.setFallOff(0.5);
jade.math.ExponentialDistribution ext = new jade.math.ExponentialDistribution();
ext.setFallOff(10);
double cur_disp = 0.5;
double cur_ext = 9.8;
rr = new MarginalRangeReconstructor(ratemodel, tree, aln);
rr.set_dipsersal(cur_disp);
rr.set_extinction(cur_ext);
rr.set_ratemodel();
double cur_score = Math.log(rr.eval_likelihood());
boolean disp_bool = true;
double new_disp = cur_disp;
double new_ext = cur_ext;
for(int i=0;i<n;i++){
if(disp_bool == true){
new_disp = Math.abs(cur_disp -(disp_sliding_window/2)+(disp_sliding_window*ran.nextDouble()));
disp_bool = false;
}
else{
new_ext = Math.abs(cur_ext -(ext_sliding_window/2)+(ext_sliding_window*ran.nextDouble()));
disp_bool = true;
}
rr = new MarginalRangeReconstructor(ratemodel, tree, aln);
rr.set_dipsersal(new_disp);
rr.set_extinction(new_ext);
rr.set_ratemodel();
double new_score =Math.log(rr.eval_likelihood());
/*
* accept or reject
*/
boolean acc = false;
double disp_prior_ratio = disp.getPDF(new_disp)/disp.getPDF(cur_disp);
double ext_prior_ratio = ext.getPDF(new_ext)/ext.getPDF(cur_ext);
double like_ratio = new_score/cur_score;
double dou_acc = disp_prior_ratio*ext_prior_ratio*like_ratio;
double min_acc = Math.min(1, dou_acc);
if(ran.nextDouble()<min_acc){
acc = true;
}
if(acc == true){
cur_disp = new_disp;
cur_ext = new_ext;
cur_score = new_score;
}
if((i%print_freq) == 0){
System.out.println(i+"\t"+cur_disp+"\t"+cur_ext+"\t"+cur_score+
"\t" +new_disp
+"\t"+new_ext
+"\t"+new_score
+"\t"+cur_score
+"\t"+like_ratio+"\t"+dou_acc);
}
if((i%report_freq) == 0 && to_file == true){
try {
FileWriter fw = new FileWriter(outfile, true);
fw.write(i+"\t"+cur_disp+"\t"+cur_ext+"\t"+cur_score+"\n");
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} |
a38b5012-dbf5-496e-b82e-46a1b1d35b37 | 0 | public static void main(String[] args)
{
SwingUtilities.invokeLater(new Kurs());
} |
2efde29f-2b9e-4916-95f7-8241be25a91f | 2 | public static void main(String[] args)
{
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <= 10; j++)
{
System.out.print("Богдан" + " ");
}
System.out.println();
}
} |
cd766017-0d8c-42c5-9e15-fdb7bea3e78c | 0 | public void setCp(String cp) {
this.cp = cp;
} |
c937c509-8f42-4535-a1c0-e6becde7de55 | 9 | static int findASolution(double[][][] graph, int[] assigned) throws Exception {
//loop: while there are still tasks that need to be assigned
//1. pick new unassigned task randomly
//2. assign that task to an agent using "action choice rule"
// init capacities
double[] capacities = new double[NUM_AGENTS];
for (int i=0; i<NUM_AGENTS; i++) {
capacities[i] = CAPACITY_VALUE;
}
//create random ordering for processing tasks
int[] order = new int[NUM_TASKS];
for (int i = 0; i < order.length; i++) {
order[i] = i;
}
// randomize order of assignments
for (int i=0; i < order.length; i++) { // Fisher-Yates (Knuth) shuffle
int random = generator.nextInt(order.length - i) + i; // [i, order.length)
int temp = order[random];
order[random] = order[i];
order[i] = temp;
}
int currTask = 0; //increment this after each iteration through loop
boolean foundFeasible = true;
while (currTask < NUM_TASKS) {
int agent = pickAgent(order[currTask], capacities, graph);
if (agent != -1) {
assigned[order[currTask]] = agent;
if (verbosity >= 1)
System.out.println("\tAssigned " + agent + " to " + currTask + " in order[]");
currTask++;
} else { // if we didn't get a proper agent, this solution wasn't feasible
foundFeasible = false;
break;
}
}
int cost = 0;
if (foundFeasible) {
for (int i = 0; i < assigned.length; i++) {
cost += graph[assigned[i]][i][0];
if (verbosity >= 1)
System.out.println("\tAgent " + assigned[i] + " now has cost " + cost);
}
}
GeneralizedAssignmentProblem.capacities = capacities;
updatePheromones(assigned, graph, foundFeasible);
return cost;
} |
8b2b4df4-bdc0-442b-84e6-d345e6d9c6e6 | 2 | private void openStream(final String param){
String appended = zybezUrl.concat(param);
try {
zybez = new URL(appended);
urlConnection = zybez.openConnection();
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
}
catch (MalformedURLException e) {
System.out.println("Web address formatted incorrectly, printing stack trace");
e.printStackTrace();
}
catch(IOException exception) {
System.out.println("Url connection has thrown an IOException, printing stack trace");
exception.printStackTrace();
}
} |
cd5aa87e-1fc4-4f7f-8ff1-8929a3620ddb | 8 | public void setType(int type) {
this.type = type;
//set color
switch (Math.abs(type)) {
case 1:
inner1 = new Color(215, 15, 55);
inner2 = new Color(254, 78, 113);
backgroundColor = new Color(247, 32, 57);
left = new Color(255, 181, 181);
right = new Color(199, 14, 51);
borderColor = new Color(158, 12, 41);
break;
case 2:
inner1 = new Color(15, 155, 215);
inner2 = new Color(33, 190, 255);
backgroundColor = new Color(9, 174, 247);
left = new Color(95, 206, 254);
right = new Color(9, 140, 196);
borderColor = new Color(2, 88, 108);
break;
case 3:
inner1 = new Color(33, 65, 198);
inner2 = new Color(47, 114, 220);
backgroundColor = new Color(33, 89, 222);
left = new Color(71, 134, 226);
right = new Color(27, 70, 169);
borderColor = new Color(1, 36, 118);
break;
case 4:
inner1 = new Color(255, 194, 37);
inner2 = new Color(255, 234, 76);
backgroundColor = new Color(255, 217, 59);
left = new Color(255, 249, 155);
right = new Color(255, 177, 37);
borderColor = new Color(153, 102, 0);
break;
case 5:
inner1 = new Color(89, 177, 1);
inner2 = new Color(128, 211, 22);
backgroundColor = new Color(99, 199, 16);
left = new Color(182, 236, 108);
right = new Color(84, 162, 13);
borderColor = new Color(2, 92, 1);
break;
case 6:
inner1 = new Color(210, 76, 173);
inner2 = new Color(246, 93, 220);
backgroundColor = new Color(232, 76, 201);
left = new Color(254, 131, 242);
right = new Color(189, 68, 166);
borderColor = new Color(102, 0, 102);
break;
case 7:
inner1 = new Color(253, 102, 2);
inner2 = new Color(252, 148, 46);
backgroundColor = new Color(255, 121, 0);
left = new Color(254, 168, 85);
right = new Color(219, 88, 2);
borderColor = new Color(153, 51, 0);
break;
default:
backgroundColor = new Color(1, 1, 1);
borderColor = new Color(25, 25, 25);
}
if (type < 0) {
inner1 = inner1.darker().darker().darker();
inner2 = inner2.darker().darker().darker();
backgroundColor = backgroundColor.darker().darker().darker();
squareColor = new Color(120, 120, 120);
left = left.darker().darker().darker();
right = right.darker().darker().darker();
borderColor = borderColor.darker().darker().darker();
} else {
squareColor = Color.WHITE;
}
setBorder(new LineBorder(borderColor));
} |
be3b5ccb-b269-4253-be98-f232450d067d | 4 | @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block b = event.getClickedBlock();
if ((b.getType() == Material.SIGN_POST) || (b.getType() == Material.WALL_SIGN)) {
Sign s = (Sign)b.getState();
Player p = event.getPlayer();
if (s.getLine(0).equals(plugin.translate("sign.text.line1"))) {
plugin.rankup( p );
}
}
}
} |
c6a0b3d3-3b60-4e4e-bb84-24631daf48ee | 1 | public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
} |
743751bd-099d-4083-a395-4882a85e76c2 | 4 | private static String getISBNFromTitle(BufferedReader reader, VideoStore videoStore, String title) throws
SQLException {
int choice;
LinkedList<Pair<String, String>> whereClauses = new LinkedList<Pair<String, String>>();
whereClauses.add(new Pair<String, String>("Title LIKE ?", '%' + title + '%'));
LinkedList<String> whereConjunctions = new LinkedList<String>();
LinkedList<Video> videos = videoStore.searchVideos(whereClauses, whereConjunctions, 'a');
String isbn;
if (videos.size() > 1) {
System.out.println(videos.size() + " videos matched the given title.");
int index = 1;
for (Video video : videos) {
System.out.println(index++ + ". " + video.getIsbn() + " - " + video.getTitle() +
" (" + video.getFormat() + ')');
}
System.out.println(index + ". Cancel");
System.out.println("Please choose the video you want to review:");
choice = readMenuChoice(reader, videos.size() + 1);
if (choice == videos.size() + 1) {
return null;
}
isbn = videos.get(choice - 1).getIsbn();
} else if (videos.size() == 1) {
isbn = videos.get(0).getIsbn();
} else {
System.out.println("No videos matched the given title.");
return null;
}
return isbn;
} |
cb43e4e8-39e4-44ed-bad1-dab179a00f0d | 0 | public static void main(String args[]) throws Exception
{
Socket socket = new Socket("127.0.0.1",6868);
//启动读写线程
new ClientInputThread(socket).start();
new ClientOutputThread(socket).start();
} |
f5a314fb-a2a9-4e2f-b6a2-b835559fe979 | 1 | private void markSubroutines() {
BitSet anyvisited = new BitSet();
// First walk the main subroutine and find all those instructions which
// can be reached without invoking any JSR at all
markSubroutineWalk(mainSubroutine, 0, anyvisited);
// Go through the head of each subroutine and find any nodes reachable
// to that subroutine without following any JSR links.
for (Iterator it = subroutineHeads.entrySet().iterator(); it.hasNext();)
{
Map.Entry entry = (Map.Entry) it.next();
LabelNode lab = (LabelNode) entry.getKey();
Subroutine sub = (Subroutine) entry.getValue();
int index = instructions.indexOf(lab);
markSubroutineWalk(sub, index, anyvisited);
}
} |
0e665c09-084a-481f-bb7e-0ac5ecb26d93 | 2 | @Override
public int compareTo(PrioritizedTask o) {
//复写此方法进行任务执行优先级排序
// return priority < o.priority ? 1 :
// (priority > o.priority ? -1 : 0);
if(priority < o.priority)
{
return -1;
}else
{
if(priority > o.priority)
{
return 1;
}else
{
return 0;
}
}
} |
72b4f63f-3788-4d97-bd6b-4daabc18b3dd | 6 | public static void waitComment(String msg){
java.util.StringTokenizer st = new java.util.StringTokenizer(msg, " \t\n", true);
String sWrapped = "";
int lineLen = 0;
int crStop = 70;
while( st.hasMoreTokens() ){
String tok = st.nextToken();
if( lineLen == 0 && (tok.startsWith( " " ) || tok.startsWith( "\t" )) ){
}
else{
sWrapped += tok;
lineLen += tok.length();
int pos = tok.lastIndexOf('\n');
if( pos != -1){
lineLen = tok.length() - pos;
}
if( lineLen > crStop ){
sWrapped += "\n";
lineLen = 0;
}
}
}
waitHere(sWrapped);
} |
42cdbd5f-61a2-48f6-b09e-383a3a122df5 | 5 | @Override
public void setString( String s ) {
if( s.length() == 0 )
s = "[]";
else{
if( Character.isWhitespace( s.charAt( 0 ) ) || Character.isWhitespace( s.charAt( s.length()-1 ) )){
s = "[" + s + "]";
}
else if( s.charAt( 0 ) == '[' && s.charAt( s.length()-1 ) == ']' ){
s = "[" + s + "]";
}
}
super.setString( s );
} |
e42a62c9-fa58-4eb2-9e86-fccfe95d632f | 0 | public String getCity() {
return City;
} |
f08e4dcf-da01-451c-92b2-68cb23dbcaee | 8 | public Player[] getWinners() {
int winner = -1;
Player players[] = this.players;
for(int i = 0; i < players.length && winner < 0; ++i) {
Player p = players[i];
if( p.equals( this.getBestPlayerBet() ) ) {
winner = i;
}
}
int winnerTeammate = 0;
int loser = 0;
int loserTeammate = 0;
if( winner == 0 ) {
winnerTeammate = 2;
loser = 1;
loserTeammate = 3;
} else if ( winner == 1 ) {
winnerTeammate = 3;
loser = 0;
loserTeammate = 2;
} else if ( winner == 2 ) {
winnerTeammate = 0;
loser = 1;
loserTeammate = 3;
} else if ( winner == 3 ) {
winnerTeammate = 1;
loser = 0;
loserTeammate = 2;
}
int roundsWon = this.players[winner].getTurnWin() + this.players[winnerTeammate].getTurnWin();
int roundsBet = this.players[winner].getOriginalBet().getNbRounds();
Player[] winners;
if( roundsWon >= roundsBet ) {
winners = new Player[]{ this.players[winner], this.players[winnerTeammate] };
} else {
winners = new Player[]{ this.players[loser], this.players[loserTeammate] };
}
return winners;
} |
40150676-f403-4673-ace8-98035e1f98a6 | 9 | public void addFamData(String entry, Family ind)
{
String delim = "[ ]+";
String[] tokens = entry.split(delim);
String tag = tokens[1];
int month = 1;
if(tag.equalsIgnoreCase("HUSB"))
{
ind.setHusb(tokens[2]);
}
else if(tag.equalsIgnoreCase("WIFE"))
{
ind.setWife(tokens[2]);
}
else if(tag.equalsIgnoreCase("CHIL"))
{
ind.addChild(tokens[2]);
}
else if(tag.equalsIgnoreCase("MARR"))
{
marrDate = true;
}
else if(tag.equalsIgnoreCase("DIV"))
{
divDate = true;
}
else if(tag.equalsIgnoreCase("DATE"))
{
if(tokens.length > 3)
{
month = getMonth(tokens[3]);
GregorianCalendar m = new GregorianCalendar(Integer.parseInt(tokens[2]), month, Integer.parseInt(tokens[4]));
if(marrDate == true)
{
marrDate = false;
ind.setMarriage(m);
}
else if(divDate == true)
{
divDate = false;
ind.setDivorce(m);
}
}
}
} |
235bdf72-27f9-407c-9991-3f22725db006 | 2 | public void notifyUserListChanged() {
try {
for(String user : _userStore.keySet()) {
System.out.println("user: "+user);
_userStore.get(user).updateUserList(getBuddies(user));
}
} catch (RemoteException e) {
System.out.println("Error: " + e.getMessage());
}
} |
988da847-79af-425b-93bc-b50add13dea7 | 2 | public static ArrayList<String> readFile (String path) {
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(path)));
ArrayList<String> contents = new ArrayList<String>();
String data = "";
while((data = reader.readLine()) != null){
contents.add(data);
}
reader.close();
return contents;
}catch(Exception e){
Debug.error("File not found '" + path + "'");
return null;
}
} |
c17ad4d4-08aa-4daa-82b6-d42e0b346453 | 0 | public int getFormat() {
return format;
} |
ce96f9da-eea3-41af-8f50-393b613458f6 | 8 | public Tile[][] getNewWorld(int width, int height) {
MapGenerator g = new MapGenerator(seed);
int[][] mapData = g.generateWorld(width/10, height/10);
width = mapData.length * 10;
height = mapData[0].length * 10;
//Resets the spawn points.
this.resetSpawnPoints();
//Create grass everywhere.
Tile[][] tiles = new Tile[width][height];
for(int x = 0; x < tiles.length; x++) {
for(int y = 0; y < tiles[0].length; y++) {
tiles[x][y] = new Tile(new Position(x, y), 0);
}
}
//Loops through every tileset and adds the right tiles.
for(int x = 0; x < mapData.length; x++) {
for(int y = 0; y < mapData[0].length; y++) {
//Adds water.
if(mapData[x][y] == MapGenerator.WATER) {
addTiles(tiles, x*10, y*10, "lots/water.lot");
}
//Adds shorelines.
else if(mapData[x][y] == MapGenerator.SHORE) {
this.buildDynamicTile(tiles, mapData, x, y, BASE_SHORE, MapGenerator.WATER, false);
}
//Adds the right road part to the world.
if(mapData[x][y] == MapGenerator.ROAD) {
this.buildDynamicTile(tiles, mapData, x, y, BASE_ROAD, MapGenerator.ROAD, false);
}
else if(mapData[x][y] == MapGenerator.HOUSE) {
this.tryPlaceBuilding(tiles, mapData, x, y, BASE_RESIDENTIAL, MapGenerator.HOUSE);
}
}
}
return tiles;
} |
87ef214d-24d1-4e09-90d3-8d49ed7eee0d | 5 | public static boolean setDebugging(String debuggingString) {
if (debuggingString.length() == 0 || debuggingString.equals("help")) {
usageDebugging();
return false;
}
StringTokenizer st = new StringTokenizer(debuggingString, ",");
next_token: while (st.hasMoreTokens()) {
String token = st.nextToken().intern();
for (int i = 0; i < debuggingNames.length; i++) {
if (token == debuggingNames[i]) {
debuggingFlags |= 1 << i;
continue next_token;
}
}
err.println("Illegal debugging flag: " + token);
return false;
}
return true;
} |
5c828e40-1016-46ce-89bd-b22b899ca8de | 3 | public char nextClean() throws JSONException {
for (;;) {
char c = this.next();
if (c == 0 || c > ' ') {
return c;
}
}
} |
10af7c5d-c170-45ef-96d2-1931d7cc37a3 | 0 | @Test
@TestLink(externalId = "T1")
public void testSuccessExternal() {
assertTrue(true);
} |
2a457234-6796-4bb5-84f5-429e767d9a4a | 9 | public static void main(String[] args){
String str = "0123456789";
long w, sum = 0;
String temp = "";
while(true){
w = Long.parseLong(str);
//System.out.println(w);
if(Integer.parseInt(str.substring(1,4))%2==0){
if(Integer.parseInt(str.substring(2,5))%3==0){
if(Integer.parseInt(str.substring(3,6))%5==0){
if(Integer.parseInt(str.substring(4,7))%7==0){
if(Integer.parseInt(str.substring(5,8))%11==0){
if(Integer.parseInt(str.substring(6,9))%13==0){
if(Integer.parseInt(str.substring(7,10))%17==0){
System.out.println(str);
sum+=w;
}
}
}
}
}
}
}
if(temp==str) break;
temp = str;
str = permute(str);
}
System.out.println("ANSWER: " + sum);
} |
40db2092-108b-4d06-bb58-2fecd858c6ac | 4 | private void addRoad(Tile temp, Point position)
{
MapObject obj = new Road(temp, sfap.objSize, this.TILE_SIZE, position);
if (Collision.noCollision(grid, obj.getStartPos(), obj.getEndPos()))
{
if (!Collision.intersects(obj.getPlace(), gridBoundary))
{
this.mapObjects.add(obj);
for (int index = 0; index < mapObjects.size(); index++)
{
if (mapObjects.get(index).equals(obj))
{
findTexture(obj , obj.getStartPos().x, obj.getStartPos().y, "LRTB", true);
this.grid[position.x][position.y].setObject(this.mapObjects.get(index));
gridArea--;
break;
}
}
}
}
} |
b5012ae8-157f-4caf-89f3-412b55bc0950 | 4 | protected List<Integer> getAllPrimes() {
boolean[] sito = new boolean[MAX_X];
for (int i = 1; i < sito.length; i++) {
sito[i] = true;
}
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < sito.length; i++) {
if (sito[i]) {
int i1 = i + 1;
list.add(i1);
int x = 2;
int j = (i1 * x);
while (j <= MAX_X) {
sito[j - 1] = false;
x++;
j = (i1 * x);
}
}
}
return list;
} |
cdd8a6e6-938e-4e69-ab82-7f00424df09e | 6 | protected BeardTemplateReferences extract(String tpl) {
BeardTemplateReferences result = new BeardTemplateReferences () ;
int len = tpl.length(), i;
String tag = null;
char character;
for (i = 0; i < len; i++) {
character = tpl.charAt(i);
if (tag != null) {
if (character == '%' && tpl.charAt(i + 1) == '>') {
this.extractTag(tag, result);
tag = null;
i++;
continue;
}
tag += character;
} else {
if (character == '<' && tpl.charAt(i + 1) == '%') {
tag = "";
i++;
continue;
}
}
}
result.refreshSuffixedVariables () ;
return result;
} |
90b4de86-00d8-45c2-bb4a-28340d1b3a02 | 4 | private OccurrenceReport getTotalOccurencesOnPage(String editorText,
boolean isCaseSensitive, String searchingText, int currentSearchingPosition) {
int lastSearchingPosition = -1;
int cnt = 0;
OccurrenceReport report = new OccurrenceReport();
if (!isCaseSensitive) {
editorText = editorText.toLowerCase();
searchingText = searchingText.toLowerCase();
}
while ((lastSearchingPosition = editorText.indexOf(searchingText,
lastSearchingPosition + searchingText.length())) != -1 && cnt < 9999) {
cnt++;
if (lastSearchingPosition == currentSearchingPosition) {
report.current = cnt;
}
}
report.total = cnt;
return report;
} |
88f5cc82-37c8-4433-8603-1b97b1435688 | 1 | public void testWithPeriodAfterStart3() throws Throwable {
Period per = new Period(0, 0, 0, 0, 0, 0, 0, -1);
Interval base = new Interval(TEST_TIME_NOW, TEST_TIME_NOW);
try {
base.withPeriodAfterStart(per);
fail();
} catch (IllegalArgumentException ex) {}
} |
2c32d820-ca1b-4ccc-b46e-67fba0739f13 | 6 | private List<Cubie> getFaceCubies(Face face) {
List<Cubie> cubes = null;
switch(face) {
case FRONT:
cubes = this.getFrontFaceCubes();
break;
case LEFT:
cubes = this.getLeftFaceCubes();
break;
case TOP:
cubes = this.getTopFaceCubes();
break;
case RIGHT:
cubes = this.getRightFaceCubes();
break;
case BOTTOM:
cubes = this.getBottomFaceCubes();
break;
case BACK:
cubes = this.getBackFaceCubes();
break;
}
return cubes;
} |
2a4047b6-1a69-4412-a188-a091baa4910a | 0 | protected void initDefaultCommand() {
// This command makes the shooter automatically time out if no command
// uses it for 5 seconds
CommandGroup timeout = new CommandGroup("Time out shooter");
timeout.addSequential(new DoNothing(),5);
timeout.addSequential(new SpinDown());
setDefaultCommand(timeout);
} |
bac28769-5b6c-471e-8243-9a5f2f84ee3e | 9 | private void checkCollision() {
Player p = null;
List<Minion> badguys = new ArrayList<Minion>();
for(Entry<Client, Entity> entry : clientEntityPairs){
Entity e = entry.getValue();
if(e instanceof Player){
p = (Player) e;
} else if (e instanceof Minion){
badguys.add((Minion) e);
}
}
for(Minion m : badguys){
if(m.getPosition().equals(p.getPosition())){
//notifyCollision(m.getMinionType());
for(Entry<Client, Entity> entry : clientEntityPairs){
if(entry.getValue() == m){
handler.notifyDestruction(new Minion(m));
if(m.getMinionType() == MinionType.SPEED){
beatTime /= 1.2; // Speed is 20% faster
Math.max(beatTime, 250000000);
} else if (m.getMinionType() == MinionType.DEATH){
running = false;
handler.notifyDestruction(this);
}
clientEntityPairs.remove(entry);
map.remove(m);
break;
}
}
}
}
} |
54f1fef5-27f7-4ca6-a5bb-60bc6461c7e2 | 1 | public boolean loadImage() {
try {
img = ImageIO.read(new File(filename));
}
catch (IOException e) {
img = null;
return false;
}
return true;
} |
68658557-41de-4807-9ea1-280098d44f8c | 2 | public URL find(String classname) {
if(this.classname.equals(classname)) {
String cname = classname.replace('.', '/') + ".class";
try {
// return new File(cname).toURL();
return new URL("file:/ByteArrayClassPath/" + cname);
}
catch (MalformedURLException e) {}
}
return null;
} |
dbecccc0-c028-4115-a0fb-016e4e69c85b | 3 | public final static void quietSleep(int milliSeconds) {
if (milliSeconds <= 0) {
return;
}
if (Config.getDebug()) {
int min = Math.round(milliSeconds / 60000);
int sec = Math.round((milliSeconds / 1000) % 60);
Output.println("Sleep for " + min + ":" + sec + " (" + milliSeconds
+ ")", Output.DEBUG);
}
try {
Thread.sleep(milliSeconds);
} catch (InterruptedException e) {
}
} |
8c57c872-ea20-41c3-9849-bc704fcabef2 | 5 | @SuppressWarnings("unchecked")
String getStringValue(Object obj, int k) {
if ((obj instanceof ArgHolder<?>)
&& ((ArgHolder<?>) obj).getType().equals(String.class)) {
return ((ArgHolder<String>) obj).getValue();
} else if (obj instanceof String[]) {
return ((String[]) obj)[k];
} else {
verify(false, "object doesn't contain String values");
return null;
}
} |
c1847f87-dd4d-4427-b140-5dd51a287f0e | 8 | public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals(ok.getActionCommand())){
try {
String selectedType = (String) typeOfEdges.getSelectedItem();
Configuration.setEdgeType(selectedType);
String selectedTransModel = (String) selectedTransmissionModel.getSelectedItem();
if(!selectedTransModel.equals(Configuration.DefaultMessageTransmissionModel)) {
Configuration.DefaultMessageTransmissionModel = selectedTransModel;
Global.messageTransmissionModel = Model.getMessageTransmissionModelInstance(Configuration.DefaultMessageTransmissionModel, new Object[0]);
}
if(drawRulerCB.isSelected() != Configuration.drawRulers){
Configuration.drawRulers = drawRulerCB.isSelected();
parent.getGraphPanel().forceDrawInNextPaint();
}
if(drawArrowsCB.isSelected() != Configuration.drawArrows){
Configuration.drawArrows = drawArrowsCB.isSelected();
parent.getGraphPanel().forceDrawInNextPaint();
}
if(drawEdgesCB.isSelected() != Configuration.drawEdges){
Configuration.drawEdges = drawEdgesCB.isSelected();
parent.getGraphPanel().forceDrawInNextPaint();
}
if(drawNodesCB.isSelected() != Configuration.drawNodes){
Configuration.drawNodes = drawNodesCB.isSelected();
parent.getGraphPanel().forceDrawInNextPaint();
}
if(usePerspectiveCB.isSelected() != Configuration.usePerspectiveView) {
Configuration.usePerspectiveView = !Configuration.usePerspectiveView;
parent.getGraphPanel().forceDrawInNextPaint();
}
} catch(WrongConfigurationException ex) {
sinalgo.runtime.Main.fatalError(ex);
}
}
this.setVisible(false);
} |
838f77d7-761b-487b-b182-2850a25af521 | 7 | @Override
public void draw(Graphics g) {
g.setColor(Color.BLACK);
g.fillRect(0, 0, width, height);
g.setColor(new Color(50, 50, 50));
g.drawLine(100, 100, 400, 100);
g.drawLine(100, 250, 400, 250);
g.drawLine(100, 400, 400, 400);
for (int x = 0; x < 300; x++) {
if (x < 299 && ys[x] != ys[x+1]) {
g.setColor(new Color(0xE74C3C));
g.drawLine(100 + x, 100 + ys[x], 100 + x + 1, 100 + ys[x + 1]);
}
g.setColor(new Color(0xE74C3C));
g.fillRect(100 + x, 100 + ys[x], 1, 1);
if (x < 299 && ys2[x] != ys2[x+1]) {
g.setColor(new Color(0x3498DB));
g.drawLine(100 + x, 250 + ys2[x], 100 + x + 1, 250 + ys2[x + 1]);
}
g.setColor(new Color(0x3498DB));
g.fillRect(100 + x, 250 + ys2[x], 1, 1);
if (x < 299 && ys[x] + ys2[x] != ys[x+1] + ys2[x+1]) {
g.setColor(new Color(0x9B59B6));
g.drawLine(100 + x, 400 + ys[x] + ys2[x], 100 + x + 1, 400 + ys[x] + ys2[x + 1]);
}
g.setColor(new Color(0x9B59B6));
g.fillRect(100 + x, 400 + ys[x] + ys2[x], 1, 1);
}
amplitude.draw(g);
period.draw(g);
amplitude2.draw(g);
period2.draw(g);
} |
11ae0bca-76c0-4a35-ac4f-d16bfe29e370 | 4 | public void startServer() {
while(!shutdown) {
try {
clientSocket = new SocketManager(serverS.accept());
if(serviceList.size() < userLimit) {
Service service = new Service(clientSocket, ip);
serviceList.add(service);
new Thread(service).start();
} else {
clientSocket.Escribir("599 ERR Server full.\n");
}
} catch (IOException e) {
}
}
for(int i = 0; i < serviceList.size(); i++) {
serviceList.get(i).terminateSesion();
}
} |
86620945-8167-4c1d-acbd-255732b63f99 | 6 | public void keyPressed(KeyEvent key){
switch (key.getKeyCode()){
case KeyEvent.VK_UP:
player.moveY(-1);
break;
case KeyEvent.VK_LEFT:
player.moveX(-1);
break;
case KeyEvent.VK_RIGHT:
player.moveX(1);
break;
case KeyEvent.VK_DOWN:
player.moveY(1);
break;
case KeyEvent.VK_E:
collision.checkInteractCollision();
break;
case KeyEvent.VK_SPACE:
player.primaryAttack();
collision.checkAttackCollision(player);
break;
}
} |
5ca55244-e85a-4211-8b58-3511ca95ef9f | 0 | @Override
public void valueChanged(ListSelectionEvent e) {
// TODO Auto-generated method stub
} |
96619b31-0da9-4baa-a4ad-4d6d9433bd22 | 0 | public FileSender(int packageSize, String destinationIpAddress,
String fileName, int destinationPort, int verbose) {
this.packageSize = packageSize;
this.destinationIpAddress = destinationIpAddress;
this.fileName = fileName;
this.destinationPort = destinationPort;
this.verbose = verbose;
} |
1ae7724a-6026-484e-b584-39b5eb12fbe6 | 3 | @SuppressWarnings("rawtypes")
protected boolean isEnum(Class clazz, Object obj) {
if (!clazz.isEnum()) {
return false;
}
for (Object constant : clazz.getEnumConstants()) {
if (constant.equals(obj)) {
return true;
}
}
return false;
} |
0e14331b-512f-47ac-beca-2c958dfabe93 | 3 | public void circle(double x, double y, double r) {
if (r < 0) throw new RuntimeException("circle radius can't be negative");
double xs = scaleX(x);
double ys = scaleY(y);
double ws = factorX(2*r);
double hs = factorY(2*r);
if (ws <= 1 && hs <= 1) pixel(x, y);
else offscreen.draw(new Ellipse2D.Double(xs - ws/2, ys - hs/2, ws, hs));
draw();
} |
95509465-3c72-420f-b7c1-c66bb867450c | 9 | @Test
public void MultiNOTTest() {
int num_bits = 4;
Node reg = new MultiNOT(num_bits);
ConstantNode in[] = new ConstantNode[num_bits];
for (int i = 0; i < num_bits; i++) {
in[i] = new ConstantNode(true);
in[i].connectDst(0, reg, i);
}
for (int i = 0; i < num_bits; i++) {
in[i].propagate();
}
for (int i = 0; i < num_bits; i++) {
assertFalse(reg.out(i));
}
in[0].setValue(false);
for (int i = 0; i < num_bits; i++) {
in[i].propagate();
}
assertTrue(reg.out(0));
for (int i = 1; i < num_bits; i++) {
assertFalse(reg.out(i));
}
in[1].setValue(false);
for (int i = 0; i < num_bits; i++) {
in[i].propagate();
}
assertTrue(reg.out(0));
assertTrue(reg.out(1));
for (int i = 2; i < num_bits; i++) {
assertFalse(reg.out(i));
}
in[0].setValue(true);
for (int i = 0; i < num_bits; i++) {
in[i].propagate();
}
assertFalse(reg.out(0));
assertTrue(reg.out(1));
for (int i = 2; i < num_bits; i++) {
assertFalse(reg.out(i));
}
} |
5f9c5009-c8fc-4d6d-bab1-b78fb8794798 | 7 | private void go (Checker checker) {
if (dontScan) {
return;
}
if (init(checker)) {
if (checker != null) {
checker.enqueueNotify(25, null);
}
if (findBeans((checker))) {
if (checker != null) {
checker.enqueueNotify(50, null);
}
if (findEntries(checker)) {
if (checker != null) {
checker.enqueueNotify(100, null);
}
initialized = true;
}
}
}
} |
ee74e685-ce12-4c87-8196-9de8594a3f95 | 8 | private byte[] readASCII(byte[] data, int start, int end) {
// each byte of output is derived from one character (two bytes) of
// input
byte[] o = new byte[(end - start) / 2];
int count = 0;
int bit = 0;
for (int loc = start; loc < end; loc++) {
char c = (char) (data[loc] & 0xff);
byte b = (byte) 0;
if (c >= '0' && c <= '9') {
b = (byte) (c - '0');
} else if (c >= 'a' && c <= 'f') {
b = (byte) (10 + (c - 'a'));
} else if (c >= 'A' && c <= 'F') {
b = (byte) (10 + (c - 'A'));
} else {
// linefeed or something. Skip.
continue;
}
// which half of the byte are we?
if ((bit++ % 2) == 0) {
o[count] = (byte) (b << 4);
} else {
o[count++] |= b;
}
}
return o;
} |
1dcadf16-95cb-4b0d-bab4-ce5eb3dc8bc2 | 4 | @Override
public boolean remove(Object o)
{
if (o != null) {
int i = index(o.hashCode());
synchronized (table[i]) {
Node<E> p = table[i], n = p.next;
while (n != null) {
if (n.element == o || n.element.equals(o)) {
p.next = n.next;
return true;
}
p = n;
n = n.next;
}
}
}
return false;
} |
dee59fa0-890f-4a32-a096-4097144b47b3 | 8 | private String getHtmlForAction(WikiContext context, String action, String title)
throws ChildContainerException, IOException {
if (action.equals("view") || // editable
action.equals("viewparent") || // view parent version read only
action.equals("viewrebase")) { // view rebase version read only
return handleView(context, title, action);
} else if (action.equals("edit")) {
return handleEdit(context, title);
} else if (action.equals("delete")) {
return handleDelete(context, title);
} else if (action.equals("revert")) {
return handleRevert(context, title);
} else if (action.equals("rebased")) {
return handleRebase(context, title);
} else if (action.equals("save")) {
// Doesn't return.
return handleSave(context, context.getQuery());
} else {
context.raiseAccessDenied("Couldn't work out query.");
}
return null; // unreachable.
} |
87b4d916-398f-49d0-a1d5-3a46edad9862 | 3 | public void writeMatchObjectSimple(MatchObject NEW) throws FileNotFoundException {
// Create a new TeamLabelObject and add the elements to it.
matchReader read = new matchReader();
ArrayList<MatchObject> NAME;
try {
NAME = (ArrayList<MatchObject>)read.readMatchObject();
} catch (ClassNotFoundException ex) {
NAME = new ArrayList<MatchObject>();
Logger.getLogger(matchWriter.class.getName()).log(Level.SEVERE, null, ex);
}
NEW.setMatchNumber(NAME.size());
//Add this element to the ArrayList Object
NAME.add(NEW);
//Save this file to the master team list file
ObjectOutputStream oos = null;
try {
oos = new ObjectOutputStream(new FileOutputStream(new File(path)));
oos.writeObject(NAME);
} catch (IOException ex) {
Logger.getLogger(matchWriter.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
oos.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
} |
3ded0108-7849-46fb-8c82-312b3c959f0e | 4 | public PowerUp(int type, double x, double y){
this. type = type;
this.x = x;
this.y = y;
if(type == 1){
color1 = Color.PINK;
r =3;
}
if(type == 2){
color1 = Color.YELLOW;
r =3;
}
if(type == 3){
color1 = Color.YELLOW;
r =5;
}
if(type == 4){
color1 = Color.WHITE;
r =3;
}
} |
bcd348d0-11f8-4e4b-a686-2e0bc9752e9d | 6 | private void throwExceptionIfNodeDoesntBelongToTree(Object node) {
boolean result = false;
if (node instanceof GenericTreeNode) {
GenericTreeNode<? extends PropertyChangeSupporter> ttn = (GenericTreeNode<? extends PropertyChangeSupporter>) node;
while (!result && ttn != null) {
result = ttn == root;
ttn = ttn.getParent();
}
}
if(!result){
throw new SwingObjectRunException(ErrorSeverity.SEVERE, "Node does not belong to the tree!", this);
}
} |
73b42835-a48b-45e4-b8ec-529d6ab06ed2 | 0 | public static void main(String[] args) {
int x = 1;
x += 1;
System.out.println(x); // 2
x *= 2;
System.out.println(x); // 4
x -= 3;
System.out.println(x); // 1
x /= 4;
System.out.println(x); // 0
float y = 1f;
y += 1;
System.out.println(y); // 2.0
y *= 2;
System.out.println(y); // 4.0
y -= 3;
System.out.println(y); // 1.0
y /= 4;
System.out.println(y); // 0.25
} |
dcef80e1-eb26-426b-8170-6180817ad39c | 9 | private Set<Integer> findGivenValueInRow(int value, int startPoint, int numberOfFinds) {
Set<Integer> valueLocations = new HashSet<Integer>();
int foundNumber = 0;
int element = (this.getSize() * this.getSize());
if (startPoint < element) {
//startPoint--;
} else {
startPoint--;
}
int stopLocation = (startPoint / this.getSize()) * this.getSize() + (this.getSize() - 1);
boolean stopSearching = false;
Set<Integer> currentSet = new HashSet<Integer>();
for (int i = (startPoint); i <= stopLocation && !stopSearching; i++) {
if (getElementWithNumber(i) == EMPTY_ELEMENT_VALUE) {
currentSet.addAll(this.validElementsCache.get(i));
for (int valueTest : currentSet) {
if (value == valueTest && foundNumber < numberOfFinds) {
valueLocations.add(i);
if (numberOfFinds != 0) {
foundNumber++;
}
} else if (value == valueTest) {
//reseting valueLocation to -1 because it found more than one location with the value in the row.
valueLocations.clear();
stopSearching = true;
break;
}
}
currentSet.clear();
}
}
return (valueLocations);
} |
95c8065e-f377-4615-ae7a-cd58501b67b2 | 5 | public void run(){
try{
boolean done = false;
while(!done){
done = true;
for(int y = 0 ; y < 9; y++){
System.out.println("");
for(int x = 0; x < 9; x++){
String value = this.field[y][x].toString();
if (value.equals("")){
value = " ";
done = false;
}
System.out.print(value);
}
}
System.out.println();
this.sleep(1000);
}
}
catch (InterruptedException e){
System.out.println(e.toString());
}
} |
e6530da9-94a4-4c05-b9ec-64aefb28261c | 0 | @Test
public void test_isGameOver() {
assertNotNull(game);
assertEquals(false, game.isGameOver());
} |
d3cc2b1d-f152-4865-8135-b1abed0c8a32 | 2 | public static StopPlaceTypeEnumeration fromValue(String v) {
for (StopPlaceTypeEnumeration c: StopPlaceTypeEnumeration.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
} |
68b9450e-aad6-44fb-afea-c0ad6719ba83 | 0 | @Column(name = "FES_ID_POS")
@Id
public Integer getFesIdPos() {
return fesIdPos;
} |
f55aba41-2400-4854-9380-49df24d74701 | 6 | public boolean getBoolean(int index) throws JSONException {
Object o = get(index);
if (o.equals(Boolean.FALSE) ||
(o instanceof String &&
((String) o).equalsIgnoreCase("false"))) {
return false;
} else if (o.equals(Boolean.TRUE) ||
(o instanceof String &&
((String) o).equalsIgnoreCase("true"))) {
return true;
}
throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
} |
823b2a61-047e-4571-a329-7a2570f753ed | 4 | public static void main(String[] args) {
ArrayList<ArrayList<Integer>> lists = new ArrayList<ArrayList<Integer>>();
lists.add(new ArrayList<Integer>());
lists.add(new ArrayList<Integer>());
setReader();
int row = 1;
ArrayList<Integer> newList = lists.get(row%2);
ArrayList<Integer> oldList = lists.get((row+1)%2);
//row 1
newList.add(reader.nextInt());
row++;
while(reader.hasNext()) {
newList = lists.get(row%2);
oldList = lists.get((row+1)%2);
newList.clear();
//first column
newList.add( reader.nextInt() + oldList.get(0) );
//middle columns
for(int i = 1; i < row-1; i++)
newList.add( reader.nextInt() + Math.max(oldList.get(i-1), oldList.get(i)) );
//last column
newList.add( reader.nextInt() + oldList.get(oldList.size()-1) );
row++;
}
int max = Integer.MIN_VALUE;
for(int num : newList)
if( num > max )
max = num;
System.out.println(max);
} |
73f14318-51c8-4b5b-8535-5b06477c4fa8 | 3 | public void onBlockAdded(World var1, int var2, int var3, int var4) {
if(this != Block.stairSingle) {
super.onBlockAdded(var1, var2, var3, var4);
}
int var5 = var1.getBlockId(var2, var3 - 1, var4);
int var6 = var1.getBlockMetadata(var2, var3, var4);
int var7 = var1.getBlockMetadata(var2, var3 - 1, var4);
if(var6 == var7) {
if(var5 == stairSingle.blockID) {
var1.setBlockWithNotify(var2, var3, var4, 0);
var1.setBlockAndMetadataWithNotify(var2, var3 - 1, var4, Block.stairDouble.blockID, var6);
}
}
} |
a8657f9b-cd04-49e7-a935-042708d19cd4 | 3 | public double[] backpropogate(double[] protosigma){
if (protosigma.length != neurons.size()){
throw new RuntimeException("Neurons size does not match!");
}
for (int i = 0; i < protosigma.length; i++){
neurons.get(i).backpropogate(protosigma[i]);
}
double[] result = new double[entryPoints.size()];
for (int i = 0; i < entryPoints.size(); i++){
result[i] = entryPoints.get(i).getSum();
}
return result;
} |
e083b87d-c151-40e0-b95b-715eaade2300 | 2 | @Before
public void setUp(){
for(int i = 0; i < 20; i++){
if(i % 2 == 0){
solutionFitness.put(i, (double)i * 2);
}else{
solutionFitness.put(i, (double) i);
}
}
classUnderTest.setSolutionFitness(solutionFitness);
} |
af07f5fe-950b-4585-9ecd-c29111a043aa | 1 | SpecialistWorkType getSpecialistWorkType(){
double t = nextRand();
if ( t < 0.8 )
return SpecialistWorkType.PRESCRIBE;
else
return SpecialistWorkType.HOSPITALIZE;
} |
1fc5eb5f-10bd-43d5-99f9-4df06d390f94 | 6 | public static boolean markAsExplicitAssertionP(Justification self) {
if (((Keyword)(Logic.$EXPLANATION_STYLE$.get())) == Logic.KWD_BRIEF) {
if (self.inferenceRule == Logic.KWD_PRIMITIVE_STRATEGY) {
{ Keyword testValue000 = ((PrimitiveStrategy)(self)).strategy;
if ((testValue000 == Logic.KWD_SCAN_COLLECTION) ||
((testValue000 == Logic.KWD_SCAN_PROPOSITIONS) ||
((testValue000 == Logic.KWD_LOOKUP_ASSERTIONS) ||
(testValue000 == Logic.KWD_EQUIVALENCE)))) {
return (true);
}
else {
}
}
}
else {
}
}
return (false);
} |
91bc0189-e2db-4025-afc6-7c16f40c3fe7 | 2 | private String createId(ArrayList<Rod> currentRodList, ArrayList<Rod> possibilitiesLeft) {
StringBuilder id = new StringBuilder();
for(Rod rod : currentRodList) {
id.append(rod.getIndex());
}
id.append(":");
for(Rod rod : possibilitiesLeft) {
id.append(rod.getIndex());
}
return id.toString();
} |
2d607263-aff0-4113-b023-0d1762dddd36 | 9 | public List<Key> getSecretKeys()
{
try
{
Pattern keyIDPattern = Pattern.compile("sec\\s+\\w+/(\\w+)\\s+.*");
Pattern uidPattern = Pattern.compile("uid\\s+(\\S+[^<>]*\\S+)\\s+<([^<>]*)>.*");
List<Key> ret = new LinkedList<>();
List<String> list = new LinkedList<String>();
list.add("--list-secret-keys");
Process p = this.runCommand(list);
Scanner in = new Scanner(p.getInputStream(), "UTF-8");
String keyID = null;
String uid = null;
String email = null;
while(in.hasNextLine())
{
String data = in.nextLine();
if(data.length() == 0)
{
if (keyID == null)
break;
Key k = new Key();
k.keyID = keyID;
k.uid = uid;
k.email = email;
ret.add(k);
keyID = null;
uid = null;
email = null;
}
Matcher m = keyIDPattern.matcher(data);
if(keyID == null && m.matches())
{
keyID = m.group(1);
}
m = uidPattern.matcher(data);
if(uid == null && m.matches())
{
uid = m.group(1);
email = m.group(2);
}
}
in.close();
if(p.waitFor() == 0)
return ret;
else
return null;
}
catch(Exception e)
{
return null;
}
} |
7bf762b1-296b-4555-a22b-7a0ed17259f8 | 0 | @Test
public void testGetS2() {
System.out.println("getS2");
PickUp instance = new PickUp(6,9);
int expResult = 9;
int result = instance.getS2();
assertEquals(expResult, result);
} |
7747f1ab-f924-41cb-8688-8a2ff9e84b6a | 2 | public void doFlat() {
switch (ai.getDirection()) {
case LEFT:
setAnimation(new String[]{"goombaFlatLeft"});
break;
case RIGHT:
setAnimation(new String[]{"goombaFlatRight"});
break;
}
setDead(true);
} |
644d6b7c-5301-4eb1-8b44-6dde6e3127d6 | 3 | public void saveProperties() {
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream(this.file);
this.properties.store(outputStream, "MaintenanceServer Properties");
} catch (IOException e) {
MaintenanceServer.LOGGER.warning("Failed to save " + this.getFile());
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
// Swallow
}
}
}
} |
7a5c9462-22db-4bd1-aaa0-2d5562c2a4e3 | 2 | private Matrix4f GetParentMatrix()
{
if(m_parent != null && m_parent.HasChanged())
m_parentMatrix = m_parent.GetTransformation();
return m_parentMatrix;
} |
e4029963-9d80-4080-a2ea-d26bfebfca16 | 4 | public static void main(String[] args) {
final int n = 9;
System.out.print("*| ");
for (int i = 1; i <= 9; i++){
System.out.print(i+" ");
}
System.out.print("\n-+-");
for (int i = 1; i <= 9; i++){
System.out.print("--");
}
for (int i = 1; i <= n; i++){
System.out.print("\n"+i+"|");
for (int j = 1; j <= n; j++){
System.out.print(" "+i*j);
}
}
} |
881ed4cf-c972-4ff2-aa4b-861547ab3006 | 1 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
JFileChooser fichero = new JFileChooser();
int opcion = fichero.showOpenDialog(this);
if(opcion == JFileChooser.APPROVE_OPTION)
{
this.jTextField3.setText(fichero.getSelectedFile().getPath());
this.rutaProgramaExterno = this.jTextField3.getText();
}
}//GEN-LAST:event_jButton3ActionPerformed |
4982983e-1f1c-4c19-a105-c6c3c09aa867 | 6 | public Map<String, Long> getCounterMap() {
return counterMap;
} |
049a7665-6867-4a9a-9250-d5f1a41bc9a4 | 4 | @Override
public void paintBorder(Component component, Graphics gc, int x, int y, int width, int height) {
Color color = gc.getColor();
if (mLeftThickness > 0) {
gc.setColor(mLeftColor);
gc.fillRect(x, y, mLeftThickness, height);
}
if (mRightThickness > 0) {
gc.setColor(mRightColor);
gc.fillRect(x + width - mRightThickness, y, mRightThickness, height);
}
if (mTopThickness > 0) {
gc.setColor(mTopColor);
gc.fillRect(x, y, width, mTopThickness);
}
if (mBottomThickness > 0) {
gc.setColor(mBottomColor);
gc.fillRect(x, y + height - mBottomThickness, width, mBottomThickness);
}
gc.setColor(color);
} |
eb2bb88f-f3a8-442c-b7bc-31444bfb892c | 7 | public void testRoot3() {
setTree(new TreeNode("dummy"));
Map refcounts = Collections.synchronizedMap(new HashMap());
refcounts.put(new TreeNode("leaf1"), new Integer(1));
refcounts.put(new TreeNode("root1"), new Integer(0));
refcounts.put(new TreeNode("leaf2"), new Integer(1));
refcounts.put(new TreeNode("root2"), new Integer(0));
try {
TreeNode result = ((Question2)answer).rootNode(refcounts);
assertTrue(null, "Your code failed to correctly deal with a Map containing `multiple` root nodes correctly.",
result != null
&& result.getData() != null
&& (result.getData().equals("root1") || result.getData().equals("root2"))
&& result.getBranch() != null
&& result.getBranch().length == 0);
} catch(ClassCastException exn) {
fail(exn, "Caught a `ClassCastException`: you should **only** need to cast to the types `TreeNode` and `Integer`. Check that:\n* your `Map` keys have type **TreeNode**\n* your `Map` values have type **Integer**");
} catch(Throwable exn) {
fail(exn, "No exception's should be generated, but your code threw: " + exn.getClass().getName());
} // end of try-catch
} // end of method testRoot3 |
a65bfb70-a0ca-496d-9ba8-2fbd2030384c | 3 | public static double gammaMode(double mu, double beta, double gamma) {
if (beta <= 0.0D) throw new IllegalArgumentException("The scale parameter, " + beta + "must be greater than zero");
if (gamma <= 0.0D) throw new IllegalArgumentException("The shape parameter, " + gamma + "must be greater than zero");
double mode = Double.NaN;
if (gamma >= 1.0D) mode = (gamma - 1.0D) * beta - mu;
return mode;
} |
b9de9011-5499-4280-8148-ac3d8e85f14b | 4 | public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) { //Presiono flecha arriba 1
direccion = 1;
buenoMov = true;
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) { //Presiono flecha abajo 2
direccion = 2;
buenoMov = true;
} else if (e.getKeyCode() == KeyEvent.VK_LEFT) { //Presiono flecha izquierda 3
direccion = 3;
buenoMov = true;
} else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { //Presiono flecha derecha 4
direccion = 4;
buenoMov = true;
}
dirAntDMouse = direccion;
//showMessageDialog(null, "Eggs are not supposed to be green.");
} |
baade63c-a36b-4b77-9c78-5f7c54cddc1f | 4 | private void deleteBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteBtnActionPerformed
try {
connectDb();
int selectedRow = questionTable.getSelectedRow();
rowID = (questionTable.getModel().getValueAt(selectedRow, 1).toString());
int errors = 0;
String deleteAnswer = "DELETE FROM fibanswer WHERE QuestionID='" + rowID + "'";
int rows2 = st.executeUpdate(deleteAnswer);
if (rows2 == 0) {
errors++;
}
String deleteQuestion = "DELETE FROM fib WHERE QuestionID='" + rowID + "'";
int rows1 = st.executeUpdate(deleteQuestion);
if (rows1 == 0) {
errors++;
}
if (errors == 0) {
JOptionPane.showMessageDialog(null, "Question was successfully deleted!");
refresh();
} else {
JOptionPane.showMessageDialog(null, "ERROR : Delete was not successfull!");
refresh();
}
} catch (Exception exc) {
exc.printStackTrace();
}
}//GEN-LAST:event_deleteBtnActionPerformed |
16abcbd3-ded6-4799-a07b-b6452875aa74 | 2 | private void substracTrackButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_substracTrackButtonMouseClicked
// TODO add your handling code here: Resta una pista del calendario.
//Habilita o deshabilita el boton substract(<<)si el calendario esta vacio.
if (substracTrackButton.isEnabled()) {
changeTracks(calendarjList, calendarTracks, allTracks, calendarTracksListModel, allTracksListModel);
checkButtonState(calendarTracksListModel, substracTrackButton, addTrackButton);
if (calendarTracksListModel.isEmpty()) {
limpiarButton.setEnabled(false);
aplyButton.setEnabled(false);
}
}
}//GEN-LAST:event_substracTrackButtonMouseClicked |
9d8f50ba-0c6c-4aaa-98d5-b39c4fb887e0 | 8 | public ParseException generateParseException() {
jj_expentries.clear();
boolean[] la1tokens = new boolean[15];
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 4; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
}
}
}
for (int i = 0; i < 15; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.add(jj_expentry);
}
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = jj_expentries.get(i);
}
return new ParseException(token, exptokseq, tokenImage);
} |
103e2db4-3fd1-48a9-b522-4f7da88802f5 | 1 | @Test
public void unEnrollsStudentToActivity() {
Student s = null;
Activity a = null;
try {
s = familyService.findStudent(1);
a = activityService.find(1);
} catch (InstanceNotFoundException e) {
fail("Activity not exists");
}
activityService.enrollmentStudentInActivity(s, a);
activityService.unEnrollsStudentToActivity(s, a);
assertFalse("Student is enrolled in the activity yet", s
.getActivities().contains(a));
assertFalse("Activity has the student enrolled yet", a.getStudents()
.contains(s));
} |
96351cf7-a48b-45e3-be80-c502baf225bb | 4 | private void createMinimap() {
Graphics2D mapGraphics = null;
int mapWidth = (map.getWidth() * map.getTileWidth());
int mapHeight = (map.getHeight() * map.getTileHeight());
minimap = new BufferedImage(mapWidth, mapHeight, BufferedImage.TYPE_INT_ARGB);
mapGraphics = (Graphics2D) minimap.getGraphics();
for (int x = 0; x < map.getWidth(); x++) {
for (int y = 0; y < map.getHeight(); y++) {
for (int z = 0; z < map.getLayerCount(); z++) {
Tile t = ((TileLayer) map.getLayer(z)).getTileAt(x, y);
if (t != null) {
mapGraphics.drawImage(t.getImage(), x << 5, y << 5, null);
}
}
}
}
minimap = minimap.getScaledInstance((int) (Main.app.getWidth() * .25f),
(int) (Main.app.getHeight() * .25f), Image.SCALE_SMOOTH);
minimapCreated = true;
} |
11c6bf88-7b09-4434-87d7-c9ab085ce456 | 1 | public boolean suspend(User toSuspend, Date until){
if(isSuspended(toSuspend)) return false;
Suspended sus = new Suspended(toSuspend, until);
this.suspendedUsers.add(sus);
save();
return true;
} |
826d52c1-ffce-4f64-806a-14fc1e9629e6 | 7 | private void fillTransitions() {
transitions = new int[template.getAnswerGroups().size()];
for (int i = 0; i < template.getAnswerGroups().size(); i++) {
AnswerGroup answerGroup = template.getAnswerGroups().get(i);
int j = i + 1;
if (j >= template.getAnswerGroups().size()) {
break;
}
int size = answerGroup.getAnswers().size();
while (j < template.getAnswerGroups().size()) {
AnswerGroup anotherGroup = template.getAnswerGroups().get(j);
int anotherSize = answerGroup.getAnswers().size();
int minSize = anotherSize > size ? size : anotherSize;
boolean contains = true;
for (int m = 0; m < minSize; m++) {
if (anotherGroup.getAnswers().get(m).getQuestionNumber()
!= answerGroup.getAnswers().get(m).getQuestionNumber()) {
contains = false;
break;
}
}
if (contains) {
j++;
} else {
break;
}
}
transitions[i] = j;
}
transitions[template.getAnswerGroups().size() - 1] = template.getAnswerGroups().size();
} |
f56f5774-2193-4e7a-91a3-ab9a1483cc07 | 3 | public static void removeSelected() {
if (Main.selectedId != -1 && !Main.getSelected().locked) {
RSInterface rsi = Main.getInterface();
if (rsi.children != null) {
int index = getSelectedIndex();
rsi.children.remove(index);
rsi.childX.remove(index);
rsi.childY.remove(index);
}
UserInterface.ui.rebuildTreeList();
}
} |
a2c49b0c-c2d9-4e05-8de9-5594a6da96d2 | 7 | public static String doubleToString(double d) {
if (Double.isInfinite(d) || Double.isNaN(d)) {
return "null";
}
// Shave off trailing zeros and decimal point, if possible.
String string = Double.toString(d);
if (string.indexOf('.') > 0 && string.indexOf('e') < 0
&& string.indexOf('E') < 0) {
while (string.endsWith("0")) {
string = string.substring(0, string.length() - 1);
}
if (string.endsWith(".")) {
string = string.substring(0, string.length() - 1);
}
}
return string;
} |
c1673e8c-f14b-4b57-af7d-1695c85a6fac | 2 | public UserlistPreview(SkinPropertiesVO skin, JPanel parent) {
if ((skin == null) || (parent == null)) {
IllegalArgumentException iae = new IllegalArgumentException("Wrong parameter!");
throw iae;
}
this.skin = skin;
this.parent = parent;
} |
5bf3d6cf-a370-4acd-8f9b-e118c81cf3cc | 3 | public void handleSlider(JSlider source){
if(source.getValueIsAdjusting()){
int delay = source.getValue();
if(delay > 0){
aTimer.setDelay(100*(11-delay));
if(aTimer.isRunning()){
aTimer.restart();
}
}
else{
aTimer.restart();
}
}
} |
b6e65d9b-1112-4ac0-bd58-7dfc5d7e6ca1 | 2 | public LRParseTableDerivationPane(GrammarEnvironment environment) {
super(new BorderLayout());
Grammar g = environment.getGrammar();
augmentedGrammar = Operations.getAugmentedGrammar(g);
if(augmentedGrammar == null) return;
JPanel right = new JPanel(new BorderLayout());
// right.setLayout(new BoxLayout(right, BoxLayout.Y_AXIS));
JLabel description = new JLabel();
right.add(description, BorderLayout.NORTH);
// FirstFollowModel ffmodel = new FirstFollowModel(g);
FirstFollowTable fftable = new FirstFollowTable(g);
fftable.getColumnModel().getColumn(0).setPreferredWidth(30);
right.add(new JScrollPane(fftable));
fftable.getFFModel().setCanEditFirst(true);
fftable.getFFModel().setCanEditFollow(true);
dfa = new FiniteStateAutomaton();
// The right split pane.
controller = new LRParseDerivationController(g, augmentedGrammar,
environment, fftable, description, dfa, this);
JPanel editorHolder = new JPanel(new BorderLayout());
EditorPane editor = createEditor(editorHolder);
controller.editor = editor;
editorHolder.add(editor, BorderLayout.CENTER);
split = SplitPaneFactory.createSplit(environment, false, 0.4,
new JScrollPane(fftable), editorHolder);
split2 = SplitPaneFactory.createSplit(environment, false, 0.7, split,
null);
right.add(split2, BorderLayout.CENTER);
GrammarTable table = new GrammarTable(
new gui.grammar.GrammarTableModel(augmentedGrammar) {
public boolean isCellEditable(int r, int c) {
return false;
}
}) {
public String getToolTipText(MouseEvent event) {
try {
int row = rowAtPoint(event.getPoint());
return getGrammarModel().getProduction(row).toString()
+ " is production " + row;
} catch (Throwable e) {
return null;
}
}
};
JSplitPane big = SplitPaneFactory.createSplit(environment, true, 0.3,
table, right);
this.add(big, BorderLayout.CENTER);
// Make the tool bar.
JToolBar toolbar = new JToolBar();
toolbar.add(controller.doSelectedAction);
toolbar.add(controller.doStepAction);
toolbar.add(controller.doAllAction);
toolbar.addSeparator();
toolbar.add(controller.nextAction);
toolbar.addSeparator();
toolbar.add(controller.parseAction);
this.add(toolbar, BorderLayout.NORTH);
} |
651135ad-3f2b-4fff-837b-7fc696b3ec2c | 7 | private boolean isOverridden(ProgramElementDoc pgmdoc, String level) {
Map<?,String> memberLevelMap = (Map<?,String>) memberNameMap.get(getMemberKey(pgmdoc));
if (memberLevelMap == null)
return false;
String mappedlevel = null;
Iterator<String> iterator = memberLevelMap.values().iterator();
while (iterator.hasNext()) {
mappedlevel = iterator.next();
if (mappedlevel.equals(STARTLEVEL) ||
(level.startsWith(mappedlevel) &&
!level.equals(mappedlevel))) {
return true;
}
}
return false;
} |
6d52f1a1-48a8-45dd-a3cc-48e51c93d7f4 | 7 | @Override
public int myResource()
{
if(lastResourceTime!=0)
{
if(lastResourceTime<(System.currentTimeMillis()-(30*TimeManager.MILI_MINUTE)))
setResource(-1);
}
if(myResource<0)
{
if(resourceChoices()==null)
setResource(-1);
else
{
int totalChance=0;
for(int i=0;i<resourceChoices().size();i++)
{
final int resource=resourceChoices().get(i).intValue();
totalChance+=RawMaterial.CODES.FREQUENCY(resource);
}
setResource(-1);
final int theRoll=CMLib.dice().roll(1,totalChance,0);
totalChance=0;
for(int i=0;i<resourceChoices().size();i++)
{
final int resource=resourceChoices().get(i).intValue();
totalChance+=RawMaterial.CODES.FREQUENCY(resource);
if(theRoll<=totalChance)
{
setResource(resource);
break;
}
}
}
}
return myResource;
} |
b88ee905-bd0a-429d-b2a1-5d954b42bcad | 6 | 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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(JdlExibirAtracao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(JdlExibirAtracao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(JdlExibirAtracao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JdlExibirAtracao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
JdlExibirAtracao dialog = new JdlExibirAtracao(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
} |
6f2bcb84-6fce-4ab2-adba-6915bbfacacd | 2 | public void setTipoInteres(float tipoInteres) {
if (tipoInteres > 100
|| tipoInteres < 0) {
return;
}
this.tipoInteres = tipoInteres;
} |
e895e557-82c0-4720-a4b5-824d73840137 | 1 | public String annaSeuraava(){
if (tila == KertausmaatinTila.TYHJA){
arvoSeuraavaKerrattavaRivi();
}
return kertaaTama(moneskoRivi);
} |
6f778596-bbce-458b-9948-5f5949844fde | 1 | public void map_click_ntf(int x, int y, int btn, int mod) {
Gob pgob;
synchronized (glob.oc) {
pgob = glob.oc.getgob(playergob);
}
if (pgob == null)
return;
Coord mc = pgob.position();
Coord offset = new Coord(x, y).mul(tileSize);
mc = mc.add(offset);
wdgmsg("click", JSBotUtils.getCenterScreenCoord(), mc, btn, mod);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.