method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
428f4fd4-6de3-4027-b7ce-c0cc450663a6 | 3 | public void setInt(TInt node)
{
if(this._int_ != null)
{
this._int_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
... |
13a6b131-d24e-47a4-b2db-ce1867f81dac | 2 | public boolean isAdjacentTo(Location other) {
if(Math.abs(other.x - x) <2 && Math.abs(other.y - y) < 2)
return true;
return false;
} |
2e0a5396-f971-44c5-9846-4697d239505d | 1 | public Torrent(byte[] torrent) throws IllegalArgumentException {
this.encoded = torrent;
try {
this.decoded = BDecoder.bdecode(
new ByteArrayInputStream(this.encoded)).getMap();
this.announceUrl = this.decoded.get("announce").getString();
this.decoded_info = this.decoded.get("info").getMap();
th... |
c95ed41e-e044-448b-bf6c-5ff38dfda3ad | 7 | static Object callSecurely(final CodeSource codeSource, Callable callable,
Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
{
final Thread thread = Thread.currentThread();
// Run in doPrivileged as we might be checked for "getClassLoader"
// runtime permission
... |
6bbd8f9a-7f10-4825-8295-e3ddd5e3f841 | 3 | private static void closeResult(ResultSet rs) {
if( rs != null ) {
try {
if( !rs.isClosed() ) {
rs.close();
}
} catch (SQLException e) {
logger.error("Error closing the result set.", e);
}
}
} |
bec38d6f-983d-44c9-b5b1-5e9b59d55bda | 5 | public InteractivePanel(){
addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if(e.getButton()!=MouseEvent.BUTTON1)
return;
double x = e.getXOnScreen();
double y = e.getYOnScreen();
Graphics g = getGraphics();
for(SUIComponent comp : components){
... |
e790bf6a-2735-486b-916e-f19bd8cdb848 | 5 | public boolean containsChord(Chord chord) {
// Check for tonic
if (tonic.equals(chord)) {
return true;
}
// Check all the subdominant chords
for (int indx = 0; indx < subdominant.length; indx++) {
if (subdominant[indx].equals(chord)) {
return true;
}
}
// Check all the dominant chords
... |
d655dc68-9f1e-44d2-b645-85b15cde5cb4 | 3 | private static ArrayList<Models.ViewModel.BillItem> getBillItems(ArrayList<Models.DatabaseModel.BillItem> billItems, ArrayList<Models.DatabaseModel.Medicine> medicines) {
ArrayList<Models.ViewModel.BillItem> viewmodelbillItemArray = new ArrayList<>();
for (Models.DatabaseModel.BillItem billItem : billI... |
e8075007-7b1d-48d0-9fcf-18ee48df51a1 | 7 | @Override
protected void init() {
try {
// check to see if the user is using a File or InputStream. This is
// here for backwards compatability
if (dataSourceStream != null) {
final Reader r = new InputStreamReader(dataSourceStream);
setDat... |
2a0d1739-fbdd-4777-a255-8834e86f59d2 | 5 | static Color getCtryColor(String country) {
// Special case: XXX means no one
if (isNotACountry(country))
country = "NAT";
else
country = toUpperCase(country);
Color ret = ctryColorCache.get(country);
if (ret == null) {
... |
9f7372cc-5414-4929-8e99-52714ec15326 | 6 | private static HashMap<String, Integer> getDocumentFrequency(String dirName,
Normalizer stemmer) throws IOException{
HashMap<String, Integer> hits = new HashMap<String, Integer>();
File dir = new File(dirName);
if (dir.isDirectory()) {
// Liste des fichiers du répertoire
// ajouter un filtre (FileNameFilter) ... |
6f636dbc-54a7-43e2-af25-e6ae90436d6e | 7 | private final void processPrivileges(ArrayList<String> privs, PrivilegeHolder entity) {
if(entity == null || privs == null)
return;
// Denials
ArrayList<String> denials = entity.getDenials();
for(String denial: denials) {
if(denial.equals("*")){
privs.clear();
break;
}
privs.remove(de... |
c06893ab-99bd-460c-a63d-f51af47eda86 | 7 | @Test
public void testNotifyAll() {
final Object o = new Object();
Runnable r = new Runnable(){
@Override
public void run() {
assertThreadIsRunnable();
try {
synchronized(o){
o.wait();
// wait can only be invoked on an object if the thread which invoked wait owns the m... |
2c222867-770b-474c-827c-187f84a2d3f7 | 7 | static void projectionTest(int n) {
planner = new Planner();
Variable scale = new Variable("scale", 10);
Variable offset = new Variable("offset", 1000);
Variable src = null, dst = null;
List<Variable> dests = new ArrayList<Variable>();
for (int i = 0; i < n; i++) {
... |
e3da4dbf-c052-4cb1-888c-12d6786efecc | 2 | public void grabData() {
if(System.getProperty("os.name").contains("Win") || System.getProperty("os.name").contains("win")) {
isWindows = true;
} else {
isWindows = false;
}
grabOSName();
grabOSVersion();
grabOSArchitecture();
} |
73d41993-de01-4c87-ac2f-16e84625da9f | 4 | public boolean hasGodmode(xAuthPlayer player, DamageCause cause) {
int godmodeLength = plugin.getConfig().getInt("session.godmode-length");
Timestamp loginTime = player.getLoginTime();
if (godmodeLength < 1 || loginTime == null || cause == DamageCause.FIRE_TICK || cause == DamageCause.DROWNING)
return false;
... |
e6638ae1-92ca-4eb0-85da-300893906739 | 1 | public static BigInteger factorial(int f)
{
BigInteger res = new BigInteger("1");
for(int i = 2; i <= f; i++)
{
res = res.multiply(new BigInteger("" + i));
}
return res;
} |
f87922b3-c74a-44c9-9ce2-9d8315e05509 | 4 | public void testSaveGosta() { Osoba o=new Osoba(); o.setImePrezime("Alen Kopic");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
o.setDatumRodjenja(sdf.parse("1992-10-21"));
} catch (java.text.ParseException p) {
System.out.println(p.toString());
}
o.setAdresa("Vitkovac 166... |
aa754af4-5776-4cb3-b978-a2024266c059 | 1 | public void makeNonVoid() {
if (type != Type.tVoid)
throw new jode.AssertError("already non void");
type = subExpressions[0].getType();
} |
76c94167-b645-40f5-a224-2de30245eef6 | 2 | public static int getIndexFromName(ArrayList<Method> methods,String possibleSetName){
for(int i=0;i<methods.size();i++){
if(methods.get(i).getName().equalsIgnoreCase(possibleSetName)){
return i;
}
}
return -1;
} |
f303d3ab-a1eb-494a-9c4b-1718ac312c59 | 9 | public static void keySet(int i, boolean b) {
if(i == KeyEvent.VK_UP) keyState[UP] = b;
else if(i == KeyEvent.VK_LEFT) keyState[LEFT] = b;
else if(i == KeyEvent.VK_DOWN) keyState[DOWN] = b;
else if(i == KeyEvent.VK_RIGHT) keyState[RIGHT] = b;
else if(i == KeyEvent.VK_SPACE) keyState[BUTTON1] = b;
else if(i ... |
573d48ce-a90b-4e17-bf33-de1f6b712ca7 | 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... |
510b44c4-7770-4336-af29-b61dabfaa8ca | 2 | public void addState(State state) {
if (!this.states.contains(state)) {
this.states.add(state);
if (state != null) state.setTray(this);
}
} |
85b43e74-5b75-424b-8b06-11cc5a116713 | 9 | public double[] distributionForInstance(BayesNet bayesNet, Instance instance) throws Exception {
Instances instances = bayesNet.m_Instances;
int nNumClasses = instances.numClasses();
double[] fProbs = new double[nNumClasses];
for (int iClass = 0; iClass < nNumClasses; iClass++) {
... |
bfc439d2-ca8b-43b6-98c6-e9e400c3d8c4 | 2 | public String highMonth(){
double max = profit[0];
String maxMonth = month[0];
for(int i = 1; i < 12; i++){
if(max < profit[i]){
max = profit[i];
maxMonth = month[i];
}
}
return maxMonth;
} |
de66a962-7d43-4390-a995-86575dbaaab7 | 3 | private String makeKey(String[] text, Boolean[] stresses) {
StringBuilder key = new StringBuilder();
key.append(Utils.join(text, KEY_DELIM));
// If we're stress sensitive, tack the stresses on the end, note
// we just use 1s and 0s to keep the string shorter than true/false would
if (stressSensitive) {
fo... |
97ab6901-392a-4fa3-9342-915950a44e53 | 3 | public Object getDefaultValue() {
switch (typecode) {
case TC_LONG:
return new Long(0);
case TC_FLOAT:
return new Float(0);
case TC_DOUBLE:
return new Double(0);
default:
return null;
}
} |
c9a14f28-cebe-4136-ace0-98003b707a4b | 3 | public static void toggleCommentInheritance(Node currentNode, JoeTree tree, OutlineLayoutManager layout) {
CompoundUndoablePropertyChange undoable = new CompoundUndoablePropertyChange(tree);
JoeNodeList nodeList = tree.getSelectedNodes();
for (int i = 0; i < nodeList.size(); i++) {
toggleCommentInheritanceF... |
6e0fbdbb-0810-4196-831a-34a3821aadd4 | 1 | public void unloadQueue(Response response) {
for (Cookie cookie : queue) {
response.addHeader("Set-Cookie", cookie.getHTTPHeader());
}
} |
727e5edb-71ba-4a08-bb27-63dc9d034dbf | 0 | public Upgrade[] getUpgrades() {
return upgrades;
} |
846f302f-244e-4f7a-b316-5180032c9cef | 6 | public static String getDefaultRegionName(Player player, RegionType regionType) {
net.sf.freecol.common.model.Map map = player.getGame().getMap();
int index = player.getNameIndex(regionType.getNameIndexKey());
if (index < 1) index = 1;
String prefix = player.getNationID() + ".region."
... |
7852d14a-6061-4cd2-aca6-b4be85c564ea | 5 | @Override
public boolean execute(CommandSender sender, String[] args)
{
if(sender instanceof Player == false)
{
sender.sendMessage("Only players can own chunks ;D");
return true;
}
if(!((Player)sender).getWorld().getName().equals(p.getWorld())) return true... |
29c65eb0-823e-4f1a-8a79-1b1e963ac0e1 | 5 | public void menuButtonClicked(String button) {
if (button.equals("Start Game")) {
onMenuScreen = false;
startGame();
} else if (button.equals("About")) {
JOptionPane
.showMessageDialog(
this,
"<HTML>Mouse Maze Escape<br>Version: "
+ version
+ "<br>Author: Thomas Auberso... |
360b7be4-c7ae-4477-86e5-c06d8f2e17f7 | 4 | public void keyTyped(KeyEvent evt) {
if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
setModelProperty(PROPERTY_NEXT_FIELD, Direction.DOWN);
} else if (evt.getKeyCode() == KeyEvent.VK_UP) {
setModelProperty(PROPERTY_NEXT_FIELD, Direction.UP);
} else if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
setModelProperty... |
b7e1bc45-a47c-4ee0-b9a3-51de10fccddf | 4 | private void doMain() {
for (String filename : filenames) {
File inputFile = new File(filename);
TextExtractor te = null;
try {
te = parsePdf(inputFile);
System.out.println(te.toXml());
} catch (IOException e) {
... |
5a455353-6482-4f23-a8bb-687cfa1183e7 | 6 | private void createGoal(int x, int y)
{
//Schnitt mit Linien pruefen
for(int i=0; i<Lines.size(); i++)
{
float d = (float) Line2D.ptSegDist(Lines.elementAt(i)[0], Lines.elementAt(i)[1], Lines.elementAt(i)[2], Lines.elementAt(i)[3], x, y);
if(d < 10){return;}
}
//Schnitt mit anderen Baellen pruefen
f... |
ffb0194f-a63f-408a-9bdb-af12f89db315 | 4 | public ArrayList<Administrador> getAll(){
PreparedStatement ps;
ArrayList<Administrador> admins = new ArrayList<>();
try {
ps = mycon.prepareStatement("SELECT * FROM Administradores");
ResultSet rs = ps.executeQuery();
if(rs!=null){
try {
... |
bf6d88f5-f8b6-4e5d-a5dd-a8f46e754c0f | 3 | private final boolean readUntilSep(final ByteBuffer nameBuffer)
throws IOException {
nameBuffer.position(0);
do {
final int read = this.in.read();
if (read == Deserializer_3.SEPERATOR_3) {
return false;
}
if (read == Deserializer_3.SEPERATOR_EXT_3) {
return true;
}
nameBuffer.put((byte)... |
e11de54e-4fc1-4708-b9d5-cb896f6b706d | 4 | public Client_Socket(String hostName, int portNumber) throws ConnectException {
try {
try {
echoSocket = new Socket(hostName, portNumber);
} catch (ConnectException e) {
throw e;
} catch (UnknownHostException e) {
System.out.pr... |
b81dc9d9-7b4a-413f-bbc1-656deaac01a5 | 4 | protected int getKnownAttributeCount() {
int count = 0;
if (bytecode != null)
count++;
if (exceptions != null)
count++;
if (syntheticFlag)
count++;
if (deprecatedFlag)
count++;
return count;
} |
1e199aa2-d60a-489b-9701-0bcb99611dca | 3 | @Override
public List<Cliente> listAll() {
Connection conn = null;
PreparedStatement pstm = null;
ResultSet rs = null;
List<Cliente> clientes = new ArrayList<>();
try{
conn = ConnectionFactory.getConnection();
pstm = conn.prepareStatement(LIST);
... |
96b9cdfa-9aa2-4ee2-9da9-13973d27e88c | 7 | public static Room buildRoom(EnumArray rm, int y, int x) {
Room room = new Room();
switch(rm) {
case PATH:
Random r = new Random();
int num = r.nextInt(10);
if (num < 2)
room.setBehavior(new ItemBehavior(new Potion()));
else if (num < 4)
room.setBehavior(new ItemBehavior(new Poison())... |
2328038f-5b19-46e6-8b7a-652bb9d74627 | 4 | @Override
public String encrypt(String str) throws IllegalBlockSizeException {
try {
// Encode the string into bytes using utf-8
byte[] utf8 = str.getBytes("UTF8");
// Encrypt
byte[] enc = ecipher.doFinal(utf8);
// Encode bytes to base64 to get a... |
6db9a971-18af-4457-8a88-545362652635 | 9 | public void moveToPosition(Position nextPosition){
if(vehicle != null && mapStolen){
flyToVaderBase();
mapStolen = false;
}
inhabitantColl = super.getInhabitantColl();
if(inhabitantColl.objectAt(nextPosition)){
TetraGUIManager.DisplaySteps("THero " + getName() + " (ID: " + getTetId() + ") cannot mov... |
5e3b673a-c080-4fa1-bdfd-b18a19cbc7aa | 9 | private void method38()
{
for(int i = -1; i < playerCount; i++)
{
int j;
if(i == -1)
j = myPlayerIndex;
else
j = playerIndices[i];
Player player = playerArray[j];
if(player != null && player.textCycle > 0)
{
player.textCycle--;
if(player.textCycle == 0)
player.textSpoken = nu... |
5b44e320-5e5f-4984-a125-a9559b38cee4 | 8 | public GrahamScan(Point2D[] pts) {
// defensive copy
int N = pts.length;
Point2D[] points = new Point2D[N];
for (int i = 0; i < N; i++)
points[i] = pts[i];
// preprocess so that points[0] has lowest y-coordinate; break ties by x-coordinate
// points[0] is an... |
75cdcfee-5fdc-4363-af89-9666cff03049 | 6 | @EventHandler
public void PigZombieResistance(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.getPigZombieConfig().getDouble("PigZo... |
874d36a8-6582-4663-88d7-3b26e4dee881 | 7 | public void deletePlayer(String lastname) {
Node node = head;
while(true){
if(node == null){
System.out.println("i could not found it");
break;
}
else if(node.getPlayer().getName().getLast().equals(lastname)){ // when found
if(node == head && node =... |
1aaff006-4132-4e22-b68e-691c49029b9b | 9 | protected Validator createValidator()
throws JspException {
FacesContext context = FacesContext.getCurrentInstance();
Validator validator = null;
ValueExpression vb = null;
// If "binding" is set, use it to create a validator instance.
if (binding != nul... |
bb86538b-0ec4-44e3-a635-6d660616dd82 | 5 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Coordinates that = (Coordinates) o;
if (x != that.x) return false;
if (y != that.y) return false;
return true;
} |
638d0608-2296-4d77-aaa1-856ec9a99ff5 | 1 | public void playFadeLoop() throws InterruptedException{
try
{
in = new FileInputStream(fade);
as = new AudioStream(in);
ap.player.start(as);
}
catch(Exception e)
{
System.out.println("Got an IOException: " + e.getMessage());
e.printStackTrace();
... |
cfb05d24-a614-4a5e-8b86-055205a04f95 | 6 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Symbol)) return false;
Symbol symbol = (Symbol) o;
if (bitMaskValue != symbol.bitMaskValue) return false;
if (id != symbol.id) return false;
if (name != null ? !name.equals(sy... |
e30626ad-08c0-4248-88f3-8f86535c191b | 7 | public String relevanceFeedback(TreeSet<SolrDocument> input) {
// TODO make a complete list of accepted fields that should be used in
// relevance feedback. ID, for example, is not wanted
StringBuilder query = new StringBuilder();
for (SolrDocument doc : input) {
// Collection<String> fields = do... |
4210198c-e51a-48c2-9902-538b21ac81d1 | 5 | public void setAbsoluteTerminalPoint(mxPoint point, boolean isSource)
{
if (isSource)
{
if (absolutePoints == null)
{
absolutePoints = new ArrayList<mxPoint>();
}
if (absolutePoints.size() == 0)
{
absolutePoints.add(point);
}
else
{
absolutePoints.set(0, point);
}
}
else... |
ab045ffd-1557-45bb-8991-1c16fec4b91a | 5 | private void init(boolean flag) {
int i;
int a, b, c, d, e, f, g, h;
a = b = c = d = e = f = g = h = GOLDEN_RATIO;
for (i = 0; i < 4; ++i) {
a ^= b << 11;
d += a;
b += c;
b ^= c >>> 2;
e += b;
c += d;
c ^= d << 8;
f += c;
d += e;
d ^= e >>> 16;
g += d;
e ... |
02fb9dc3-813e-40b6-b1e0-c21c8fce69fd | 4 | public static DataContainer readTableDescriptions() throws IOException {
DataContainer allData = new DataContainer();
File fileDir = new File(backupFilePath);
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileDir), "UTF8"));
Map<String, Row> rowsForC... |
f3d167bd-04ff-48d8-9794-24ae66d70772 | 9 | private void help(CommandSender s) {
s.sendMessage(ChatColor.RED + "Ender's Game Commands You Can Use");
if (s.hasPermission("EndersGame.join")) s.sendMessage(ChatColor.GOLD + "/eg join [arenaID]");
if (s.hasPermission("EndersGame.join")) s.sendMessage(ChatColor.GOLD + "/eg leave");
if (s.hasPermission("EndersG... |
b98e0c4f-f0f8-4408-ad67-0f3886c14ef7 | 3 | public void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
String itemText = (String)jComboBox1.getSelectedItem( );
if (itemText.equalsIgnoreCase("Farenheit"))
{
String tester = itemText;
TPT test = new TPT();
... |
9f015b60-6073-4422-a3f1-a0cbbf92837c | 4 | public Tile getTile(int x, int y) {
if (x < 0 || x >= width || y < 0 || y >= height) return Tile.VOID;
return tileset.getTile(tiles[x + y * width]);
} |
1761170c-36b8-4f31-9260-44a2844ecd70 | 0 | @Override
public void windowDeiconified(WindowEvent e)
{
} |
19d75a80-6a09-45a5-98db-25872da90b36 | 3 | public void adicionaDisciplina(String nome, String codigo)
throws DisciplinaJaExisteException {
boolean teste = false;
for (Disciplina e : disciplina) {
if (e.getCodigo().equals(codigo)) {
teste = true;
break;
}
}
if (teste == false) {
Disciplina disc = new Disciplina(nome, codigo);
disci... |
bb9ae112-60d3-488e-8baf-26478d586db6 | 0 | @Test
public void insertSingleElementToAnEmptyListMinMax() {
l.insert(v);
assertEquals(v, l.min());
assertEquals(v, l.max());
} |
a3428d9c-d162-48a2-bd12-61ffb7eb209d | 4 | public void keyPressed(int x, int y){
keys.clear();
for(int i = 0; i < width; i++){
for(int j = 0; j < height; j++){
Tile tile = tiles[i][j];
if(tile.getType() == 5 || tile.getType() == 6) {
tiles[i][j] = new Tile(0, false, tile.x,tile.y);
}
}
}
} |
01513ba5-fcf5-4cac-8b37-48c7ac5c411d | 6 | @EventHandler
public void onBlockBreak(BlockBreakEvent evt) {
Player p = evt.getPlayer();
Block b = evt.getBlock();
ConfigurationSection cProfs = plugin.getConfig().getConfigurationSection("profs");
Set<String> profs = cProfs.getKeys(false);
Iterator<String> i = profs.iterator();
while ( i.hasN... |
ffaec118-d00c-4775-bf4f-04249213075a | 3 | @Override
public void handleMouse(int posX, int posY, int flag) {
if (!enabled) return;
if ((flag & 1) != 0) texY = 57;
else if ((flag & 2) != 0) clickEvent.trigger();
else texY = 109;
} |
0d03c30f-05e3-4083-8d1a-9fd72b59b9e4 | 6 | private void saveFactsAndAllRules(Collection<Rule> rules) throws IOException {
if (null == rules || rules.size() == 0) return;
for (Rule rule : rules) {
StringBuilder sb = new StringBuilder();
if (!rule.getLabel().startsWith(DEFAULT_RULE_LABEL_PREFIX)) sb.append(rule.getLabel());
if (!"".equals(rule.getMod... |
01b82f8e-e562-4b31-b098-dcb6e782efe2 | 9 | public Request resolve(Request request) throws UnknownHostException{
request.getClass().cast(request);
switch(request.operation){
case ADD:
request.setReply(true);
break;
case REMOVE:
request.setReply(true);
break;
case CHECK:
request.setReply(true);
break;
case CHANGENAME:
r... |
5ed79f6e-f77b-459b-be56-dc16d5bcbac0 | 9 | @Override
public boolean equals( Object other ) {
if ( other == this ) {
return true;
}
if ( !( other instanceof TByteList ) ) return false;
if ( other instanceof TByteArrayList ) {
TByteArrayList that = ( TByteArrayList )other;
if ( that.size() !... |
fc4f260b-3087-42b1-abfc-13805cc9c88f | 9 | static void test13() {
grid_size = 3;
int num_generations = 1000;
int num_atoms = 13;
int population_size = 10;
double max_potential;
double min_potential;
double[][][] population = new double[population_size][][];
double[] fitness = new double[population_... |
ebab7880-f0a0-4125-ada0-f24cb6bff901 | 0 | public String end_graph() {
return "}";
} |
7ca57857-7e2a-41dc-8517-5e5482f8b702 | 2 | public static ArrayList<CardAccount> getAll(){
SQLiteJDBC db = new SQLiteJDBC();
ArrayList<CardAccount> card_accounts = new ArrayList<CardAccount>();
String sql = "SELECT account_num FROM card_accounts";
ResultSet resultSet = db.query(sql);
try {
... |
eaf5f95d-784b-4bd1-bd7a-b4b78cdef776 | 4 | public Tile getTile(int x, int y) {
if (x < 0 || x >= width || y < 0 || y >= height) return Tile.OBSIDIAN;
return Tile.tiles[tiles[x + y * width]];
} |
6481fa97-1d03-4448-bfe4-d00d91076f22 | 7 | private void UpdateCharacterPosition(int rowPosition, int columnPosition, String characterName )
{
int randmomMovement = new Random().nextInt( movements.length );
if( characterName == "Victim" )
{
Boolean shouldVictimMove = ShouldVictimMove( rowPosition , columnPosition );
if( shouldVictimMove ==... |
93c72454-f249-4717-90f9-085f2d1d1ad3 | 0 | public IntBTNode getRight( )
{
return right;
} |
dae05e67-e73f-4265-988c-e3c13de42dcd | 9 | public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final MethodCall that = (MethodCall)o;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (params != null ? !params.equal... |
1b203e24-a1e0-4738-82a8-1321a277ec66 | 0 | public void mouseEntered(MouseEvent e)
{
String str = "The mouse has entered the Frame !";
System.out.println(str);
} |
f654fb82-b096-4d35-850a-b627a0de8c5e | 6 | private int getVersionNumberFromFileServer(String filename, FileServerInfo info)
{
int version = -1;
try
{
Socket socket = new Socket(info.getAddress(), info.getPort());
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
oos.flush();
ObjectInputStream ois = new ObjectInputStre... |
401ad04c-4797-44d2-b7a4-1b55c31805fe | 0 | public static void main(String args[]){
GenericsTypeOld type = new GenericsTypeOld();
type.set("Pankaj");
// type.set(1); ClassCastException
String str = (String) type.get(); //type casting, error prone and can cause ClassCastException
System.out.println(str);
} |
cea23fcb-b338-46d6-ae6f-5432938ff466 | 5 | private void generateJMenuBar() {
JMenuBar jMenuBar = new JMenuBar();
JMenu file = new JMenu("File");
JMenu calculate = new JMenu("Calculate");
JMenu speed = new JMenu("Speed");
JMenuItem resetGrid = new JMenuItem("Reset Grid");
resetGrid.addActionListener(new ActionLis... |
7e203ee9-6914-4007-96c4-4392bdbcd2b6 | 4 | public String[] getSets1(){
String[] sets=null;
try{
sets = textField_1.getText().split(",");
if(textField_1.getText().length()<1) return null;
int x = Integer.valueOf(nbrVarComboBox.getSelectedItem().toString());
x = (int) Math.pow(2, x);
for(String s : sets){
int set = Integer.valueOf(s);
if (!(se... |
4aa975d6-273d-4108-9cab-1578bbd9aeac | 1 | public static boolean getMouseUp(int mouseButton) {
return !getMouse(mouseButton) && lastMouse[mouseButton];
} |
6f9b791d-e8d2-4c9d-9e20-b06f035743d2 | 3 | public void run() {
try {
Socket socket = _ss.accept();
socket.setSoTimeout(60000);
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.ge... |
661c9e1e-d6ff-45eb-a775-b734e1dbf200 | 3 | private boolean checkUser(String user, String pass){
/**
* - FOR TAM -
* Database Requirements
*
*
* CHECK IF USERNAME AND PASSWORD ENTERED ARE CORRECT.
* ALSO, NEED TO GENERATE A RANDOM SESSION ID TO COUNTER MULTIPLE LOGINS.
*
* Example is kinda shown below.
*
* If the login ... |
824f61a8-6ab4-4272-bff5-03439b904255 | 3 | public Sprite getSprite(String ref) {
//Check for already existing sprite
if (sprites.get(ref) != null) {
return (Sprite) sprites.get(ref);
}
//Get new sprite
BufferedImage sourceImage = null;
try {
URL url = this.getClass().getClassLoader().getResource(ref);
if (url == null){
fail("Can't... |
e5af4f9a-77d6-418f-aa63-ecd316b806ac | 5 | public final void gameOver() {
// XXX hmm. we should check out these conditions
if ( inGameState("GameOver")
|| (!inGameState("InGame") && !inGameState("LifeLost")) ) return;
// System.err.println( "Warning: gameOver() called from other state"
// +" than InGame or LifeLost." );
//}
clearKey(key_continue... |
fac077e8-b503-41c7-a4a8-eaa0f13a1a57 | 8 | public static int floodfill( char s , int i , int j ){
Queue<Integer> x = new LinkedList<Integer>();
Queue<Integer> y = new LinkedList<Integer>();
x.add(i);
y.add(j);
int c = 1;
v[i][j] = true;
while(!x.isEmpty()){
int xa = x.poll();
int ya = y.poll();
m[xa][ya] = '&';
for (int k = 0; k < d... |
ab903672-b587-41f9-be34-c90789357725 | 0 | public List<Feature> getFeatures()
{
return features;
} |
049fb495-d0b5-4610-9d0d-70b518a796a8 | 0 | public static Forme L() {
ArrayList<Vecteur> liste = new ArrayList<>();
liste.add(new Vecteur(1, 0));
liste.add(new Vecteur(1, 1));
liste.add(new Vecteur(1, 2));
liste.add(new Vecteur(0, 2));
Vecteur<Integer> _centre = new Vecteur(1, 2);
return new Forme("L", lis... |
3c3bd86f-1348-48b2-9578-fe2f7eb2ad9e | 7 | public static String postData(Reader data, URL endpoint, Writer output) throws Exception
{
System.out.println("dfsln");
HttpURLConnection urlc = null;
try
{
urlc = (HttpURLConnection) endpoint.openConnection();
try
{
urlc.setRequest... |
f11c165a-bc15-4245-9ff1-ee1f64ab1e46 | 1 | public void AddToMenu() {
if (Glob.instance != null) Glob.instance.paginae.add(res);
} |
2d616fd7-288f-401a-a4b2-fa30388247e5 | 6 | public void drawIndexedSprite(int x, int y) {
x += offsetX;
y += offsetY;
int destOff = x + y * Graphics2D.width;
int srcOff = 0;
int height = this.height;
int width = this.width;
int destStep = Graphics2D.width - width;
int srcStep = 0;
if (y < Graphics2D.topY) {
int topMargin = Graphics2D.topY - ... |
a489c5dd-4e72-489c-9d74-987159bef452 | 5 | @Test
public void getCostsTest() {
TopAthlete test = null;
TopAthlete test1 = null;
try {
test = new TopAthlete("Franz", 3);
test1 = new TopAthlete("Karl", 5);
} catch (Exception e) {
fail("Unexpected Exception");
}
try {
TopAthlete test3 = new TopAthlete("Sepp", 12);
} catch (ValueException... |
6ffcbd98-8ae8-4aa3-9964-2447b5b5ef42 | 2 | void concatFiles(File file, File other) {
// concatenates other to the bottom of file
try {
BufferedReader oreader = new BufferedReader(new FileReader(other));
BufferedWriter fwriter = new BufferedWriter(new FileWriter(file,true));
String line;
while((line = oreader.readLine()) != null) {
fwriter.wr... |
1e007bd2-d2e9-4231-b26e-14126a38184d | 6 | private static final int method2922
(int i, int i_148_, byte[] is, int[] is_149_, int i_150_, int i_151_,
int i_152_, int i_153_, int i_154_, int i_155_, int i_156_,
Class348_Sub16_Sub5 class348_sub16_sub5, int i_157_, int i_158_) {
if (i_157_ == 0
|| ((i_154_ = i_151_ + (i_156_ - i_150_ + i_157_ - 257) / i_... |
c5c518d4-28e4-4239-a5c4-5cc8ca287204 | 3 | @Override
public void run() {
System.err.println("Die Acquise wurde gestartet!");
do {
Cashpoint cashpoint = getNextCashpoint();
WaitingQueue waitingQueue = cashpoint.getWaitingQueue();
synchronized (waitingQueue) {
Kunde kunde = new Kunde();
waitingQueue.add(kunde);
cashpoint.writeToBalance(n... |
9506ea12-1747-4882-a7bf-54e7b8325c62 | 5 | public static void main(String[] args) {
// Using Sieve of Eratosthenes to mark all primes below 2,000,000
boolean[] nums = new boolean[2000000];
long sum = 0;
for (int i = 2; i < nums.length; i++)
nums[i] = true;
int nextPrime = 2;
while (nextPrime < nums.length) {
int i = nextPrime;
sum += nextPr... |
20b4124d-370e-455e-830b-f7f2e286ff3b | 2 | public LinkedList<Segment> getEdges() {
LinkedList<Segment> edges = new LinkedList<Segment>();
for(Entry<Point, HashSet<Point>> e: graph.entrySet()) {
for(Point P : e.getValue()) {
edges.add(new Segment(e.getKey(), P));
}
}
return edges;
} |
811889f5-b555-48c8-b28d-af30c8292af8 | 5 | private void list_framesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_list_framesMousePressed
current_sprite=null;
hitbox_index_selected=-1;
frame_index_selected=Integer.parseInt(""+list_frames.getSelectedIndex());
//NodeList listOfMoves = hitboxes_doc.getElementsByTagName("Move");
... |
07d9f8a6-65fc-4f10-86be-b7ee9685fb9b | 3 | public String apply(Ast ast){
decl += ast.getClass().getSimpleName() + "_" + i + " [label=\"" + ast.getClass().getSimpleName() + "\"]\n";
int n = i++;
Ast[] objs = ast.getVariables();
//System.out.println(objs[0] + " " + objs[1]);
if (objs !=null) {
for ( int j = 0; j<objs.length; j++){
if (objs[j] != ... |
a43d8c72-9015-4e67-8d2b-42ca8b8aebfb | 7 | @Override
public void executeMsg(Environmental myHost, CMMsg msg)
{
super.executeMsg(myHost, msg);
if((msg.source()==invoker())
&&(msg.target() instanceof MOB)
&&(msg.targetMinor()==CMMsg.TYP_DAMAGE)
&&(msg.tool()==msg.source().fetchWieldedItem())
&&(!(""+msg.target()).equals(lastMOB)))
{
if((msg.tra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.