method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
792d365a-8dd8-4f3a-9b8f-db86dae35142 | 2 | public void die() {
this.animation = death;
if(!dead){
if (isCat()){
SoundLibrary.playSound("catdead.wav");
} else {
SoundLibrary.playSound("dogdead.wav");
}
death.start();
}
dead = true;
} |
fb803ed2-b2f8-497f-ba27-ef79f5f95be0 | 4 | public List<String> process(String query) throws IncorrectQueryException {
StringReader reader = new StringReader(query);
String sqlQuery = "";
String next = nextTerm(reader);
int count = 0;
while (!next.isEmpty()) {
++count;
i... |
dc99ccb1-6a0c-4596-b6c4-584f4ce13408 | 8 | public HashMap<String, ArrayList> income(Double amount)
{
HashMap<String, ArrayList> result = null;
int raw_amount = new Double(amount * 100).intValue();
try
{
List<String> commands = new ArrayList<String>();
commands.add("/bin/bash");
commands.ad... |
2c51240e-a7c9-46dc-a29c-e7d85774a9ff | 9 | public double calculateScore(ArrayList<seed> seedlist) {
double total = 0.0;
for (int i = 0; i < seedlist.size(); i++) {
double score = 0.0;
double chance = 0.0;
double totaldis = 0.0;
double difdis = 0.0;
for (int j = 0; j < seedlist.size(); j++) {
if (j != i) {
totaldis = totaldis + Math.p... |
8cbe07cc-0fa3-4483-ab38-23ae7f82f062 | 2 | private static int[] getColorOccurrences(Image image, ChannelType color) {
int[] dataset = new int[Image.MAX_VAL + 1];
for (int x = 0; x < image.getWidth(); x++) {
for (int y = 0; y < image.getHeight(); y++) {
dataset[(int) Math.floor(image.getPixel(x, y, color))]++;
}
}
return dataset;
} |
e011cc49-a3fa-4c84-8645-27c15d104c65 | 6 | public void removeItem(Item item, int amount) {
if (amount <= 0 || item.getMaxStackSize() == 0) return;
int totalAmount = getItemAmount(item);
int amt = (amount <= totalAmount ? amount : totalAmount);
int stackIndex;
while (amt > 0) {
stackIndex = getItemStackIndexBa... |
a0bec99c-1877-45bd-8dac-17665d8e0a8c | 9 | protected boolean isPrimitiveValue(Object value)
{
return value instanceof String || value instanceof Boolean
|| value instanceof Character || value instanceof Byte
|| value instanceof Short || value instanceof Integer
|| value instanceof Long || value instanceof Float
|| value instanceof Double || v... |
0a713bb4-4d66-42c7-a9bc-0cd1b078d8cb | 8 | private UncaughtExceptionDialog(Dialog.ModalityType modalityType, String s, UncaughtExceptionParameters params) {
setResizable(false);
setTitle(params.getTitle());
setIconImage(params.getDialogIconImage());
setModalityType(modalityType);
setDefaultCloseOperation(DISPOSE_ON_CLOSE)... |
7a68a5a0-4488-4a06-8c39-8fe42fa073e7 | 3 | @Override
public void insertString(int offs, String str, AttributeSet a)
throws BadLocationException {
if (str == null)
return;
StringBuilder sb = new StringBuilder();
if (((getLength() + str.length()) <= limit)) {
if (test(str)){
super.insertString(offs, str, a);
... |
4260274b-f5c3-4d46-bb69-a85c6453886c | 8 | private void checkResources() {
int level = 0;
int needed = 0;
int[] levels;
int[] resourcesInLevels;
Resource resource = null;
ResourceType resourceType = null;
for (int i = 0; i < resourceTypes.size(); i++) {
resourceType = resourceTypes.get(i);
... |
eb7f9bd8-f421-41c4-8dea-8a4e36c4e101 | 4 | public TreeNode searchFirstCommonAncestor(TreeNode a, TreeNode b) {
ArrayList<TreeNode> pathA = searchReturnPath(tree.root, a,
new ArrayList<TreeNode>());
ArrayList<TreeNode> pathB = searchReturnPath(tree.root, b,
new ArrayList<TreeNode>());
TreeNode tmp=tree.root;
int i=0;
while(true){
if(i>=pathA... |
544a4c44-a2c5-4440-8eec-b7433eec33e9 | 5 | @Override
public void clearCache()
{
if (!clearLocalCacheOnly)
{
for (Painter<T> p : painters)
{
if (p instanceof AbstractPainter)
{
AbstractPainter<?> ap = (AbstractPainter<?>) p;
ap.clearCache();
}
}
}
super.clearCache();
} |
d6053023-6729-443d-a5e6-01aae7d8b08d | 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 in... |
b743f547-7eb0-4467-863e-54c2cc09b21d | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Bigram other = (Bigram) obj;
if (word1 == null) {
if (other.word1 != null)
return false;
} else if (!word1.equals(other.word1))
retur... |
ee67508f-751a-42d1-93c7-d3deea7157ef | 1 | public static boolean isEffectivelyResting(Matter matter) {
return matter.getVerticalVelocity() < 0.1 && matter.getHeight() < 0.1;
} |
c0978099-8f24-4805-83c1-f76ad20435e8 | 3 | private int jjMoveStringLiteralDfa13_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjMoveNfa_0(0, 12);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
return jjMoveNfa_0(0, 12);
}
switch(curChar)
{
case 45:
return jjMoveStringLiter... |
3fc442b7-1a1f-4277-8050-a2bfc8794b0c | 5 | public void updateEdgeFlow(String src, String dest, int newFlow) {
boolean found = false;
Vertex v = vertexMap.get(src);
for (Edge e : v.adj) {
if (e.dest.name.equals(dest)) {
e.flow += newFlow;
found = true;
break;
}
... |
78ef81f5-1d14-4384-bd19-aff5383a9052 | 9 | private void markExploredCell(String descriptor) throws ArenaMapException {
String binStr = null;
try{
binStr = hexToBinaryStr(descriptor);
}catch(NumberFormatException e){
throw new ArenaMapException(2, "The descriptor contains some non-hex digit");
}
if(binStr.length() != this.rowCount * this.colu... |
64c38270-2f23-45d6-baa3-625564bb4fcf | 6 | private void createGUIComponents(int players) {
table = new Table();
hand = new CardViewer(new InSearcherMouseAdapter(Zone.HAND));
playersInfo = new PlayerInfo[players];
for (int i = 0; i < playersInfo.length; i++) {
playersInfo[i] = new PlayerInfo(i, "...waiting...");
... |
41074f93-f0ff-463e-b978-86c258121174 | 4 | private static boolean check(final double value) {
if (Double.isNaN(value)) {
if (Debug.DEBUG) {
System.out.println("NaN occurs.");
}
return false;
}
if (Double.isInfinite(value)) {
if (Debug.DEBUG) {
System.out.prin... |
d582e320-4c09-4f9a-a816-73f221b5937e | 5 | public void filter(byte[] samples, int offset, int length) {
if (source == null || listener == null) {
// nothing to filter - return
return;
}
// calculate the listener's distance from the sound source
float dx = (source.getX() - listener.getX());
float ... |
d5395ede-b04f-4692-8338-3f0c01bb84bf | 7 | public static void main(String[] args) throws Exception {
/** main method does the following:
* setup logging
* read and process commandline args
* fire CreateNewHrisPersonList()
* generates list of HRIS uri's
* fire IterateThroughHrisPersonList()
* iterates through list and fires proces... |
0bb1355c-1c8e-487c-8db8-ab6d03b26d28 | 2 | public String recorreIteractivo(){
String resultado = "";
if(this.inicio == null){
return "Lista vacia";
}else{
Nodo<T> nodoQ = this.inicio;
while(nodoQ != null){
resultado = resultado + nodoQ.getInfo().toString() + "->";
nodoQ = nodoQ.getLiga();
}
}
return resultado + "null";
} |
7c8668a4-a4b5-4479-a4b5-0c178fbe5cfc | 4 | public void update(int x, int y, int button){
if(collides(x, y)){
setHover(true);
if(button != -1) setPressTime(5);
}else setHover(false);
color = 0xff505050;
if(hover) color = 0xff303030;
if(pressTime > 0){
color = 0xff505050;
pressTime--;
}
} |
06d0d7ed-6054-424f-b9a6-fc3f418b5db1 | 2 | private void initializeFrame() {
if (fullscreen) {
GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironment();
device=env.getDefaultScreenDevice();
GraphicsConfiguration gc=device.getDefaultConfiguration();
frame=new Frame(gc);
frame.setUndecorated(true)... |
b6134f89-00d9-474f-9c61-1cd18ac200c9 | 7 | private void mostrar() {
String diaSemana = "";
switch (Obj.principal.mes[Obj.principal.mesActual].dia[Obj.principal.diaActual].getDiaSemana()) {
case 1:
diaSemana = "Lunes";
break;
case 2:
diaSemana = "Martes";
brea... |
7f8dd9b9-9681-41dd-9031-c77c332f9f41 | 5 | public void run() throws InstantiationException, IllegalAccessException, SQLException {
try {
//Initalize connection to db
Class.forName(con.getDriver()).newInstance();
Connection conn = DriverManager.getConnection(con.getUrl() + con.getDbName(), con.getUser... |
ef6b2f50-10a6-448a-b1fd-f9bf3c53c0e5 | 9 | protected ScorpionRed scorpionMove(short[][][] maze, Human man) {//Horizontal then vertical
// This method was written using a different logic than the current one
ScorpionRed tam = new ScorpionRed(this.getX(), this.getY());
if (tam.samePlace(man)) {
return tam;
} el... |
87175fb4-d680-4144-a91b-207f2a532b15 | 4 | public final String getString() {
StringBuilder ret = new StringBuilder();
int c;
while ((c = getUByte()) != 0) {
if (c >= 128 && c < 160) {
char n = charSubs[c - 128];
if (n == 0) {
n = '?';
}
c = n;
}
ret.append((char) c);
}
return ret.toString();
} |
04a8a241-6e8a-4012-b3e3-440559331bc7 | 3 | @Override
public void render(GameContainer container, StateBasedGame game, Graphics g)
throws SlickException {
g.setAntiAlias(false);
backgroundManager.draw();
tileManager.draw(camera);
playerShadows.draw( camera, ws.p1.getPosition(), ws.p1.getPlayerState() );
playerShadows.draw( camera, ws.p2... |
a29585c1-aeb2-4b7e-a9a5-b0e9b7af6722 | 4 | public static void main(String[] args) throws IOException {
File f;
ObjectOutputStream out;
char [][] seats = new char[26][40];
for(int i =0 ; i < 26; i++)
for(int j = 0; j < 40; j++)
seats[i][j] = 'L';
for(int i = 1; i <= 1500; i++){
f = new File(i+".txt");
if(!f.exists())
f.createNewF... |
84457bab-37f6-46a5-b90e-5e08c403406e | 0 | public void reiniciar(){
formattedTextField.setText("");
textField.setText("");
comboBox_2.setSelectedItem("<Selecciona>");
textField_1.setText("");
textField_7.setText("");
textField_8.setText("");
textField_2.setText("");
textField_3.setText("");
formattedTextField_1.setText("");
textField_4.setTe... |
c103701d-5ad5-407a-9dcb-847fbf495cb1 | 5 | public void run() {
byte[] buffer = new byte[1536];
DatagramPacket packet = new DatagramPacket(buffer, 1536);
while (isListening) {
try {
packet.setLength(1536);
socket.receive(packet);
OSCPacket oscPacket = converter.convert(buffer, packet.getLength());
dispatcher.dispatchPacket(oscPacket);
... |
e46f9226-b464-422b-a392-682dc5a3516c | 5 | private int evaluateWave(int amplitude, int phase, int table) {
if (table == 1)
if ((phase & 0x7fff) < 16384)
return amplitude;
else
return -amplitude;
if (table == 2)
return sine[phase & 0x7fff] * amplitude >> 14;
if (table == 3)
return ((phase & 0x7fff) * amplitude >> 14) - amplitude;
if (... |
87c1f1c0-0749-4cf5-a7c0-3caf342d57c3 | 8 | public static double[] read(File file) {
double[] solution = new double[FileHelper.countFiles(file) - 2];
BufferedReader bufferedReader = null;
try {
bufferedReader = new BufferedReader(new FileReader(file));
String str;
int ctr = 0, separtorCount = 0;
while ((str = bufferedReader.readLine()) ... |
5979c25f-bc16-4235-807c-faa978be66b7 | 8 | @Override
public void subSample(int[] input, int[] output)
{
SliceIntArray src = new SliceIntArray(input, 0);
SliceIntArray dst = new SliceIntArray(output, 0);
this.dwt.forward(src, dst);
int offs = 0;
final int sh = this.shift;
final int h = this.height;
final int w = t... |
e5588db0-5a1d-4cdb-bc65-5f218570a6c8 | 2 | private void findDeviceParser(String type) throws ParseException {
if (type != null) {
logger.info(String.format(
Messages.getString("device_found"), type)); //$NON-NLS-1$
currentParser = parserFactory.getParser(type);
if (currentParser != null) {
logger.info(String.format(Messages.getString("pa... |
19a64637-32c2-44d6-80d2-dc639e900644 | 8 | public boolean interrogateNewAgent_NETCAT_OLDER(BufferedReader brSocket)
{
try
{
String strThirdLine = brSocket.readLine();
if ((strThirdLine != null) && (strThirdLine.trim().equals("")))
{
Driver.sop("-->>> Almost there... Confidence level is 75% ...");
sendCommand_RAW_ToA... |
46688247-d888-4129-b1d5-3c5db6892c8b | 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 Artikel)) {
return false;
}
Artikel other = (Artikel) object;
if ((this.id == null && other.id != null) || (thi... |
8ffbc9e8-172d-45fd-9ebf-9be38efec96a | 4 | public void weightedLinkLayer(final int l1, final int l2) {
//
final Layer layer1 = this.layers.get(l1);
final Layer layer2 = this.layers.get(l2);
//
for (int i = layer1.arrayslbd; i <= layer1.arraysubd; i++) {
final CellArray a1 = this.arrays.get(i);
if (... |
20439d92-6db3-451a-9d52-8aaafc010456 | 3 | public void solve() {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
BigInteger[] dp = new BigInteger[31];
for (int i = 0; i < dp.length; i++) {
dp[i] = BigInteger.ZERO;
}
dp[0] = BigInteger.ONE;
for (int i = 1; i < dp.length; i++) {
for (int j = 0; j < i; j++) {
... |
3df4c071-0082-4950-9647-bd46ab303f55 | 3 | public Edge remove(Node from, Node to) {
//remove the edge from the EdgeCollection
edgeIterator.reset();
while(edgeIterator.hasNext()){
Edge edge = edgeIterator.next();
if((from.ID == edge.startNode.ID)&&(to.ID == edge.endNode.ID)){
edgeIterator.remove();
edge.removeEdgeFromGraph(); // does not free... |
f130a69a-e2b0-46ae-a76d-49a774c8496d | 9 | @Override
public MatchResult checkKoota(Nakshatra boyStar, Nakshatra girlStar) {
MatchResult matchResult = MatchResult.ADHAMA;
if (vedhaiDetailsCache.get(boyStar) != null && !vedhaiDetailsCache.get(boyStar).equals(girlStar)) {
matchResult = MatchResult.UTTAMA;
}
if (vedhaiDetailsCache.get(boyStar) == null)... |
4e513d7f-792b-4a9d-9d30-4a1bafeb17fd | 2 | private void write_To_file() {
try {
WriteHand = new BufferedWriter(new FileWriter("table.txt"));
myDataList mytable = (myDataList) arrList.get(0);
for (int i = 0; i < mytable.size(); i++) {
WriteHand.write(((data) mytable.get(i)).getChar());
... |
162cfc21-87db-4150-b220-2acb4fb1dae3 | 3 | private void performLayout(Automaton automaton, Set locStates) {
// Apply the graph layout algorithm to those states that
// appeared without the <x> and <y> tags.
if (locStates.size() == automaton.getStates().length)
return;
AutomatonGraph graph = new AutomatonGraph(automaton);
LayoutAlgorithm layout = ne... |
d5752f6c-74b5-48b2-bffe-590b4ec83fb8 | 8 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
PopupMenuRetorna = new javax.swing.JPopupM... |
0f9108b7-984b-4a57-a6a7-666e58bfcf55 | 6 | private void doLynch(int guilty) {
if (guilty == -1) {
return;
}
String guiltyStr = players2.get(guilty);
players2.kill(guilty);
if (!isInChannel(guiltyStr)) {
bot.sendMessage(gameChan, getFromFile("LYNCH-LEFT", CONTROL));
return;
}
String role;
if (players2.isSeer(guilty)) {
bot.sendMess... |
72c6d6d9-1935-4f37-a379-09c3ad5a3d2f | 0 | @Override
public void method1() {
System.out.println("ClassA method1()");
} |
60d064fa-aaa5-4c1a-9131-b1848eae438d | 0 | public Inner inner() {
return new Inner();
} |
5816970f-396c-4701-ab78-9a04e01eb56f | 6 | @EventHandler
public void CreeperNausea(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getCreeperConfig().getDouble("Creeper.Nause... |
3941a0e6-4116-48b2-ab4d-39e9bc45fed4 | 3 | public void initialiseWordsList() {
try{
final BufferedReader reader = new BufferedReader(new FileReader("MegaDictionary.txt"));
String current = reader.readLine();
while(current != null) {
Game.words.add(current.toLowerCase());
current = reader.readLine();
}
reader.close();
}
catch(fi... |
4a61bee8-cab5-4065-96cf-810b871319d5 | 7 | private FTPClient getFtpConnection (URL url) throws IOException {
logger.entering(getClass().getName(), "getFtpConnection", url);
String protocol = url.getProtocol();
String host = url.getHost();
String userInfo = url.getUserInfo();
String path = url.getPath();
String[]... |
6fbe5348-509b-4df2-8d00-f4370ed2958b | 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... |
a08be900-bf7b-49ee-a0da-b2bb742ea2bc | 6 | @EventHandler
public void SlimeHarm(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getSlimeConfig().getDouble("Slime.Harm.DodgeCha... |
d9dce9d9-7e8c-42e6-8bf1-e55d9a0a4906 | 7 | public LineSegmentInt inflateYAlpha(InflateData inflateData) {
final int ypos = inflateData.getPos();
final int inflation = inflateData.getInflation();
if (isVertical()) {
return new LineSegmentInt(p1.inflateY(inflateData), p2.inflateY(inflateData));
}
if (getP1().getYint() == ypos && getP2().getYint() == ... |
24f3e8b7-4e31-4a53-b97f-db031ec05042 | 0 | public Item SwapBodyArmor(Item willBeSwappedItem) {
return bodyArmorSlot.swap(willBeSwappedItem);
//return false; // swap failed
} |
7608ee3b-4e7a-476e-90b5-5ffc679152f3 | 3 | @Override
public double estimateMiceNumber(int nbOcc){
double comp = 0;
for(int i = b; i <= 32 ; i++)
for(Occurrence occ : strTab.get(i))
if(occ.nbOcc == nbOcc)
comp++;
return comp * Math.pow(2, b);
} |
198d07a9-5699-47c3-8b8f-6a309c9f863c | 3 | public void draw(Graphics g) {
if(gender.equalsIgnoreCase("m")) {
g.setColor(Color.blue);
}else if(gender.equalsIgnoreCase("f")) {
g.setColor(Color.red);
}else if(gender.equalsIgnoreCase("b")) {
isBaby = true;
}
... |
ff1cf980-0a66-4d87-87b2-5b6c4b4efe6a | 5 | public void startGame() {
tc.startGame();
Thread t = new Thread(new Runnable(){
@Override
public void run() {
while(tc.gameOn){
tick(TetrisController.DOWN);
}
count ++;
sum += tc.rowsCleared;
max = max == 0 || tc.rowsCleared > max ? tc.rowsCleared : max;
min = min == 0 || ... |
949ab07d-0248-4789-be1f-219b3b233c23 | 2 | public Port()
{
super("Hello, World!");
mxGraph graph = new mxGraph() {
// Ports are not used as terminals for edges, they are
// only used to compute the graphical connection point
public boolean isPort(Object cell)
{
mxGeometry geo = getCellGeometry(cell);
return (geo != null) ? geo... |
b6fb8e0f-9250-4bb1-8dbf-d412d9d33e31 | 6 | public void updateTheGraph(Document doc) throws Exception{
ArrayList<Sentence> sentencesList = doc.getSentences();
String clusterID = doc.getId();
for (int sentenceIndex = 0; sentenceIndex < sentencesList.size(); sentenceIndex++) {
Sentence currentSentence = sentencesList.get(sentenceIndex);
ArrayList<... |
890139d7-4be9-46bd-b2b1-cb29f5297af6 | 9 | private void main() throws IOException {
while (true) {
byte[] data = new byte[Constants.MAX_UDP_BYTE_READ_SIZE];
DatagramPacket packet = new DatagramPacket(data, data.length);
localSocket.receive(packet);
MessageHeader header = new MessageHeader(packet);
Message message = messageFactory.buildMessageF... |
e5371c20-ffa5-4a33-9a5b-4c78bf9713c2 | 7 | public Server() {
outputArray = new ByteArrayOutputStream();
try {
outputStream = new ObjectOutputStream(new BufferedOutputStream(outputArray));
} catch (IOException e) {
e.printStackTrace();
}
running = true;
clientList = new HashMap<InetSocketAd... |
3e44ac1d-ac10-46e6-baae-c71b42f2ba87 | 3 | public static ProbabilityOfOccurrenceEnum fromString(String v) {
if (v != null) {
for (ProbabilityOfOccurrenceEnum c : ProbabilityOfOccurrenceEnum.values()) {
if (v.equalsIgnoreCase(c.toString())) {
return c;
}
}
}
throw new IllegalArgumentException(v);
} |
0f4afe30-d671-4e88-b153-c6bf4be4f51f | 7 | @Override
public boolean next() throws java.sql.SQLException
{
while (true)
{
if (!iter.hasNext())
return false;
final Backend.RecordInfo rowInfo = iter.next();
if (countValue != null)
{
currentRow++;
return true;
}
if (conditions.size() > 0)
{
final boolean[] dataLoaded = new... |
b2bde1cd-9b82-4a42-88fb-728a17e309d8 | 3 | public static Vector Double(Vector Vec, boolean X, boolean Y, boolean Z) {
if (X) {Vec.setX(Vec.getX()*2);}
if (Y) {Vec.setY(Vec.getY()*2);}
if (Z) {Vec.setZ(Vec.getZ()*2);}
return Vec;
} |
954b5aed-437c-4f8c-9680-0e97f9b6f6af | 2 | public ArrayList<String[]> regresaCatalogoConId(String catalogo) {
String res = "";
ArrayList<String[]> resultado = new ArrayList<>();
String[] nombre = new String[2];
try {
Class.forName(driver);
Connection con = DriverManager.getConnection(connectString, user, p... |
ef9f01cc-ed3f-4b6f-9f17-ffc407210b78 | 9 | public static void main(String[] args) {
User u;
if (args.length > 0) {
u = new User(args[0]);
}
else {
u = new User("localhost");
}
Console con = System.console();
String user_name = con.readLine("Insert your username for this session: ")... |
cd84e409-7f89-4a02-b971-5141cdae1658 | 8 | private boolean checkReturn(Node node, String scope){
if (node.getClass() == Block.class) {
LinkedList<Node> bl = ((Block)node).getContent();
for (Node n : bl) {
if(checkReturn(n, scope))
return true;
}
return false;
} else if (node.getClass() == ReturnStatement.class) {
return true;
} el... |
834f3727-c724-4e74-8dbc-96a5421b5602 | 4 | @SuppressWarnings("unchecked")
static <V> DenseImmutableGrid<V> create(Grid<? extends V> grid) {
if (grid instanceof DenseGrid) {
return new DenseImmutableGrid<V>((DenseGrid<V>) grid);
}
int rowCount = grid.rowCount();
int columnCount = grid.columnCount();
validat... |
2368b24a-27a1-415f-a943-0388d8c3c58b | 1 | public boolean setWindowHeight(int height) {
boolean ret = true;
if (height < UISizeInits.WINDOW.getHeight()) {
this.window_Height = UISizeInits.WINDOW.getHeight();
ret = false;
} else {
this.window_Height = height;
}
somethingChanged();
... |
60fba3fd-4b86-4a9f-b5a0-014e9ed07a6f | 2 | public boolean hitWall(Wall w){
if(this.isLive && this.getRect().intersects(w.getRect())){
this.isLive = false;
return true;
}
else
return false;
} |
af5a3e9b-9b1a-44e1-a31b-2cce2ff4dfed | 4 | @Override
public boolean equals(Object other)
{
if(other == null || !((other instanceof Version) || (other instanceof Double)))
{
return false;
}
Double d = toDouble();
if(other instanceof Version)
{
return d.equals(((Version)other).toDouble());
}
else
{
return d.equals((Double)other);
}
... |
c56cd123-e252-4113-ad00-8530f51b5fea | 3 | private void func_22183_a(File var1, ArrayList var2, ArrayList var3) {
ChunkFolderPattern var4 = new ChunkFolderPattern();
ChunkFilePattern var5 = new ChunkFilePattern();
File[] var6 = var1.listFiles(var4);
File[] var7 = var6;
int var8 = var6.length;
for(int var9 = 0; var9 < var8; +... |
3e9fdfef-bd89-48ad-a0a6-deb681cfb6d3 | 1 | protected void removerLinhaVenda(LinhaVenda lv) throws ExceptionGerenteVendas{
if(!linhas.contains(lv)){
throw new ExceptionGerenteVendas("Linha de Venda n�o existe para esta venda");
}else{
linhas.remove(lv);
lv.setVenda(null);
total-= lv.getTotaldaLinha();
desconto-= lv.g... |
e4f04135-6ed7-4d38-861d-c89d366acf36 | 3 | public void inint(int n) {
d = new int[n][n];
for (int i = 0; i < n; i++)
for (int k = 0; k < n; k++)
if (i != k)
d[i][k] = INF;
} |
18d53e0d-7374-4ab3-aeda-58e75a4342ba | 8 | public static BooleanQuery randBoolQuery(Random rnd, boolean allowMust, int level, String field, String[] vals, Callback cb) {
BooleanQuery current = new BooleanQuery(rnd.nextInt()<0);
for (int i=0; i<rnd.nextInt(vals.length)+1; i++) {
int qType=0; // term query
if (level>0) {
qType = rnd.ne... |
2a8c29ca-3b5c-44e7-9732-d5929b764d3d | 1 | public static void addPointsToLevel(Player p, double i){
if(warnLevel.get(p) == null){
addPlayer(p);
}
double oldValue = warnLevel.get(p);
warnLevel.remove(p);
warnLevel.put(p, oldValue + i);
} |
38e53b58-e08d-468b-a287-c2c449ff8f44 | 1 | @Override
public void addNotify() {
super.addNotify();
if (thread == null) {
thread = new Thread(this);
addKeyListener(this);
thread.start();
}
} |
737aa221-9af5-42ff-9f8f-68213426a36f | 8 | public void Iniciar() {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
... |
ec1e9cea-e3eb-4b63-89bb-fab708c71a77 | 8 | @EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (!ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("Shooting Star Commands")) {
return;
}
Player player = (Player) event.getWhoClicked();
event.setCancelled(true);
if((event.getCurrentItem() == null) || (eve... |
d0a201da-1da5-4465-aed1-7a3fb9b44bb7 | 4 | public String[] getTopFourMoves(int l) {
ArrayList<Integer> sort = new ArrayList<Integer>(list.keySet());
Collections.sort(sort, new Comparator<Integer>(){
public int compare(Integer o1, Integer o2) {
if (o1 > o2) {
return -1;
}
if (o1 < o2) {
... |
0c7bc702-15dc-4daa-a14d-c84ca7a9094b | 5 | @Override
public List<Row> compose(List<Glyph> glyphs, ViewEventArgs args) {
List<Row> rows = new ArrayList<Row>();
if (glyphs == null || glyphs.size() == 0){
return rows;
}
Row currentRow = new Row();
int currentTop = args.getTop();
currentRow.setStartIndex(0);
currentRow.setLeft(args.getLeft(... |
c216ece6-ca32-4bc4-b450-4caa8f883103 | 8 | boolean can_include_char_in_digest(byte ch) {
if (!(ch >= 'a' && ch <= 'z') && !(ch >= 'A' && ch <= 'Z')
&& !(ch >= '0' && ch <= '9') && ch != '\n' && ch != ' ')
return false;
return true;
} |
aff0971b-ac00-41b1-83ef-d087a2df1a7b | 5 | public boolean cargarDesdeCSV(String path) throws IOException {
File archivo = new File(path);
if (archivo.exists() && !archivo.isDirectory() && path.endsWith(".csv")) {
try {
BufferedReader br = new BufferedReader(new FileReader(archivo));
String cad = br.rea... |
2b813921-5ec2-45c4-b029-b7c58e71468a | 7 | void createColorAndFontGroup () {
/* Create the group. */
colorGroup = new Group(controlGroup, SWT.NONE);
colorGroup.setLayout (new GridLayout (2, true));
colorGroup.setLayoutData (new GridData (SWT.FILL, SWT.FILL, false, false));
colorGroup.setText (ControlExample.getResourceString ("Colors"));
colorAndFon... |
1990e331-c73b-48fb-9072-bff554b0bda8 | 0 | public TrainNumber getTrainNumber() {
return this._trainNumber;
} |
bd443f31-5a4c-4457-9d53-f6c7f5d273a4 | 1 | public void drawSelect(){
parent.background(0); // Refresh Background
display(); // Refresh display
parent.stroke(255); // Outline (255) or white
parent.noFill(); // Nothing drawn inside shape
parent.rect(listImages.get(listPosition).getX() - 3,
listImages.get(listPosition).getY() - 3,
lis... |
31e61aeb-66ea-43c1-8118-f8d07161c8e7 | 0 | public void setId(String value) {
this.id = value;
} |
9be3b157-acf3-4577-90f0-5c87fb92df39 | 0 | @Override
public void mouseMoved(MouseEvent e)
{
mX = e.getX();
mY = e.getY();
cX = (int) Math.floor((mX - Game.MAPOFFX) / (double) Game.TILESIZE) + Game.xOff;
cY = (int) Math.floor((mY - Game.MAPOFFY) / (double) Game.TILESIZE) + Game.yOff;
Game.gui.update(mX, mY, false,... |
2917061b-5c5f-4508-bf84-c0086aca62a4 | 4 | public ArrayList<Stone> parsingSAX(){
try {
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
SAXParser parser = saxParserFactory.newSAXParser();
SAXHandler handler = new SAXHandler();
parser.parse(new File("src/resources/stone.xml"), handler);
... |
5a6acb67-ec5e-4492-98d0-8d37d311d5c8 | 6 | @Override
public boolean equals(Object obj)
{ if(obj instanceof Matrix)
{ Matrix that=(Matrix)obj;
if(this.matrix.length!=that.matrix.length || this.matrix[0].length!=that.matrix[0].length)
{ return false;
}
else
{ for(int i=0;i<this.matrix.length;i++)
{ for(int j=0;j<... |
21fe531e-5b59-4794-846b-66d97ee3613a | 1 | @Override
public void init(List<String> argumentList) {
functionName = argumentList.get(0);
if (functionName.indexOf("<") != -1) {
functionName = functionName.substring(0, functionName.indexOf("<"));
}
startLineNumber = Integer.parseInt(argumentList.get(1));
endLi... |
b3c02cb9-06b5-4215-b886-d649f81b00e0 | 9 | public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
if (ActionText == "Exiting...") {
// If the exit command is used, InvalidCommandText becomes equal to Exiting...
// When this happens, call the game container's exit function
gc.exit();
} else if (ActionText == "You... |
beb34b36-21c7-4488-a95c-87c6f32f2ffd | 0 | public void setAlgorithm(String value) {
this.algorithm = value;
} |
f056b84f-bbd7-41a1-9614-bd1ddd7ab8b6 | 5 | public void findRegistrations(Participant p){ //inserts workshops into the participants schedule
ArrayList<String>registrations = ReadFromFile.getRegistrationList();
for(int i = 0; i < registrations.size();i++){ //goes through WKSHP_REGISTRATIONS and finds participants registered to workshops
String line = regis... |
e72dba80-dcdc-4a0a-9790-be3001624dbe | 6 | @MCCommand(cmds = { "setOptions" }, op = true, usage = PORT_SET_OPTIONS)
public boolean portSetOptions(CommandSender sender, Port port, String[] args)
{
List<String> portOptions = new ArrayList<String>();
for (int i = 2; i < args.length; i++)
{
String op = args[i];
if (!Port.checkOption(op))
{
send... |
e09316e6-7326-4763-8c77-d01dbbcbde8b | 3 | private boolean overlapsWithObject(RenderObject other) {
return (x < other.x + other.getWidth() &&
x + getWidth() > other.x &&
y < other.y + other.getHeight() &&
y + getHeight() > other.y);
} |
2d2cb907-b7a4-48d8-8455-9b891ad7de46 | 7 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
String productionType = request.getParameter("i... |
5e2001d4-916c-4d59-822a-458d178cfe2e | 7 | public void onTick() {
for (int i = 0; i < enemyList.size(); i++) {
if (enemyList.get(i).onTick()) {
lives -= Constants.enemyDamage[enemyList.get(i).enemyID];
enemyList.remove(i);
i--;
}
}
for (Tower towerI : towers) {
towerI.onTick();
}
for (int i = 0; i < projectileList.s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.