method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
7e6bd3d1-315b-44ff-afb6-5489345fc609 | 7 | public byte variance(String fileName) throws IOException {
FileInputStream is = null;
DataInputStream dis = null;
BufferedWriter br = new BufferedWriter(new FileWriter("variance_bin.txt"));
NumberFormat formatter = new DecimalFormat();
formatter = new DecimalFormat("0.000E00");
try {
is = new FileInpu... |
7f70b080-ba26-4047-b383-c2d0613ed530 | 0 | public Spielfeld(Game game) {
super();
this.game = game;
this.setFocusable(true);
} |
0c593063-bb21-4f76-999b-1078134dfcdd | 4 | private void lifeCycle() {
String s = "";
StringBuilder sb = new StringBuilder();
while (isInputActive) {
try {
s = readInput();
if (s.length()==0) {
this.isInputActive = false;
break;
}
if (this.isValidInput(s)) {
sb.append(s);
}
} catch (IOException e) {
... |
c4b95748-c2ed-44b1-8e61-e5e936788a06 | 8 | public void renderProjectile(int xp, int yp, Projectile p){
xp -= xOffset;
yp -= yOffset;
for(int y=0;y<p.sprite.SIZE;y++){
int ya = y + yp + 0;
for(int x=0;x<p.sprite.SIZE;x++){
int xa = x+xp;
if(xa< -p.sprite.SIZE || xa >= width || ya<0 || ya >=height) continue;
if(xa<0) xa =0;
... |
82dd5cda-d54e-4985-ae1b-3a166cccd928 | 0 | public synchronized void setValues(Double[] values, Double marked1, Double marked2)
{
this.values = values.clone();
this.marked1 = marked1;
this.marked2 = marked2;
repaint();
} |
2a40ef14-8c88-4a01-aca0-14ccb122487b | 8 | public StringBuilder readFromFileMethod(String fileName) {
try {
// Initialize the file input stream
FileInputStream fstream = new FileInputStream(fileName);
int count = 0;
// Get DataInputStream object
in = new DataInputStream(fstream);
br = new BufferedReader(new InputStreamReader(in));
String ... |
3d619e47-cbfe-4256-88ca-3168e957c7ef | 3 | private void addStakesToStakeTempStartingFrom(int i) {
while (lastStake() < endStake) {
if (nextStakeFitsInGeometry(i)) {
addNewStake(i);
resetLeftovers();
} else if (onlyOneStakeLeft(i)) {
addFinalStake(i);
break;
} else {
addRestOfTheGeometryToLeftovers(i);
i++;
}
}
} |
b5524b6e-1cd8-46eb-935e-6b1bff73f6c6 | 4 | @Override
public void process(Deque<String> par1Args) {
for(int i = 0; i < argc; i++){
String s = par1Args.poll();
if(s.length() < 1) continue;
if(s != null && conv.accept(s)){
vals.add(s);
} else {
throw new IllegalArgumentException();
}
}
} |
ee529a31-b812-4c92-9313-8da935f4f01f | 3 | void coverageByExons(Marker read, Marker m, String typeRank) {
// Find corresponfing transcript
Transcript tr = (Transcript) m.findParent(Transcript.class);
if (tr == null) return;
// Number of exons
int exons = tr.numChilds();
// Do we need to add new counters?
if (coverageByExons.size() <= exons) {
... |
e0d6c6a4-3b37-4172-b596-72a823dd2fd9 | 8 | private void grabBranch() {
if(Main.VERBOSE) System.out.println("[INFO] Determining current Git branch...");
BufferedReader buffRead = null;
String branch = null;
try {
Process proc = Runtime.getRuntime().exec("git branch");
buffRead = new BufferedReader... |
ed75dbf0-b2dc-412f-a5a4-fcc2c6e8b150 | 6 | private static void extractFromZip(
String szZipFilePath, String szExtractPath,
String szName,
ZipFile zf, ZipEntry ze)
{
if(ze.isDirectory())
return;
String szDstName = slash2sep(szName);
String szEntryDir;
if(szDstName.lastIndexOf(File.separator) != -1)
{
... |
35ae8dd8-e78d-483c-85b2-03cd5466f102 | 3 | private static String byte2hex(byte[] b) {
StringBuilder hs = new StringBuilder();
String stmp;
for (int n = 0; b != null && n < b.length; n++) {
stmp = Integer.toHexString(b[n] & 0XFF);
if (stmp.length() == 1)
hs.append('0');
hs.append(stmp);
}
return hs.toString().toUpperCase();
} |
c4b9ed86-6ff7-4ffd-855c-6d40d4746450 | 5 | public static void printFactorization(int num) {
int temp = num;
ArrayList<Integer> array = new ArrayList<Integer>();
while (temp != 1) {
for (int i = 2; i <= temp; i++)
if (temp % i == 0) {
array.add(i);
temp /= i;
break;
}
}
Collections.sort(array);
System.out.print(num + " = ... |
95d6616e-7a9e-44ea-8c0b-83f045192561 | 4 | private void renderBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_renderBrowseButtonActionPerformed
JFileChooser f = new JFileChooser(renderToField.getText());
File fi = new File(renderToField.getText());
if(fi.isDirectory()) {
f.setCurrentDirectory(fi... |
85e9dd92-9fa4-40b5-a0f8-20f1b5654bf4 | 4 | public void entrenar(String[][] entradas){
boolean finalizado = false;
int Pw,error, y;
this.numeroEpocasFinal = 0;
while(!finalizado){
finalizado = true;
for(int n = 0; n < entradas.length; n++){
Pw = this.desicion(entradas[n]);
y = Integer.valueOf(entradas[n][entradas[n].le... |
0827a383-de12-47d0-9c28-0c18504c0647 | 4 | public static synchronized Object evalSubL(CycAccess connection, String subl) {
Object result = null;
try {
if (CycConnection.inAWTEventThread()) {
throw new RuntimeException("Unable to communicate with Cyc from the AWT event dispatch thread.");
}
long resultMsecs = 0;
if(useTimi... |
1b8da40a-9018-4ac1-90e2-fb83199a272e | 7 | public boolean start() {
synchronized (optOutLock) {
// Did we opt out?
if (isOptOut()) {
return false;
}
// Is metrics already running?
if (task != null) {
return true;
}
// Begin hitting the s... |
2ade7ea7-a8a3-452f-9e81-4fc4bd0e0255 | 7 | private boolean waitForSelect(){
try{
while (!fNext && !fCancel){
Thread.sleep(50);
}
if (fNext){
PrintLog.Log("button was pressed");
String path = textField.getText();
File f = new File(path);
if... |
20e73061-2e08-48bb-9bf4-057d06734cc4 | 5 | private void verifyPlayersInBoard() throws Exception {
for (int row = 0; row < _board.length; ++row) {
for (int col = 0; col < _board.length; ++col) {
if (isCellEmpty(row, col)) {
continue;
}
if (_board[row][col] != _leftPlayer && _board[row][col] != _rightPlayer) {
throw new JProblemsE... |
6c6e57e9-0184-43fc-aeb0-2d02264a3ae6 | 2 | public void testToStandardDays_months() {
Period test = Period.months(1);
try {
test.toStandardDays();
fail();
} catch (UnsupportedOperationException ex) {}
test = Period.months(-1);
try {
test.toStandardDays();
fail();
... |
6d3425da-2d8e-41d7-90b6-e2d23705ec25 | 0 | public Color getGroutingColor(Color c) {
return groutingColor;
} |
a72cae46-f988-4ca9-b8aa-4553a1fa4526 | 2 | @Override
public
String toString() {
String className = this.getClass().getSimpleName();
return ((getTitle() == null || getTitle().isEmpty())? url.toString() : "[" +className+ "] " + getTitle());
} |
ea284641-74ae-4183-9eab-b160c4108a54 | 7 | private void initProjectivization(DependencyStructure pdg) throws MaltChainedException {
nodeLifted.clear();
nodeTrace.clear();
headDeprel.clear();
nodePath.clear();
isCoveredRoot.clear();
nodeRelationLength.clear();
for (int index : pdg.getDependencyIndices()) {
nodeLifted.add(false);
nodeTrace.ad... |
79388936-69fe-43a2-a3dd-88b185f43a03 | 3 | protected String readStream() throws Exception {
while (!reader.ready()) {
Thread.sleep(50);
}
String out = reader.readLine();
for (int i = 0; i < error.length; i++) {
if (out.equals(error[i])) {
throw new Exception();
}
}
return out;
} |
ea85b621-a758-4927-809e-014ebf582f5d | 4 | @Override
public final synchronized void display() {
this.slider.setMinimum(this.min);
this.slider.setMaximum(this.max);
this.slider.setValue((int) (this.value * this.factor));
this.slider.setPaintTicks(true);
this.slider.setPaintLabels(true);
this.slider.setMajorTickSpacing(this.step);
this.slider.setMi... |
5b1999c0-b379-409e-8332-c21d8b8f18e5 | 4 | public boolean deleteItem(int id, int slot, int amount) {
if (slot > -1 && slot < playerItems.length) {
if ((playerItems[slot] - 1) == id) {
if (playerItemsN[slot] > amount) {
playerItemsN[slot] -= amount;
} else {
playerItemsN[slot] = 0;
playerItems[slot] = 0;
}
resetItems(3214);
... |
3a3aa2a4-da4b-46e4-bb2c-64c18a558ba5 | 5 | @Override
public void render(Graphics g) {
if (slomoEffect > 0) {
g.setColor(new Color(0.0F, 0.0F, 0.0F, 0.051F));
} else {
g.setColor(defaultBackground);
}
g.fillRect(0, 0, Game.WIDTH, Game.HEIGHT);
g.setColor(defaultColor);
g.setFont(new Font("Courier New, Courier", 12, 12));
if (firstRun) {
... |
c792d8e5-7180-411c-8e89-403f759419cc | 2 | public int etsiOikeaX(){
int oikX = 0;
for (Palikka palikka : palikat) {
if (palikka.getX() > oikX){
oikX = palikka.getX();
}
}
return oikX;
} |
0b14ac6c-9a16-4853-910c-dc60cc4f2821 | 4 | void paintOpacityFlow(CPRect srcRect, CPRect dstRect, byte[] brush, int w, int opacity, int flow) {
int[] opacityData = opacityBuffer.data;
int by = srcRect.top;
for (int j = dstRect.top; j < dstRect.bottom; j++, by++) {
int srcOffset = srcRect.left + by * w;
int dstOffset = dstRect.left + j * width;
... |
0a1d98c8-758a-47b0-ae01-e5d76714b031 | 8 | private void sendClickBlockToController(int par1, boolean par2)
{
if (!par2)
{
this.leftClickCounter = 0;
}
if (par1 != 0 || this.leftClickCounter <= 0)
{
if (par2 && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == EnumMovingObjectTy... |
187690ab-427e-4f18-8208-8327b95a29a6 | 4 | public void test_04_Pe() {
int numTests = 1000;
Random rand = new Random(20100617);
for( int t = 0; t < numTests; t++ ) {
// Create gap
String gapStr = "";
int gap = rand.nextInt(50) + 1;
for( int i = 0; i < gap; i++ )
gapStr += "N";
// Sequence 2
int len1 = rand.nextInt(100) + 1;
Stri... |
023955a8-f140-46d4-854a-81294b0cbd69 | 8 | public static CustomButton doFileMoveButton(final File dls) {
final String title = dls.getName();
final CustomButton a = new CustomButton(title);
a.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
String root = EarningsTest.PATH_SOURCE.getText();
if ... |
1886c72e-2502-4499-a86d-2785897e7456 | 0 | public void enable() {
} |
c72b9be6-11c6-421a-a610-ea4e08be9e7b | 2 | @Override
public void setVisible(boolean b) {
if (b) {
serverTextField.setText(Config.getInstance().getHost());
int port = Config.getInstance().getPort();
if (port == 0) {
portTextField.setText("");
} else {
portTextField.setTex... |
274d4d70-c20d-4bf0-a111-455c8149e8b6 | 3 | public JSONObject putOnce(String key, Object value) throws JSONException {
if (key != null && value != null) {
if (opt(key) != null) {
throw new JSONException("Duplicate key \"" + key + "\"");
}
put(key, value);
}
return this;
} |
d21bc6dd-ad79-4cf8-8c75-feeb454df75d | 8 | protected static String parsePathForZip( String p, String parentDir )
{
if( ((p.indexOf( "/" ) != 0) || (p.indexOf( "\\" ) == 0)) )
{
while( p.indexOf( ".." ) == 0 )
{
p = p.substring( 3 );
if( !parentDir.equals( "" ) && ((parentDir.charAt( parentDir.length() - 1 ) == '/') || (parentDir.charAt( paren... |
597c92c1-6e25-4341-82d8-97a3fcf09018 | 9 | public static double[] evaluateWinningOdds(Cards[] hands, Cards board, Cards other) {
int numhands = hands.length;
double[] odds = new double[numhands];
int[] wins = new int[numhands];
int[] ties = new int[numhands];
int total = 0;
// Get a fresh deck
Cards remai... |
1407a727-7277-4d94-b1a5-48455ed4b703 | 7 | public void run() {
long lastTime = System.nanoTime();
double ns = 16666666.666666666D;
double delta = 0.0D;
double delta2 = 0.0D;
int ticks = 0;
int frames = 0;
long timer = System.currentTimeMillis();
while (run) {
long now = System.nanoTime();
delta += (now - lastTime) / ns;
delta2 += (now -... |
bf253f8f-2739-4194-a4c9-903e96703f43 | 9 | public boolean hasSpam(String text) {
String[] words = text.toLowerCase().split(" ");
for (String imp : impossibles) {
if (text.contains(imp))
return true;
}
boolean hasSpam = true;
for (String word : words) {
if (word.length() > 20)
return true;
for (String vowel : vowels) {
... |
72e448ef-1118-4316-867f-a312894a6020 | 6 | public void updateStarAnm(int k, Character plat) {
// manages vertical moving platforms
Platform tempStar = (Platform) plat;
int tempy1 = tempStar.getY();
int tempv = tempStar.getVV();
int vcount = tempStar.getVcount();
if (tempv == -1) {
if (vcount >= 100) {
tempStar.setVV(1);
}
if (vcount ... |
e68ed3bc-4742-4abc-9a0c-ab7979c707a8 | 3 | private Game createGame(String gameType) {
Game game = null;
Player playerA = null;
Player playerB = null;
if (gameType == null) {
new MemoryGameError().displayError("MainCommands - create: gameType is null");
return null;
}
if (g... |
03e7156f-3674-42fe-b5ba-1413cda5c89e | 4 | public void setBubbleRange( String bubbleSizes )
{
if( (bubbleSizes != null) && !bubbleSizes.equals( "" ) )
{
myseries.getParentChart().setMetricsDirty();
Ai ai = myseries.getBubbleValueAi();
if( ai.getWorkBook() == null )
{
ai.setWorkBook( wbh.getWorkBook() );
}
ai.changeAiLocation( ai.toStr... |
19b46cf8-1a27-47b4-85a7-c0a50a30c412 | 1 | @Test
public void kameraSeuraaOikein() {
this.k = new Kamera(0, 0);
this.p = new Pelaaja();
p.setXY(new Piste(0, 0));
for (int i = 0; i < 100; i++) {
k.seuraa(p);
}
assertTrue("Kamera ei liikkunut oikeaan x - koordinaattiin, vaan "
+ k.to... |
672919aa-605e-4074-9af5-cf92d068e176 | 4 | private void initIgnored() {
if (!fIgnore.isFile())
return;
String line;
try {
BufferedReader br = new BufferedReader(new FileReader(fIgnore));
while ((line = br.readLine()) != null) {
ignoredList.add(new File(line));
}
br.close();
} catch (FileNotFoundException e) {
// checked with ".exis... |
2de76853-c766-45d3-99b7-e389a8a49036 | 7 | private List<Tile> getShuffledTiles() {
List<Tile> shuffledTiles = new ArrayList<Tile>();
for (int i = 0; i < BEARS; i++)
shuffledTiles.add(new Bear());
for (int i = 0; i < FOXES; i++)
shuffledTiles.add(new Fox());
for (int i = 0; i < LUMBERJACKS; i++)
shuffledTiles.add(new Lumberjack(... |
abe32673-ac79-40c2-824f-2374eeace46b | 9 | void animate(int start,int end, float interpolation,ArrayList<Integer> aggNodes,boolean outlineOnly){
Integer startPosition = this.persistence.get(start);
Integer endPosition = this.persistence.get(end);
int interpolationAmt=0;
if (startPosition ==1 && endPosition ==... |
4d388015-bbc5-4216-8fc5-18a438c5a8a5 | 1 | public boolean shapeValido() {
return (numSymbol != 4 ? true : false);
} |
26dde7ef-be3f-4a41-885f-2cd4575d9c07 | 9 | public void setup() {
//To reduce pixelation
smooth();
noStroke();
//Create an PApplet ssize of 800x700
size(800, 700);
//Zooming and Panning Libaries
zoomer = new ZoomPan(this);
zoomer.setZoomMouseButton(PConstants.RIGHT);
//Get the observer, map and sizes
this.obiwan = w.getObserver();
curMap... |
27499783-0764-44d5-9621-f86e0519c8e9 | 2 | public void fullyMoveTondeuses() {
for (int i = 0; i < tondeuses.size(); i++) {
Tondeuse t = tondeuses.get(i);
Integer totalNumberOfActions = t.getActions().size();
for (int j = 0; j < totalNumberOfActions; j++) {
t.executeAndRemoveNextAction();
}
}
} |
3387dcf8-c35e-4782-9184-b325c9a0bfba | 1 | static byte[] changeLdcToLdcW(byte[] code, ExceptionTable etable,
CodeAttribute ca, CodeAttribute.LdcEntry ldcs)
throws BadBytecode
{
ArrayList jumps = makeJumpList(code, code.length);
while (ldcs != null) {
addLdcW(ldcs, jumps);
ldcs... |
ec9e13ae-3603-45aa-8e81-c0471a5f19ed | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Membergebuehr)) {
return false;
}
Membergebuehr other = (Membergebuehr) object;
if ((this.id == null && other.i... |
145b7f86-9f1e-4ef9-9e83-d4df03aadd8e | 3 | public synchronized void addBaudRate(Link link)
{
double baudRate = link.getBaudRate();
if (baudRates_ == null) {
return;
}
baudRates_.add( new Double(baudRate) );
if (bandwidth_ < 0 || baudRate < this.bandwidth_) {
this.setBandwidth(baudRate);
... |
dd6daea1-171c-416c-a152-954cfa44b7c2 | 3 | public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) {
if((flags & HEIGHT)!=0) {
this.imgHeight=height;
}
if((flags & WIDTH)!=0) {
this.imgWidth=width;
}
return(this.imgHeight<0 || this.imgWidth<0 /*|| this.imgBitsPerPixel ... |
29cf051e-df2f-4163-951a-b62120c634b5 | 4 | private void initComponents(){
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
backButton = new JButton("<");
trackSelection = new JLabel();
Dimension labelSize = new Dimension(200,50);
trackSelection.setPreferredSize(labelSize);
trackSelection.setText("Next Track... |
7d338ec7-6d37-4f0b-b092-92b610e715c5 | 5 | public void deleteElement(String value) {
ListElement index = head;
if (index.value == value) {
deleteFromBegin();
} else {
while (index.next != null) {
if (index.next.value == value) {
index.next = index.next.next;
} el... |
c1e83a4b-6a7f-496e-9c9a-0ab1d0a4e025 | 7 | private static Path getCodegenDir(CommandLine line) {
if (!line.hasOption(CODEGEN)
&& (!line.hasOption(SHOW_VALUES) && !line.hasOption(OUTPUT_MODEL))) {
printHelp(configureOptions());
System.exit(1);
}
if (line.hasOption(CODEGEN)) {
File codegenDir = new File(line.getOptionValue... |
902d6d3a-f5ac-4acc-9e2d-716c885ce0b8 | 0 | public HTMLParser(String file) {
File html = new File(file);
parseHTML(html);
} |
81b8932a-f2f8-4abc-bf3d-f06a49a48267 | 6 | public static NumberWrapper timesComputation(NumberWrapper x, NumberWrapper y) {
{ double floatresult = Stella.NULL_FLOAT;
{ Surrogate testValue000 = Stella_Object.safePrimaryType(x);
if (Surrogate.subtypeOfIntegerP(testValue000)) {
{ IntegerWrapper x000 = ((IntegerWrapper)(x));
... |
3a514818-f012-4266-93eb-2874d160d552 | 8 | public static String getOption()
{
String option = "gui";
try
{
BufferedReader r = new BufferedReader(new FileReader("config.txt"));
String line = r.readLine();
while (line != null)
{
if (line.startsWith("Option="))
... |
63feb011-4264-4948-b0e6-0772d45c0333 | 0 | @Override
public String getAcademicLevel() {
return super.getAcademicLevel();
} |
ae0cfe09-652d-441c-9075-69df2c761cc0 | 1 | public boolean matches(Operator loadop) {
return (loadop instanceof InvokeOperator || loadop instanceof GetFieldOperator);
} |
f7adbd76-0bba-4c9c-bc6a-5be4385d2ec3 | 6 | private void setUpdateStatementValues(ArrayList<Integer> keyIndexes,
PreparedStatement pstmt, String[] columns, String[] values,
Double[] doubleValues) throws MobbedException {
String[] keyColumns = addByIndex(keyIndexes, columns);
String[] nonKeyColumns = removeByIndex(keyIndexes, columns);
String[] keyVal... |
f41b3cc5-3163-4ae6-8178-3ed2bd2928eb | 0 | public SelectHTMLExportStyleDialog(Frame owner, String title) {
super(true, true, true, INITIAL_WIDTH, INITIAL_HEIGHT, MINIMUM_WIDTH, MINIMUM_HEIGHT);
// Initialize
CSS_DIR = new File(Outliner.PREFS_DIR + System.getProperty("com.organic.maynard.outliner.Outliner.cssdir", "css") + System.getProperty("file.separ... |
9780b62d-4a9f-4249-afd7-3eb4005890b2 | 2 | private int isEqualSomething(String str) {
for (int i = 0; i < list_From_file.size(); i++) {
if (((data) list_From_file.get(i)).getBinary_Code().equals(str))
return i;
}
return -1;
} |
49fd45b4-467a-4a7b-83e2-44e920d445f6 | 7 | public static void main(String[] args) {
List<Integer> abundants = new ArrayList<>();
for (int i = 1; i < 28123; i++) {
Collection<BigInteger> factors = Utils.factorize(BigInteger
.valueOf(i));
int sum = 0;
for (BigInteger factor : factors) {
sum += factor.intValue();
}
if (sum > i) {
... |
0b6ad325-f595-465f-ab19-31a257584a93 | 9 | private static int applyComboScore(String passwd, int letterScore, int numberScore, int specialScore)
{
int comboScore = 0;
// COMBOS
// [verified] both upper and lower case
if (letterScore == MIXED_IMPLIED)
{
comboScore += 2;
log.debug("2 combo points for upper and lower letters.");
}
//... |
b99e0c7f-a27d-4b2a-a69a-09b8d6286951 | 7 | public void doConversion(){
String worldName;
String fileName;
String number = "0";
String[] oldData;
String[] newData;
String[] worlds = FH.getFolders("Undo Saves");
for(int i = 0; i < worlds.length; i++){
worldName = worlds[i];
File folde... |
09f7c75d-c244-41d1-ad70-1648bda6c203 | 9 | @Override
public boolean MoveUp() {
undodata.addLast(dataClone());
undoscore.addLast(scoreClone());
initFlag();
win = false;
noMoreMoves = false;
boolean flag = true;
int count = 0;
while (flag == true)
{
flag = false;
for(int i=1; i<N; i++)
{
for(int j=0; j<N; j++)
{
if (data[i... |
0bd3f657-9567-4d55-aa55-e39e8ecd627b | 9 | public static String desencriptar(/*String passPhrase, */String str) {
Cipher ecipher = null;
Cipher dcipher = null;
try {
// Crear la key
KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), SALT_BYTES, ITERATION_COUNT);
SecretKey key = SecretKeyFactor... |
1f7708f8-df1b-4926-bf7c-00421ee6ae63 | 2 | public static int getIntFromUser(String prompt) {
while (true) {
try {
return Integer.parseInt(getUserInput(prompt));
} catch (Exception e) {
System.out.println("FUCK OFF THATS NOT A NUMBER");
}
}
} |
e6877ec9-5e1e-4f74-b329-119cf4e42f66 | 1 | public boolean matchesAndOneAbove(Card other) {
return (other.getSuit() == this.suit && this.rank.ordinal() == other.getRank().ordinal() + 1);
} |
1b1084f2-e329-46c3-8a32-6a5ce662ddeb | 8 | public void union(Set s) {
ListNode thisNode = list.front();
ListNode anotherNode = s.list.front();
while (thisNode.isValidNode() && anotherNode.isValidNode()) {
try {
Comparable thisItem = (Comparable) thisNode.item();
Comparable anotherItem = (Comparable) anotherNode.item();
if (thisItem.compareT... |
bd0f2390-702e-495c-a2dc-192b17cf773a | 7 | public void setNetwork(HaplotypeNetwork hapNet) {
this.hapNet = hapNet;
maxCardinality = 0;
maxDist = 0;
//Go through all haplotypes and create haplotypeElements for each one
ArrayList<NetworkNode> haps = hapNet.getAllNodes();
for(NetworkNode node : haps) {
Haplotype hap = (Haplotype)node;
if (hap.... |
aed5e58e-27d4-4c01-9fa2-6e878407e344 | 7 | public void onloadBrowserHandler(JavascriptContext ctx) {
String inpUrl = findUrlField().getText();
this.ctx = ctx;
// added download button
Button dload = new Button("Download");
dload.setName("Download");
dload.addActionListener(new ActionListener() {
public void actionPerformed... |
0659c72c-20ac-4830-81f1-e41bbb6d6e0d | 6 | public boolean equals(Object obj) {
if (!(obj instanceof Point))
return false;
Point point = (Point) obj;
if (this.getX() == point.getX())
if (this.getY() == point.getY())
if (this.getColor() == point.getColor())
if (this.getDotLineSize() == point.getDotLineSize())
if (this.getDotLineForme().... |
a98c5e09-81e2-4c4e-aa1e-5defd6f07b46 | 8 | public int update(MouseEvent event) {
int mask = (event.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK);
boolean buttonDown = mask == MouseEvent.BUTTON1_DOWN_MASK;
if (_pressed && !buttonDown) {
_pressed = false;
return _id;
}
if (event.getX() >= _rec... |
bedb6f51-7ccc-445e-924b-a827dafae62a | 2 | private void initOldTables() {
oldTables = new ReferenceTable[reference.getFileCount()];
for (int i = 0; i < oldTables.length; i++) {
ByteBuffer data = reference.get(i);
if (data != null) {
oldTables[i] = new ReferenceTable(i, data, null);
}
}
} |
4a58904f-2180-4a0c-965c-c36e20a976b4 | 0 | public byte[] getAuthenticatorClient() {
return authenticatorClient;
} |
e4c45471-c171-4296-82cb-daefc635582b | 8 | public String properCase(String value) {
if (value == null) {
return "";
}
if (value.isEmpty()) {
return "";
}
String[] delimiterlist = {" ", "-", "_", "'", "."};
boolean first = true;
boolean afterdelimiter = false;
String destina... |
81bb1c23-2304-4b4d-a58d-10bc02f7b1a7 | 8 | @Override
public Object getValueAt(int rowIndex, int columnIndex) {
SimpleDateFormat format = new SimpleDateFormat("HH:mm");
switch(columnIndex) {
case 0: return trains.get(rowIndex).getNumber();
case 1: return trains.get(rowIndex).getFromStation();
case 2: retur... |
75ba8d2e-64db-4e37-a1a9-432d699ba718 | 9 | @Override
public void input() {
if (Input.isLocked())
{
if (Input.getKeyDown(Input.KEY_ESCAPE))
Input.setLocked(false);
yaw(-Input.getMouseDX() * sensitivity);
pitch(Input.getMouseDY() * sensitivity);
} else {
if (Input.getMouseDown(Input.MOUSE_LEFT))
{
Input.setLocked(true);
}
... |
3c5ba3c8-015f-486c-a5f2-350da35995c1 | 3 | public void acquirePackets(final List<Packet> buffer, final int count) { //Method to hold the received packets in an arrayList of packets
//ArrayList of packets called List
final PacketReceiver receiver = new PacketReceiver() { //Declaration of a new packetReciever called receiver
@Override
public voi... |
9f8a0222-5645-4525-bd6b-35149ae50f9a | 7 | public Profile getProfile(String id) {
System.out.println("MineshafterProfileClient.getProfile(" + id + ")");
URL u;
try {
u = new URL(API_URL + "?uuid=" + id);
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
InputStream in = conn.getInputStream();
String profileJSON = Streams.toStr... |
fd44f019-7774-4527-906d-a445325ffb09 | 1 | @Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
} |
a9134b81-f483-4213-a413-40e460f6f463 | 8 | private static void updateViewTable(final String itemContent) {
/**
* itemContent is the format:
* PathToFile:::FunctionName:::Type+LineNo
*/
System.out.println("Adding from tableResult: " + itemContent);
final String[] itemColums = itemContent.split(":::");
Display display = Display.getCurrent();
... |
12cf5478-0a49-499c-9eb5-1fff9f71e5cd | 2 | public boolean interactOn(Tile tile, Level level, int xt, int yt, Player player, int attackDir) {
if (player.health < player.maxHealth && player.payStamina(staminaCost)) {
player.heal(heal);
return true;
}
return false;
} |
53a93f38-2e02-449c-ac1e-0754df684c51 | 9 | public static Stella_Object accessContextSlotValue(Context self, Symbol slotname, Stella_Object value, boolean setvalueP) {
if (slotname == Stella.SYM_STELLA_CHILD_CONTEXTS) {
if (setvalueP) {
self.childContexts = ((List)(value));
}
else {
value = self.childContexts;
}
}
... |
9c12fba8-c402-41eb-83ed-1b6b52b10e90 | 5 | public boolean isValid() {
//check for valid number of states
if (brainInstructions.size() > 10000) {
return false;
}
//check that instructions use correct syntax
int i = 0;
int j = 0;
boolean valid = true;
boolean match = false;
//iterate through each instruction and check for a match in
//the ... |
8e87e8f3-65ce-4ba5-924f-0240c1399813 | 9 | private void checkVehicletool() {
List<Integer> list = new ArrayList<Integer>();
for (Route r : Solution.getRoutes()) {
list.clear();
int vehicle = 0;
boolean b=false;
if (r.isHasType()) {
vehicle = r.getType();
}
List<Integer> vehicleTool = getToolVehicle(Instance.getFleet()
.get(vehicle... |
dd6c9837-6e27-4fa4-9857-2badd592f82c | 6 | protected void processWindowEvent(WindowEvent e) {
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
if( rosterDB.isDataChanged () || tripDB.isDataChanged() || riverDB.isDataChanged() ) {
if ( JOptionPane.showConfirmDialog(null,
"Sollen die Daten jetzt abgespeichert werden?",
"... |
a29ca178-b50f-402f-af1f-a0148e825afb | 3 | final public void And_operator() throws ParseException {
/*@bgen(jjtree) And_operator */
SimpleNode jjtn000 = new SimpleNode(JJTAND_OPERATOR);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
if (jj_2_73(3)) {
jj_consume_t... |
e1b63468-a170-4ecd-a305-be8b748558ef | 6 | public static void sortStudentsPromotion() {
if (FileReadService.sList.isEmpty()) {
System.out.println("There is no Student !");
} else if (FileReadService.pList.isEmpty()) {
System.out.println("There is no Promotion !");
} else {
System.out
.println("Do you want to sort in an Ascending Order (0)... |
68efa8a9-935d-486e-9073-cfa81ce74f79 | 0 | public Graph() {
edges = new DynamicArray();
vertices = new DynamicArray();
adjacencyList = new AdjacencyList();
directed = false;
hasNegativeWeights = false;
} |
3a5e2972-c358-4af9-8a0c-cde00f2b3fd2 | 4 | @Override
public Action choose() {
switch (this.getCurrent()) {
case 0:
return Action.MOVE;
case 1:
return Action.ATTACK;
case 2:
return Action.CAST;
case 3:
default:
return Action.CANCEL;
}
} |
395bc7b5-28ad-41c7-9dd3-a307da563cb3 | 3 | public boolean equals(Puzzle p)
{
boolean equals = true;
for(int i=0; i<9; i++)
{
for(int j=0; j<9; j++)
{
equals = equals && grid[i][j].equals(p.getGrid()[i][j]);
}
}
return equals;
} |
ebd614cb-7f75-46e4-95b3-a99b4d71aa58 | 9 | public static void main(String[] args) throws SlickException {
new AppGameContainer(new StateFreeGame("CameraTest"){
private Camera cam;
private Vector2i loc;
@Override
public void renderProcess(GameContainer arg0, Graphics arg1) {
cam.draw(arg0,arg1);
arg1.setColor(Color.gray);
arg1... |
f61afb8e-5e14-4126-a9f8-af9163604887 | 1 | public static void newTurn()
{
for(int i = 0; i < unitList.size(); i++) //Loops through all units
{
unitList.get(i).reset();
}
} |
ac44c623-3ee9-4241-810a-f2ae1ce3728d | 5 | public int searchInsert(int[] A, int target) {
int low = 0;
int high = A.length - 1;
while (low <= high) {
if (low == high) {
if (A[low] >= target)
return low;
return low + 1;
}
int mid = (low + high) >>> 1... |
2e56e681-7978-460c-924b-ced856bb3873 | 1 | @Override
public void setCurrentHp(int hp) {
if (hp > this.maxHP) {
this.curHP = this.maxHP;
} else {
this.curHP = hp;
}
} |
ba91deb6-af87-4df1-9257-a49d129e41f0 | 5 | public static void sendAdminChat( String message, Server server ) {
if ( ChatConfig.logChat ) {
LoggingManager.log( message );
}
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream( b );
try {
out.writeUTF( "S... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.