method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
a9a9bd8c-1c80-446a-922d-8e340413847d | 1 | public static int raceToId(String race) {
HashMap<String, Integer> races = new HashMap<String, Integer>();
races.put("baden-württemberg", 1);
races.put("bayern", 2);
races.put("berlin", 3);
races.put("brandenburg", 4);
races.put("bremen", 5);
races.put("hamburg", 6);
races.put("hessen", 7);
races.put(... |
1776cd25-fb1b-448f-8a7e-08b85cbb2f79 | 9 | @Override
public String toString() {
if (this.type == NUM) {
return "NUM: " + this.value;
} else if (this.type == CMD) {
return "CMD: " + this.name;
} else if (this.type == UNK) {
return "UNK";
} else if (this.type =... |
2c3356d5-1510-4186-9dca-535c63be2b48 | 9 | static final public ValueExpression value_spec() throws ParseException {
Token tok; TupleExpression tup; VariableExpression var; ActorIdentifier actId;
if (jj_2_12(4)) {
tok = jj_consume_token(TUPLETAG);
tup = new TupleExpression(tok.image);
jj_cons... |
add70a49-e5f3-4383-bcc4-938ff46dd48b | 9 | public static Circle reconstructCircle( final String[] elements ) {
if( elements == null ) {
throw new IllegalArgumentException( "The parameter 'elements' must not be 'null'." );
}
final Map< String, Object > attributesP = new HashMap< String, Object >();
final Map< String, O... |
efb72acc-460c-43b6-9d52-bf33a040530c | 6 | public static int[][] getTiles(int dx, int dy, int width, int blockAdd, int tilesetAdd, int tilesetBankOffset) {
int[] rom = curGb.getROM();
int[][] tmp = new int[24][20];
int add = blockAdd;
for (int y=0;y<5;y++) {
for (int x=0;x<6;x++) {
int block = getBlockVal(tilesetBankOffset, rom, add);
for (in... |
aee7f939-4c02-4de6-8aa5-131a574bb09f | 5 | public static void main(String[] args){
HybridTrie hbt = new HybridTrie();
String[] arr = {"abc", "abcd", "abcde", "bcde", "bce", "eofl", "cctv"};
for(int i = 0; i < arr.length; i++){
String s = arr[i];
hbt.put(s, i + 1);
}
Integer result = hbt.get("cctv");
LinkedList<String> resultList = (LinkedList<... |
6a969f9c-4030-41d9-a606-acd2d40ebb58 | 7 | @Override
public void run() {
String s;
while(true) {
if (!csConnection.m_incomingMsgQueue.isEmpty()) {
s = csConnection.m_incomingMsgQueue.remove();
//System.out.println("PIM:" + s);
try {
JSONObject j = new JSONObject(s);
if (j.has("Message")) {
System.out.println(j.get("Mess... |
d4c1049d-b0d1-4ab0-9703-07de5ac28486 | 7 | public static void makeCompactGrid(Container parent,
int rows, int cols,
int initialX, int initialY,
int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout)pa... |
0a4714ee-90c6-496b-80ea-e85b96c9c705 | 8 | public void addSeries(float[] values,
int seriesNumber, Comparable seriesKey) {
invalidateRangeInfo();
int i;
if (values == null) {
throw new IllegalArgumentException("TimeSeriesDataset.addSeries(): "
+ "cannot add null array of values.");
... |
de7a4d43-0fcc-480f-89af-323cd8103b5d | 8 | public void evalGarbledGate(boolean alice_interpret, boolean bob_interpret) {
int i;
int permuted_index;
byte[] dec_key;
byte[] cipher;
byte perm_dec_key;
// Do something only if gate hasn't been evaluated yet
if (garbled_value == null) {
// Construc... |
626904c1-f502-4e95-97cb-947a3df33978 | 1 | public int getLevel() {
int level = 0;
if (item != null) {
level = item.getLevel();
}
return level;
} |
9d0abb5b-6cd7-454c-8587-bf41d31ec8b9 | 8 | private void drawLoginScreen(boolean originalLoginScreen) {
setupLoginScreen();
loginBoxLeftBackgroundTile.initDrawingArea();
titleBoxImage.drawImage(0, 0);
int x = 360;
int y = 200;
if (loginScreenState == 0) {
int _y = y / 2 + 80;
fontSmall.drawCentredTextWithPotentialShadow(onDemandFetcher.statusSt... |
980b7a6a-7eb4-4d45-a4f0-b169e496001b | 8 | public static WidgetChild getCompass() {
final Record record = get();
update(record);
if (record.index_widget == -1) {
return null;
}
final Widget widget = Widgets.get(record.index_widget);
if (widget != null) {
if (record.index_compass == -1) {
for (final WidgetChild widgetChild : widget.getChild... |
1b57b39b-5682-4144-933a-79e1352ecd49 | 8 | public void run(String arg) {
ImagePlus image = IJ.getImage();
int currentChannel = image.getChannel();
int currentSlice = image.getSlice();
int currentFrame = image.getFrame();
ImageStack stack = image.getStack();
HashMap<Integer, Integer> histogram = new HashMap<Integer... |
df49043b-4b93-48fc-8e06-3631c84a383e | 8 | private boolean r_postlude() {
int among_var;
int v_1;
// repeat, line 56
replab0: while(true)
{
v_1 = cursor;
lab1: do {
// (, line 56
... |
74d99c69-9b80-4ea6-a763-d20243895567 | 2 | private void moveUp() {
int[] rows = table.getSelectedRows();
DefaultTableModel model = (DefaultTableModel) table.getModel();
try {
if (model.getRowCount() >= 2) {
model.moveRow(rows[0], rows[rows.length - 1], rows[0] - 1);
table.setRowSelectionInterval(rows[0] - 1,
rows[rows.length - 1] - 1);
... |
f4c7051a-cb92-4037-9a84-03c80e8880ed | 0 | public Long getId() {
return id;
} |
2c2fb9d6-8dfc-4dc3-9da8-7fd496793c2a | 5 | private void initGui()
{
this.setPreferredSize(new Dimension(640, 480));
this.setSize(new Dimension(640, 480));
this.setResizable(false);
this.setBackground(Color.WHITE);
this.setLayout(new BorderLayout());
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
chatWindow = new JPanel();
chatWindow.setLayout... |
6d37603e-3743-4148-a7d8-716b821d5d9a | 1 | public Match getCurrentMatch(int userID){
if(alstNewMatchRequests.contains(userID)){
return this.upcomingMatches.peek();
}
return this.runningMatch;
} |
a0cdbd67-adb2-4000-9c76-efefded44227 | 4 | private void p_searchPage(){
p_searchPane = new JPanel();
p_searchPane.setBackground(SystemColor.activeCaption);
p_searchPane.setLayout(null);
JLabel lbl_searchPatient = new JLabel("Search Patient");
lbl_searchPatient.setFont(new Font("Arial", Font.BOLD, 30));
lbl_searchPatient.setBounds(376, 20, 221, 41... |
2ce04791-d511-403e-9886-f239457be63c | 0 | public temp (String text)
{
this.text = text;
} |
12433c32-6b74-4f67-84b4-16f6deb6f9aa | 5 | public GraphicInterface(final TaskManager tManager) {
super("Running Task Program");
setBounds(500,100,570,520);
setLayout(null);
this.tManager = tManager;
name = "gg";
laTitle.setBounds(120,10,100,15);
add(laTitle);
laActiveTasks.setBounds(400,10,100,15... |
bf7e6ebe-1e41-4718-b454-3195810c393f | 9 | protected Collection getCells(Collection cells, boolean edges,
boolean ordered) {
Set result = null;
if (ordered && order != null) {
result = new TreeSet(order);
} else {
result = new LinkedHashSet();
}
Iterator it = cells.iterator();
while (it.hasNext()) {
Object cell = it.next();
if ((e... |
37181d7d-34ae-47ed-9143-74df1e4a3e1a | 6 | public int firstMissingPositive(int[] A) {
if (A.length == 0)
return 1;
boolean[] f = new boolean[A.length+1];
for (int i=0;i<=A.length; i++) f[i] = false;
for (int i = 0 ;i< A.length ;i++)
{
if (A[i] > 0 && A[i] <= A.length + 1)
{
f[A[i] -1] =true;
}
}
int j = 0;
while ( f[j] )
{
... |
ee8e1d34-4921-41d1-adc4-7f13d3265621 | 4 | public void turnLeft() {
if(speedX > 0) {
this.speedX = 0;
this.speedY = speedOfSnake;
} else if(speedX < 0){
this.speedX = 0;
this.speedY = -speedOfSnake;
} else if(speedY > 0) {
this.speedY = 0;
this.speedX = -speedOfSnake;
} else if(speedY < 0) {
this.speedY = 0;
this.speedX = speedOf... |
d6cab760-37d3-4efd-815b-c5893c3f493d | 7 | private int checkCross(GameBoardMark playerMark) {
int k, l, x;
for (k = 1; k < 7; k++) {
for (l = 1; l < 7; l++) {
x = k + 10 * l;
if (gameBoard.mainBoard()[x] == playerMark.index && gameBoard.mainBoard()[x + 2] == playerMark.index && gameBoard.mainBoard()[x... |
312a9097-baf5-4fa3-85a0-4e836167df59 | 8 | private void OkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OkButtonActionPerformed
String user = UsernameText.getText();
String pass = new String(PasswordText.getPassword());
if (!user.equals("") && !pass.equals("")) {
String q = "select contrasenna from ... |
80027fbb-ded2-4dc2-a62a-bb075e22224b | 1 | public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws IOException, ServletException {
//first goal is to be able to receive and process
//a well formatted XML moveTwo piggybacked on a POST
//this gives me a raw stream to payload of Post requ... |
c0893b5f-6b9d-4d84-baa7-9dea22d49e5b | 3 | public void flush()
{
BufferedWriter saveWriter = null;
try
{
saveWriter = new BufferedWriter(new FileWriter(saveFile));
saveWriter.write("# Automatically generated file; DO NOT EDIT\n");
saveWriter.write("#Contacts\n");
for(Contact contact : contactList)
{
saveWriter.write(((ContactI... |
a4798f43-7a75-4509-8787-e7cfcf707209 | 1 | public JSONObject getJSONObject(int index) throws JSONException {
Object object = get(index);
if (object instanceof JSONObject) {
return (JSONObject)object;
}
throw new JSONException("JSONArray[" + index +
"] is not a JSONObject.");
} |
9f6c2cd8-e27b-4d2a-9002-08b6ff794857 | 1 | public static void msg(String msg, boolean debugging_on)
{
if(debugging_on)
System.err.println("DEBUG ("+System.currentTimeMillis()+"): "+msg);
} |
417cb90c-5b74-462f-af85-52ea7b338112 | 4 | private boolean checkFieldColumnWinn(int columnNumber, char cellValue){
boolean checkColumn = true;
for (int i = 0; i <= fieldSize - WIN_NUMBER_OF_CELLS ; i++){
checkColumn = true;
for(int j = i; j < i + WIN_NUMBER_OF_CELLS; j++){
if( field[columnNumber][j] != c... |
e94eaf5f-e4d8-46a6-8f5e-8a6ebd7d1cb9 | 6 | public static void main(String[] args){
int[] p = new int[(int)1e6];
for(int i=2;i<1e6;i++) p[i]=1;
sieve(p);
int count=0;
for(int i=2;i<1e6;i++){
if (p[i]==1){
List<Integer> rotations = rotate(i);
boolean circular = true;
for(Integer k:rotations){
if(p[k] == 0) circular = false;
}
... |
e18610f4-6464-4f03-822b-45f8525bacda | 9 | private void cftbsub(int n, float[] a, int offa, int[] ip, int nw, float[] w) {
if (n > 8) {
if (n > 32) {
cftb1st(n, a, offa, w, nw - (n >> 2));
if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (n > ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) {
... |
cf073d05-b50a-48ec-9fbe-f449bf9b1f4e | 1 | public void resetSyntax() {
for (int i = ctype.length; --i >= 0;)
ctype[i] = 0;
} |
9e41da5e-84cc-4abe-8f0c-86517f5faa5e | 1 | public boolean is(Object key) {
Boolean b = get(key);
if (b == null) {
return false;
}
return b;
} |
9ea82f39-bfe3-4d66-b2ce-7a8b237883ab | 2 | @Override
public double escapeTime(Complex point, Complex seed) {
// Keep iterating until either n is reached or divergence is found
int i = 0;
while (point.modulusSquared() < escapeSquared && i < iterations) {
// Z(i+1) = (Z(i) * Z(i)) + c
point = point.square().add(... |
3ffab664-0d3e-4551-8464-880142c2c6e4 | 1 | private void deepLearn(){
DL_layers++;
//Add another layer
if (DL_layers < DL_maxlayers){
int dl = drawNet.layers.get(1).length - DL_layers*DL_drawdelta,
pl = playNet.layers.get(1).length - DL_layers*DL_playdelta;
//if (Game.verbose)
System.out.println("Casandra: Adding DEEP LEARNING layer #"+DL_lay... |
4e87006f-a73b-49eb-abb5-c86cd0e8304d | 7 | private Giocatore[] getBestAtt(Formazione f){
Giocatore[] att=new Giocatore[3];
Giocatore[] squad=f.getGiocatori();
Giocatore tmp=squad[0];
int st=0, nd=0, temp=0;
for(int j=0;j<3;j++){
for(int i=1;i<11;i++){
if(squad[i].getAttacco()>=tmp.getAttacco() && (i!=st || i!=nd) ){
tmp=squad[i];
temp... |
0d883f80-781d-485e-9e69-230267c15998 | 7 | @Override
public void mouseReleased(MouseEvent me) {
if (me.getSource() instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) me.getSource();
if (menuItem.getActionCommand().compareTo("FILE->INSERT") == 0) {
StudentsInformation.StudentsName(stdname.getText());
... |
63808824-65eb-409f-bd5b-5477f13deec6 | 5 | public static void mergePropertiesIntoMap(Properties props,
Map<String, Object> map) {
if (map == null) {
throw new IllegalArgumentException("Map must not be null");
}
if (props != null) {
for (Enumeration<?> en = props.propertyNames(); en
.hasMoreElements();) {
String key = (String) en.nextElem... |
e6be7c64-b7ed-4118-8c00-d452b11f4dab | 8 | public static int findMaximumPathSum(){
String linestr;
String[] tokens;
int lines = 0, i = 0;
int j,temp;
try{
BufferedReader br = new BufferedReader(new FileReader("triangle"));
LineNumberReader reader = new LineNumberReader(new BufferedReader(new FileReader("triangle")));
while((reader.readLine(... |
41a8a8fb-c7fb-4961-b404-0941a4d68af6 | 4 | public int read(BitReader bitreader) throws JSONException {
try {
this.width = 0;
Symbol symbol = this.table;
while (symbol.integer == none) {
this.width += 1;
symbol = bitreader.bit() ? symbol.one : symbol.zero;
}
tick(... |
47dbe88e-e1d6-49c3-85aa-40dea88ba6da | 8 | @Override
@SuppressWarnings({ "nls", "boxing" })
protected void initialize(Class<?> type, Object oldInstance,
Object newInstance, Encoder enc) {
super.initialize(type, oldInstance, newInstance, enc);
if (type != oldInstance.getClass()) {
return;
}
MenuBar bar = (MenuBar) oldInstance... |
b3a42f7b-2783-40a4-a219-9f097b067277 | 5 | public void run() {
try {
/*
* A server socket is opened with a connectivity queue of a size specified in int floodProtection. Concurrent login handling under normal
* circumstances should be handled properly, but denial of service attacks via massive parallel program login... |
32b7d16b-6490-4c01-bb85-17d7051ca85e | 6 | public boolean getBoolean(String key) throws JSONException {
Object object = this.get(key);
if (object.equals(Boolean.FALSE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("false"))) {
return false;
} else if (object.equals... |
65d52684-88b9-4572-a321-53216d057e26 | 2 | public void writeTo(String outname)
throws IOException {
if(!assembled) {
throw new IllegalStateException("assemble method must be called before writeTo");
}
WordWriter out;
if(outname.equals("-")) {
out = new WordWriter(System.out, littleEndian);
... |
362f4ce1-a042-4465-a1ea-2ca66a6cb9d0 | 1 | private Combination<Colors> generateCombination(Answer lastAnswer) {
// / to be completed !!!
String combi = "RRRRR";
List<Token<Colors>> colors = new ArrayList<Token<Colors>>();
for (int i = 0; i < combi.length(); i++) {
colors.add(new Token<Colors>(Colors.valueOf(combi.substring(i, i + 1))));
... |
f109dd3e-04b6-475a-8052-c58ab54555fa | 4 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
if (!sender.hasPermission("VanishCommand.isVanish")) {
sender.sendMessage(ChatColor.RED + "No permission!");
return true;
}
if (args.length != 1)
return false;
Player p = Bukkit.getPlayer(args[0]... |
20618bf4-f7ed-4379-9095-0bc6f974a542 | 7 | private <T extends NeuralNetwork> ArrayList<T> merge(ArrayList<T> one,ArrayList<T> two){
ArrayList<T> merged=new ArrayList<>();
while(!one.isEmpty()&&!two.isEmpty()){
if(one.get(0).getFitness()>two.get(0).getFitness())
merged.add(one.remove(0));
else if(one.get(0)... |
eb1d0670-db4f-426f-8113-35173b103e6d | 1 | public static void main(String[] args){
TreeNode root = new TreeNode(1);
TreeNode node1 = new TreeNode(2);
TreeNode node2 = new TreeNode(3);
TreeNode node3 = new TreeNode(4);
root.left = node1;
root.right = node2;
node2.left = node3;
List<List<Integer>> re... |
5e051ffb-c726-4cf1-b1cd-fcb9a8ab1da7 | 2 | public static void compareFiles(File f1, File f2) throws IOException {
assertEquals(f1.length(), f2.length());
try (BufferedInputStream b1 = new BufferedInputStream(new FileInputStream(f1));
BufferedInputStream b2 = new BufferedInputStream(new FileInputStream(f2))) {
byte[] buf1 = new byte[1024 * 16], buf2 =... |
a0d6481f-3fff-43c2-9879-c98e783c3724 | 2 | public static void main(String[] args) {
try {
Socket socket = new Socket("localhost", 3300);
new ObjectOutputStream(socket.getOutputStream()).writeObject(new SimpleMessage("pera", "marko", 1));
System.out.println(new ObjectInputStream(socket.getInputStream()).readUTF());
} catch (UnknownHostException ... |
09ed9d7b-141c-48f9-a4af-7245398c6b24 | 4 | public void destroy(BitacoraId id) throws NonexistentEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
Bitacora bitacora;
try {
bitacora = em.getReference(Bitacora.cl... |
429e0b30-dd9d-452a-808e-bf231d3ebe63 | 3 | public char nextClean() throws JSONException {
for (; ; ) {
char c = next();
if (c == 0 || c > ' ') {
return c;
}
}
} |
54362574-7cec-4ac1-bbe2-398c81ece075 | 6 | @Override
public void paint(Graphics jframeg) {
//super.paint(g);
Graphics g = bi.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, 500, 500);
for (int i = 0; i < points.size(); i++) {
GeoRef p = points.get(i);
... |
98f6fad1-5105-4808-9f36-0d93d07fcef4 | 5 | protected int getRowofvalue(int a) {
int lngRow = 0;
if(lisCol.get(0).contains(a)) {
lngRow = 0;
}else if(lisCol.get(1).contains(a)) {
lngRow = 1;
} else if(lisCol.get(2).contains(a)) {
lngRow = 2;
} else if(lisCol.get(3).contains(a)) {
... |
9b991423-93aa-4d1d-9a29-4ad814a142b3 | 3 | public void setGraphComponent(mxGraphComponent graphComponent)
{
mxGraphComponent oldValue = this.graphComponent;
if (this.graphComponent != null)
{
this.graphComponent.getGraph().removeListener(repaintHandler);
this.graphComponent.getGraphControl().removeComponentListener(
componentHandler);
this... |
0e7de618-9274-42b3-bb13-da7caf4dcac0 | 5 | private static void test(Mat src, Mat tpl)
{
//Imshow.show(src);
//Imshow.show(tpl);
// generate log polar images
Mat srcPolar = new Mat(src.rows(), src.cols(), src.type());
Mat tplPolar = new Mat(tpl.rows(), tpl.cols(), tpl.type());
Mat srcCart = new Mat(src.rows(), src.cols(), src.type());
Mat tpl... |
f4ada3d8-d4e6-4c9e-b3ff-9e19eb630f8d | 0 | public void addResponseHeader(String name, String value)
{
response.add(name+": "+value+"\n");
} |
83229013-8c01-4fe1-9c9a-51c9b92bf431 | 4 | int divide(int dividend, int divisor) {
long a = Math.abs(( long)dividend);
long b = Math.abs(( long)divisor);
int ans = 0, i = 0;
while (a > b){
i++;
b = b << 1;
}
while (i >= 0){
if (a >= b){
a -= b;
... |
85f941ed-cf83-47bd-8b69-ca860b3f6d0a | 6 | public void init(Map attributes)
throws InvalidKeyException, IllegalStateException {
synchronized(lock) {
if (state != -1) {
throw new IllegalStateException();
}
Integer want = (Integer) attributes.get(STATE);
if (want != null) {
switch (want.intValu... |
762f7a49-b9ce-41fc-b801-98350873bcb0 | 4 | @Override
public void processPacket(Packet p) {
String username = "";
String message = "";
ChannelBuffer data = p.getData();
int updateFlags = data.readByte();
if ((updateFlags & 0x1) == 0x1) {
int messagesToRead = p.getData().readByte();
for (int i = ... |
10dcb413-97d3-4d2c-8346-dccc6a76cbed | 3 | void rightRotate(RedBlackNode y)
{
RedBlackNode x = y.left; // set x
y.left = x.right; // turn x's right subtree into y's left subtree
if(x.right != nil)
x.right.parent = y;
x.parent = y.parent; // link y's parent to x
if(y.parent == nil)
root = x;
else if (y == y.pa... |
a9499d1b-0e1b-462f-b02a-9fe00aa55247 | 8 | public static String createHref(String contextPath, String actionPath, String action) {
StringBuffer sb = new StringBuffer();
if (contextPath != null) {
sb.append(contextPath);
}
if (actionPath != null) {
sb.append(actionPath);
if (sb.charAt(sb.length()-1) != '/') {
sb.append('/');
}
}
St... |
1e249a4c-1fe0-4209-990d-ee42d662af14 | 5 | @Test
public void testServerGetQueueTimeoutDisconnectIndividualHashEx() {
LOGGER.log(Level.INFO, "----- STARTING TEST testServerGetQueueTimeoutDisconnectIndividualHashEx -----");
boolean exception_other = false;
String client_hash = "";
try {
server2.setUseMessageQueues(t... |
2a7fd3b9-9839-40b5-89b4-e54bbd1d0451 | 0 | public T[] getFooArray()
{
return fooArray;
} |
b29495ce-4e6f-4e9d-b016-79b59f7396ca | 0 | public int getBumonCode() {
return bumonCode;
} |
53024ad6-e398-4468-b6f9-c6eb48074d66 | 3 | public void bindThumbnailTexture(Minecraft var1) {
if(this.texturePackThumbnail != null && this.texturePackName < 0) {
this.texturePackName = var1.renderEngine.allocateAndSetupTexture(this.texturePackThumbnail);
}
if(this.texturePackThumbnail != null) {
var1.renderEngine.bindTexture... |
8a3ebf84-bc14-404c-ada2-8bc9680c9f75 | 1 | public boolean insertar(BeanProducto bean) {
boolean estado = false;
try {
PreparedStatement ps = MySQL_Connection.getConection().
prepareStatement(insertar);
ps.setString(1, bean.getNombre());
estado = ps.executeUpdate() != 0;
ps.cl... |
f57a94d3-b9a3-436c-b040-2678dc5c79c7 | 1 | @Test
public void testPlayGame()
{
Player winPlayer = _underTest.playGame(_player1, _player2);
if (winPlayer != null) // it was no tie
{
assertEquals(1, winPlayer.getNumberOfWins());
// use knowledge about Player to verify behaviour.
}
} |
537ebe70-6621-41e4-8272-56101c15d06c | 5 | public void render(GameContainer gc, Graphics g) throws SlickException {
if (state != STATE.INVISIBLE) {
if (state == STATE.ON || state == STATE.REFRESH) CustomRender(gc, g);
if (state == STATE.FREEZE_NEXT) {
sence.getGraphics().clear();
CustomRender(gc, s... |
58ee65b3-8842-4003-bc2e-209bc15d7339 | 9 | public void update(int wx, int wy, int wz, int r) {
depth = wz;
visible = new boolean[world.width()][world.height()];
for (int x = -r; x < r; x++) {
for (int y = -r; y < r; y++) {
if (x*x + y*y > r*r)
continue;
if (wx + x < 0 || wx + x >= world.width() || wy + y < 0 || wy + y >= world.height()... |
dc86cf20-2b36-4883-9689-d3831163884e | 3 | private void getModsPath(){
String OS = System.getProperty("os.name").toLowerCase();
OS = OS.substring(0,3);
if(OS.equals("win")){
modsPath = System.getProperty("user.home")+ "/AppData/Roaming/.minecraft/mods";
}
else if(OS.equals("mac")){
modsPath =System.getProperty("user.home")+"/Library/Application... |
c9283241-df3b-4086-afe4-e381ff4a124c | 7 | public void parseXML() throws FileNotFoundException {
try {
if (file != null) {
DocumentBuilderFactory newDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder newBuilder = newDocumentBuilderFactory.newDocumentBuilder();
Docum... |
448864b7-8ec1-4efe-8f64-bafdcaa8644e | 4 | public static JSONObject getJSON(HttpResponse response) throws IOException {
final String json = getString(response);
if (json == null || json.length() == 0) throw new IOException("JSON response is empty");
try {
return new JSONObject(json);
} catch (JSONException e) {
... |
046becf1-3898-49b8-9846-bc034b623c16 | 1 | public static void printList(ListNode list){
while(list!= null){
System.out.print(list.val+" ");
list = list.next;
}
} |
610130f1-557a-4696-85d5-83b34de204e5 | 9 | public List<Usuario> listarProfessor(Professor professor){
ArrayList<Usuario> listaRetorno = new ArrayList<Usuario>();
if (professor.recuperarSiape().isEmpty()
|| professor.recuperarSiape() == null){
for (Usuario usuario : this.usuarios) {
if(usuario instanceof Professor &&
usuario.rec... |
b8b1d58b-7c48-4d17-916d-c113a4742b3a | 4 | public static void initializeWeights(){
//input to hidden weights
for(int i = 0; i < inHid.length; i++){
for(int j = 0; j < inHid[i].length; j++){
inHid[i][j] = (Math.random()/10) - 0.5;
}
}
//set the bias to one
// for(int j = 0; j < inHid[0].length -1; j++){
// inHid[numInputs - 1][j] = 1;
// ... |
1918c8c5-fff1-4b38-8297-b3b893918876 | 9 | private void postPlugin(final boolean isPing) throws IOException {
// The plugin's description file contain all of the plugin data such as
// name, version, author, etc
final PluginDescriptionFile description = plugin.getDescription();
// Construct the post data
final StringBuilder data = new StringBuilder()... |
2049de0a-38c8-47c8-978a-baaf0f079f93 | 3 | public void atira() {
for (int i = 0; i < 10; i++) {
double angulo = 0.2 * i * Math.PI;
int cos = (int) (Math.cos(angulo));
int sen = (int) (Math.sin(angulo));
int x = pos.x + (int) (10 * cos);
int y = pos.y + (int) (10 * sen);
int sinalx, ... |
61746ee2-df15-4f8a-825d-e1f83d1c2968 | 6 | * @param terminalP
* @param frame
* @return Keyword
*/
public static Keyword selectTestResult(boolean successP, boolean terminalP, ControlFrame frame) {
if (successP == ((Boolean)(Logic.$REVERSEPOLARITYp$.get())).booleanValue()) {
ControlFrame.setFrameTruthValue(frame, Logic.FALSE_TRUTH_VALUE);
... |
0cafd873-86e0-4dc4-8e7f-3af25383cd35 | 3 | public void setDead(int number){
if (beings.get(number).isHuman() || beings.get(number).isZombie()) {
turnToDeadMan(number);
} else if (beings.get(number).isDead()){
turnIntoHuman(number);
}
} |
dc3049cb-abc7-44c7-8d93-030102e0f79a | 0 | public String getSearchAuthArg()
{
_read.lock();
try
{
return _searchAuthArg;
}
finally
{
_read.unlock();
}
} |
e3940ac4-e68a-43f4-8279-9d88180de0ad | 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... |
85293839-ce03-4046-b0d5-49796d62e9f8 | 9 | public static boolean bringOnScreen(final boolean move, final Entity e) {
final Tile nearLoc = e instanceof Locatable ? getReachable((Locatable) e) : null;
if (e instanceof Locatable && nearLoc == null) {
return false;
}
if (turnTo(e)) {
return true;
} else if (e instanceof Locatable && move) {
final... |
2e370543-d01a-4fc1-a282-ade10b43ab8d | 8 | private void resolution() {
if (width == 800 && height == 600) {
} else {
if (width == 1024 && height == 768) {
} else {
if (width == 1152 && height == 864) {
} else {
if (width == 1280 && height == 720) {
... |
be69c1f2-df8c-4d15-b18d-ce2bf06f6f98 | 8 | public static void shogwarr_mcu_run()
{
int mcu_command;
if ( shogwarr_mcu_status != (1|2|4|8) ) return;
mcu_command = mcu_ram.READ_WORD(shogwarr_mcu_command_offset);
if (mcu_command==0) return;
if (errorlog!=null) fprintf(errorlog,
"CPU #0 PC %06X : MCU executed command at %04X: %04X\n",
cpu_... |
c72a096d-577b-48a0-b8e8-f8633f670be1 | 0 | public final String getVersion() {
return version;
} |
b5d59611-2b00-4561-a23e-4dd78794a134 | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
if((mob.getWorshipCharID().length()==0)
||(CMLib.map().getDeity(mob.getWorshipCharID())==null))
{
mob.tell(L("You must worship a god to use this prayer."));
return false;
}
final Deity ta... |
834150bc-7932-49eb-aee1-f7911dd4ca10 | 5 | protected void action(){
if(!dead){
if(wallExistsRight()){
if(game.getCurrentLevel().blockAtPixelExists(x+(width)-1,y+(height/4))){
Block bl = game.getCurrentLevel().getBlockAtPixel(x+(width)-1,y+(height/4));
activateDoor(bl);
} else {
Block bl = game.getCurrentLevel().getBlockAtPixel(x+(wid... |
49fc80a5-1b1f-42d7-a108-d29f2af063bb | 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 RecordingEntity)) {
return false;
}
RecordingEntity other = (RecordingEntity) object;
if ((this.recordedName ==... |
0fab1084-f85e-4017-88ae-0493e9897a70 | 0 | public void setUitleenDatum(GregorianCalendar UitleenDatum) {
this.UitleenDatum = UitleenDatum;
} |
c1865341-98be-4808-91cd-9de27ed46e3b | 3 | private int boardValue(Board board) {
//Take the next checker.
Checker curChecker = board.pop();
//Exception case: there is no board!
if (curChecker == null)
return 0;
//Every piece has an initial value of 2 points.
int value = 2;
//Having a king is worth another 3 points.
if (curCh... |
fe423a8d-8d4d-4498-b437-b273bad0f7f7 | 9 | public File createSSTableFiles(String csvFile, String keyspace, String columnFamily, MutableInt lineCounter, MutableBoolean lastLineRead, BufferedReader reader) throws IOException {
File directory = new File(keyspace+columnFamily);
if (directory.exists()) {
FileUtils.deleteDirectory(directo... |
9e98f59b-730a-432b-9556-05504291b695 | 5 | @Override
public void deserialize(Buffer buf) {
super.deserialize(buf);
playerId = buf.readInt();
if (playerId < 0)
throw new RuntimeException("Forbidden value on playerId = " + playerId + ", it doesn't respect the following condition : playerId < 0");
playerName = buf.re... |
1cf36a8f-a9f8-4d87-97cc-8f3b52a784b8 | 3 | @Override
public void handle(HttpExchange he) throws IOException {
String requestedFile = he.getRequestURI().getPath().substring(1);
File file;
if (requestedFile.equals("")) {
file = new File(contentFolder + "index.html");
contentType = "text/html";
} else i... |
04d69e1f-8d5b-4822-9ae3-3b36bc92ee16 | 4 | public static Movimientos getInstance(int tipo){
switch(tipo){
case 1: return movimientos1;
case 2: return movimientos2;
case 3: return movimientos3;
case 4: return movimientos4;
}
return null;
} |
f1a7f2e9-9819-49d2-8037-eda3a0256708 | 1 | public int compareTo(StatView o) {
int r = getName().compareTo(o.getName());
if (r == 0) {
r = -stat.getWhen().compareTo(o.stat.getWhen());
}
return r;
} |
bf98828f-820e-461a-8b5d-1650fcd7d04b | 9 | @Override
public double calculateJuliaWithPeriodicity(Complex pixel) {
iterations = 0;
check = 3;
check_counter = 0;
update = 10;
update_counter = 0;
period = new Complex();
Complex tempz2 = new Complex(init_val2.getPixel(pixel));
Complex[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.