method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
0803e896-f66a-4c3a-bffd-5eb0081a01b8 | 3 | @Override
public List<Fornecedor> listAll() {
Connection conn = null;
PreparedStatement pstm = null;
ResultSet rs = null;
List<Fornecedor> fornecedores = new ArrayList<>();
try{
conn = ConnectionFactory.getConnection();
pstm = conn.prepareStatement(LIS... |
557a4a3a-e3f3-4f4a-ac25-c466037b89ea | 1 | @Override
public void actionPerformed(ActionEvent e) {
int decision = JOptionPane.showConfirmDialog(
controller.getMainJFrame(),
"Do you really want to exit?",
"Exit the application",
JOptionPane.YES_NO_OPTION
);
if ( decision == JOptionPane.YES_OPTION ) {
controller.getMainJFrame().dispose... |
d6c67856-a518-4435-8607-69d7bf0526bb | 8 | @Override
public void paint(Graphics g){
super.paint(g);
int env[][] = this.environment.getEnvironment();
g.setColor(Color.LIGHT_GRAY);
g.drawLine(0, 0, 0, env[0].length * DY);
g.drawLine(0, 0, env.length * DX, 0);
for (int i = 0; i < env.length; i++){
g.drawLine((i + 1) * DX, 0, (i + 1) * DX, env... |
27dde5ff-6792-4a12-9302-72634855c3fa | 0 | public Program(String name)
{ this.name = name; } |
2e03c752-5e39-4623-9e2a-9d01e4792962 | 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... |
77cd1e69-e41e-4466-b9f7-73fd5eabb680 | 2 | @Override
public Object stringToValue(String text) throws ParseException {
return new Integer(Math.min(Math.max(Numbers.getLocalizedInteger(text, mMinValue <= 0 && mMaxValue >= 0 ? 0 : mMinValue), mMinValue), mMaxValue));
} |
28b722a1-b37e-4ae0-9434-01d1eef60e7b | 7 | private int loadPtrOffset() throws ScriptException{
int ptr = data[programPointer++]&0xFF;
if((ptr&0x80)==0){
switch((ptr>>5)&0x3){
case 1:
return register[ptr & 0x1F];
case 2:
return register[ptr & 0x1F]+loadPtrOffset();
case 3:
return register[ptr & 0x1F]*loadPtrOffset();
default:
t... |
1e529abd-2271-4178-b4c5-adde1cab43a6 | 1 | public void drawTool(Graphics g) {
if (currentTool == null)
return;
currentTool.draw(g);
} |
a942d4d3-edd3-4b33-a50b-e38ba04622b7 | 4 | public static void sort_names(String[] names) {
Map<String, List<String>> map = new TreeMap<>();
for (String name : names) {
String lastName = name.split("\\s")[1];
if(!map.containsKey(lastName)) {
map.put(lastName, new ArrayList<String>());
}
... |
faff2f0b-277a-4194-a108-21f68255c367 | 2 | public boolean checkPing(String ping){
if(lasping.equals(ping) || (":" + lasping).equals(ping)){
this.is_pinged = true;
return true;
} else {
this.is_pinged = false;
return false;
}
} |
ddca18e7-352a-4fe5-9eea-d64ad970e22b | 4 | public void resetItems(int WriteFrame) {
outStream.createFrameVarSizeWord(53);
outStream.writeWord(WriteFrame);
outStream.writeWord(playerItems.length);
for (int i = 0; i < playerItems.length; i++) {
if (playerItemsN[i] > 254) {
outStream.writeByte(255); // item's stack count. if over 254, write by... |
e8d22b2b-bd97-40c2-b2b5-accb91f131c9 | 5 | protected Stmt createUndefinedStore(final VarExpr target) {
if (target.type().isReference()) {
return new ExprStmt(new StoreExpr(target, new ConstantExpr(null,
Type.OBJECT), target.type()));
}
if (target.type().isIntegral()) {
return new ExprStmt(new StoreExpr(target, new ConstantExpr(
new Intege... |
618bf077-9e6a-4c5e-b097-d7b752654c45 | 6 | private static String[][] HFSA(String[] input) {
int NGramLength = input.length;
//String[] transitions = {" ", ",COMMA", ".PERIOD", "?QMARK", "!EXCL"}; //Change space to null
int numberOfTransitionsInString = input.length/2;
int internalCounters[] = new int[numberOfTransitionsInString];... |
539d98d0-0090-44f1-8cf0-31eb80ba53a6 | 3 | RecordTypeNode recordType() {
read(RECORD, "RECORD");
List<FieldListNode> fieldLists = new ArrayList<FieldListNode>();
FieldListNode node = fieldList();
if(node!=null)
fieldLists.add(node);
while (test(SEMICOLON)) {
read(SEMICOLON,";");
node = fieldList();
if(node!=null)
fieldLists.add(node);
... |
b53ceb9a-e06b-4f2b-a1c2-982297a2e18c | 2 | @Override
public void move() {
if (alive) {
if (stomache > 0) {
addGlied();
stomache--;
}
super.move();
invertedBevoreMoves ++;
}
} |
f71b9a17-1982-43c9-802b-46d379ce9a90 | 1 | public int getGravityDelay() {
if(frame == null) buildGUI();
return gravityDelay.getValue();
} |
24bc1f9e-f5fb-4ccf-aa99-0134da12122c | 1 | @Override
public void setVisible(boolean visible) {
if (visible) {
setLocation(50, 50);
}
super.setVisible(visible);
} |
31dfa065-4be5-4067-83db-9d50a97146b3 | 0 | @Override
public void beginDraggingFrame(JComponent f) {
//System.out.println("beginDraggingFrame");
isDragging = true;
super.beginDraggingFrame(f);
} |
e10bb9f1-900e-456f-bd7d-11bb24db9fe2 | 0 | public static Connection getConnection() throws SQLException {
Connection c = DriverManager.getConnection(getJdbcString(), "linse", "linse");
return c;
} |
cc66fba8-51e7-449c-9287-10c5c2b9edf4 | 4 | public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
String line = "";
HashMap<Integer, Character> hm2 = new HashMap<Integer, Character>();
int con = 1;
... |
f931158c-3b40-4716-af41-ae226e0ca03d | 1 | private void setPopupMenu(JComponent component){
final JPopupMenu popup = new JPopupMenu();
JMenuItem menuItemOk = new JMenuItem("Подтвердить заявку");
JMenuItem menuItemCancel = new JMenuItem("Отменить заявку");
popup.add(menuItemOk);
popup.addSeparator();
popup.add... |
0d897775-71b2-49ae-844c-14d1c24a88c9 | 0 | public void setCtrEstado(String ctrEstado) {
this.ctrEstado = ctrEstado;
} |
ad15b480-c18d-4938-975c-6872f40a8094 | 4 | public String execute() throws Exception {
int index = 1, i = 0;
int item_index = new Integer(itemname);
Object[] objects = null;
List list = (List) this.getSession().get("itemNames");
Iterator iterator = list.iterator();
while (iterator.hasNext()){
objects = (Object[]) iterator.next();
if(it... |
32a14ea5-34bd-44d8-95fe-1f6d2e0c393c | 5 | public void Decorate() {
super.Decorate();
currentIcon = icons[0].getImage();
try {
g = currentIcon.getGraphics();
}
catch (NullPointerException e) {
System.out.println("Could not get Graphics pointer to " + getClass() + " Image");
return;
... |
9239a850-3e8e-4992-b12b-cbbb7a2421e3 | 8 | public void executeQuery(String query) {
boolean notRows = true;
if (connection == null || statement == null) {
System.err.println("There is no database to execute the query.");
return;
}
try {
/*gavarela: Innecesrio que imprima en la consola de Java
System.out.println("JDBCAdapter:... |
ad89f2d4-63ca-4234-9254-265fa42254dd | 4 | public boolean canRobotMove(Direction direction) {
boolean result = true;
/* Each case checks for 2 things: if the robot will move outside of the bounds
* and if there is a rock in the robot's path.
*/
switch(direction) {
case UP:
result &= robot.getLocation().y > 0;
result &= !rocks.contains(new Re... |
886251ed-45ec-4c84-bea6-b3e9f7c72a52 | 1 | @PostConstruct
private void postConstruct() {
log.warn("Database folder : " + path);
try {
provider = new MyTableProviderFactory().create(path);
} catch (IOException e) {
log.error("Cannot use directory! " + path + " " + e.toString());
}
} |
c4995e4a-59ba-4b05-a321-9602637b5cd8 | 7 | public void loadImage() {
if (path == null)
return;
if (getWidth() <= 0 || getHeight() <= 0)
return; // not ready yet
ImageIcon tmpIcon = new ImageIcon(path);
if (getLockRatio()) {
float rx = (float) tmpIcon.getIconWidth() / (float) (getWidth() - 10);
float ry = (float) tmpIcon.getIconHeight() / (fl... |
3a0853bd-b007-4ace-be62-5ed47e254af0 | 3 | @Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == exitMenuItem)
{
exit();
}
else if(e.getSource() == configMenuItem)
{
//TODO
}
else if(e.getSource() == aboutMenuItem)
{
//TODO
}
} |
b10d8bd6-d64d-49f7-ba58-bffa6c62d8ed | 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
... |
f9d5847d-4226-47e1-aac7-29b886569d5f | 3 | public static void main(String[] args) {
double c1,c2,c3;
int exp,ppt;
double a,b,xr,fa,fb,error,fd,epsilon;
double eaux=0;
double cpt,cst;
Scanner lector = new Scanner(System.in);
System.out.println("Dame el coeficiente del termino cuadratico");
c1=1;
System.out.println("Dame el exponente del te... |
29915bf1-c084-4a6b-ad67-7cd515a64c55 | 0 | @Test
public void dedup_whenInputContainsDuplicatedChars() {
String word = "aaa";
assertEquals("[[a, a]]", combination.combine(word, 2).toString());
assertEquals("[[a, a, a], [a, a, b], [a, b, b], [b, b, b]]", combination.combine("ababbbba", 3).toString());
} |
efa0de90-6a70-4ae4-86a7-58d3bf2f14c9 | 5 | void setExampleWidgetPopupMenu() {
Control[] controls = getExampleControls();
for (int i = 0; i < controls.length; i++) {
final Control control = controls [i];
control.addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
Menu menu = control.getMenu();
i... |
0ded760f-29a0-4068-9c1e-42b395272be6 | 0 | public PrimitiveUndoableEditableChange(Node node, int oldState, int newState) {
this.node = node;
this.oldState = oldState;
this.newState = newState;
} |
08655a49-5c86-4da2-a783-07adf412f365 | 7 | public int playHand()
{
//Card c1 = h1.player1play();
//Card c1 = h1.player1play();
Card c1 = ((Card)this.h1.p1Queue.dequeue());
Card c2 = ((Card)this.h1.p2Queue.dequeue());
int hw = 0;
//System.out.println("hw: " + hw);
if (console)
{
Syst... |
e82aee45-1bf9-4096-97f4-95f1eaccd5d3 | 9 | public static ParameterContent parse(Class<?> parameter, Annotation[] annotationList) {
ParameterContent pc = new ParameterContent();
pc.setType(parameter.getName());
for(Annotation annotation : annotationList) {
// Jersey - @DefaultValue
if(annotation instanceof DefaultValue) {
DefaultValue dv = (Def... |
31db33b1-6949-4953-8d5a-3bcf69598947 | 3 | @Override
public boolean execute(CommandSender sender, String[] args) {
if (args.length != 0) {
return false;
} else {
if (!hasPermission(sender)) {
sender.sendMessage(ChatColor.RED + "You do not have sufficient permissions to do that!");
return true;
}
sender.sendMessage(ChatColor.AQUA + "[Ge... |
a4185828-9d70-456c-9438-51356bef1cb6 | 1 | public synchronized void addReceivedPacketHistoryToOutgoingPacket(Packet packet) {
if(packet != null) {
packet.setLastReceivedSequenceNumber(lastReceivedPacketSequenceNumber);
packet.setReceivedPacketHistory(receivedPacketHistoryInt);
}
} |
0686bf0b-b4f1-47a9-935e-379a98302240 | 7 | public static JSONObject parseObject(ParseInfo info) throws Exception {
if (info.peek() != '{') {
giveup(info, "Failure to begin an object with a {");
} // if (info.peek() != '{')
JSONObject obj = new JSONObject();
String start = info.info();
info.next();
info.skipWhitespace();
while ((!info.atEnd()) && (in... |
b9cd6cb1-54e6-4db7-b590-22736381fbe7 | 8 | public static Map<String, String> returnShipAdviceHeader(String identifier) {
// Select the customer ID from the table and add to the map.
Map<String, String> headerValues = new HashMap<String, String>();
if (conn == null) {
getConnection();
}
try {
String... |
f0788e23-ddb6-4cb6-8169-80dff4ac1b4f | 4 | @Override
public int compareTo(AppWindow other) {
if (this != other) {
String title = getTitleForWindowMenu();
String otherTitle = other.getTitleForWindowMenu();
if (title != null) {
if (otherTitle == null) {
return 1;
}
return title.compareTo(otherTitle);
}
if (otherTitle != null) {
... |
280d28f4-1e07-4ce8-8948-a729ac68559f | 4 | private final void sendResponse(HttpExchange exc, Response response) throws IOException {
for (Map.Entry<String, List<String>> entry : response.getParams().entrySet()) {
for (String value : entry.getValue()) {
exc.getResponseHeaders().add(entry.getKey(), value);
}
... |
6c013378-c855-4143-b55e-358ed6befd4c | 1 | private String getByteRange() throws IOException {
try {
String[] splitOnConnection = requestArray[3].split("Connection:");
String[] splitOnBytes = splitOnConnection[0].split("bytes=");
return splitOnBytes[1];
} catch (ArrayIndexOutOfBoundsException e){
return "No Range Given";
}
... |
d929df4f-5c7c-442b-a918-26dc72ff2434 | 4 | public char getCharSurroundedByWhitespace() {
char alpha = 0;
try {
while (true) {
int curr = reader.read();
if (curr < 0)
break;
char c = (char) curr;
if (!Character.isWhitespace(c)) {
al... |
41be85e9-0a9c-4a94-817a-fad5fc83ac78 | 9 | private boolean flipVertical(long binPosition, boolean goesDown){
boolean hasFlippableDisk = false;
long searchPosition = binPosition;
if(goesDown && (binPosition & 0x00000000000000FFl) == 0)
searchPosition = binPosition >> 8;
else if( !goesDown && (binPosition & 0xFF000000... |
9cc00ff3-f2e3-4374-ba72-2f6300d79150 | 0 | public ContainerListener onStart(ClientRequest cr) {
return new SendPackageListener();
} |
b7eb0126-902d-40ee-bf16-6faa61c354ea | 7 | @Override
public boolean isAControlledFollower(MOB invoker, MOB mob, Ability A)
{
if((mob==null)||(mob==invoker)||(!mob.isMonster()))
return false;
if(A==null)
return mob.getStartRoom()==null;
A = mob.fetchEffect(A.ID());
if(A==null)
return false;
if((A.invoker() == invoker)||(A.invoker()==null))
... |
1c4df8bb-ae68-49de-afae-8f3b5024f3ff | 5 | public static void fillDatabase() {
itemDatabase = new ArrayList<String>();
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(System.getProperty("resources") + "/database/items"));
String line;
while((line = reader.readLine()) != null) {
String[] temp = line.split("... |
c6af2fef-d11b-45a1-97d1-7aa7db6a6bbe | 4 | public boolean compareType(GameMatter i){
switch (type){
case "sell":
return i instanceof Sellable;
case "key":
return i instanceof Key;
case "static":
return i instanceof FurnitureStatic;
case "knife":
return i instanceof Knife;
}
return false;
} |
c967272f-212c-41ea-bb1e-131cabb9f705 | 5 | public static void main(String[] args) throws MalformedURLException {
mainWindow = new windowManager("Demo", 100, 100, 640, 480);
video = new videoSystem2D(mainWindow.getWidth(), mainWindow.getHeight());
keyboard = new keyboardSystem();
video.createImage(0, 0, 0, 50, 658, 512, "images/circle.png");
video.... |
c2df0e2a-94d5-4650-b7c6-0a221aeb5eb6 | 0 | @Basic
@Column(name = "value")
public String getValue() {
return value;
} |
b3706e80-aa51-4cc1-8c26-5c241a672458 | 7 | public void testRemoveManyWithNulling() {
Table<Integer> buf=new Table<>(3, 10, 0);
for(int i: Arrays.asList(1,2,3,4,5,6,7,9,10))
buf.add(i, i);
List<Integer> list=buf.removeMany(true, 3);
System.out.println("list = " + list);
assert list != null && list.size() == 3;
... |
c54c052f-313d-427b-9f39-744d61279568 | 5 | private boolean mouseOverTopArrow(int mx, int my) {
if (!isVisible) return false;
if (mx < positionX || mx > positionX + width) return false;
if (my < positionY || my > positionY + height) return false;
return (my <= positionY + 16);
} |
25daf5f4-7766-4582-817c-1f8b849b6fc1 | 0 | public int GetTotalLeftAtBusStop()
{
//get person left at a stop
return totalLeftAtBusStop;
} |
75d6b1b7-de78-4960-a3e9-c292410472ac | 4 | public int deleteValue(String key) throws IOException {
if (!keyPointers.containsKey(key))
return 3;
long position = keyPointers.get(key);
int size = 0;
RandomAccessFile data = new RandomAccessFile(dataStorage, "rw");
data.seek(position);
char c;
while... |
819f43f8-f7c2-401c-8dbd-155aade4b765 | 9 | private boolean check() {
if (!isBST())
StdOut.println("Not in symmetric order");
if (!isSizeConsistent())
StdOut.println("Subtree counts not consistent");
if (!isRankConsistent())
StdOut.println("Ranks not consistent");
if (!is23())
StdOut... |
bf0d03ea-70fd-4be5-aea6-a0a993fb658b | 2 | public GuessTheNumberPlayer getPlayer(Position p) {
GuessTheNumberPlayer g = null;
for (GuessTheNumberPlayer guessTheNumberPlayer : players) {
if(guessTheNumberPlayer.getPosition().equals(p)) {
g = guessTheNumberPlayer;
break;
}
}
return g;
} |
5b851c8c-5ae1-44db-8a4b-65bdb4456be4 | 2 | protected void run() throws Exception
{
this.initializeOpenGL();
this.isRunning = true;
this.initializeGame();
log("Game sucessfully initialized");
log("Entering game loop");
try
{
while (this.isRunning)
{
Display.sync(60);
Display.update();
this.tick();
this.render();
}
... |
c744abbe-e432-4bee-98de-1c4071528af6 | 0 | public void setGameStart(Calendar newGameStart)
{
gameStart = newGameStart;
} |
0a1702cb-12ba-4d33-a3d9-f5745b7319db | 7 | public void checkFeatures() throws IOException
{
Reply reply = sendCommand(new Command(Command.FEAT));
reply.dumpReply();
if (ReplyCode.isPositiveCompletionReply(reply)) {
List<String> lines = reply.getLines();
for (String s : lines) {
if (s.indexOf(Command.SSCN) > -1) {
setSscnSupport(true);
... |
ab850691-2b6f-4e02-a180-9ea1cb33b28d | 7 | protected double meanOrMode(Instances instances,
int[] instList,
int attIndex) {
double result, found;
int[] counts;
int numInst = instList.length;
if (instances.attribute(attIndex).isNumeric()) {
result = found = 0;
for (int j = 0; j < numInst; j++) {
Instance currInst = i... |
89e289ff-d5d9-4d95-acf4-75b57ae75e3c | 0 | public City_Graph(){
} |
114906b8-e536-4650-b496-13e89f5bb96e | 7 | public static boolean findSubString(char[] subString, char[] parentString) {
int indexOfSubString = 0;
int solutionIndex = 0;
for(int i=0; i<parentString.length; i++) {
if(subString[indexOfSubString] == parentString[i]) {
if(indexOfSubString == 0) {
... |
d366e866-067b-4213-8f0c-0ea8dbc0f823 | 6 | ObjectLoader(GameMode class230, int i, boolean bool, IndexLoader class45,
IndexLoader class45_29_) {
aClass60_3350 = new Cache(64);
((ObjectLoader) this).aClass60_3360 = new Cache(500);
((ObjectLoader) this).aClass60_3361 = new Cache(30);
((ObjectLoader) this).aClass60_3362 = new Cache(50);
do {
try {
... |
9606815c-3c15-4bf2-af73-39fc4171b677 | 8 | public void update_pf_moving() {
if (path == null)
return;
if (JSBotUtils.isMoving()) return;
if (path_step < path.size()) {
if (myLastCoord.equals(path.get(path_step))) {
path_moving = false;
path_step++;
}
}
i... |
e72a9bcd-652e-4862-90ed-a347826e542d | 7 | public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player player = (Player) sender;
if(commandLabel.equalsIgnoreCase("Pyro") && sender instanceof Player){
if (player.hasPermission("EasyPvpKits.Pyro")){
if (!plugin.kits.contains(player.getName())){
ItemStac... |
d938f773-a96a-476d-b852-72939ecb6e51 | 7 | public static void main(String[] args){
try{
BufferedReader in=null;
if(args.length>0){
in = new BufferedReader(new FileReader(args[0]));
}
else{
in = new BufferedReader(new InputStreamReader(System.in));
}
// BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
ArrayList<St... |
1e5c4f47-60dd-43b9-a716-bac01516cd10 | 7 | @SuppressWarnings("unchecked")
public static <T> T createObject(Class<T> clazz) {
Constructor<?> constructor;
try {
constructor = clazz.getConstructor();
return (T) constructor.newInstance(new Object[] {});
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.p... |
cfe92317-5e1a-4421-9efa-cad6c408fcd3 | 5 | @Override
public void mousePressed(MouseEvent e) {
// only update their choice on their turn
if (( (HumanPlayer) players.get(0)) .getHumanMustFinish()) {
// find clicked cell
int row = (e.getPoint().y - 2*board.cellYSize)/board.cellYSize;
int col = e.getPoint().x/board.cellXSize;
BoardCell cli... |
8eab9399-f9b2-4af2-a965-8e33861b9f5a | 2 | @Test
public void testAvg() throws Exception
{
double average = 199.0 / 2.0;
// create a database connection
PersistenceManager pm = new PersistenceManager(driver, database, login, password);
// drop all tables
pm.dropTable(Object.class);
// create some test data
for (int x = 0; x < 200; x++)
{
... |
91932c1d-9802-4c4f-81e7-9234f29a0aa2 | 8 | public static void loop() {
while (CSGame.state == States.ThreeDeeTest) {
// Clear the screen of its filthy contents
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Push the screen inwards at the amount of speed
glTranslatef(0, 0, speed);
// Begin drawing... |
195de282-5427-40e3-85ba-ce0a554c407a | 5 | public void moveSharks(){
for(int i = 0; i<sharks.size(); i++){
// make shark hunt enemies
// if the shark is not in place
if(sharks.get(i).getInPlace() == false){
// then get the shark in place
sharks.get(i).initialSharkMove();
... |
0b1b9058-d01f-4aff-baf5-e09e3f8d3b8e | 1 | public Player(int x, int y) {
this.x = x;
this.y = y;
try {
image = ImageIO.read(new File("res/player/playerSide.png"));
} catch (IOException e) {
e.printStackTrace();
}
} |
ee70f597-6073-4535-beb8-9dd611f93e78 | 1 | public Object pop() {
if(top != null) {
Object item = top.data;
top = top.next;
size--;
return item;
}
return null;
} |
20cdaea7-245e-45ff-aa53-aea6ba293ea6 | 3 | @Override
public void run() {
String serverAddress = SERVER_IP;
try {
Socket socket = new Socket(serverAddress, SERVER_PORT);
BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
PrintWriter out = new PrintW... |
0e44d791-753f-4d8c-8e41-80b73a970456 | 4 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line = "";
StringBuilder out = new StringBuilder();
for (int i = 1; i < dp.length; i++)
dp[i] = (1.0 / (i + 1)) + dp[i - 1];
while ((line = in.readLine()) != null && ... |
521bd1fc-fb0e-4d5a-86db-68695025d1d4 | 8 | public void mouseReleased( MouseEvent e ) {
Node mouseOverN = tgPanel.getMouseOverN();
if (mouseOverN!=null && dragAddNode!=null && mouseOverN!=dragAddNode) {
Edge ed=tgPanel.findEdge(dragAddNode,mouseOverN);
if (ed==null) tgPanel.addEdge(dragAddNode,mouseOverN, Edge.DEFAULT_LEN... |
cc4779f2-22fc-49ac-a846-2c2f12307cbf | 4 | private Set<Point> n4(Point p) {
Set<Point> n4 = new HashSet<Point>();
if (p.x > 0) {
n4.add(new Point(p.x - 1, p.y));
}
if (p.x < w - 1) {
n4.add(new Point(p.x + 1, p.y));
}
if (p.y > 0) {
n4.add(new Point(p.x, p.y - 1));
}
if (p.y < h - 1) {
n4.add(new Point(p.x, p.y + 1));
}
return n4... |
a345f34a-fabc-4673-9233-33dd71e8a276 | 8 | @Override
public void executeMsg(final Environmental myHost, final CMMsg msg)
{
super.executeMsg(myHost,msg);
if(!(affected instanceof MOB))
return;
final MOB mob=(MOB)affected;
if((msg.amISource(mob))
&&(gettingBonus)
&&(msg.targetMinor()==CMMsg.TYP_WEAPONATTACK)
&&(CMLib.dice().rollPercentage()>... |
76ce8eb0-3523-47ef-97de-02a4967f8ff7 | 4 | public static int calcMinEditDist(String original, String target) {
int[][] minDistMap = new int[original.length() + 1][target.length() + 1];
for(int i = 0; i <= original.length(); i++) {
minDistMap[i][0] = costDelete * i;
}
for(int j = 0; j <= target.length(); j++) {
minDistMap[0][j] = costInsert *... |
45da23af-cfa5-4670-8f4c-2dd44ff94420 | 2 | @Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (rotation % 2 == 1) {
g.drawRect(50, 85, 100, 30);
g.drawLine(0, 100, 50, 100);
g.drawLine(150, 100, 200, 100);
g.drawLine(50, 55, 80, 75);
g.drawLine(80, 75,... |
757ab1c4-63bd-4f26-a7f8-f7c5eab7c929 | 2 | private static String recursiveStringManipulation(String s, char i, int index) {
// recursive method cutoff, prevents an infinite loop
if(index < s.length()) {
modifiedStr = (s.charAt(index) == i) ? modifiedStr.append("*") :
modifiedStr.append(s.charAt(index));
... |
f90693e4-87af-4b0a-920f-2c65622bcd10 | 0 | private static void init() {
//init
command = new String();
stillPlaying = true;
//items
Items item0 = new Items();
item0.setItemName("Water");
item0.setDesc("--Will you take some water?");
Items item1 = new Items();
... |
ebbb0f9f-5d42-42ab-9b3d-13e37a77fb5e | 3 | public void Poison() {
//if(Poisoned = false)
{
if(PoisonDelay <= 1)
{
poisondmg = true;
newhptype = true;
... |
716d0459-633f-42ae-8acb-7eee4b9080f3 | 2 | public void zeichneSpieler(Graphics g){
//g.setColor(Color.WHITE);
for(int x =0; x < level.tileIDs.length;x++){ /*level.karte.getWidth()*/ /*spieler.pos_y-10;x < spieler.pos_x +10*/
for(int y =0; y < level.tileIDs.length;y++){
System.out.println(level.getID(x,y));
}
}
} |
5598d45a-7c3e-4890-858d-ef672397a274 | 5 | public void control()
{
//Abrir canal de comunicación desde el teclado
Video video = new Video();
String texto = "";
int x=0;
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader buffer = new BufferedReader(in);
System.out.println("... |
c8fa1db0-9a11-4157-b6f3-fa2f35d0719e | 8 | protected void doUpdateItem(Item item, Object element) {
// update icon and label
// Similar code in TableTreeViewer.doUpdateItem()
IBaseLabelProvider prov = getLabelProvider();
ITableLabelProvider tprov = null;
if (prov instanceof ITableLabelProvider) {
tprov = (ITableLabelProvider) prov;
}
int colu... |
71930ccc-4426-462b-9a78-6a9cc15cfec2 | 0 | public static String formatHtml(String s) {
return s.toString().replaceAll("\n", "<br>").replaceAll("\t",
" ");
} |
f7ff837b-0555-4866-b67b-23b273985d59 | 8 | private void _listDirFilesToCLient(File fp, Request req, Response resp) throws IOException {
String path = req.getPath();
String key = fp.getPath() + fp.lastModified();
if((path.endsWith("/") || path.endsWith("\\") ) && !path.equals("/")) path = path.substring(0, path.length() - 1);
String chtml = (String)ge... |
695a056e-4299-41d9-8bb4-cfba988b5edf | 8 | private void horizontalCompactionLeft(Digraph<BrandesKoepfNode,Boolean> graph) {
for (BrandesKoepfNode v : graph.vertices()) {
v.sink = v;
v.sink2 = v;
v.shift = Integer.MAX_VALUE;
v.x = Integer.MIN_VALUE; // undefined
}
for (BrandesKoepfNode v : graph.vertices()) {
if (v.root == v) {
placeBloc... |
815115df-3d09-4767-90ed-3c90a31f53dd | 9 | @Override
public void actionPerformed(ActionEvent e) {
JButton aceptar = vista.getLogin().getBtnAceptar();
JButton cancelar = vista.getLogin().getBtnCancelar();
JMenuItem mostrarAgregarUsuario = vista.getMenAgregarUsuario();
JButton agregar = vista.getAgregarUsuar... |
402c1426-980c-47de-aade-ac4d8b961630 | 1 | @Override
public void run() {
InputStream inputStream = requestHandler.getInputStream();
RequestParser requestParser = new RequestParser(inputStream);
HTTPStatusCodes httpStatusCodes = new HTTPStatusCodes();
Routes routes = new Routes(directory);
Response response = new Response(httpStatusCodes, r... |
41ccc1c0-b1b1-4e63-a9f1-d98e13308864 | 2 | public boolean isPannableUnbounded()
{
return grid != null && (grid.getNumRows() == -1 || grid.getNumCols() == -1);
} |
d7220ffd-81ac-4bdf-b8a0-5f55fe48daff | 0 | public void mouseDragged(MouseEvent e)
{
String str = "x: " + e.getX() + ",y: " + e.getY();
System.out.println(str);
} |
959da6d2-ac45-46a3-82a3-4d1678fbb559 | 8 | public static boolean search(int[] A, int target) {
int first = 0;
int last = A.length - 1;
while (first != (last + 1)) {
int mid = (first + last) / 2;
if(A[mid] == target){
return true;
}else if (A[first] < A[mid]) {
if (A[fir... |
1eba4f26-89dc-430a-985e-8cb476861e52 | 9 | public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
for (int i = 1; i <= 1000; i++) {
if ((i % 3 == 0) && (i % 5 == 0)) {
... |
d4a7ce46-e423-4620-9c0c-2de63add86b9 | 7 | public boolean setup2(XTreeCompiler compiler, XCodeGen code) {
result = scope.get(ident, ident.name, access);
switch(result.r){
case DUPLICATED:
compiler.addDiagnostic(ident, "duplicated.var", ident.name, result.var.t.position.position.line);
break;
case FOUND:
break;
case DECLARED:
if(result.var.... |
6b43e202-e829-4695-a06e-fcb58f205551 | 9 | @Override
public void act()
{
// Removes the dead handleds
removeDeadHandleds();
// Checks collisions between all the listeners and collidables
for (int listenerind = 0; listenerind < getHandledNumber(); listenerind++)
{
// Remembers the important data about the listener
CollisionListener listener ... |
8c49ada4-9d23-4c0e-9eec-f1b9aa41213d | 9 | public final void clock(long cycles) {
if (nextCheck > cycles) return;
autoForward(cycles);
int delta = (int) (cycles - lastCycles);
lastCycles = cycles;
nextCheck = cycles + 13;
via1T1Ctr = via1T1Ctr - delta;
if (via1T1Ctr <= 0) {
if ((via1AuxControl & 0x40) == 0x40) {
// I... |
9dcb8e4f-0bf4-4e63-9e26-e1fefc5a3c83 | 4 | public Boolean podeComerFanstasma(int n){
Query q2;
switch(n){
case 0:
q2 = new Query("comerBlinky");
return q2.hasSolution();
case 1:
q2 = new Query("comerClyde");
return q2.hasSolution();
case 2:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.