text stringlengths 14 410k | label int32 0 9 |
|---|---|
public static Integer idFromUrl(String url) {
Pattern idPattern = Pattern.compile("http://myanimelist.net/(\\w+)/(\\d+)/?.*");
Matcher matcher = idPattern.matcher(url);
if (matcher.find()) {
return Integer.valueOf(matcher.group(2));
}
return 0;
} | 1 |
public boolean more() throws JSONException {
char nextChar = next();
if (nextChar == 0) {
return false;
}
back();
return true;
} | 1 |
public static void testValidity(Object o) throws JSONException {
if (o != null) {
if (o instanceof Double) {
if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
throw new JSONException(
"JSON does not allow non-finite numbers.");
... | 7 |
protected final void handleUpdate(Result result) {
this.result = result;
if (result == Result.UPDATE_AVAILABLE) {
this.registerNewNotifier();
} else {
result.handleUpdate(this.plugin.getLogger());
}
} | 1 |
public void setOptions(String[] options) throws Exception {
String optionString;
optionString = Utils.getOption('X', options);
if (optionString.length() != 0) {
setAttsToEliminatePerIteration(Integer.parseInt(optionString));
}
optionString = Utils.getOption('Y', options);
if (optionStrin... | 7 |
public static void delete(String filename) {
try {
File file = new File(filename);
if (file.exists()) {
if (file.delete()) {
System.out.println(filename + " is deleted!");
} else {
System.out.println("Delete operation is failed. "
+ filename + " cannot be deleted");
}
}
} cat... | 3 |
private BuilderPattern(Builder builder) {
this.title = builder.title;
this.auther = builder.auther;
this.location = builder.location;
this.published = builder.published;
this.pageno = builder.pageno;
} | 0 |
public static void writeBlocking( WebSocketImpl ws, ByteChannel channel ) throws InterruptedException , IOException {
assert ( channel instanceof AbstractSelectableChannel == true ? ( (AbstractSelectableChannel) channel ).isBlocking() : true );
assert ( channel instanceof WrappedByteChannel == true ? ( (WrappedByte... | 3 |
public int updateVariableData(byte[] newData, int offset)
{
int vertexCount = getVertexCount();
vertexIndexArray = new int[vertexCount];
for (int index = 0; index < vertexIndexArray.length; ++index)
{
ByteConversions.setUnsignedShortInByteArrayAtPosition(vertexIn... | 6 |
* @return the XML datetime string corresponding to the given CycL date
* @deprecated use DateConverter.
*/
static public String xmlDatetimeString(final CycList date) throws IOException, CycApiException {
try {
final CycNaut dateNaut = (CycNaut) CycNaut.convertIfPromising(date);
final Date javada... | 2 |
@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 Defi)) {
return false;
}
Defi other = (Defi) object;
if ((this.id == null && other.id != null) || (this.id != n... | 5 |
public boolean DownloadFile(String httpUrl,String saveFile){
int bytesum = 0;
int byteread = 0;
URL url = null;
try {
url = new URL(httpUrl);
} catch (MalformedURLException e1) {
System.out.println("URL format error");
// e1.printStackTrace();
... | 4 |
public static void createDefprintUnit(Stella_Class renamed_Class) {
if (!(KeyValueList.dynamicSlotValue(renamed_Class.dynamicSlots, Stella.SYM_STELLA_PRINT_FORM, null) == null)) {
Cons.walkAuxiliaryTree(Cons.list$(Cons.cons(Stella.SYM_STELLA_DEFMETHOD, Cons.cons(Stella.SYM_STELLA_PRINT_OBJECT, Cons.cons(Cons.... | 9 |
@Override
protected String doPostWork(Params params) {
String action = params.getValue("action");
if(action == null) {
return WebUtil.error("unknown action!");
}
if("list".equals(action)) {
Templates templates = Global.getInstance().getTemplates();
return templates.listTemplatesJSON();
}
String n... | 9 |
void split(String filename, long cSize, File sf) throws FileNotFoundException, IOException
{
BufferedInputStream in = new BufferedInputStream(new FileInputStream(sf));
// get the file length
long fileSize = sf.length();
// loop for each full chunk
int subfile;
for (subfile = 1; subfile < fileSize / ... | 4 |
public int readBit() throws IOException {
int retVal;
// 当前mBytePos指向字节已经读完
if(mBitPos == 8){
if (isEnd && mBytePos == mEndBytePos){
// 到达数据流的末端
throw new EOFException();
}
// 缓冲区的数据完全读取完了
if(mBytePos == mByteBuf.le... | 6 |
@Override
public void action() {
if(agente.getPasso() == 3){
if(agente.getQuantidadeDeAgentesVendedores() > 0){
System.out.println("Passo 3 AI");
ACLMessage mensagem = new ACLMessage(ACLMessage.CFP);
mensagem.setProtocol(FIPANames.InteractionProtocol.FIPA_CONTRACT_NET);
mensagem.setRe... | 4 |
public String toString(){
String result = "";
for(int i=0; i<=height+1; i++){
for(int j=0; j<=width+1; j++){
if (area[i][j]){
result+=1 ;
}else{
result+=0;
}
}
result+='\n';
}
return result;
} | 3 |
private double testDoublyLinkedListDeletions(int inserts) {
System.out.println("Testing DoublyLinkedList with " + inserts + " deletions");
long[] times = new long[20];
long startTime;
long endTime;
for (int i = 0; i < 20; i++) {
doublyLinkedList = new DoublyLinkedLi... | 4 |
public void create(Software software) throws PreexistingEntityException, RollbackFailureException, Exception {
if (software.getComputadoraCollection() == null) {
software.setComputadoraCollection(new ArrayList<Computadora>());
}
EntityManager em = null;
try {
em =... | 7 |
public List<Archivio> archiviCreatiIl(String data) {
List<Archivio> lista = new ArrayList<>();
if (super.getDataCreazione().equals(data)) lista.addAll(this.elementi);
for(Archivio elemento: this.elementi){
if (elemento.getClass() == Cartella.class && elemento.getDataCreazione().equals(data)){
lista.add(ele... | 4 |
public boolean globtype(char k, KeyEvent ev) {
if ((k == 27) && (this.menu_current_parent_resource != null)) {
this.menu_current_parent_resource = null;
menu_current_layer_elements_offset = 0;
updlayout();
return (true);
} else if ((k == 'N') && (layout[gs... | 5 |
@Test
public void testLpaLimits() {
Metabolism m = new Metabolism();
try {
m.setLpa(0.);
} catch(IncoherentLpaException e) {
fail("An IncoherentLpaException has been thrown.");
}
try {
m.setLpa(-1.);
fail("An IncoherentLpaException should have been thrown.");
} catch(IncoherentLpaException e) {... | 4 |
public void processEvent(Event event)
{
// the last directory response
if (event.getType() == Event.COMPLETION_EVENT)
{
return;
}
if (event.getType() != Event.OMM_ITEM_EVENT)
{
System.out.println(_instanceName + " Received an unsupported Even... | 7 |
@Override
public Complex getPixel(Complex pixel) {
/* LEFT */
if(parser[0].foundC()) {
parser[0].setCvalue(pixel);
}
/* RIGHT */
if(parser[1].foundC()) {
parser[1].setCvalue(pixel);
}
int result = expr[0].getValue().compare(e... | 8 |
private Boolean fieldCheck(){
Boolean fields_pass_check;
// If any of the conditions are true, popup a menu
if ( course_name_field.getText().equalsIgnoreCase("") // course name empty
|| course_id_field.getText().equalsIgnoreCase("") ... | 7 |
public static boolean fuzzyEquals (double a, double b) {
// value based on this table:
// http://en.wikipedia.org/wiki/Machine_epsilon#Values_for_standard_hardware_floating_point_arithmetics
final double EPSILON = 5.96e-08;
if (Double.isNaN(a) && Double.isNaN(b) || Double.isInfinite(a) &... | 4 |
public static void print(UndirectedGraphNode node) {
if (null == node) return;
List<UndirectedGraphNode> nodes = new ArrayList<UndirectedGraphNode>();
int index = 0;
if (null != node)nodes.add(node);
while (index != nodes.size()) {
UndirectedGraphNode n = nodes.get(index);
System.ou... | 5 |
private boolean isOperator(String ch){
String operators = "*/%+-";
if (operators.indexOf(ch) != -1)
return true;
else
return false;
} | 1 |
public boolean hasPrevious() {
if(previousShort != null)//Already found. This is prevention for possible inappropriate call.
return true;
while(strings.hasNext()){
previousShort = strings.previous();
index--;
if(previousShort.length() <= maxLen)
previousIndex = index;
return true;
}
previou... | 3 |
@Override
public void openIF(boolean safeMode) throws RoombaIFException {
serialPort = new SerialPort(portName);
if (isOpened) {
throw new RoombaIFException(RoombaIFException.TYPE_ALREADY_OPEN);
}
try {
serialPort.openPort();
serialPort.setParams(B... | 8 |
public static Cons cppTranslateMethodCall(Cons tree, boolean referencedP) {
{ Symbol methodname = ((Symbol)(tree.rest.value));
Surrogate owner = ((Surrogate)(tree.value));
Cons arguments = tree.rest.rest;
if ((methodname == Stella.SYM_STELLA_DEFINEDp) ||
(methodname == Stella.SYM_STELLA... | 8 |
public boolean isSolved() {
boolean solved = true;
for (int x=0; x < size*size && solved; x++) {
for (int y=0; y < size*size && solved; y++) {
solved = (!sudokuGrid[x][y].equals(new String("*")));
}
}
return solved;
} | 4 |
private Expression equal( List<Expression> args, String caller ) {
if ( args.size() != 2 ) {
System.err.println("= expected 2 arguments and got " + args.size() );
System.exit(1);
}
DeferredSubst df = DeferredSubst.getInstance();
// if the values are the same
... | 2 |
public int setCurrency(int amount)
{
ownCurrency = amount;
int overflow = ownCurrency - 3904;
int large = (int)Math.floor(ownCurrency / largeCurrency);
if (large > 0)
inventory.setItem(2, new ItemStack(largeCurrencyItem.getType(), large));
else {
inventory.clear(2);
}
int m... | 3 |
public void saveToFile(File file) {
String suffix = file.getAbsolutePath().substring( file.getAbsolutePath().lastIndexOf(".")+1);
boolean saved = false;
if (suffix.equalsIgnoreCase("fasta") || suffix.equalsIgnoreCase("fas") ) {
FastaParser parser = new FastaParser(sunfishParent);
parser.writeData(file, curr... | 8 |
private static void handleError(String message, Throwable e)
{
MessageDialog.getInstance().showError(message);
LOGGER.error(message, e);
} | 0 |
private void preencherCampos() {
ArrayList<String> telefones;
ArrayList<Premiacao> premiacoes;
jTextFieldAltura.setText(Double.toString(piloto.getAltura()));
jTextFieldBairro.setText(piloto.getEndereco().getBairro());
jTextFieldCategoriaPeso.setText(Double.toString(piloto.getPes... | 7 |
static boolean player1Move(int x, int y) {
if (getGame().m_board.anyValid(m_player1Colour)) {
if (getGame().move(x, y, m_player1Colour)) {
if (m_p1colour == Piece.OthelloPieceColour.WHITE) {
m_gridButtons[x][y].setIcon(m_whitePiece);
} else {
m_gridButtons[x][y].setIcon(m_blackPiece);
}
O... | 3 |
public void run()
{
while(true) {
try{
long t = System.currentTimeMillis();
//check if products are still up to date and put the new ppc id in ppc otherwise
if(!vn.validateProducts(init.getPPC()))
{
barPanel.initBarProducts();
System.out.println("Er is een product geupdate");
}
/... | 3 |
public void received(Connection c, Object o)
{
if(o instanceof Packet)
{
Packet p = ((Packet)o);
p.decompressData();
// BlockyMain.console("Received packet "+p.name);
if(p.name.equals("Ping+infos response"))
{
try
... | 6 |
@Test
public void testSignedIntegerCompare() throws Exception {
int[] testNumbers = {
Integer.MIN_VALUE,
-1000,
0,
1000,
Integer.MAX_VALUE};
for (int n1 : testNumbers) {
byte[] n1Bytes = toSortableBytes(n1);... | 8 |
public static Ime_Velicina_Adresa OBRADI_izravni_deklarator(int trenutacnaLabela){
String linija = mParser.ParsirajNovuLiniju(); // ucitaj IDN
UniformniZnak uz_idn = UniformniZnak.SigurnoStvaranje(linija);
linija = mParser.DohvatiProviriVrijednost();
UniformniZnak uz_1 = UniformniZnak.SigurnoStvaranje(linija... | 8 |
protected void consumeMethodHeader() {
// MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt
// AnnotationMethodHeader ::= AnnotationMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt
// Recovery... | 7 |
public void setUserData(String userData) {
this.userData = userData;
} | 0 |
public void testStringSort() throws IOException, ParseException {
r = newRandom();
ScoreDoc[] result = null;
IndexSearcher searcher = getFullStrings();
sort.setSort(
new SortField("string", SortField.STRING),
new SortField("string2", SortField.STRING, true),
SortField.FIELD_DOC )... | 9 |
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String action = (String)req.getParameter("action");
if (action == null) action = "";
ProductViewHelper productViewHelper;
String url = "/ProductView.jsp";
switch (action) {
case View... | 5 |
public void insertVisitingHours(VisingHoursBean bean){
ResultSet rs=null;
Connection con=null;
PreparedStatement ps=null;
try{
String sql="INSERT INTO OFFICE_HOURS(p_id, weekday, timings) VALUES (?,?)";
con=ConnectionPool.getConnectionFromPool();;
ps=con.prepareStatement(sql);
ps.setInt(1, bean.get... | 7 |
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IdCount idCount = (IdCount) o;
if (id != idCount.id) return false;
return true;
} | 4 |
final public void AndExpression() throws ParseException {
EqualExpression();
label_2: while (true) {
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case AND:
break;
default:
jj_la1[2] = jj_gen;
break label_2;
}
ASTFunNode jjtn001 = new ASTFunNode(JJTFUNNODE);
boolean jjtc001 = true;
... | 8 |
public MapEntry acquire(int length) throws IOException {
// length check
int fIndex = mapLengthToFreeEntryArrayIndex(length);
if (fIndex < 0 || fIndex >= FREE_ENTRY_ARRAY_SIZE) throw new IllegalArgumentException(length + " <= 0 or > max allowed data slot length " + MAX_DATA_SLOT_LENGTH);
// metrics
this.to... | 8 |
public void process() {
List<CycleEventContainer> eventsCopy = new ArrayList<CycleEventContainer>(events);
List<CycleEventContainer> remove = new ArrayList<CycleEventContainer>();
for (CycleEventContainer c : eventsCopy) {
if (c != null) {
if (c.needsExecution())
c.execute();
if (!c.isRunning()) {... | 5 |
public static AbstractTableModel getBoundProperties(final CSProperties p, String boundName) throws ParseException {
final int rows = DataIO.getInt(p, boundName);
final List<String> arr = keysByMeta(p, "bound", boundName);
return new AbstractTableModel() {
@Override
pu... | 1 |
public JSONObject optJSONObject(int index) {
Object o = this.opt(index);
return o instanceof JSONObject ? (JSONObject) o : null;
} | 1 |
private static Tree setParents(Tree a, int[] L) {
for(int i=0;i<L.length;i++){
if(L[i]==0){
a.addLeaf(i+1); }
}
for(int i=0;i<L.length;i++){
if(L[i]!=0){
a.addLeaf(L[i],i+1);
}
}
return a;
} | 4 |
final private boolean jj_3R_189() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(85)) {
jj_scanpos = xsp;
if (jj_scan_token(86)) {
jj_scanpos = xsp;
if (jj_scan_token(83)) {
jj_scanpos = xsp;
if (jj_scan_token(84)) {
jj_scanpos = xsp;
if (jj_scan_token(92)) {
jj_scanpos... | 9 |
public static boolean isAlpha(int c) {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
} | 3 |
public static void main(String[] args) {
Inner1 inner = new Inner1();
inner.dosomething();
} | 0 |
@Override
public void propertyChange(PropertyChangeEvent evt)
{
CompoundPainter<?> painter = ref.get();
if (painter == null)
{
AbstractPainter<?> src = (AbstractPainter<?>) evt.getSource();
src.removePropertyChangeListener(this);
}
else
{
String property = evt.getPropertyName();
... | 6 |
@SuppressWarnings("unchecked")
public static <T> ImmutableList<T> of(
final ImmutableList<? extends T> left,
final ImmutableList<? extends T> right) {
if (right.isEmpty()) {
return (ImmutableList<T>) left;
}
if (left.isEmpty()) {
return (Immuta... | 4 |
public void doVictimsOfCrime(Area A, LegalBehavior B, Law theLaw, MOB mob, boolean allowedToModify)
throws IOException
{
if(mob.session()==null)
return;
mob.tell(getFromTOC("P3"+(theLaw.hasModifiableLaws()?"MOD":"")));
mob.tell(L("Protected victims: @x1",CMLib.masking().maskDesc(theLaw.getInternalStr("PROTE... | 7 |
private byte[] handleHandshake(NfcMessage inputMessage) {
// no sequence number in handshake
if (inputMessage.isSelectAidApdu()) {
/*
* The size of the returned message is specified in NfcTransceiver
* and is currently set to 2.
*/
if (Config.DEBUG)
Log.d(TAG, "AID selected");
return ne... | 9 |
public void paintColorsMode(Graphics g, int x, int y) {
Point p = new Point(x, y);
String rbs =request.buttonGroup.getSelection().getActionCommand(); //radio button selected
colorBiddableLand(g);
Grid grid = request.operator.getGrid();
grid.goToSurface();
if (rbs.equals("B")){ //If the bid radio box ... | 6 |
public PrintableDialog() {
setTitle("Print Preview");
printMode.setStyle(CharProps.getIntProperty("last.printmode.style", PrintMode.STYLE_CRAM));
printMode.setText(CharProps.getIntProperty("last.printmode.text", PrintMode.TEXT_CHARS));
Container thiss = this.getContentPane();
th... | 9 |
public static void main(String[] args) {
long start = System.nanoTime();
int found = 0, sum = 0;
for (int i = 19; found < 11; i += 2) {
if (isPrime(i)) {
if (isTruncatable(Integer.toString(i))) {
found += 1;
sum += i;
}
}
}
System.out.println(sum);
System.out.println("Done in " + (do... | 3 |
private void setMenuItems(){
// file menu
// help menu
welcome = new JMenuItem("Welcome");
about = new JMenuItem("About this");
help.add(welcome);
help.add(about);
} | 0 |
public void enter(Miner miner){
if (miner.getLocation() != Location.saloon)
{
miner.changeLocation(Location.saloon);
System.out.println(miner.getName() + " Boy, ah sure is thusty! Walking to the saloon");
}
} | 1 |
public static final void login(final SeekableLittleEndianAccessor slea, final MapleClient c) {
final String login = slea.readMapleAsciiString();
final String pwd = slea.readMapleAsciiString();
c.setAccountName(login);
final boolean ipBan = c.hasBannedIP();
// final boolean macBan... | 9 |
public void sendGuessMove(String guess){
check(isMyTurn() && currentMove == GUESS);
int maxDigit = (Integer)state.get(MAXDIGIT);
check(masterMindLogic.checkValidCode(guess, maxDigit));
this.sendGuessOperation(coderId, guesserId, guess, state);
} | 1 |
public static String shitWordN(String s,int n){
if(s!=null && n >= 0 && n <= s.length()){
char[] shit = s.toCharArray();
reverseChar(shit,0,n-1);
reverseChar(shit,n,s.length()-1);
reverseChar(shit,0,s.length()-1);
return new String(shit);
}
return null;
} | 3 |
public Address getIndirizzo() {
return address;
} | 0 |
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] argx)
{
List<String> listWithDup = new ArrayList<String>();
listWithDup.add("1");
listWithDup.add("2");
listWithDup.add("3");
listWithDup.add("1");
List<String> listWithoutDup = new Array... | 0 |
public static void main(String[] args) throws IOException,
InstantiationException, IllegalAccessException, InterruptedException, ExecutionException {
System.out.println("Running benchmark. Press any key to continue.");
System.in.read();
Map<Class<?>, Map<String, String>> keyLookupCl... | 4 |
public AttributeInfo copy(ConstPool newCp, Map classnames) {
if (methodIndex() == 0)
return new EnclosingMethodAttribute(newCp, className());
else
return new EnclosingMethodAttribute(newCp, className(),
methodName(), methodDescriptor()... | 1 |
public static Subject findSubjectOfBestHj(Data myData, Subject[] givenSubjects){
int i = 0;
Subject bestSubject = givenSubjects[i];
for(int j=i+1; j<givenSubjects.length; j++){
if (findBestSubjectSemester(bestSubject)==null){
bestSubject = givenSubjects[j];
... | 5 |
public void run() {
while(active){
if(freeze){
try {
this.freeze = false;
Ob.wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
sim = new Driver();
sim.Constants = this.Constants;
sim.verbose = this.verbose;
... | 6 |
public void assignRoles() {
calculateRatio();
for (Player player : players.getPlayers()) {
if (getRandomDecision()) {
assignAsMafia(player);
} else {
assignAsVillager(player);
}
}
} | 2 |
@Override
public DefaultConnectionLabel toItem( ConnectionLabelData data, DefaultUmlDiagram diagram ) {
AbstractConnection connection = (AbstractConnection)diagram.getItem( data.getConnection() );
if(connection == null){
throw new IllegalStateException( "cannot find connection of label" );
}
DefaultConne... | 1 |
public static void main(String[] args) {
long[]arr = new long[]{1,3,4,1,2,5};
display(arr);
InsertSort.sort(arr);
display(arr);
} | 0 |
public static String producto(String archivo, String factorA, String factorB) {
try {
Workbook libro = Workbook.getWorkbook(new File("src/txts/" + archivo));
int altoTabla = libro.getSheet(0).getRows();
String[][] tabla = new String[libro.getSheet(0).getColumns()][altoTabla];... | 7 |
public static ClassLoader getDefaultClassLoader() {
ClassLoader cl = null;
try {
cl = Thread.currentThread().getContextClassLoader();
} catch (Throwable ex) {
// Cannot access thread context ClassLoader - falling back to system
// class loader...
}
if (cl == null) {
// No thread context class load... | 2 |
@Override
void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
{
// Replace child
if(this._condicao_ == oldChild)
{
setCondicao((PExpLogica) newChild);
return;
}
for(ListIterator<PComando> i = thi... | 4 |
public String getStateName() {
return stateName.get();
} | 0 |
ArrayList<String> wordBreakDFS( String s, Set<String> dict ) {
ArrayList<String> result = new ArrayList<String>(), tmpList;
for( int i = 0; i < s.length(); i++ ) {
String head = s.substring(0, i+1);
String tail = s.substring(i+1);
if( dict.contains(head) ) {
... | 5 |
public static void main(String args[]){
System.out.println("Digite o numero para verificar se é primo ou não:");
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
boolean primo = true;
for (int i = n-1; i > 1; i--) {
if (n%i == 0) {
... | 3 |
public Image[] getCells(ImageRetriever paramImageRetriever, int paramInt1, int paramInt2)
{
Integer localInteger = new Integer(paramInt1);
if (animationList == null)
animationList = new Hashtable();
Object localObject = animationList.get(localInteger);
Image[] arrayOfImage;
if (localObject =... | 4 |
@Test
public void ensureSalaryItemInBudgetContainsDifferentValueFormObjectTestTwo() {
when(budgetFormData.getSalary()).thenReturn(new BigDecimal("2500"));
try {
budget.buildBudget(budgetFormData);
} catch (Exception e) {
e.printStackTrace();
}
asser... | 1 |
public void render(Screen screen) {
Vector2i pos = getPlayers().get(0).getPos().toVector2i();
int xOffset = pos.getX() - screen.w / 2;
int yOffset = pos.getY() - screen.h / 2;
screen.setOffset(xOffset, yOffset);
int x0 = xOffset >> 4;
int x1 = (xOffset + screen.w + 16) >> 4;
int y0 = yOffset >> 4;
int ... | 7 |
public void mouseExited(MouseEvent event) {
adapter.mouseExited(event);
} | 0 |
public static JSONObject toJSONObject(String string) throws JSONException {
JSONObject jo = new JSONObject();
HTTPTokener x = new HTTPTokener(string);
String token;
token = x.nextToken();
if (token.toUpperCase().startsWith("HTTP")) {
// Response
jo.p... | 2 |
public int getPoints() {
return points;
} | 0 |
public static String convert(String s, int nRows) {
String result = "";
if (nRows < 2 || s == null) {
return s;
}
String[] strings = new String[nRows];
int current = 0;
int dir = -1;
for (int i = 0; i < s.length(); i++) {
if (strings[curre... | 8 |
public static int triangleBsum1(int x[][]) {
int sum = 0;
for (int i = 0; i < x.length; i++) {
System.out.println();
for (int j = 0; j < x[i].length; j++) {
if (i >= j) {
System.out.print(x[i][j] + " ");
sum = sum + x[i][j];
}
}
}
System.out.println();
return sum;
} | 3 |
public boolean validateConnection(String direction) {
switch (direction) {
case "north":
if (this.north[0].equals("X")) {
return false;
} else {
return true;
}
case "east":
if (this.ea... | 8 |
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
for (int x = 0; x < tiles.length; x++){
for (int y = 0; y < tiles[x].length; y++){
if (tiles[x][y] != null)
tiles[x][y].render(
x*tiles[x][y].getSprite().getWidth(),
y*tiles[x][y].getSprite().getHeight()
... | 3 |
public void update(GameContainer gc, StateBasedGame sb, float delta) {
if (cooldown <= 0) {
cooldown = 0;
onCooldown = false;
} else if (onCooldown) {
cooldown -= delta;
}
} | 2 |
public void process(String dirname) {
FileWriter fw = null;
try {
File dir = new File(dirname);
fw = new FileWriter(output);
BufferedWriter bw = new BufferedWriter(fw);
File[] fa = dir.listFiles(new EndsWithFilter(extension));
for (File f : fa) {
String name = f.getName();
System.out... | 9 |
private int addNewPlayers(List<Player> player, Message mg) {
int numberOfPlayers = 0;
while(numberOfPlayers == 0){
try{
numberOfPlayers = Integer.parseInt(getInput());
} catch (NumberFormatException e){
mg.displayMessage(3);
}
}
/*
* This code generates the new players by user input
... | 8 |
World(int level) {
walls = new ArrayList<Wall>();
walls.add(new Wall(0, 0, 600, 20));
walls.add(new Wall(0, 0, 20, 600));
walls.add(new Wall(0, 571, 600, 600));
walls.add(new Wall(571, 0, 600, 600));
switch(level) {
case 1: initWorldLevelOne(); break;
... | 3 |
@Test
public void testGetQuantidadeProduto() {
try {
Assert.assertEquals(10, facade.getQuantidadeProduto(1));
} catch (FacadeException e) {
Assert.fail(e.getMessage());
}
try {
facade.getQuantidadeProduto(5);
Assert.fail("era para lanÁa exceÁ„o");
} catch (FacadeException e) {
// n„o È par... | 4 |
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.