method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
56ded1c6-d82d-4c66-a5e9-fd5670967913 | 9 | public void init() throws SlickException
{
try
{
// Load main character
Image StrongGuyImage = new Image("src/res/strongguysheet.png", true);
rChar = new Player("strongguy", xChar, yChar, StrongGuyImage);
Character = rChar.getAnimation("left");
// prepare maploader
map = new MapLoader("test",... |
25f3ad3c-d684-41ba-bc25-26abbfb582cf | 3 | public boolean placeHasColor(int x, int y, PieceColor color) {
if(placeInRange(x, y)) {
Piece piece = pieces[x][y];
if(piece != null && piece.getColor() == color) {
return true;
}
}
return false;
} |
d5ad50b3-5000-4531-9656-68e171476017 | 0 | public boolean hasVoice() {
return _prefix.indexOf('+') >= 0;
} |
1c298d16-6acb-48ac-aa70-34610fa78db6 | 1 | private void resize() {
if (getParent() != null) {
((JComponent) getParent()).revalidate();
}
} |
7a1720f8-7e58-43fd-a495-0e1c9c185bcb | 5 | public void run(){
n = SIZE;
while(n>2){ /* stop the algorithm when there are only two vertices left */
/* generate two random vertices, or one edge */
do {
i = generator.nextInt(SIZE);
j = generator.nextInt(SIZE);
} while(mat[i][j] <=... |
0f7f86eb-b658-4ec5-9571-56c987dc3648 | 7 | public void paint(Graphics g) {
g.setColor(Color.red);
for (int i = 1; i <= x; i++) { // 畫縱線
g.drawLine(i * 20, 0, i * 20, 200);
}
for (int j = 1; j <= y; j++) { // 畫橫線
g.drawLine(0, j * 20, 200, j * 20);
}
int width = x + 2;
// 畫出每一格目前的狀態
for (int i = 1; i <= y; i++) { // 由上而下
int tmp = i * wi... |
53eb7fc1-2576-452c-aea0-12938459a9f8 | 3 | @Override
public boolean estFini() {
if (heros.getSante() == Sante.MORT || kidnappeur.getSante() == Sante.MORT || pasJeuCourant == getMaxPasJeu()){
return true;
}
return false;
} |
0c4629a3-6d7d-44e0-aa6f-362b1434e437 | 6 | public void run()
{
while(true)
{
for(int y = 0; y < fireGrid.length; y++)
{
for(int x = 0; x < fireGrid.length; x++)
{
if(fireGrid[y][x] <= 0 && fireGrid[y][x] > -100)
{
burnBabyBurn(x,y);
try {
Thread.sleep(2000);
} catch (Interrupte... |
def01216-30ae-45b5-995a-94c397d2891e | 3 | @Override
public void focusLost(FocusEvent arg0) {
try {
String Str = _view.edt_ID.getText();
if (!Str.isEmpty()) {
psearch(Integer.parseInt (Str));
}
} catch (NullPointerException E){
E... |
e90df3f5-f8d1-419b-8e02-44ca5d88eaff | 3 | public static void main(String[] args) throws Exception {
BackusNaur bn = new BackusNaur(new File("resources/test.bn"));
HashMap<String, TreeSet<String>> res = new HashMap<String, TreeSet<String>>();
boolean matched = bn.matches("fruit", "apple", res);
if (matched) System.out.println("matched");
... |
af3228ef-266b-4c13-8439-52fc5ce125e9 | 9 | public static final String[] getParameters(String argument, String key, String separator) throws InvalidArgumentException {
ArrayList list = new ArrayList();
if (argument == null) {
throw new InvalidArgumentException("Das angegebene Argument ist null");
}
if (key == null) {
throw new InvalidArgumentExcept... |
448c6cee-c2a6-4ef6-aac2-4e82275fb6ad | 2 | public List<Position> getPositions() {
List<Position> positions = new ArrayList<Position>();
positions.add(getPosition());
for (int i = 1; i < length; i++) {
Position pos = null;
if (direction == Direction.HORIZONTAL) {
pos = new Position(getPosition().xCoordinate + i, getPosition().yCoordinate);
... |
896c75ab-607a-48fa-a54b-6df6d63ac28f | 0 | public static FileNameFilter getExtensionNameFilter(String keyword) {
return new FileNameFilter(keyword, true);
} |
b44196cb-f648-451c-b0da-101b7e556b4b | 3 | public void refreshList () {
if ((riverListModel == null) || (MainWindow.riverDB == null))
return;
riverListModel.removeAllElements();
for (River r: MainWindow.riverDB.getAllRivers(true)) {
riverListModel.addElement( r);
}
riverList.setSelectedIndex(0);
} |
ed33aef9-68a7-4144-b7a9-e943ebe32d01 | 6 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
init();
while ((line = in.readLine()) != null && line.length() != 0) {
int t = Integer.parseInt(line.trim());
f... |
3bb20ffe-0889-4cd6-98bf-42c2ab135b7d | 5 | public Integer getWorstBorrower() {
Map<Integer, Integer> total = new HashMap<Integer, Integer>(), current;
for (Integer id : this.stock.keySet()) {
current = this.stock.get(id).getWorstBorrower();
for (Integer w : current.keySet()) {
total.put(w, total.containsK... |
469d5708-9aef-4857-a954-e923c260aacb | 5 | protected MoveResult checkresign(HantoPieceType pieceType, HantoCoordinate from,
HantoCoordinate to) throws HantoPrematureResignationException {
MoveResult result = MoveResult.OK;
if(pieceType == null && from == null && to == null) {
if(turn.equals(HantoPlayerColor.BLUE)) {
result = MoveResult.RED_WINS... |
bf902b7f-c64b-400a-97be-6ac882fc8f61 | 3 | public static void initialize_Connection_SQL()
{
try
{
Class.forName(sqlJDBCDriver);
try
{
sqlConn = java.sql.DriverManager.getConnection(SQLconnectionUrl, SQLusername, SQLpassword);
} //end inner try
catch (java.sql.SQLException e)
{
System.err.println(e);
} //end inner catch
} //e... |
085e3e36-3a6c-45a9-b927-a9186653932a | 0 | @Override
public void keyPressed(KeyEvent e) {
keyboardState[e.getKeyCode()] = true;
} |
0f0c5cfc-4246-42b9-b5ec-009f7e5b1f1b | 5 | private void handleUpcomingAbility() {
if (upcomingAbility != null) {
int numAbilities = 0;
for(AbilityType a : abilities){
if(a != null){
numAbilities++;
}
}
if(numAbilities == maxAbilities){
addAbilitySwapDialog(upcomingAbility);
}else{
for(HUD_InputListener listener : listeners)... |
aea70cb5-c4e3-4752-ab10-92d691260e89 | 8 | private void checkAdjacentNodes(Node origin) {
Node n = null;
for (int i = origin.x-1; i <= origin.x+1; i++) {
for (int j = origin.y-1; j <= origin.y+1; j++) {
n = new Node(i, j);
int dirr = directionFromAdjacentNode(origin, n);
if (dirr == 1) {
if (isValid(n)) {
n.parent = origin;
i... |
397bd1db-8989-4d9e-8365-779bd542e2f6 | 6 | public int maxDepth(TreeNode root) {
// Note: The Solution object is instantiated only once and is reused by each test case.
// bfs
if(root == null) return 0;
Queue<TreeNode> q = new LinkedList<TreeNode>();
int depth=0;
q.add(root);
q.add(null);
TreeNode currentNode;
while(q.isEmpty()==false){
curr... |
3142cb57-0673-4472-96f9-30b7e559f020 | 1 | public final Stroke getStroke() {
if (stroke == null)
stroke = new BasicStroke((float) Math.max(0.0, getLineWidth()));
return stroke;
} |
48afeaa9-47bc-4633-92bf-9e5bfee1f288 | 9 | public void run() {
while(true){
String message;
try {
message = in.readUTF();
if (message.equals("pu"))
{
int pid = in.readInt();
int x = in.readInt();
int y = in.readInt();
int hp = in.readInt();
client.game.updatePlayer(pid, x, y, hp);
System.out.println(x + " - " + ... |
bdeccf25-d2ed-4806-a9e9-7abe0fd96b33 | 9 | * </ul>
*/
public void select (int index) {
checkWidget ();
if (!(0 <= index && index < itemsCount)) return;
selectItem (items [index], (getStyle () & SWT.MULTI) != 0);
if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) {
redrawItem (index, false);
}
getAccessible().selectionChanged();
} |
78c5c77d-0dc3-4f02-a115-e2772f42131d | 7 | public Object nextContent() throws JSONException {
char c;
StringBuffer sb;
do {
c = next();
} while (Character.isWhitespace(c));
if (c == 0) {
return null;
}
if (c == '<') {
return XML.LT;
}
sb = new Str... |
e793e38f-d5f0-4d37-a89f-f7ead69692a7 | 1 | public String leiaString()
{
String linha = "";
BufferedReader entra = new BufferedReader(new InputStreamReader(System.in)) ;
try
{
linha = entra.readLine() ;
}
catch (Exception erro)
{
System.out.println("erro de entrada de dados");
... |
b3155a3b-3e20-44a2-801e-046bc72b1485 | 1 | public float getMinGain() {
GameSong gs = getCurrentSong();
if(gs != null) {
minGain = gs.getMinGain();
}
return minGain;
} |
1baf1468-5ae8-465f-9b3f-1cb72d257e10 | 4 | private static boolean isTokenMoveable(List<Boolean> moveableList){
boolean result = false;
int count = 0;
for(int i=0; (i < moveableList.size()) && !result; i++){
if(!moveableList.get(i)){
count++;
if(count == 2) result = true;
}
}
return result;
} |
ca35379e-7015-4d79-b899-c4bc95b08cbb | 8 | protected final void initUI()
{
// initialize window manager:
wm = new WindowManager();
// initialize a layout manager:
setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
// set up FileChooser for this class:
fc = new JFileChooser();
fc_filter = new ... |
3f694d9d-3407-4204-ad4b-610fba2998df | 6 | @Override
public Object receiveData(Identifiable data) {
Object result = GenericResponses.ILLEGAL_DATA;
if (data instanceof DataPacketImpl) {
final DataPacketImpl dp = (DataPacketImpl) data;
final Object innerData = dp.getData();
if (innerData instanceof Message)... |
ecbee27c-f702-4e5a-a789-eec03599d769 | 5 | public final boolean hasLocalSlot() {
return opcode == opc_iinc || opcode == opc_ret || opcode >= opc_iload
&& opcode <= opc_aload || opcode >= opc_istore
&& opcode <= opc_astore;
} |
0d0095fb-a66e-464a-8345-5b8f5a767a28 | 2 | public static void printelementListArray() {
for (int x = 0; x <= totalElements - 1; x++) {
for (int y = 0; y <= totalElements - 1; y++) {
System.out.print(elementListArray[x][y] + ", ");
}
System.out.println();
}
} |
bb1ee66d-65c8-4e2b-8d19-c89737e3227e | 7 | @Test
public void resolve() {
int[] data=new int[11];
data[1]=1;
for(int i=2;i<=10;i++){
data[i]=i*data[i-1];
}
int count=999999;
List<Integer> positions=new ArrayList<>();
for(int level=10;level>1;level--){
int pos = count/data[level-1];
positions.add(pos);
count=count-pos*data[level-1];
}... |
2fbcd899-1914-435b-a5a9-39492a9b743a | 0 | public int getSizeRank() {return this.sizeRank;} |
b11c8999-ba0d-4554-9b08-5335e0aed4da | 3 | public static void main(String[] args) {
/*
String f = "pidof apache2";
f = CommandSystem.exec(f).trim();
String[] ff = f.split(" ");
for (String s : ff) {
System.out.println("s =" + s+"=");
}*/
/*
String f = "smshilo";
f = CommandSystem.exec(f).trim... |
e00cd5b0-b48a-41da-8a42-1f3d97685e82 | 8 | public boolean hasCycle(ListNode head) {
//if no elements are there, there cannot be a cycle
if (head == null)
return false;
//If its just one element, there cannot be a cycle
if (head.next == null)
return false;
//If there are just two elements, we cann... |
ee49cd75-9a83-4cdb-b2fb-74ca957c5c90 | 5 | private void onSaveAs() {
ImagemIFrame frame = getSelectedFrame();
if (frame == null)
return;
if (frame.getFile() != null)
getSaveDialog().setSelectedFile(frame.getFile());
if (getSaveDialog().showSaveDialog(this) != JFileChooser.APPROVE_OPTION)
ret... |
826038f0-36cf-4843-86bf-b75912381458 | 6 | public void nqueen(List<String> l,int startI,int startJ,int cnt,List<List<String>> solutions){
int n = l.size();
if(n==cnt){
if(!solutions.contains(l)) {
solutions.add(l);
}
return;
}
// int lastI = -1,lastJ = -1;
for(int i=startI;i<n;i++){
for(int j=startJ;j<n;j++) {
int res = canSetQ( l, ... |
25bb7951-6073-4a1a-806a-c9a6a34fb331 | 8 | private Location closestMate()
{
Location route;
int movementcol;
int movementrow;
int closest = 999999;
Location mate = null;
Field field = getField();
if(field.getAllCompatibleActors(this)!=null && mate() == false) {
List<Location> all = field.getAllCompatibleActors(this)... |
e2ed5f83-73d7-4752-9322-49ded7d48bf2 | 3 | public boolean intersects(Box that) {
return !(
that.min.x() > this.max.x() ||
that.max.x() < this.min.x() ||
that.min.y() > this.max.y() ||
that.max.y() < this.min.y()
);
} |
d330a17e-88df-4cfc-b817-3defba8513a8 | 0 | public int getRemainingSize() {
float finalDecay = 0.01f;
// derived from Math.pow(decay,x) <= finalDecay
int numRemainingBuffers = (int)Math.ceil(
Math.log(finalDecay) / Math.log(decay));
int bufferSize = delayBuffer.length * 2;
return bufferSize * numRemainingBuffe... |
ba1b21ab-c3e4-4f93-b76f-058af1f071d3 | 6 | private void addTerrain(Terrain t) {
int imax = 0;
int disp = 0;
switch (t) {
case PLAINE:
imax = 0;
disp = 0;
break;
case FORET:
imax = 5;
disp = 3;
break;
case DESERT:
imax = 3;
disp = 2;
break;
case MONTAGNE:
imax = 3;
disp = 1;
break;
case VILLE:
imax = 3;
... |
e2c43acb-51e5-4081-940b-35044240d33f | 6 | public boolean liesToClose(ForbiddenZone fz, Difficulty diff) {
int a = GetConfigByDiff.setRecAccuracy(diff)*2;
for (Point point:this.data){
double x1 = point.getX();
double y1 = point.getY();
if ((Math.abs(fz.getX()-x1)<a) || (Math.abs(fz.getY()-y1)<a) || (Math.abs(... |
cb599a42-15c3-4d2e-b14c-a66f9124b96d | 2 | public boolean isValidFor(int[] test_coords) {
assert (test_coords.length == 3);
for (int d=0; d<3; d++) {
if (Math.abs(test_coords[d] - coords[d]) > margin[d])
return false;
}
return true;
} |
97bb2f34-8ecb-4413-aa50-4afdd0678486 | 5 | public int getNumberOfThings(int Index)
{
if (Index == 1)
{
return numberOfRedies;
} else if (Index == 2)
{
return numberOfPinkies;
} else if (Index == 3)
{
return numberOfOrangies;
} else if (Index == 4)
{
return numberOfBiggies;
} else if (Index == 5)
{
return numberOfBlocks;
... |
b50926db-2b2b-4a42-9a17-072e98673dd5 | 8 | private Point imageMatching(Mat source, Mat template)
{
//TODO source greater than template -> resize?
if(source.cols() < template.cols())
{}
if(source.rows() < template.rows())
{}
Mat sourcePolar = new Mat(source.rows(), source.cols(), source.type());
Mat templatePolar ... |
35dcd07c-aafb-48cb-b312-02ad6c34c5d9 | 7 | public static void startupStellaSystem() {
synchronized (Stella.$BOOTSTRAP_LOCK$) {
if (Stella.currentStartupTimePhaseP(0)) {
if (!(Stella.systemStartedUpP("stella", "/STELLA"))) {
Stella.startup(false);
}
}
{ Object old$Module$000 = Stella.$MODULE$.get();
Object o... |
1402caf8-db0a-4b36-bb9c-f86d5e881672 | 7 | public static World generateWorld() {
World world = new World();
for(int i = 0 ; i < 200 ; i ++){
for(int j = 6 ; j < 15 ; j ++){
world.addBlock(i, j, new AirBlock());
}
for(int k = 200; k>=0; k--) {
double r = ... |
4fdececb-0812-45a4-9244-949024266f20 | 3 | public boolean saveSign(Location signLoc, int liftID, int floor){
int i=1;
while(signConfig.get("signs." + i)!=null){
if(signConfig.get("signs." + i + ".liftID")!=null){
i++;
}else{
break;
}
}
signConfig.set("signs." + i + ".liftID", liftID);
signConfig.set("signs." + i + ".stockwerk"... |
f6e8acaa-5076-4a81-9671-bc341efe3ce3 | 9 | public void setData(Instances instances) throws Exception {
// sync order of variables
int [] order = new int [getNrOfNodes()];
for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
String sName = getNodeName(iNode);
int nNode = 0;
while (nNode < getNrOfNodes() && !sName.equals(instances.attribute(nNode... |
b9af52f4-9f14-4eef-9b85-327d43caf93c | 5 | @Raw @Model
private void setCurrentActionPoints(int actionPoints) {
int oldAP = this.currentActionPoints;
this.currentActionPoints = (actionPoints <= 0) ? 0 : Math.min(actionPoints, getMaximumActionPoints());
if (actionPoints <= 0 && oldAP > actionPoints && this.getWorld() != null && this.getWorld().getActive... |
48c1ddb4-041c-48ee-80ab-a8dbffcae992 | 6 | public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int Q = sc.nextInt();
sc.nextLine();
while (Q > 0) {
Q--;
int male = 0, female = 0;
String s = sc.nextLine();
for (int i = 0; i < s.length(); i++) {
... |
dae83ef2-e427-48a6-bdb9-fb183c0fdf10 | 2 | private String[] filterColumns(Field[] fieldNames) {
ArrayList<String> columns = new ArrayList<String>();
for (int i = 0; i < fieldNames.length; i++)
if (!columnFilter.contains(fieldNames[i].getName()))
columns.add(fieldNames[i].getName());
return columns.toArray(new String[columns.size()]);
} |
dac645cd-65aa-4374-8138-b0d48f180c5e | 3 | public int sample(double[] prob, int[] probs_ids)
{
int i=0;
int indSample=0;
boolean found=false;
double rand=random.nextDouble();
while(i<prob.length && !found)
{
rand=rand-prob[probs_ids[i]];
if(rand<0)
{
indSample=probs_ids[i];
found=true;
}
i++;
}
return indSample;
} |
0c33d460-abbe-4951-b27e-b78beea5afd3 | 1 | public void test_now_nullDateTimeZone() throws Throwable {
try {
MutableDateTime.now((DateTimeZone) null);
fail();
} catch (NullPointerException ex) {}
} |
8944256d-185b-45ef-ba07-acc67da6cc86 | 7 | public Object tooltip(Coord c, boolean again) {
Slot slot = bhit(c);
Resource res = (slot == null) ? null : slot.getres();
long now = System.currentTimeMillis();
if ((res != null)
&& ((res.layer(Resource.action) != null) || (res
.layer(Resource.tooltip) !=... |
bd4f14ce-158e-4f05-ac37-ad0cddfb819e | 4 | public Plant(int pType) {
plantType = pType;
if (plantType == GREEN_PLANT) {
energy = 100;
} else if (plantType == RED_PLANT) {
energy = 50;
} else if (plantType == YELLOW_PLANT) {
energy = 70;
} else if (plantType == MAGENTA_PLANT) {
energy = 90;
} else {
energy = 0;
}
} |
2008dfb1-4ace-4d8f-a521-2fca15fc424c | 1 | public Iterator<String> getIterator() {
Set<String> set = attributes.keySet();
if (set == null)
return null;
return set.iterator();
} |
b78176e9-9419-48c8-aa34-84b7b9553b77 | 1 | @Override
public int attack(double agility, double luck) {
if(random.nextInt(100) < luck)
{
System.out.println("I just spiked the enemy with some earth!");
return random.nextInt((int) agility) * 2;
}
return 0;
} |
9fa3f324-e406-414e-8f19-00c5f46fd8e6 | 1 | public boolean isEmpty() {
return unit == null && !hasStatus(TileStatus.Type.BLOCKED);
} |
2b633536-1099-4fdc-9637-e55ab0408d33 | 6 | public boolean moveForward()
{
if (currentCar != null && forward != null && forward.currentCar == null && ((light != null && light.isGreen()) || light == null)) {
currentCar.setCurrentPosition(forward);
forward.currentCar = currentCar;
currentCar = null;
retur... |
776e86e9-d1d9-4076-901e-5d5dec6d50dc | 6 | @Override
public void mouseClicked(final MouseEvent e) {
this.e = e;
player.setActivityTimer(1000);
//if(player.getActivityTimer()==0){
new Thread(new Runnable(){
@Override
public void run() {
DancefloorOverlay overlay = (DancefloorOverlay)((JLabel) e.getSource()).getParent();
overlay.pr... |
f07c27a2-d18e-482e-b1dc-31f4d4842445 | 8 | @Test(dataProvider = "regCSVDataBB_club", dataProviderClass = BBRegistrationDataClub.class, enabled=true)
public void newClubRegistrationUsingCSVFile(BBRegistrationDataClub registrationData) {
Log.startTestCase("newClubRegistrationUsingCSVFile");
driver.get(appURL);
Log.info("URL accessed");
Home newHome = Pag... |
ba688ae3-f41b-42bd-89d1-da7b74910393 | 5 | @SuppressWarnings("unchecked")
public HashMap<Integer, Integer> loadDurabilityFromFile() {
if (!durabilityFile.exists() || plugin.getListener() == null || plugin.getListener().getShieldDurability() == null) {
return null;
}
new File(directory).mkdir();
HashMap<Integer, Integer> map = null;
Object result... |
f47e199f-7b4a-4697-b202-ba06e999c0a2 | 5 | private void searchNearestRecursively(double[] vec, KDTreeNode root){
if(root == null)
return;
int split = root.split_dimension;
double dist = MatrixUtils.calcDist(vec, root.vec);
if(dist<nearestDistance){
nearestDistance = dist;
nearestData = root.vec;
}
if(vec[split]<=root.vec[split])
searchNe... |
6cf738cf-3dbb-48bb-850c-772ea890a330 | 7 | private void setExtraStoryFieldVisibility() {
boolean displayExtra = storyIndividualFileRadioButton.isSelected();
boolean displayThird = ((Integer)storySpinner.getValue()) == 3;
if (displayExtra) {
sourceFileLabel.setText("First Story File:");
this.sourceFileNameButton.setToolTipText("S... |
72ba863d-0968-424a-9e6b-c056345fbb0b | 0 | public void foam() {
append(" foam()");
} |
bc1e375d-4c72-49a2-b3fe-aa095831aa7d | 4 | public void run()
{
String[] xsplit = x.split("::");
//Verifies that the argument has a username and password.
if(xsplit.length < 3)
{
System.err.println("Error with argument " + x);
LolDataServer.log.severe("Error with argument " + x);
System.err.println("Ignoring that argument...");
LolDataSer... |
66514eb8-d4c8-4a7b-a263-d9090f2d2624 | 9 | public static long findThePrime(int index) throws InterruptedException{
if(1==index){//the first factor is 2
return 2;
}
if(2==index){//the second factor is 3
return 3;
}
int count = 3;//the count of factors have found
long factor = 5;//the value which try
long lastFactor = 5;//the largest factor
... |
ff5afee6-6ff9-443e-9867-b26549266188 | 7 | public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals(KeyMapper.MOVE_BACKWARD)) {
backward = isPressed;
} else if (name.equals(KeyMapper.MOVE_FORWARD)) {
forward = isPressed;
} else if (name.equals(KeyMapper.MOVE_RIGHT)) {
right = ... |
4d08e41b-8563-4945-988c-d3c082bcbe44 | 5 | @Override
public void run() {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
while (ejecution) {
ventanaReproduccion.terminoTablero();
try {
Thread.sleep(70);
} catch (InterruptedException e) {
e.printStackTrace();
}
ventanaReproduccion.pintarLet... |
5bda1107-f2f0-465e-9fdf-a47ba16cee8a | 6 | @Override
public synchronized void run() {
try {
logger.debug("Updating server heartbeat timestamp...");
Connection dbConnection = DbHelper.getMainDb().getConnection();
if (dbConnection == null) {
logger.error("Error connecting to database when trying to update heartbeat timestamp. Timestam... |
3c86dd71-76f8-4fab-b067-9254794010d7 | 6 | public Token simpleExpr() throws OperazioneNonValidaException, ParentesiParsingException
{
Token t = peek();
if(t.ritornaTipoToken().equals(Tok.LEFT_PAR))
{
consume();
Token result = expr();
try
{
if(point>text.size()-1||!peek().ritornaTipoToken().equals(Tok.RIGHT_PAR))
throw new ParentesiPars... |
129be5ab-47f8-49b7-bb97-ca9bbb70e604 | 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://down... |
ca54827e-6a4f-4b53-aa9a-ab8ca0f9d9ec | 5 | public static int removeDuplicates(int[] A) {
if (A.length >= 2) {
int i = 0;
int j = 1;
int dump = 1;
while (j < A.length) {
if (A[j] == A[i]) {
j++;
dump++;
} else {
if (dump >= 2) {
A[++i] = A[j - 1];
A[++i] = A[j++];
dump = 1;
} else {
i = i + dump;
... |
a2c26edb-eb92-452d-8b5a-a42be719b91d | 2 | public FunctionStatement(Symbol name, Tree paramList, Tree compoundStatement){
this.name = new Identifier(name.getValue(),-1,current_block + " : func");
it.addIdentifier(this.name);
this.paramlist = paramList;
this.compoundStatement = compoundStatement;
this.lableLast = Tree.getNextLabel();
this.returnAddre... |
a5a34e7c-1ec7-4787-8401-118f9ece282b | 6 | public static void main(String args[]) {
SimpleLAnalyzer tokeniser;
if (args.length == 0) {
System.out.println("Reading from standard input . . .");
tokeniser = new SimpleLAnalyzer(System.in);
} else if (args.length == 1) {... |
70ade518-410a-420b-a39d-e5bad9eabdc0 | 9 | public int probe(int x, int y) {
if (finished)
return look(x, y);
else if (x < 0 || x >= c || y < 0 || y >= r)
return OUT_OF_BOUNDS;
else if (mark_map[y][x])
return MARKED;
unprobed_map[y][x] = false;
if (mine_map[y][x] < 0) {
if (realrules) {
// find non-mine
int tx,ty;... |
ef7d9ac7-28c2-4d27-ae74-f812013366ae | 6 | boolean isRegularForStatement()
{
int curTok = 1;
Token tok;
tok = getToken(curTok++);
if ( tok.kind != FOR ) return false;
tok = getToken(curTok++);
if ( tok.kind != LPAREN ) return false;
while (tru... |
af00db05-2eaf-496f-9e9d-e3f031d0c1c9 | 7 | public static void addWorld(World world) {
if (world == null) {
if (ChristmasCrashers.isDebugModeEnabled())
System.err.println("Failed to add world - null World object provided.");
return;
}
if (world.getID() < 0 || world.getID() > 4) {
if (ChristmasCrashers.isDebugModeEnabled())
System.err.print... |
05ee3a4a-4251-4806-87bc-219bf234f9fc | 3 | public Boolean isFollower(String playerName, String targetName) {
String patronName = plugin.getPatron(targetName);
// plugin.info("isYourFollower1 "+targetName +" > " + patronName);
// String patronChain = targetName + ">" + patronName;
int i = 0;
while (true) {
if (patronName == null)
break;
... |
4ba61493-e3db-4b51-9a84-c197934bc681 | 1 | public final int[] getOrder() {
return mPrimary ? PRIMARY_ORDER : SECONDARY_ORDER;
} |
5ea16895-463f-47c1-9af4-f74a8bb694c5 | 1 | public static double getPoints(Player p) {
if(warnLevel.get(p) == null){
addPlayer(p);
}
return warnLevel.get(p);
} |
fc80b2df-3c3c-4ee9-8f47-5ec6d359b7da | 4 | static String getPlatformFont() {
if(SWT.getPlatform() == "win32") {
return "Arial";
} else if (SWT.getPlatform() == "motif") {
return "Helvetica";
} else if (SWT.getPlatform() == "gtk") {
return "Baekmuk Batang";
} else if (SWT.getPlatform() == "carbon") {
return "Arial";
} else { // photon, etc ...
... |
17b052ba-230a-4275-abb6-d8c3a32a5453 | 4 | public void keyPressed(KeyEvent e) {
// if we're waiting for an "any key" typed then we don't
// want to do anything with just a "press"
if (game.isWaitingForKeyPress()) {
return;
}
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
game.setLeftPressed(true);
}
if (e.getKeyCode() == KeyEvent.VK_RIGHT)... |
a9df1ee8-0923-4e6a-aa87-554dd7477968 | 7 | public boolean put(int column) {
if (p) System.out.println("put " + column + "(num listeners = " + listeners.size() + ")");
if (getRules().getGameVariant() != 3) {
System.out.println("Column " + (column+1) + " played.");
} else {
System.out.println("Column " + ((column&3)+1) + "-" + (char)('A' + (column>... |
1a96533e-c610-44d6-90e8-ebd3bf031602 | 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://down... |
5db5b8d1-8647-4b60-80a9-57f040b46f29 | 0 | @Override
public String toString() {
return "id=" + id +",name=" + name;
} |
e101765f-0d36-4c1c-9812-1ee01fe9d671 | 6 | @Override
public int visibleCell(int row, int column) {
switch (column) {
case 0:
if (row == -1) {
return -1;
}
SpanInfo si1 = columnMap.get(0).get(row);
return si1.row;
case 1:
case 2:
case 3:
case 6:
SpanInfo si2 = columnMap.get(2).get(row);
return si2.row;
default:
return row;... |
a8e3b067-497b-4bf0-abf1-9257bc8570a1 | 9 | public MindMapNode addNew(final MindMapNode target, int newNodeMode,
final KeyEvent e) {
final MindMapNode targetNode = target;
MindMapNode newNode = null;
switch (newNodeMode) {
case MindMapController.NEW_SIBLING_BEFORE:
case MindMapControl... |
836b471f-eeb5-40e8-b16e-0fe2b7c90d3b | 4 | public static void main(String[] args) {
System.out.print("Ingrese su edad: ");
Scanner Scanner = new Scanner(System.in);
int edad;
edad= Scanner. nextInt();
if (edad<=18)
System.out.println("Menor de edad");
else if (edad<=30)
System.out.println("Joven");
else if (edad<=50)
System.out.println... |
435b3c84-4a14-4899-8a3f-341ae586033b | 7 | protected boolean addLand(Point point)
{
if (point.x < 0 || point.x >= WIDTH || point.y < 0 || point.y >= HEIGHT)
return false;
else
{ // random land tile (same as in constructor)
int random = (int)(Math.random()*10);
if (random == 2 || random == 9)
campus[point.x][point.y] = new Tile(Tile.Type.GRAS... |
568a8ad5-4ca1-4190-95be-e12a4c63b0b0 | 4 | public void visitNegExpr(final NegExpr expr) {
expr.visitChildren(this);
genPostponed(expr);
if (expr.type().isIntegral()) {
method.addInstruction(Opcode.opcx_ineg);
} else if (expr.type().equals(Type.FLOAT)) {
method.addInstruction(Opcode.opcx_fneg);
} else if (expr.type().equals(Type.LONG)) {
met... |
889021e4-ebcb-4352-b9ae-63b9f3ce7bec | 8 | public double[][] predictIntervals(double conf) {
// Update the bandwidth
updateBoundariesAndOrWeights();
// Compute minimum and maximum value, and delta
double val = Statistics.normalInverse(1.0 - (1.0 - conf) / 2);
double min = m_TM.firstKey() - val * m_Width;
double max = m_TM.lastKey() + v... |
a2e00393-aacd-47da-86bd-16033f8e5d55 | 5 | @Override
public void keyPressed(int key, char c) {
// EnterSpaceŊm&폜
if ( key == Keyboard.KEY_RETURN || key == Keyboard.KEY_SPACE ) {
if ( !"".equals(text) ) {
inputString(text);
}
changeText("");
// BackSpaceňꕶ폜is[g͂Ȃj
} else if ( key == Keyboard.KEY_BACK ) {
changeText(text.substring(0, Math... |
081d625a-c908-4f81-8446-693a05d86daa | 8 | private Document execute(HttpMethod method) throws ClientException, ApiException {
try {
method.setRequestHeader(
"User-Agent",
"Java Viddler API Client/" + CLIENTVERSION + " (" + System.getProperty("os.name") + " "
+ System.getProperty("os.version") + "; Java " + System.getP... |
d1b0d53f-a533-4e91-81e0-30bdadb0fbe7 | 4 | public static Ptg calcNormInv( Ptg[] operands )
{
try
{
double p = operands[0].getDoubleVal();
if( (p < 0) || (p > 1) )
{
return new PtgErr( PtgErr.ERROR_NUM );
}
double mean = operands[1].getDoubleVal();
double stddev = operands[2].getDoubleVal();
if( stddev <= 0 )
{
return new Pt... |
1c5d3f2e-71d7-4d5a-a1ee-668c7f5158c0 | 6 | @SuppressWarnings("deprecation")
private boolean checkFail(String text) {
if (text.length() != 5) return true;
if (!Character.isDigit(text.charAt(0))) return true;
if (!Character.isDigit(text.charAt(3))) return true;
if (!Character.isJavaLetter(text.charAt(1))) return true;
if (!Character.isJavaLetter(text.c... |
bda79e05-91f7-4614-aafd-3f2f94a20db8 | 3 | public List<Material> findOriginalMaterials(String xunhao){
List<Material> materialsTemp=new ArrayList<Material>();
for (Material material : materials) {
if(material.getXunhao().equals(xunhao)&&material.getYouxianji().equals("1")){
materialsTemp.add(material);
}
}
return materialsTemp;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.