method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
29e06bab-739f-4bc4-bf46-e97935471bda | 2 | public void run() {
try {
while (true) {
TimeUnit.MILLISECONDS.sleep(100);
System.out.println(Thread.currentThread() + " " + this);
}
} catch (InterruptedException e) {
System.out.println("sleep() interrupted");
}
... |
5a3fcc5c-b625-4974-8dfc-5f1bf8e75fb5 | 8 | public static BigDecimal[] realRoots(BigDecimal p[]){
int n = p.length-1;
if(n==1){
return new BigDecimal[]{
p[1].negate().divide(p[0], mc)
};
}
/*if(n==2){
BigDecimal D = p[1].multiply(p[1],mc).subtract(p[0].multiply(p[2]).multiply... |
a3fb9c6c-d44b-4ba6-8894-9f5650dce395 | 3 | public DefaultListModel<String> buildList() {
DefaultListModel<String> listModel = new DefaultListModel<String>();
String line;
try {
BufferedReader reader = new BufferedReader(new FileReader(System.getProperty("resources") + "/database/factions"));
while((line = reader.readLine()) != null) {
listMo... |
57ee5d73-80b5-4601-ab8d-cf5558d9bc59 | 1 | public void startApp() {
try {
Image im ;
im = Image.createImage("/smartravelmobile/media/accueil.jpg");
f1.append(im);//pour l'authentification
f1.setTicker(t1);//pour l'authentification
f1.append(login);//pour l'authentifica... |
f3407435-69b8-4fa2-a808-b8dab9cb5cae | 2 | @SuppressWarnings("rawtypes")
private void dealWithObjectReceived (String inType, Object inObj) {
Class c = null;
try {
c = Class.forName(inType);
}
catch (ClassNotFoundException e) {
System.out.println("Client's object type is not found...");
ret... |
b87ce2d5-e85c-485c-8183-1fb3fb2655cf | 3 | static Element[] getElementsByTagNameNR(Element e, String tagName)
{
Vector<Element> elements = new Vector<Element>();
Node child = e.getFirstChild();
while (child != null)
{
if (child instanceof Element && child.getNodeName().equals(tagName))
{
elements.add((Element) child);
}
child = child.ge... |
854824a5-f3d1-4bf7-ad14-b7072dee07e4 | 8 | protected static void printStandardPlayerCells(BufferedWriter bw, String level, ProfileHandler sp, Player player,
int gameId) throws IOException {
bw.write(String.format("<td class=\"%s\">%s</td>", CSS_NUMBER, player.rank));
bw.write(String.format("<td class=\"avatar\"><img src=\"%s\" alt=\"\"></td>", sp.getImgs... |
b9e3d4d6-f3de-48b3-b0e5-fbb2a8000636 | 6 | Vector merge(Vector v1, Vector v2) {
if (v1 == null || v1.isEmpty())
return v2;
if (v2 == null || v2.isEmpty())
return v1;
Vector result = (Vector) v1.clone();
Enumeration enum_ = v2.elements();
while (enum_.hasMoreElements()) {
Object elem = enum_.nextElement();
if (!result.contains(elem))
re... |
003cadcc-0224-4168-aece-576402c7907f | 5 | public Matrix forwardSubstitution(Matrix b) {
if(rows != cols) {
throw new IllegalArgumentException("Matrica nije kvadratna!");
}
if(b.rows != rows || b.cols != 1) {
throw new IllegalArgumentException("Krivi format vektora!");
}
double[] y = new double[rows];
for(int i = 0; i < rows; i++) {
... |
f5fcb46b-1a74-4ff5-bbcd-98b18c65217e | 6 | protected static String getUrlParams (TrackerRequest req) {
try {
StringBuilder sb = new StringBuilder("?");
sb.append("info_hash=");
sb.append(req.getInfoHash().toUrlEncodedString());
sb.append("&peer_id=");
sb.append(req.getPeerId().toUrlEncodedStr... |
5685296e-a80d-4287-8663-101d732fc067 | 2 | private void saveSettings() throws InvalidAttributeValueException {
if ( userForm.getNickname().isEmpty() )
throw new InvalidAttributeValueException("Přezdívka musí být vyplněna");
else if ( userForm.getUsername().isEmpty() )
throw new InvalidAttributeValueException("Uživatelské... |
01f0c4da-77de-4770-8edf-95293607bac3 | 8 | public void TranslationSpeed(Object[] speed) {
if (! (speed.length == 3 && speed[0] instanceof Double &&
speed[1] instanceof String && speed[2] instanceof String))
throw new IllegalArgumentException
("\nTranslationSpeed must be number, units, and time base") ;
... |
213986b1-bb0e-4376-a9d4-23860f504bd7 | 8 | private void importData(String dataSetName, String vocabularyName){
//Read documents
documentNames = new HashMap<String,String>();
documentOrder = new ArrayList<String>();
try(BufferedReader br = new BufferedReader(new FileReader("lyricsdata/document_order.txt"))) {
String line = br.readLine();
... |
7a406c45-dcd1-4da4-9a52-e7f39eee7bab | 5 | public CollisionResult collide(CollisionShape other) {
CollisionResult res;
if (other instanceof CollisionCircle) {
res = collideCircle((CollisionCircle) other);
} else if (other instanceof CollisionPolygon) {
res = collidePolygon((CollisionPolygon) other);
} else... |
15559d93-4ed7-4172-bc78-a58f7109168c | 5 | @Override
public Pos WhereSet(Bord bord,Pos clickPos) {
Pos retPos = null;
ArrayList<Pos> myHands = bord.getCanSetList(getMyColor());
if (myHands.size() > 0) {
// 四隅だけは優先して置くように
if (HighWeightList.containsAll(myHands)) {
for (Pos pos : HighWeightList) {
if (bord.CanSet(pos, getMyColor())) {
... |
72173320-76ac-45dd-a1d3-04a13cee08b7 | 1 | protected String getLink(Element item) {
switch (type) {
case Atom: return item.getElementsByTag("link").attr("href");
default: return item.getElementsByTag("span").text();
}
} |
d928bec3-717a-49cf-8d40-5e999a6757f3 | 8 | public Entity getEntity(int x, int y){
for(Entity e: entities){
if(e instanceof Structure){
Structure structure = (Structure) e;
int dx = x - structure.getxPos();
int dy = y - structure.getyPos();
if(dx >= 0 && dy >= 0){
if(dx < structure.getSize() && dy < structure.getSize()) return... |
4cf44363-14c4-4d82-b8f4-cff674d619b0 | 2 | public static void main(String[] args) {
// All code that accesses the simple GUI must run in the AWT event handling thread.
// A simple way to achieve this is to run the entire application in the AWT event handling thread.
// This is done by simply wrapping the body of the main method in a call of EventQueue.inv... |
2827d9e8-46d3-4655-a86f-6f3e0a7c5422 | 4 | public void setScoreboard() {
for(Player p : Bukkit.getOnlinePlayers()) {
Scoreboard sb = getDefaultScoreboard();
Random r = new Random();
String sbobjname = "RUSH"+r.nextInt(10000000);
int ping = ((CraftPlayer)p).getHandle().ping;
Objective obj = sb.registerNewObjective(sbobjname, "dummy");
obj = s... |
b76283bb-2e4f-42eb-bab0-d09582e77836 | 6 | public void mapTitle() {
int i = 1;
try {
File titleFile = new File("xkcdTitles.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(titleFile)));
String title = "";
while((title = reader.readLine()) != null) {
if(i == 100 || i == 404 || i == 1037) {
Sys... |
7bf868d5-d9d0-472b-998d-fb71774f4567 | 9 | public StringBuilder listQuestWinners(Session viewerS, String rest)
{
final StringBuilder buf=new StringBuilder("");
if(CMLib.quests().numQuests()==0)
buf.append(L("No quests loaded."));
else
{
buf.append("\n\r^xQuest Winners Report:^.^N\n\r");
final int COL_LEN1=CMLib.lister().fixColWidth(5.0,viewerS... |
1f2a0853-c3aa-47d7-85ff-1e86f4be3c2a | 4 | public static void kaufeWesen(Squad s, Rasse rasse, int investition) {
int erg = 0;
switch (rasse) {
case Ork:
s.hinzufuegen(Farseer.getInstance());
erg = investition - Rasse.Farseer.getKosten();
erstelleWesen(s, Rasse.Ork, erg, new Ork());
break;
case Untote:
s.hinzufuegen(Lich.getInstance());
... |
ddb3c866-6d66-4b47-880a-8c5fc8c51483 | 7 | @Override
public void layoutContainer(Container parent) {
Insets insets = parent.getInsets();
synchronized (parent.getTreeLock()) {
int n = parent.getComponentCount();
Dimension pd = parent.getSize();
int y = 0;
// work out the total size
f... |
e32f6bc4-8211-4bf4-b05c-1ed8e66ea6fe | 5 | public World initialiseWorld(Pattern p) throws PatternFormatException
{
World result = null;
if (longButton.isSelected())
{
result = new PackedWorld();
}
else if (arrayButton.isSelected())
{
result = new ArrayWorld(p.getWidth(),p.getHeight());
}
else if (agingButton.is... |
20fabae0-8742-40d0-b4c1-25f8b5a6aaac | 6 | @FXML
private void saveGame(ActionEvent event) {
if (HockmanMain.game != null) {
if(currGameFile == null) {
if(!needsFileChooserWorkaround()) {
FileChooser fileChooser = new FileChooser();
fileChooser.setInitialDirectory(new File("."));
fileChooser.getExtensionFilters().add(new ExtensionF... |
9fd4f40b-fb42-426f-bea2-0b96493044db | 8 | @Override
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append("\n------- Adjacency-List --------\n\n");
for(int i= 0 ; i< V(); i++){
Iterator<Integer> iterator = adjIterator(i);
sb.append(String.format("%-2s", i) + " | ");
while (iterator.hasNext()) {
int next = iterator.n... |
d19fa6ad-8e07-4ec8-92d1-e7c6a2a3beca | 5 | public void map(LongWritable key, Text values, Context context) throws IOException, InterruptedException {
String item = null;
String value = null;
Map<String, String> listresults = new HashMap<String, String>();
String[] splits = values.toString().split("\n");
for (String val : ... |
9c63daf5-e5f5-4cc4-ba94-0b0751bafb4e | 2 | private Boolean getBoolean(String value) {
if (value == null || value.trim().isEmpty()) {
return null;
}
return new Boolean(value);
} |
30104a1d-2292-4d45-ac23-8ff0310d27df | 5 | Step update( FragKind kind, int x )
{
Step s,t;
switch ( kind )
{
case exchanged: case inserted:
s = new Step( this, kind, this.x+1 );
if ( x-this.x>1 )
{
t = new Step( s, FragKind.merged, x );
... |
dffb9dd7-3fc6-4296-9202-4e3555e91f73 | 5 | @Override
public void execute() {
MahTreez.status = "Banking";
System.out.println("Executing banking.");
if (!Bank.isOpen()) {
Bank.open();
Task.sleep(Random.nextInt(300, 700));
// while ((Inventory.contains(MahTreez.LOG_ID))) {
while (Inventory.contains(1511))
Bank.deposit(1511, Amount.ALL)... |
2a0c4630-f7b0-43bd-b17a-6ead4803f8b1 | 1 | public void draw(Graphics g)
{
g.drawImage(background, Frame.transx, Frame.transy, Main.width + Frame.transx, Main.height + Frame.transy,
(int) -x, 0, (int) -x + Main.width, Main.height, null);
g.drawImage(title, Main.width / 2 - title.getWidth() / 2 + Frame.transx, 10 + Frame.transy, null);
for(int i = 0; i... |
a96b6c76-939d-49fb-b0d1-9f590ce9980c | 6 | public static void main(String[] args) {
int numOfAttempts = 3;
ProcessRunner<String, Failure1, Failure2> runner = new ProcessRunner<String, Failure1, Failure2>();
for(int i = 0; i < numOfAttempts + 1; i++) {
runner.add(new Processor1());
}
try {
System.ou... |
201673f3-59cf-40be-856d-481770767f2e | 1 | public void remove(Configuration configuration) {
Component comp = (Component) configurationToButtonMap
.remove(configuration);
if (comp == null)
return;
selected.remove(configuration);
remove(comp);
} |
186df27f-1fcd-4110-b5f0-d05193f21707 | 3 | public void createTileArray(int numTiles)
{
arrTiles = new int[numTiles];
arrTilesCount = new int[numTiles];
int halfTiles = numTiles / 2;
int c = 0;
try
{
// First set of tiles
for (int n = 0; n < (halfTiles); n++)
{
arrTiles[n] = r... |
c544f540-bdd6-4837-b5c0-74deae4afcf0 | 7 | @EventHandler (priority = EventPriority.HIGH)
public void onCommand(PlayerCommandPreprocessEvent e){
Player player = e.getPlayer();
if(player.hasPermission("oitc.admin") || player.isOp()){
return;
}
if(Arenas.isInArena(player)){
Arena arena = Arenas.getArena(player);
if(arena.isOn()){
if(!e.get... |
ded72597-bd40-499d-8d35-9214fbf48a23 | 8 | private static boolean req_join(ObjectInputStream in, ObjectOutputStream out, String name, ScoreTableModel scoretable ) throws Exception {
if (in == null || out == null) {
throw new Exception("Given stream is null.");
} else if (name == null) {
throw new Exception("Invalid name.");
}
// Requesting to j... |
0b97e504-d1de-45f8-82c6-d6335f2af6b1 | 6 | public static void main(String[] args) throws IOException{
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
String line;
while((line = r.readLine()) != null && line.length() != 0){
int n = Integer.parseInt(l... |
7cf4199a-386e-4197-8bf3-98ba3315dd64 | 1 | private static String executeShowAllTablesCommand(DataBaseManager dbManager, Command command) {
Collection<String> tableNamesCollection = dbManager.getAllTableNames();
String result = "";
for (String s : tableNamesCollection) {
result += s;
result += "\n";
}
... |
4e368ce5-8313-4251-85e1-d8590de0e1bb | 8 | public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
//System.out.println("Press: " + e.getKeyText(e.getKeyCode()));
KeyBoard mInstance = KeyBoard.getInstance();
switch (keyCode) {
case KeyEvent.VK_UP :
mInstance.Press(KeyBoard.KEY_CODE.KEY_UP);
break;
case KeyEvent... |
eb87d03a-fddb-48b1-8eb3-1e901a81a6ac | 2 | private static boolean isPalindrome(int n){
String s = Integer.toString(n);
for (int i=0;i<s.length()/2;i++){
if (s.charAt(i) == s.charAt(s.length()-1-i)){
continue;
} else{
return false;
}
}
return true;
} |
545171c1-f69e-405c-b315-814ff9e835b0 | 5 | public static final void DropMeso(final int meso, final MapleCharacter chr) {
if (!chr.isAlive() || (meso < 10 || meso > 50000) || (meso > chr.getMeso())) {
chr.getClient().getSession().write(MaplePacketCreator.enableActions());
return;
}
if (chr.getCheatTracker().isSpam(... |
aaf88f80-29cd-492a-bf97-e0e82440859f | 1 | public ArrayList<String> getOpiskellutAsiatJaOpiskelunKesto(){
ArrayList<String> opiskellut = new ArrayList();
for (String avain : opiskelut.keySet()) {
opiskellut.add(avain + " " + opiskelut.get(avain) + " minuuttia");
}
Collections.sort(opiskellut);
return opiskellu... |
2a378a45-b870-4178-94d3-8fdef2fb985a | 5 | public int rule() {
Scanner s = new Scanner(System.in);
int option;
System.out.println("Qual estilo de jogo que voce deseja Jogar?");
do {
System.out.println("[1] Normal");
System.out.println("[2] High Life");
System.out.println("[3] Day ... |
adbfd30a-688e-460a-8125-3d92208d5af8 | 4 | public static void muteBackground(){
// Used for loops
int i;
// Used so that the methods associated with a midi player can be accessed.
MidiPlayer currentMidiPlayer;
// Checks the slide for content
if (null != entityPlayers )
{
for(i =0;i <entityPlayers.size(); i++)
{
// test whether the midi ... |
85242051-09b8-4ae7-acfb-d422d4b66b03 | 9 | public static void main(final String[] args) throws Exception {
int i = 0;
int flags = ClassReader.SKIP_DEBUG;
boolean ok = true;
if (args.length < 1 || args.length > 2) {
ok = false;
}
if (ok && "-debug".equals(args[0])) {
i = 1;
flag... |
9dabaccc-24d8-469e-a8a9-7908e61da323 | 6 | public DesktopApplication1View(SingleFrameApplication app) {
super(app);
DesktopApplication1.getApplication().getMainFrame().setResizable(false);
Toolkit kit = Toolkit.getDefaultToolkit();
Image frameIcon = kit.getImage("C:/Users/aditya/Documents/NetBeansProjects/DesktopApplication1/src/desktopapplica... |
a8f9bdc6-5486-40b1-a947-4c6cec1c3ad6 | 8 | protected void testsWithoutClass(boolean weighted,
boolean multiInstance) {
boolean PNom = canPredict(true, false, false, false, false, multiInstance, NO_CLASS)[0];
boolean PNum = canPredict(false, true, false, false, false, multiInstance, NO_CLASS)[0];
boolean PStr... |
f993b47d-b593-485d-8f30-bec1efde3f2d | 8 | public void insertSorted(double distance, Instance instance) {
if (isEmpty()) {
m_First = m_Last = new NeighborNode(distance, instance);
} else {
NeighborNode current = m_First;
if (distance < m_First.m_Distance) {// Insert at head
m_First = new NeighborNode(distance... |
76001527-b6e8-41a1-aa68-26da9b636d2c | 2 | public boolean insertaMovimientos(int id_usuario, int id_equipo, String descripcion, String fecha) {
boolean res = true;
Statement statement;
ResultSet resultSet;
try {
Connection con = DriverManager.getConnection(connectString, user, password);
statement = con.c... |
6d0ac7a7-92ae-48bb-8c2f-c04fa7298de1 | 6 | void validate() throws validate_failed
{
int i=0;
node s=startNode;
boolean success=true;
while((s=s.nextNode()).getId()!=startNode.getId())
{
if (s.lfilledF>2 && s.getLtableF(1).getId()!=s.nextNode().nextNode().getId())
{
common.outputtoScreen("@@@@@@@@see node id="+s.getId());
dumpstate();
... |
4ab394c1-91f1-4a02-80bc-5be63ee5ab7b | 0 | public void setDataNascita(Date dataNascita) {
this.dataNascita = dataNascita;
} |
9e3161e3-9384-43e8-a06b-fecc448cf055 | 8 | public JPanel setUpToolsPanel() {
// Set up the shape combo box
ImageIcon squareButtonIcon = createImageIcon("square.gif");
ImageIcon rectangleButtonIcon = createImageIcon("rectangle.gif");
ImageIcon rightAngleButtonIcon = createImageIcon("rightAngle.gif");
JComboBox<ImageIcon> shapesComboBox = new JComboBox<... |
0713a3f4-ce28-4c00-bebf-96652f9f9701 | 5 | private int getOption() {
int option = EXIT_OPTION;
boolean done = false;
while (!done) {
System.out.print("\nSelect option: ");
try {
option = new Scanner(System.in).nextInt();
if ((option >= 1 && option <= menuItems.length) || option == ... |
8ad8f9e2-a0c7-43b9-8024-0d972d6f2208 | 0 | public void removeEdge(Object from, Object to) {
adjacent(from).remove(to);
} |
59864732-0187-4c18-a998-d8fdf50333c5 | 6 | private Calendar lastCancelTime(final List<JobAction> actionList, final Communicator comm) {
List<Calendar> cancelTimes = new ArrayList<Calendar>();
boolean idMatch, descriptionMatch;
for (JobAction ja : actionList) {
idMatch = comm != null && ja.getOwnerId() != null && ja.getOwnerId... |
252e3a22-ef8e-4c8d-8137-6cc39ae69a17 | 6 | public List<Trade> getLastestTradeOrders( Long fromTime, Long endTime ){
List<Trade> result = new ArrayList<Trade>();
String sql = " select T.* from tradeOrders T where " ;
if( fromTime != null )
sql += " T.TradeTime >= "+fromTime +" and ";
if( endTime != null )
sql += " T.TradeTim... |
438ddbc3-22ad-4a7b-bfc4-e411cb065447 | 2 | public static void main(String args[]) throws InterruptedException{
board = new RaspberryPi();
pluginManager = new PluginManager();
systemLogger = new SystemLogger();
pluginManager.loadRasPiPlugins();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
while(true){
try... |
5816ec60-47ed-4cd3-8bf0-92efca14c3bc | 5 | private final String getChunk(String s, int slength, int marker)
{
StringBuilder chunk = new StringBuilder();
char c = s.charAt(marker);
chunk.append(c);
marker++;
if (isDigit(c))
{
while (marker < slength)
{
c = s.charAt(marker... |
c275ea9f-e3cf-4905-89a2-da77de4f34d3 | 3 | public void generateRandomSymbols(int size) {
Random randGen = new Random();
for (int i = 0; i < size; i++) {
int rand = randGen.nextInt(2);
//Si le bit genere est egale a 0
if (rand == 0)
//Ajouter false a la liste informationGeneree
informationGeneree.add(false);
//Si le bit genere est egale ... |
4716af97-f6fa-441d-8c8f-64b0ef3da392 | 2 | public long longValue() // returns Long type value of data N,I
{
String s = value.trim();
return ( s.length()==0 || s.indexOf("*")>=0 ? 0 : Long.parseLong(s) );
} |
66c3be9a-e6de-4ed1-a969-f64bb0a6662e | 7 | private void takeTurn(JTable table) {
String playersMarker;
int selectedRow = table.getSelectedRow();
int selectedColumn = table.getSelectedColumn();
Point selectedLocation = new Point(selectedRow, selectedColumn);
Player currentPlayer = this.game.getCurrentPlayer();
Pla... |
81bc09e9-969b-4e6d-ae05-9cd7cedc1001 | 4 | public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_LEFT)
ddx = 0;
if (key == KeyEvent.VK_RIGHT)
ddx = 0;
if (key == KeyEvent.VK_UP)
ddy = 0;
if (key == KeyEvent.VK_DOWN)
ddy = 0;
} |
81dfbdaf-47ea-474f-9fcd-798f61431372 | 1 | public void setGameScreen(String gameScreenName) {
if (gameScreens.containsKey(gameScreenName)) {
waitingGameScreen = gameScreens.get(gameScreenName);
} else {
logger.error(new NullPointerException(), "Attempted to change the game screen to a screen that doesn't exist! Name :: ", gameScreenName);
}
} |
daedb2ad-083a-4c98-af03-2808ec95e15b | 5 | public static String NameCheck (String Name){
String result = "Valid Name";
for (int y = 0; y < Name.length(); y++){
if ((Name.charAt(y) >= 65 && Name.charAt(y) <= 90) ||
(Name.charAt(y) >= 97 && Name.charAt(y) <= 122)){
}
else{
result = "Name has invalid characters";
}
}
return(res... |
a3abebaf-21ab-4b23-afcc-ae13948f3ac9 | 5 | public static List<String> getPossibilities(CommandSender sender, Command cmd, String[] args){
if(cmd.getName().equalsIgnoreCase("check")) {
if(sender.hasPermission("modreq.check")) {
List<String> a = new ArrayList<String>();
if(args.length == 0) {// check <last page> <pending> <claimed> <closed>
... |
bd9b7056-5273-40f7-8e59-600e4ff648a8 | 4 | public static byte[] decrypt(byte[] in,byte[] key){
int i;
byte[] tmp = new byte[in.length];
byte[] bloc = new byte[16];
Nb = 4;
Nk = key.length/4;
Nr = Nk + 6;
w = generateSubkeys(key);
for (i = 0; i < in.length; i++) {
if (i > 0 && i % 16 == 0) {
bloc = decryptBloc(bloc);
System.arr... |
d3ff6059-65e5-41b1-9f55-11feef7ec717 | 5 | public static void username()
{
List<Employee> employee = ExtractEmployees.employee;
String tempUsername = null;
String username = "";
Scanner sc = new Scanner(System.in);
System.out.println("Login Display");
System.out.println();
while (tempUsername == null)
{
System.out.print("Enter your userna... |
78c668d2-8931-4c5f-a904-a11347a9e524 | 2 | public void boardWipe(String type) {
for (Card c : this.permanents) {
if (c.getTypes().contains(type)) {
this.destroy(c);
}
}
} |
00710138-08df-49f5-9b47-5ca0dd30e3e7 | 2 | private void tick() {
currentScreen.tick();
keyboard.tick();
if (keyboard.hitbox) {
if (!hitboxKeyPressed) {
showHitboxes = !showHitboxes;
}
hitboxKeyPressed = true;
} else {
hitboxKeyPressed = false;
}
} |
317159f8-29a5-4d9f-a32f-e63505a314bc | 3 | public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
... |
0a7809a8-01ec-46df-9e5f-34f02ae9a13a | 7 | @Override
protected void paintComponent(Graphics graphics) {
super.paintComponent(graphics);
BufferedImage off = new BufferedImage(getWidth(), getHeight(), TYPE_4BYTE_ABGR);
Graphics buffer = off.getGraphics();
if (image != null) {
int targetWidth = getWidth();
int targetHeight = getWidth();
double pr... |
0e5c0ee1-75e3-43f8-99da-9ca7d213231d | 2 | @Override
public String toString () {
final StringBuilder sb = new StringBuilder("{\n");
for (final Map.Entry<String,Value<?>> me : value.entrySet()) {
sb.append(" \"");
sb.append(me.getKey());
sb.append("\":");
sb.append(me.getValue().toString().rep... |
6167f1b8-48d6-4afe-b855-4d2d568ab497 | 4 | @Override
public Map<String, String> getParsedResults() {
if (!resultingMap.isEmpty()) {
return resultingMap;
}
String[] lines = stringBuilder.toString().split("\n");
for (String line : lines) {
line = line.trim();
if (line.startsWith("时间:")) {
parseStartAndEndTime(line.substring("时间:".length()));... |
9028b706-590f-44a9-904b-8fc9d2160489 | 4 | public void save() {
try {
if(!file.exists()) {
if(file.getParentFile()!=null)
file.getParentFile().mkdirs();
if(file.createNewFile())
super.save(file);
else
throw new Exception("Cannot save: File can not be created!");
}
else
super.save(file);
} catch (Exception e) {
e.printStackTrace();... |
0133392b-e830-4c33-9e1c-5de398f3c292 | 9 | ClosedArea append(LineSegmentInt other) {
if (isClosed()) {
throw new IllegalStateException();
}
if (getSegments().contains(other)) {
throw new IllegalArgumentException();
}
final ClosedArea result = new ClosedArea();
for (LineSegmentInt seg : segmentsList) {
result.addSegment(seg);
}
if (resul... |
4c93764f-3e5b-4e15-b7d6-c3d7167e143e | 9 | public void okButton_actionPerformed(ActionEvent e) {
String script = null;
String output = null;
String comparison = null;
if(scriptFileChooser.isFileNameChanged() || !scriptFileChooser.getFileName().equals("")) {
script = scriptFileChooser.getFileName();
scrip... |
49eb6b1c-88aa-4c6a-89f8-aa755d0e9270 | 5 | public FireCreep(int id){
if (id >= 1 && id <= 3){
if (id == 1){
maxHp = 50;
armor = 10;
speed = 3f;
}else if (id == 2){
maxHp = 500;
armor = 15;
... |
1f105b52-a5a5-408e-b3f7-2aaa856fa665 | 1 | @Test
public void exceededCapacityTest2() {
Activity activity = new Activity("Baloncesto Primaria", 1,
new BigDecimal(20.0), new BigDecimal(0), new HashSet<Student>());
try {
activityService.create(activity);
} catch (DuplicateInstanceException e) {
fail("Duplicated activity");
}
assertFalse(acti... |
6ddba45f-0b86-4023-9c9d-6f1025bd6184 | 1 | public double getHarmonicAverage() {
double sum = 0;
for (Association association : associationsSet)
sum += (1 / association.getDistance());
return (associationsList.size() / sum);
} |
d76d1756-f558-4f94-814c-5f4de649dcfb | 8 | boolean move(Game game)
{
// creature has not moved
boolean moved = false;
// move away from other creatures randomly if too close
moved = repulsion(game);
// if existing goal is not reachable, ditch that goal
if (fCreature.getGoal() != null &&
... |
a4b5ecfb-03c2-4a14-a3e4-d00c921991e6 | 5 | public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
Integer number = new Integer(value.toString());
if (number == 0)
return;
else if (number == 1)
return;
else if (number... |
5dccfcac-5f0c-4383-928a-5da50a6807c2 | 6 | static EventObject jdialog(JFrame owner,String title,JComponent body,JComponent ...ok){
JDialog dialog = new JDialog(owner,title);
dialog.setContentPane(body);
dialog.pack();
if(owner!=null)dialog.setLocationRelativeTo(owner);
else centerLocation(dialog);
JEventQueue events = new JEv... |
971171c2-ff80-4e27-a732-b2e67ab3fd27 | 9 | public void genLines() {
lines = new Line2D[(xTiles + 1) * (yTiles + 1) * 2];
int pos = 0;
for(int i = 0; i < numNodes; i++) {
if(nodes[i].y == 0 || !adj[i][i - 1]) {
if(i == entry) entryl = pos;
lines[pos++] = new Line2D.Float(nodes[i].y * tileSize + adjustx,
nodes[i].x * tileSize + adjust... |
98e90904-35ba-4bf5-b36c-263207fb1ef2 | 7 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(canBeUninvoked())
{
if((affected!=null)
&&(affected instanceof MOB)
&&(tickID==Tickable.TICKID_MOB))
{
final MOB mob=(MOB)affected;
if((bonding==null)||(mob.location()==null))
{
messedUp=true;
unInvoke();
}
... |
007aa1be-3a6c-41d1-b909-c75d9c4ca81f | 0 | static public void setImageSizeH(int height)
{
imageSizeH=height;
} |
66d2d948-22a0-4334-b0a1-91a6b2e43b12 | 8 | public void keyPressed(KeyEvent ke)
{
int kc = ke.getKeyCode();
if(kc == KeyEvent.VK_RIGHT || kc == 68)
p.input.addKey(Input.RIGHT);
if(kc == KeyEvent.VK_LEFT || kc == 65)
p.input.addKey(Input.LEFT);
if(kc == KeyEvent.VK_UP || kc == 87)
p.input.addKey(Input.UP);
if(kc =... |
e9306429-5e79-4d00-84c0-c27cf99d7674 | 3 | public static ScopeTypeEnumeration fromString(String v) {
if (v != null) {
for (ScopeTypeEnumeration c : ScopeTypeEnumeration.values()) {
if (v.equalsIgnoreCase(c.toString())) {
return c;
}
}
}
throw new IllegalArgumentException(v);
} |
672e5c41-c578-4783-892d-eebda2250a4a | 7 | public void run() {
int readPoint = 0;
int bytesRead = 0;
try {
while (notYetEOF) {
if(GameData.musicMuted)stop();
else start();
if (playing) {
bytesRead = in.read (buffer,
readPoint,
buffer.length - readPoint);
if (bytesRead == -1) {
... |
b897c498-6cd7-4d33-befe-d297c90f01b1 | 0 | public void setSampleInput(String sampleInput) {
this.sampleInput = sampleInput;
} |
8f6f8d42-f9d9-4350-a452-f4169bb972b2 | 7 | private void parseNode ( Node currentNode )
{
nodeInfo = new InsenseNode();
for (int i = 0; i < currentNode.getAttributes().getLength(); i++)
{
if ("name".equals(currentNode.getAttributes().item(i).getNodeName()))
{
if (null != currentNode.getAttribute... |
41273d2d-3cbb-494d-80f6-2a44e61c219a | 2 | public static Map<String,Cliente> leerFichero(){
Map<String,Cliente> array=new HashMap<String,Cliente>();
try{
File fichero=new File("src/Ficheros/Clientes.txt");
FileReader fr=new FileReader(fichero);
BufferedReader br=new BufferedReader(fr);
String linea="";
while((linea=br.readLine())!=null){
... |
41754058-cae1-4ba0-b268-b5abc623176d | 7 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(!super.tick(ticking,tickID))
return false;
if(affected==null)
return false;
if(!(affected instanceof MOB))
return true;
final MOB mob=(MOB)affected;
if((!mob.amDead())&&((--diseaseTick)<=0))
{
diseaseTick=DISEASE_DELAY();
if(... |
b1d41d56-dd5b-47bb-a03e-ee0d6531adf6 | 1 | private void showLicense() {
JDialog dialog = new JDialog(this, resources.getString("dialog.license.title"));
final JEditorPane text = new JEditorPane();
try {
URL url = getClass().getResource("GNULicense.txt");
text.setPage(url);
} catch (Exception e) {
text.setText(res... |
3a6312aa-4241-488d-ab87-c0516c5aee35 | 1 | private boolean jj_2_77(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_77(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(76, xla); }
} |
8add0881-6f74-4d37-9ab8-79895ecd10c2 | 3 | public void tick(long delta) {
// drawX = (int)(realX - game.getCameraX()) - (width / 2);
// drawY = (int)(realY - game.getCameraY()) - (height / 2);
//animation
if(animated) {
animationTimer -= ((0.000000001 * animationSpeed) * delta);
if(animationTimer < 0) {
... |
9a37069d-9fab-40d5-bbe2-5b294c7a7204 | 7 | public void moveRow(int start, int end, int to)
{
if (start < 0)
{
String message = "Start index must be positive: " + start;
throw new IllegalArgumentException( message );
}
if (end > getRowCount() - 1)
{
String message = "End index must be less than total rows: " + end;
throw new IllegalArgume... |
8a05b1c8-b1a8-4839-aae8-c76d5c0291f1 | 4 | static private boolean jj_3_12() {
if (jj_scan_token(TUPLETAG)) return true;
if (jj_scan_token(LPAREN)) return true;
Token xsp;
xsp = jj_scanpos;
if (jj_3_11()) jj_scanpos = xsp;
if (jj_scan_token(RPAREN)) return true;
return false;
} |
4ba13914-4a77-423e-82c0-dcb049e58391 | 6 | public Point setPopUpMenuLocation(Point p, Dimension d) {
Rectangle bounds = getSafeScreenBounds(p);
int x = p.x;
int y = p.y;
if (y < bounds.y) {
y = bounds.y;
} else if (y > bounds.y + bounds.height) {
y = bounds.y + bounds.height;
}
if (... |
cdcc0a3e-2e50-418e-a832-a891d7b3b848 | 0 | public FractionResource(FractionType type, float value) {
this.type = type;
this.value = value;
} |
030730f1-5e30-4de0-b1c2-ac2fd0c30729 | 4 | private void parseBaseLevel(Node node) throws TemplateException {
if (node.getNodeName().equals("dc:title")) {
// title element
Element titleNode = html.createElement("title");
titleNode.setTextContent(node.getTextContent());
tagHead.appendChild(titleNode);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.