text stringlengths 14 410k | label int32 0 9 |
|---|---|
@Override
public boolean equals(Object other)
{
return other != null && other instanceof CharSequence ? toString().equals(other.toString()) : false;
} | 2 |
public static Position moveFromExplicitMoveString(Position pos, String move) {
//System.out.println("Get move from explicit: " + move);
//handle king side castle:
if(move.equals("O-O") || move.equals("O-O+")) {
return ChessMover.moveWeird(pos, Position.KING_SIDE_CASTLE);
//handle queen side castle:
} e... | 9 |
public int getProtons(String str)
{
for(int i = 0; i < eSymbol.length; i++) //look for symbols that match the string
if(str.equals(eSymbol[i]))
return i;
str = str.toLowerCase();
for(int i = 0; i < eName.length; i++) //look for names that match the string
if(str.equals(eName[i].toLowerCase()))
r... | 4 |
public void info() {
super.info();
System.out.println ("head:\t" + head);
} // end info() | 0 |
@Override
protected void finalize()
{
if(m_resource.RemoveReference() && !m_fileName.isEmpty())
{
s_loadedModels.remove(m_fileName);
}
} | 2 |
@Override
public void reduce(Text text, Iterator<IntWritable> intWritableIterator, OutputCollector<Text, IntWritable> textIntWritableOutputCollector, Reporter reporter) throws IOException {
} | 0 |
public void setAccount(Account account) {
this.account = account;
} | 0 |
public void transformPointer(Face face) {
if(face==Face.SOUTHERN){
rotationRequired = Math.toRadians(90);
}else if(face==Face.WESTERN){
rotationRequired = Math.toRadians(180);
}else if(face==Face.NORTHERN){
rotationRequired = Math.toRadians(270);
}else if(face==Face.EASTERN){
rotationRequired = Math... | 4 |
private static void readMagicItemsFromFile(String fileName,
ListMan lm) {
File myFile = new File(fileName);
try {
Scanner input = new Scanner(myFile);
while (input.hasNext()) {
// Read a line from the file.
... | 2 |
protected void initate(int cells, boolean debug) {
this.debug = debug;
if (data == null) data = new byte[cells];
else
for (int i=0; i<data.length; i++)
data[i] = 0;
if (exec != null) exec.stop();
dataPointer = 0;
charPointer = 0;
posInput = 0;
breakCycle = false;
close = false;
ide.c... | 7 |
private void texData(BufferedImage img) {
if(glTexId == -1 || img == null) {
return;
}
int[] pixels = new int[textureWidth*textureHeight];
img.getRGB(0, 0, textureWidth, textureHeight, pixels, 0, textureWidth);
Out.dbg("TexData!");
ByteBuffer buf = BufferUtils.createByteBuffer(textureWidth*textureH... | 5 |
private boolean topEdge(int particle, int cubeRoot) {
for(int i = 1; i < cubeRoot + 1; i++){
if(particle < i * cubeRoot * cubeRoot - 1 && particle > i * cubeRoot * cubeRoot - cubeRoot){
return true;
}
}
return false;
} | 3 |
Class<?> getReturnType(String methodRoot) {
Class<?> returnType = null;
String methodName = "get" + methodRoot;
Widget[] widgets = getExampleWidgets();
try {
java.lang.reflect.Method method = widgets[0].getClass().getMethod(methodName, (Class<?>)null);
returnType = method.getReturnType();
} catch (Excep... | 4 |
public static void main(String[] args) {
Scanner teclado = new Scanner(System.in);
int numAlum=teclado.nextInt(),
i=0, j=0;
double suma = 0, media=0,Suma=0;
//
System.out.println("numero de alumnos de la clase: "+numAlum);
int[]notas = new int[numAlum];
//
for(i = 0; i<notas.length;++i)... | 6 |
public void stop() {
if (!isRunning)
return;
isRunning = false;
} | 1 |
public Codec( String extension, Class iCodecClass )
{
extensionRegX = "";
// Make sure an extension was specified:
if( extension != null && extension.length() > 0 )
{
// We are only interested in the file extension. The filename
//... | 3 |
public static String fromArray (byte[] data) {
// allocate result buffer
StringBuffer buf = new StringBuffer();
int size = data.length;
// compute padding
int padding = (3 - (size % 3)) % 3;
// process all bytes in array...
for (int n = 0; n < size; n += 3) {
// check for final (truncated) block
... | 9 |
public ImageIcon getFoldingIcon(mxCellState state)
{
if (state != null && isFoldingEnabled()
&& !getGraph().getModel().isEdge(state.getCell()))
{
Object cell = state.getCell();
boolean tmp = graph.isCellCollapsed(cell);
if (graph.isCellFoldable(cell, !tmp))
{
return (tmp) ? collapsedIcon : exp... | 5 |
private static <S> TreeNode<S> seekAccept(ArrayDeque<TreeNode<S>> stack) {
while (!stack.isEmpty()) {
TreeNode<S> top = stack.pop();
stack.addAll(top.children);
if (top.isAccept()) {
return top;
}
}
return null;
} | 2 |
public void wakeUp() {
if (getState() == STATE_NORMAL && getVelocityX() == 0) {
setVelocityX(-getMaxSpeed());
}
} | 2 |
protected static Ptg calcColumns( Ptg[] operands )
{
//
if( operands[0] instanceof PtgFuncVar )
{
// we need to return the col where the formula is.
PtgFuncVar pfunk = (PtgFuncVar) operands[0];
try
{
int loc = pfunk.getParentRec().getColNumber();
loc += 1;
return new PtgInt( loc );
}
... | 5 |
public String getRadioButtonSelected()
{
String returnVal = null;
Enumeration<AbstractButton> allRadioButton=group.getElements();
while(allRadioButton.hasMoreElements())
{
JRadioButton temp=(JRadioButton)allRadioButton.nextElement();
if(temp.isSelected())
{
returnVal = temp.getText();
... | 2 |
public Object clone() {
try {
SlotSet other = (SlotSet) super.clone();
if (count > 0) {
other.locals = new LocalInfo[count];
System.arraycopy(locals, 0, other.locals, 0, count);
}
return other;
} catch (CloneNotSupportedException ex) {
throw new jode.AssertError("Clone?");
}
} | 2 |
public Level NextLevel() {
if (currentlevel < maxlevel) {
Level lvl = new Level(levels[currentlevel].toString());
currentlevel++;
return lvl;
} else {
Framework.gameState = Framework.GameState.COMPLETED;
return null;
}
} | 1 |
public void selectedTeam(String team, String homeOrAway) {
try {
//load xml file to get team
File file = new File("teams/" + team + ".xml");
JAXBContext jaxbContext = JAXBContext.newInstance(Players.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Players players = (Play... | 5 |
public static void main(String[] args) {
new Car(22).start();
} | 0 |
private boolean isLowestRankingStraight(ArrayList<Integer> sortedHand) {
for (int i = 0; i<sortedHand.size()-3; i++) {
if (sortedHand.get(0) == 2 && //has 2
sortedHand.get(1) == 3 && //has 3
sortedHand.get(2) == 4 && //has 4
sortedHand.get(3) == 5 ) //has 5
return true;
}
return false;
} | 5 |
private static void unitTest() {
System.out.println("PARSE/ASSEMBLE TESTS");
// Dirs and Files
unitTestParseAssemble("http://www.organic.com");
unitTestParseAssemble("http://www.organic.com/");
unitTestParseAssemble("http://www.organic.com/file.jsp");
unitTestParseAssemble("http://www.organic.com/dir"... | 0 |
public DFS addBankJumpPointerTable(int address, int length) {
rom.labelType[address] = 3;
for(int i=0; i<length; i++) {
int ca = address + 3*i;
rom.type[ca] = ROM.DATA_BANKJUMPPOINTER;
if (i > 0 && i % 8 == 0)
rom.comment[ca] = "$" + Util.toHex(i);
int goalBank = rom.data[ca] ... | 5 |
public void asetaPelaajanAlkusijainti(Piste sijainti) {
this.pelaajanAlkusijainti = sijainti;
} | 0 |
private boolean goBack(Command command){
int backage = 0;
if(!command.hasNthWord(2)){
backage = 1;
} else {
String sWord = command.getNthSegment(1);
try {
backage = Integer.parseInt(sWord);
} catch(NumberFormatException e) {
... | 5 |
public void setComment(String comment) {
this.comment = comment;
} | 0 |
static int Action(Client joueur) {
int tempDette = 0;
int choiceInt = -1;
boolean wrong = true;
boolean quit = true;
do {
System.out.println("Que voulez vous faire?"
+ "\n pour dormir tapez 1"
+ "\n pour appeler le room service ... | 8 |
public static void main(String[] args) {
LabControl control = get();
if(args.length < 4){
control.err("wrong parameter count!");
control.halt();
}
if(args[3].equalsIgnoreCase("train")) control.executeTrainAction(args[0], args[1], args[2]);
if(args[3].equalsIgnoreCase("resumetrain")) control.executeResum... | 5 |
public Board getDeepCopy() {
Piece[][] piecesCopy = new Piece[8][8];
for(int x = 0; x < pieces.length; x++) {
Piece[] row = pieces[x];
for(int y = 0; y < row.length; y++) {
if(row[y] != null) {
piecesCopy[x][y] = row[y].getDeepCopy();
}
}
}
re... | 3 |
@Override
public void update(GameContainer gc, StateBasedGame sbg, int delta)
throws SlickException{
if(MenuManager.getMenuType()==0)
MenuManager.menuUpdate(gc, sbg, delta);
else if(MenuManager.getMenuType()==1)
MenuManager.levelUpdate(gc, sbg, delta);
} | 2 |
private String calcWeekDay(final String input) throws ParseException {
String res = "";
String y,m,newInput;
StringTokenizer st = new StringTokenizer(input,"-");
y=st.nextToken();
m=st.nextToken();
newInput = new StringBuilder()
.append(y)
.append("-")
.append(Integer.parseInt(m)+1).to... | 0 |
protected void mixnmatch(Organism org1, Organism org2) {
posX = (org1.posX + org2.posX) / 2;
posY = (org1.posY + org2.posY) / 2;
if (r.nextInt(2) == 1) {
speed = org1.speed;
} else {
speed = org2.speed;
}
if (r.nextInt(2) == 1) {
defense = org1.defense;
} else {
defe... | 3 |
public static void main(String[] args) {
Collection<Integer> collection = new ArrayList<Integer>(
Arrays.asList(1, 2, 3, 4, 5)
);
Integer[] moreInts = { 6, 7, 8, 9, 10 };
collection.addAll(Arrays.asList(moreInts));
// Runs significantly faster, but you can't
// construct a Collection this way:
Collect... | 0 |
@Test
public void getValofCol_test() {
try{
double [][]mat= {{3.0,2.0}, {1.0,3.0}};
int j=0;
double[]result = Matrix.getVecOfCol(mat, j);
double []exp= {3.0,1.0};
Assert.assertArrayEquals(exp, result, 0.0);
}
catch (Exception e) {
// TODO Auto-generated catch block
fail("Not yet implemented"... | 1 |
public boolean checkPostion() {
if (x < 0 || x > 800 || y < 0 || y > 600)
return true;
return false;
} | 4 |
public void Assign(String name) {
boolean error = false;
if(Values.getType(name) == null) {
Error("Variable \'" + name + "\' has not been declared.");
return;
}
if(current.getId().equals("ASSIGN")) {
nextToken();
Expression(name);
}
else if(current.getId().equals("LSBRACKET")) {
nextToken();
... | 7 |
public void setState(String state) {
//Verify state Abbreviation (2) places
if(state == null || state.isEmpty() || state.length() > 2){
throw new IllegalArgumentException();
}
this.state = state;
} | 3 |
private EventJsonConverter() {
} | 0 |
public void raiseSalary(int employeeType) throws Exception
{
switch (employeeType) {
case JUNIOR:
this.salary = (salary * 105 + 10000) / 100;
break;
case MEDIOR:
this.salary = (salary * 106 + 20000) / 100;
break;
case SENIOR:
this.salary = (salary * 107) / 100;
break;
default:
throw new ... | 3 |
public void testHeavyConcurrentAccess()
{
final int MAX = 1 << 20;
// Writers pop from this.
final AtomicStack<Integer> source = new AtomicStack<Integer>();
// Writers push to this, Readers pop from this (concurrent action!).
final AtomicStack<Integer> transfer = new AtomicStack<Integer>();
// Readers p... | 5 |
@SuppressWarnings("unchecked")
private static final Object[] decodeDictionary(byte[] bencoded_bytes, int offset) throws BencodingException
{
HashMap map = new HashMap();
++offset;
ByteBuffer info_hash_bytes = null;
while(bencoded_bytes[offset] != (byte)'e')
{
//... | 8 |
private void parsePacket(byte[] data, InetAddress address, int port) {
String message = new String(data).trim();
PacketTypes type = Packet.lookupPacket(message.substring(0, 2));
switch (type) {
default:
case INVALID:
break;
case LOGIN:
Packet00Login packet = new Packet00Login(data);
System.out.prin... | 5 |
public double CalculateNDCG(Corpus corpus, int K, int numtopics,
TIntIntHashMap trainCitations) {
double CNDCG = 0;
System.out.println("Stat: test docs:" + corpus.docs.size()
+ ":Total citations in training:" + trainCitations.size());
for (int doc = 0; doc < corpus.docs.size(); doc++) {
ContextDocument... | 9 |
public static ArrayList<MediaCopy> searchMediaByTitle(String title){
try {
if(conn == null || conn.isClosed()){
conn = DatabaseConnection.getConnection();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ArrayList<MediaCopy> medi... | 5 |
public static void copyPEFiles(File startFolder) throws IOException {
File[] files = startFolder.listFiles();
if (files == null) {
System.out.println("Skipped unreadable file: "
+ startFolder.getCanonicalPath());
return;
}
for (File file : files) {
total++;
if (file.isDirectory()) {
copyPEF... | 9 |
public void testBigData6MB() throws TimeoutException, MemcachedException {
if(c instanceof QuickCachedClientImpl) {
c.setMaxSizeAllowedForValue(-1);
} else if(c instanceof XMemcachedImpl) {
//does not send the command to server at all for large value
//todo verify this
return;
} else if(c instanceof S... | 5 |
private void updateSettingsSaveBtnVisibility()
{
boolean show=false;
if( btnFkSettingsSave != null)
{
if( FkManager.getInstance().getBanner().compareTo( txtBanner.getText() ) != 0 )
{
show=true;
}
if( cmbLayout.getSelectionIndex() != -1 && cmbLayout.getItem(cmbLayout.getSelectionIndex()).compar... | 5 |
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... | 6 |
@Override
public void registUrl(String url, String keyword, String twitterUserName) {
try {
String query = "INSERT INTO " + TABLE_NAME;
query += " (url,search_word,twitter_user_name, created_at,updated_at) VALUES (?,?,?,?,?) ";
PreparedStatement stmt = con.prepareStatement(query);
stmt.setString(1, url... | 1 |
public static void indent(Node node, StringBuffer buf) {
for (int i = 0, limit = node.getDepth(); i < limit; i++) {
buf.append("\t");
}
} | 1 |
public BankAccount getMainBankAccount() {
if (!Constants.Banking) {
return null;
}
Connection conn = null;
ResultSet rs = null;
PreparedStatement ps = null;
BankAccount account = null;
try
{
conn = iConomy.getiCoDatabase().getConnection();
ps = conn.prepareStatement("S... | 7 |
private void systemListAddListener() {
systemList.addMouseMotionListener(genericMouseMotionListener);
systemList.addMouseListener(new MouseListener() {
private String chosenSystem;
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mousePressed(MouseEvent e) {}
@Override
... | 2 |
public void setValueAt(Object valor, int indiceLinha, int indiceColuna) {
//Obtém o objeto em questão, para alteração, de acordo com o índice de linha recebido
JobProtheus job = linhas.get(indiceLinha);
if (indiceColuna == 0){
job.setStatus((String) valor... | 9 |
public void add(ChangeEffect changeEffect) {
// Passes the filter? => Add
if ((changeEffectResutFilter == null) || (!changeEffectResutFilter.filter(changeEffect))) changeEffects.add(changeEffect);
} | 2 |
private Gene matchingGeneSelect_secondMethod(Gene par1, Gene par2) {
int x = (Math.random() < 0.5) ? 0 : 1;
//TODO
return null;
} | 1 |
public void testMultipliedBy_int() {
Years test = Years.years(2);
assertEquals(6, test.multipliedBy(3).getYears());
assertEquals(2, test.getYears());
assertEquals(-6, test.multipliedBy(-3).getYears());
assertSame(test, test.multipliedBy(1));
Years halfMax = Years... | 1 |
static void preprocess(char[] p) {
int i = 0, j = -1, m = p.length;
b = new int[p.length + 1];
b[0] = -1;
while (i < m) {
while (j >= 0 && p[i] != p[j])
j = b[j];
b[++i] = ++j;
}
} | 3 |
@Override
public void fill(Parameter parameter, Type type, Annotation[] annotations)
{
Requirement requirement = Requirement.DEFAULT;
for (Annotation annotation : annotations)
{
if (annotation instanceof Optional)
{
requirement = Requirement.OPTION... | 2 |
public static boolean isVariableInProductions(Grammar grammar,
String variable) {
ProductionChecker pc = new ProductionChecker();
Production[] productions = grammar.getProductions();
for (int k = 0; k < productions.length; k++) {
if (ProductionChecker.isVariableInProduction(variable,
productions[k])) {... | 2 |
public void run() {
position++;
} | 0 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
HtmlAttributeToken other = (HtmlAttributeToken) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(o... | 9 |
public void setNewImage(String newImage)
{
URL loc = this.getClass().getResource("/karel/themes/" + newImage);
ImageIcon iia = new ImageIcon(loc);
Image image = iia.getImage();
this.setImage(image);
} | 0 |
String getSpaceGroupInfoText(String spaceGroup) {
if (frame == null)
return "";
SpaceGroup sg;
String strOperations = "";
int modelIndex = viewer.getDisplayModelIndex();
if (spaceGroup == null) {
if (modelIndex < 0)
return "no single current model";
if (frame.cellInfos == null)
return "not ap... | 9 |
public void stopGame() {
// Setting isRunning to false will
// make the thread stop (see run())
this.isRunning = false;
// Unset the game model...
this.view.setModel(null);
// Stop listening for events
this.view.removeKeyListener(this.keyListener);
// Make sure we wait until the thread has stopped...... | 3 |
public static double toDouble(String nb){
char[] nr=nb.toCharArray();
int i;
double f;
double result=0;
boolean fraction=false;
if(nb==null||nb.equals(""))
return 0;
for(i=0;i<nr.length &&!fraction;i++)
if(Character.isDigit(nr[i]))
{result*=10;
result+=(nr[i]-'0');
}
else
{fractio... | 8 |
public static void main (String [ ] args) {
int x = 1;
int y = 1;
while (x < 5) {
if (y < 5) {
x = x + 1;
if (y < 3) {
x = x - 1;
}
}
y = y + 2;
System.out.print (x + "" + y + " ")... | 3 |
static double[] eigenValues(double[][] A){
double[] values = new double[A.length];
String[][] stringA = new String[A.length][A.length];
for(int i = 0; i < A.length; i++)
for(int j = 0; j < A.length; j++){
if(i == j)
stringA[i][j] = String.valueOf(A[i][j]) + " - x";
else
stringA[i][j] ... | 3 |
private void handleNumericAttribute(Instances trainInstances)
throws Exception {
m_c45S = new C45Split(m_attIndex, 2, m_sumOfWeights);
m_c45S.buildClassifier(trainInstances);
if (m_c45S.numSubsets() == 0) {
return;
}
m_errors = 0;
Instances [] trainingSets = new Instances [m_compl... | 9 |
public String verificaMenorTempo()
{
double tempoTorno;
double tempoMandril;
double tempoFresa;
ordenaPeloTempoDeSaidaM(maquinaMandril);
ordenaPeloTempoDeSaidaF(maquinaFresa);
ordenaPeloTempoDeSaidaT(maquinaTorno);
if(maquinaTorno.get(0).getRolamento() != null)
{
tempoTorno=maquinaTorno.get(0)... | 9 |
public static int getNextIDDzien(){
if(dni[0]==null)
return 1;
for(int i=0 ; i<10 ; i++)
if(freeIDDni[i]!=0)
{
int d = freeIDDni[i];
freeIDDni[i]=0;
return d;
}
int ID;
boolean flaga=true;
while(true)
{
IteratorDni.first();
ID= dni[CountDni-1].id + 1;
while(IteratorDni.isDone())
{
... | 7 |
public static boolean addInfo(databook bk){
boolean flag=false;
try{
contct=connector.getConnection();
Sttt=contct.prepareStatement("insert into bk "+"values(?,?,?,?,?,?)");
Sttt.setString(1,bk.Gin());
Sttt.setString(2,bk.Gte());
Sttt.setString(4,bk.Gpe());
Sttt.setString(6,bk.Gpr());
... | 2 |
public RiverNode calculateNext() {
double[][] array = instance.array;
ArrayList<Integer[]> o = getNearbyRegions(array, x, y);
double min = array[x][y];
int mX = x, mY = y;
for (Integer[] i : o)
if (array[i[0]][i[1]] <= min) {
min = array[i[0]][i[1]];
mX = i[0];
mY = i[1];
}
return new Rive... | 2 |
public ListNode rotateRightII(ListNode head, int n) {
int length = 0;
ListNode newHead = null, prevNewHead = null, end = null;
for (ListNode node = head; node != null; node = node.next) {
if (node.next == null) {
end = node;
}
length++;
}
if (length < 2 || n == 0 || n % length == 0) {
return h... | 7 |
@Override
public void onCommand(String command) {
final String[] splits = command.split(" ");
if (splits[0].equals("enlist")) {
// enlist <<node_id>> <<transaction_id>>
Integer tid = Integer.parseInt(splits[2]);
if(!_xacts.containsKey(tid)){
System.out.println("Invalid tid " + tid.toString());
... | 8 |
long f(int n) {
cache.put(1, 1L);
cache.put(2, 2L);
for (int i = 3; i <= n; i++) {
if (cache.get(i) == null) {
cache.put(i, cache.get(i - 1) + cache.get(i - 2));
}
}
return cache.get(n);
} | 2 |
public Collision collision( GameObject with )
{
if ( topX >= with.getX()+with.getWidth() ||
topX+width <= with.getX() ||
topY >= with.getY()+with.getHeight() ||
topY+height <= with.getY() )
return Collision.NO_HIT;
else {
return Collision.HIT;
}
} | 4 |
public List getList(Class type)
{
if (type == null) return entities;
List list = new ArrayList();
for (Object e : entities)
{
if (type.isInstance(e))
{
list.add(e);
}
}
return list;
} | 3 |
* @param options
* @return Cons
*/
public static Cons decomposeNamestring(String namestring, Cons options) {
{ PropertyList self000 = PropertyList.newPropertyList();
self000.thePlist = options;
{ PropertyList plist = self000;
Keyword breakoncap = Stella.KWD_CLEVER;
Keyword break... | 6 |
protected static void add(DoItLater c) {
if (isHtmlOutput()) {
getInstance().actionQueue.add(new DoItLater() {
@Override
public void doIt() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
}
});
getInstance().actionQueue.add(c);
}
} | 2 |
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (Exception ex) {
Logger.getLogger(ControlJson.class
.getName()).lo... | 1 |
public List<Alignment> importAlignments() throws IOException, ImportException
{
boolean done = false;
List<Taxon> taxonList = null;
List<Alignment> alignments = new ArrayList<Alignment>();
while (!done) {
try {
NexusBlock block = findNextBlock();
if (block == NexusBlock.TAXA) {
taxonList =... | 7 |
public ArrayList<String> getMovieXml(String movieName) throws TransformerConfigurationException, TransformerException{
URL url;
try {
url = new URL("http://www.omdbapi.com/?t="+movieName+"&y=&plot=short&r=xml");
URLConnection conn = url.openConnection();
Docum... | 6 |
public void make(Move m) throws IllegalMoveException {
FifteenMove fifteenMove = (FifteenMove) m;
isGameNew = false;
if (!isLegal(fifteenMove)) {
throw new IllegalMoveException(fifteenMove);
}
if (fifteenMove.equals(new FifteenMove(QUIT))) {
resignation(nextPlayer);
return;
}
if (nextPlayer == Ga... | 7 |
private int getEdgeNumber(double edgeLenght) {
System.out.println("D: " + edgeLenght);
int edgeNumber = -1;
if (edgeLenght < (edgeA + moe) && edgeLenght > (edgeA - moe))
return 0;
else if (edgeLenght < (edgeB + moe) && edgeLenght > (edgeB - moe))
return 1;
else if (edgeLenght < (edgeC + moe) && edgeL... | 8 |
public static State findBoxPathToGoal(Position box, Position goal, State currentState) {
HashSet<State> visited = new HashSet<>();
PriorityQueue<StateHolder> prio = new PriorityQueue<>();
// add the first state to the prio
prio.add(new StateHolder(currentState, box));
... | 7 |
private boolean processNumberedReference() {
boolean isHexNumberedReference =
originalMessage.charAt(nextPotentialReferencePosition + 2) == 'x' ||
originalMessage.charAt(nextPotentialReferencePosition + 2) == 'X';
try {
int value = (!isHexNumberedReference) ?
... | 3 |
public void monitorarBatimentosCardiacos(float batimentos, Paciente paciente)
throws ControllerException {
try {
if (batimentos < 0) {
throw new ControllerException(
"valor de quantidade de batimentos/seg inválido");
}
if (ValidarPaciente(paciente)
&& (batimentos < 30 || batimentos > 100))... | 7 |
public void update(GameContainer gc, StateBasedGame sb, int delta) {
for (Component component : getComponents()) {
component.update(gc, sb, delta);
}
int mousePosX = Mouse.getX();
int mousePosY = Math.abs(Mouse.getY() - Game.app.getHeight());
Input input = gc.getInput();
if ( mousePosX > getPositio... | 6 |
public void keyPressed(int k){
if(k == KeyEvent.VK_RIGHT) player.setRight(true);
if(k == KeyEvent.VK_LEFT) player.setLeft(true);
if(k == KeyEvent.VK_W) player.setJumping(true);
if(k == KeyEvent.VK_R) player.setScratching();
if(k == KeyEvent.VK_F) player.setFiring();
} | 5 |
private void init( File file )
{
fileRef = file ;
String fileName = fileRef.getName() ;
int i1 = fileName.indexOf( '_' ) ;
int i2 = fileName.indexOf( '.', -1 ) ;
prefix = "" ;
suffix = "" ;
// check the java style filename -> "name_language_country_variant.php"
if ( i1 > 0 ) // has... | 8 |
private static void calcNoOfNodes(Node node) {
if (node instanceof Parent) {
if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
noOfNodes += tempChildren.size();
f... | 3 |
public SoundClip(String clipURL)
{
clipLoader = new AudioClipLoader();
try {
clip=clipLoader.loadClip(clipURL);
} catch (UnsupportedAudioFileException | IOException
| LineUnavailableException e)
{
e.printStackTrace();
}
} | 1 |
public void checkTriggers(){
Debug.println("Checking room triggers");
ArrayList<Trigger> all_trig = new ArrayList<Trigger>(triggers);
for(String item : items){
all_trig.addAll(Game.item_list.get(item).getTriggers());
}
for(String container : containers){
all_trig.addAll(Game.container_list.get(container... | 9 |
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... | 6 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.