method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
d7aa785a-cfc6-4e1d-8d9d-22caa64e9c87
1
public void mouseDrag(int x, int y){ if(movingInputTime){ node.setPosition(x); } }
d24db0f4-fa22-4db4-b800-b35866c450f9
2
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpSession session = ((HttpServletRequest)request).getSession(true); Locale locale = (Locale) session.getAttribute(JSP_LOCALE); ...
69e8b4f1-a705-4ae7-b18e-6bd86d3ec4c1
9
protected void addNewAciton() { // Action type Object typeValueItem = typeNAJcbx.getSelectedItem(); String typeValue = null; if (typeValueItem != null ) { typeValue = typeValueItem.toString(); } // Claims", "Counter Claims", "Evidene", "Counter Evidence", // "Bi-polar Questions", "Response to Bi-pol...
f2a7620e-270d-4990-a483-162c9bea5993
2
@Override public void onFirstUpdate(){ if (sound.Manager.enabled) { sound.Event effect = new sound.Event(getPosition(), getVelocity(),sound.Library.findByName(SHOOT_EFFECT)); effect.gain = EFFECT_VOLUME; sound.Manager.addEvent(effect); } if(ParticleSystem...
8f3a4cd0-f15f-4728-8fb9-2c91cbd600b0
7
protected void attachToHost() { if (host == null) return; if (host instanceof Particle || host instanceof RectangularObstacle) { switch (getAttachmentPosition()) { case CENTER: setLocation(host.getRx(), host.getRy()); break; case ENDPOINT1: float length = (float) getLength(); float invLe...
af913eb6-6593-4536-a2fc-ed426f05744b
8
public static void load(){ BufferedReader reader = null; try{ if(USER_DATA_FILE.exists() == false){ //System.out.println("USER DATA DOES NOT EXIST"); USER_DATA_FILE.createNewFile(); makeAllDefault(); ...
95108d06-edd4-444e-9bb5-f1201988a316
9
public static String sendPost(String url, String contents,HashMap<String, String> propertyMap){ InputStreamReader inr = null; try{ System.out.println("post>>>"+url); URL serverUrl = new URL(url); HttpURLConnection conn = (HttpURLConnection) serverUrl.openConn...
e5547c8b-9d21-45f5-89dc-cd51e92bd71a
5
public void render() { clear(); Graphics g = graphics(); if (isPushed)// modified by Kerrigan { if (a) g.drawImage(up, 0, 0, null); else if (isHovered) g.drawImage(hover, 0, 0, null); else g.drawImage(dow...
c19a955b-7255-4042-bbe5-1c816e782f4a
3
public static byte[] handshake(byte[] info_hash, byte[] peer_id){ byte[] hand_shake = new byte[68]; //<19><BitTorrent protocol><00000000> //copy the handshake_header into the handshake message for(int i = 0; i<handshake_header.length; i++) hand_shake[i] = handshake_header[i]; //fill 28 - 47 with the SHA1 ...
f515ddbc-3d1b-4ff3-9516-4907ac965536
8
public boolean isSymmetricItr(TreeNode root){ ArrayDeque<TreeNode> queue1 = new ArrayDeque<TreeNode>(); ArrayDeque<TreeNode> queue2 = new ArrayDeque<TreeNode>(); queue1.offerLast(root); queue2.offerLast(root); while(!queue1.isEmpty() && !queue2.isEmpty()){ TreeNode n...
66d1efd6-dbd6-49e7-8e64-10546b4b7c5b
9
public String searchTagAttributeValue(Document doc, String rootNodeName, String tag, String attributeName, boolean strict) throws TagNotFoundException, AttributeNotFoundException { NodeList nodes = doc.getElementsByTagName(rootNodeName); try { DOMW...
49b509ee-c385-40f1-8e7b-4ca08f4dc420
6
public boolean choqueObstaculo(int posicionX, int posicionY){ for (int i = 0; i < listaObjetos.size(); i++){ //Si es de tipo Roca y la posicion esta dentro de su perimetro no permite el movimiento if( (listaObjetos.get(i).getTipoObjeto().getClass() == (new ObjetoRoca().getClass())) && ( (listaObjetos.get(i).ge...
f146ef80-1991-4efc-86c8-1c479c6044f4
9
public void updateList(String remoteMachineID, MemberList incomingMemberList) { int localIndex=-1,otherIndex=0; String currentIP; int localMemberListsize = this.memList.size(); int incomingMemberListsize = incomingMemberList.memList.size(); for ( otherIndex = 0; otherIndex < incomingMemberListsize; oth...
43be1c9d-6101-4968-beae-954f77413134
7
@Override public void update(Observable o, Object arg) { if (!this.gm.getBoard().getWinner().equals(GameResult.GameRunning)){ endGame(); } if (this.gm.canDraw() && (!isDrawVisable)) { isDrawVisable = true; int wantsDraw = JOptionPane.showConfirmDialog( myCheckmate, "It is possible to declare thi...
bac27119-f3c4-4d6e-9809-025a83ee6c40
8
public void run() { long current = 0, size = totalSize(); for (Pair<File,File> pair : pairs) { File src = pair.get1(); File dst = pair.get2(); if (src.exists() && src.isFile()) { if (!dst.exists() || dst.isFile()) { try { if (dst.exists()) dst.delete(); dst.createNewFile(); pr...
9b4f8282-bcb8-41fd-a5b6-0d82d0d5189a
2
private void handleUpdate() { if (pref instanceof PreferenceString) { ((PreferenceString) pref).setTmp((String) box.getSelectedItem()); } else if (pref instanceof PreferenceLineEnding) { ((PreferenceLineEnding) pref).setTmp((String) box.getSelectedItem()); } }
e60920ff-01fd-413e-8fa1-c45e1873dd1b
2
public List<Produto> listarTodos() throws ErroValidacaoException, Exception{ List<Produto> produtos = new LinkedList<>(); try{ PreparedStatement comando = bd.getConexao() .prepareStatement("SELECT p.id,nome,descricao,valor_uni_Venda, " ...
b7ba0d8e-cc0c-4207-9a62-b7fe86c76441
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person1 = (Person) o; if (age != person1.age) return false; if (firstName != null ? !firstName.equals(person1.firstName) : person1.first...
cf59df84-6456-4970-8497-7991dfd72c79
1
public static void splitLabel(Transition transition, Automaton automaton){ FSATransition trans = (FSATransition) transition; State from = transition.getFromState(), f = from, to = transition .getToState(); automaton.removeTransition(trans); String label = trans.getLabel(); for(int i=label.charAt(label.index...
e7100552-edef-493e-a3e5-845d5eb911fd
3
@Override public void sort(int[] array) { for( int i = array.length-1; i > 0; --i ) { for( int j = 0; j < i; ++j ) { if( array[j] > array[j+1] ) { int swap = array[j+1]; array[j+1] = array[j]; array[j] = swap; } } } }
9541a123-0160-467e-b737-64a5c5e844d1
8
protected void constBranchEliminate(Block root) { Queue<Entry<Block, HashMap<Integer, SSAorConst>>> queue = new LinkedList<Entry<Block, HashMap<Integer, SSAorConst>>>(); HashMap<Integer, SSAorConst> propagator = new HashMap<Integer, SSAorConst>(); queue.add(new AbstractMap.SimpleEntry<Block, HashMap<Integer, SSAo...
0e21ba3d-7986-468b-88f9-520710555ba8
4
public static Window getWindowForComponent(Component comp) { while (true) { if (comp == null) { return JOptionPane.getRootFrame(); } if (comp instanceof Frame || comp instanceof Dialog) { return (Window) comp; } comp = comp.getParent(); } }
381bae1f-80d2-4f91-9b26-441468c5a3a1
1
public Server() { // Show server view serverView = new ServerView(this); serverView.getFrame().setVisible(true); // Start server and listen from port 1099 Rmi rmiService = null; try { rmiService = new RmiImpl(); Registry registry = LocateRegistry.createRegistry(1099); registry.rebind("pcs", rmiSer...
d1f60b23-9d70-46a2-9e7b-5c63c558f4f9
9
public void mouseClicked(MouseEvent pEvent) { mLastMouseClickedPosition = pEvent.getPoint(); Point p = pEvent.getComponent().getLocationOnScreen(); mLastMouseClickedPosition.x += p.getX(); mLastMouseClickedPosition.y += p.getY(); TableViewAdapter adapter = (Ta...
18f4148c-71bd-4497-ac2d-b11c51b0f2ed
6
public void actionPerformed(ActionEvent e) { if (e.getSource() == buttonPlay) { wait = !wait; } else if (e.getSource() == buttonPrev) { wait = true; view.controller().prev(); view.flush(); repaint(); } else if (e.getSource() == buttonNext) { wait = true; view.controller().next(); view...
26f51f7c-3b76-4fa2-9a1b-e100712bff46
2
public TileMap() { for (int x = 0; x < 16; x++) { for (int y = 0; y < 10; y++) { putTile(Tile.GRASS_1, x, y); } } }
1d3dddf1-8e1b-4680-8d21-6693dabc3c4f
8
protected static Instances getMiningSchemaAsInstances(Element model, Instances dataDictionary) throws Exception { FastVector attInfo = new FastVector(); NodeList fieldList = model.getElementsByTagName("MiningField"); int classIndex = -1; int a...
51426979-e5fc-4b1f-baeb-78bd1f21d326
1
private boolean jj_2_61(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_61(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(60, xla); } }
56b73466-a1fd-4b6e-bc5f-b626d5b662d1
4
public boolean saveSmfUser(String user) throws ClassNotFoundException, SQLException { // SMF activation sqlClass(); sqlCon(); if (!customField.isEmpty()) { query = "SELECT id_member FROM " + tablePref + "themes WHERE variable='" + smfFieldValue() + "' AND value='" + user + "'"; ResultSet rs =...
a24988ef-8290-418e-b150-b735ec9ce578
4
@Override public Void call() { final String timestamp = this.writer.timestamp.format(new Date()); this.markers.clear(); for (final World world : this.writer.plugin.getServer().getWorlds()) { for (final Wolf wolf : world.getEntitiesByClass(Wolf.class)) { if (!wolf...
93b98a58-fdb1-4131-95f5-980f8d60e941
0
public static Object getObjectFromRequestParameter(String requestParameterName, Converter converter, UIComponent component) { String theId = JsfUtil.getRequestParameter(requestParameterName); return converter.getAsObject(FacesContext.getCurrentInstance(), component, theId); }
fb62e27a-63b0-4d4e-a760-72acf587c9da
1
private void checkMagicChar(char expected, String position) throws IOException { int magic = this.in.read(); if (magic != expected) { throw new IOException("Stream is not BZip2 formatted: expected '" + expected + "' as " + position + " byte but got '...
de2cf73c-a1f2-4ea5-9858-4eeb3503edb3
1
protected void createReaderWriter() throws JoeException { // try to create an appropriate reader-writer ourReaderWriter = new PdbReaderWriter() ; // if we fail ... if (ourReaderWriter == null) { throw new JoeException(UNABLE_TO_CREATE_OBJECT) ; } // end if } // end protected method PdbReaderWriter
441bd5d1-2c16-45e5-8698-294a57aa5fbf
1
private static boolean isInteger(String lexeme) { try { return Integer.signum(Integer.parseInt(lexeme)) != -1; } catch (NumberFormatException e) { return false; } }
ec27f303-6dcd-49c1-8acc-de204230ea5a
0
public final void setDistance(double distance) { this.distance = distance; parametersToNumbers.put("distance", new Double(distance)); }
b4ea6457-fe13-4b99-b41d-abd3a3564896
6
public BMPImage copyPart(int x, int y, int width, int height) { BMPImage image = new BMPImage(this); image.imageHeader.biHeight = height; image.imageHeader.biWidth = width; image.fileHeader.bfSize = FILE_HEADER_SIZE + IMAGE_HEADER_SIZE + height * width; BMPColor[][] bitmap = new...
f2b09fa3-dfce-4e33-b1f5-a41d3fd94a50
0
public void setTelefon2(String telefon2) { this.telefon2 = telefon2; }
8b2c168c-7b43-4001-9698-f49cba76833c
4
@EventHandler(priority=EventPriority.NORMAL) public void exploded(EntityExplodeEvent event) { Iterator<Block> i = event.blockList().iterator(); List<Block> blockToHandleList= new LinkedList<Block> (); while(i.hasNext()) { Block block = (Block)i.next(); CustomBlock cblock = this.plugin.getCustomBlock(blo...
4a9f5b39-73ae-41b0-90fb-b92183ecc685
8
private void createReferenceFile(final ObjectStreamClass osc) { final File referenceDir = context.getReferenceBaseDir(); final File referenceFile = new File(new File(referenceDir, osc.getName()), Long .toString(osc.getSerialVersionUID()) + ".ser"); ...
dfdb2971-03c1-46fa-b90d-c2d507a1a2a2
5
public void print(List<String> IdsToStrings,String pad) { Iterator<T> biIter=BigramCounts.keySet().iterator(); T myValue; UnigramCountsModel<K> model; int getVal; if (pad==null) { pad=""; } while (biIter.hasNext()) { myValue=biIter.next(); model=BigramCounts.get(myValue);...
565d2e10-b01a-4c3e-87cd-bba0625c01d4
1
public void removeTray(Tray tray) { if (this.trays.contains(tray)) { this.trays.remove(tray); tray.setStorageUnit(null); } }
adb67980-5ab1-4c58-bca0-bcd6b931320a
7
private Object[] readIndexTenor(XMLStreamReader2 streamReader) throws XMLStreamException { Integer periodMultiplier = null; PeriodEnum period = null; int startingDepth = streamReader.getDepth(); while(streamReader.hasNext()) { switch(streamReader.next()) { case XMLEvent.START_ELEMENT: ...
bb5c6f40-5e8c-4f59-a272-42b345cac3e6
2
void decorate(AbstractAxisChart chart) { chart.setTitle(title); chart.setSize(plotSizeX, plotSizeY); int gridx = (maxX - minX) / 10; int gridy = (maxY - minY) / 10; if( (gridx > 0) && (gridy > 0) ) chart.setGrid((maxX - minX) / 10, (maxY - minY) / 10, 3, 2); // Adding axis info to chart. chart.addXAxisL...
15bc2fa8-f8ac-495f-92dd-d3f2d90a08c4
0
public long getDaysOlder(String personA, String personB) throws Exception { String[] personDataA = getPersonData(personA); String[] personDataB = getPersonData(personB); long agePersonA = getDaysFromSeconds(getAgeInSeconds(personDataA[DOB_INDEX])); long agePersonB = getDaysFromSeconds(ge...
4231f9e0-ece4-4b75-a9e4-e5d57ecda93e
5
public void showItem(Item item) { //when messing with craft book selector w/o item first loaded if (item == null) { return; } currentItem = item; //CraftIntoPanel treats all Items equally. guiCraftIntoPanel.craftTable.setData(item); //Casting for CraftComponentPanel and ItemInfoPanel. switc...
26c358ca-5f97-4634-8216-bd840e729bb4
4
@Override public boolean replicaAll(Hashtable<String, Integer> objects, String server) throws RemoteException { //Interface to access other server to get all objects InterfaceAcesso ia = null; //Was replicaAll a success? boolean success = true; //Looking for the server try { ia = (InterfaceAcesso...
3a24c997-ff09-4e6e-a785-240b5c5cd02b
8
void updateHitboxes(Element frame) { blue_hitboxes.clear(); red_hitboxes.clear(); boolean empty_red = false; boolean empty_blue = false; for(Node hitbox=frame.getFirstChild();hitbox!=null;hitbox=hitbox.getNextSibling())//Hitbox loop { if(hitbox.getNodeName().equals("Hitboxes"))...
6744668f-94c4-47da-8498-5542176ada91
1
public String bitrate_string() { if (h_vbr == true) { return Integer.toString(bitrate()/1000)+" kb/s"; } else return bitrate_str[h_version][h_layer - 1][h_bitrate_index]; }
4f37742a-9020-4f36-b3d1-cc683e253bd7
0
public static<X> X getMiddle(X[] a) { return a[a.length / 2]; }
7b69b2d1-b476-451e-a095-888fe57db77a
5
public static DBQueryUserResult getUser(String username, String password) { preQueryConnect(); Actions.addAction(new Action(ActionType.INFO, "User query requested for input: " + username + ".")); DBQueryUserResult userQueryResult = null; if(username.contains("'") || username.contains("\"") || username.contains(...
fa8cd170-6843-414d-ab52-eea0a924fb11
0
public void setCombinacion(int combinacion) { this.combinacion = combinacion; }
1031993c-fffa-4f70-ba39-0c047a818ca4
8
public boolean isInitial(int c){ return Character.isLetter(c) || c == '*' || c == '/' || c == '>'|| c == '<' || c == '=' || c == '?' || c == '!' || c == '.'; }
9b8ac687-f03c-424b-996d-f9d6e8b64f61
6
private static String convertNumber(String number) { if (number.length() > 3) throw new NumberFormatException( "La longitud maxima debe ser 3 digitos"); // Caso especial con el 100 if (number.equals("100")) { return "CIEN"; } StringB...
a20d473e-ba3f-4536-9de6-8984efda59c5
5
@Override public void publish(LogRecord record) { if (painted.get()) { synchronized (lock) { final LogEntry peek = logEntries.peekLast(); if (peek == null || !peek.text.equals(record.getMessage())) { logEntries.offer(new LogEntry(record)); } else if (peek.text.equals(record.getMessage())) { ...
415eff71-b2c7-44c2-99d8-6d68d1acc686
7
@Override public void setValues(Component target, int tweenType, float[] newValues) { switch (tweenType) { case X: target.setLocation(Math.round(newValues[0]), target.getY()); break; case Y: target.setLocation(target.getX(), Math.round(newValues[0])); break; case XY: target.set...
b1f5e946-6023-47ab-bf1d-6d03ac70444a
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; LadoSe other = (LadoSe) obj; if (cabecalho == null) { if (other.cabecalho != null) return false; } else if (!cabecalho.equals(other.cabe...
314714cf-81ad-4fec-a5a5-5e8aa4fc942e
3
private void processMoveFromBoard(MouseEvent e) { int col = findCol(e.getX()); List<Card> possibleCards = game.getBoard().get(col); int index = findCardIndex(possibleCards, e.getY(), col == 0); if (index == -1) { //Indicates none found. return; } ...
d74050b6-7e63-4c58-aaf0-3cdd4f29dd3a
1
public void mainAction() { ship s = getShipToPerformAction(); if(getTurnDecay() == 0) { s.addHardpoints(h); } else { modifyTurnDecay(-1); } }
79454a23-bd4f-4a72-94bc-daf38914b860
1
public BufMgr( int numbufs, String replacerArg ) { numBuffers = numbufs; frmeTable = new FrameDesc[numBuffers]; bufPool = new byte[numBuffers][MAX_SPACE]; frmeTable = new FrameDesc[numBuffers]; // Initialize the Buffer Table with empty frame descriptions for (int i = 0; i < numBuffer...
3e8fd439-64b8-4d36-812c-4bdcc7501931
5
@Override public void run() { setStopped(false); try { while ((!Thread.currentThread().isInterrupted()) && (!isStopped())) { Thread.sleep(IDLE_TIMEOUT / 2); try { if (!isStopped()) { send(ISession.KEEPALIVE_MESSAGE, null); } }...
85bcc8b8-44ef-4b3f-b08f-3ef040a4b807
9
private long readLong_slow (boolean optimizePositive) { // The buffer is guaranteed to have at least 1 byte. int b = buffer[position++]; long result = b & 0x7F; if ((b & 0x80) != 0) { require(1); byte[] buffer = this.buffer; b = buffer[position++]; result |= (b & 0x7F) << 7; if ((b & 0x80) != 0) ...
244e3b59-8d71-459e-84a0-450be1f43fba
5
@RequestMapping(value = "/list", method = RequestMethod.GET) public String start(ModelMap modelMap, HttpSession session) { List<Content> restrictedContentList = new ArrayList<>(); Integer numberOfElementsToDisplay = (contentService.getAll().size() >= 5) ? 5 : contentService.getAll().size(); ...
dd0b91fd-2f12-4bb5-9c44-f0b0f9658d52
2
public boolean add(T t) { boolean result = false; if(array.length <= index) { T[] newArray = (T[])Array.newInstance(type, array.length * 2); for(int i = 0; i < array.length; i++){ newArray[i] = array[i]; } array = newArray; } array[index] = t; index++; result = true; return result; }
7fc33d10-71d5-4c05-b301-4dc6b2c5acfb
9
public boolean equalsXMLElement(IXMLElement elt) { if (! this.name.equals(elt.getName())) { return false; } if (this.attributes.size() != elt.getAttributeCount()) { return false; } Enumeration en = this.attributes.elements(); while (en.hasMoreEleme...
75073bcd-4210-42bc-b0db-99c0e64f3011
0
public CallType getCallType() { return callType; }
a46120e7-8aa0-4045-a236-83fa3a7f2fd6
8
public static SeqDist getClosestInFile(int[] u, File file) throws IOException { /* * ///!!!\\\ all the sequences in the file must have the same size */ DnaFileReader reader = new DnaFileReader(file); int nSeq = reader.totalNumberofSeq(); int[] bestSeq = null, curSeq = null; int bestDist = Integer.MA...
48d403e2-48e5-42ef-b6c5-4892d39c1019
3
private String getNameforNum(int n) { //SWAP 1 TEAM 5. /* * QUALITY CHANGES * Looked things up and found an easier way to do days of the week; a lot easier to understand * while compressing 20 lines of useless duplicate code. */ if(n == 1) { return "Sunday"; } else if (n > 1 && n <= 7){ retur...
e9632b87-9654-44f3-9fb1-07ff31a8acde
8
private void calculateGreatMargin(Double fieldA, Double factor) { if((ourProportion.compareTo(fieldA) <= 0) && ((purchaseCost.compareTo(0.0) != 0) ? minMarginOnPosition.compareTo((minCostOnAll - 0.02) / purchaseCost * 100.0 - 100.0) < 0 : minMarginOnPosition.compareTo(0.0) < 0)) { if(settlementCost....
92327940-ed70-474d-afdf-bdacd3819cab
2
private void notifyListeners(AccessToken token) { for (TokenRetrievedListener listener : mListeners) if (listener != null) listener.notify(token); }
649361d4-d16b-4145-89ea-f52e52983e0c
9
@Deprecated public static final Object getMethodValue(OgnlContext context, Object target, String propertyName) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException { return getMethodValue(context, target, propertyName, false); }
009095a2-5ab2-4766-b88a-67f2359866a9
2
public double rawAllResponsesStandardDeviation(){ if(!this.dataPreprocessed)this.preprocessData(); if(!this.variancesCalculated)this.meansAndVariances(); return this.rawAllResponsesStandardDeviation; }
c3d314ce-9c3a-4dbe-a1a0-5e31bc74670a
2
public static void saveAs(ArrayList<String> lines) throws IOException { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Save file as? "); int result = chooser.showSaveDialog(null); if (result == JFileChooser.APPROVE_OPTION) { File file = chooser.ge...
53bd6291-efdf-4f8d-b396-e9c9c0007f98
8
private final void calcGaps(ComponentWrapper before, CC befCC, ComponentWrapper after, CC aftCC, String tag, boolean flowX, boolean isLTR) { ContainerWrapper par = comp.getParent(); int parW = par.getWidth(); int parH = par.getHeight(); BoundSize befGap = before != null ? (flowX ? befCC.getHorizontal() :...
aef3c6fb-ea24-4ea6-b6b4-59cf922c82bb
4
public void setModel(Model model) { setSimulation(false); if (this.model != null) { this.model.unregisterListener(this); } this.model = model; final boolean isModelPresent = model != null; fileSave.setEnabled(isModelPresent && model.hasBackingFile()); ...
182fbce8-9fd3-429e-8694-84141d1526a3
9
private char escapedStringChar(J_PositionTrackingPushbackReader var1) throws IOException, J_InvalidSyntaxException { char var3 = (char)var1.read(); char var2; switch(var3) { case 34: var2 = 34; break; case 47: var2 = 47; break; case 92: va...
fb7b66b6-dbf1-49bf-a501-9517701e6cc1
4
private void loginSuccess() { if (user != null) { System.out.println("username: " + user.getUsername()); this.setVisible(false); if (user.getRole().equals("Tutor")) { TutorGUI tutorGUI = new TutorGUI(user); tutorGUI.setSize(880, 500); tutorGUI.setLocation(250, 100); tutorGUI.setTitle("Debate"...
2f489834-d93e-493e-9d89-1f0a68c968c7
0
@Test public void testGetInstruction() throws IOException { System.out.println("getInstruction"); String antBrainFile = "cleverbrain1.brain"; AntBrain instance = new AntBrain(antBrainFile); int currState = 0; Sense expResult = new Sense(Sense.dirFromString("here"),32, 1,Sense...
7229dbb1-7a6f-43db-93b8-b890c4f66447
7
static private DamageCause getType(String str) { // Renamed if (str.equalsIgnoreCase("burning")) { return DamageCause.FIRE_TICK; } // By Name DamageCause[] types = getTypes(); for (int i = 0; i < types.length; i++) { if (types[i].name().equalsIgnoreCase(str)) return types[i]; } for (int i = ...
5475b23e-11a5-4888-99c2-90bfbfcaeb8d
3
public static InformationStatusEnum fromString(String v) { if (v != null) { for (InformationStatusEnum c : InformationStatusEnum.values()) { if (v.equalsIgnoreCase(c.toString())) { return c; } } } throw new IllegalArgumentException(v); }
90774d50-da0e-4b21-9d83-2539384e17eb
6
public FloodWorld(Player.PlayerType playerType) { super(80, 80, 10); backgroundMusic.playLoop(); setPaintOrder(MuteButton.class, Overlay.class, Counter.class, Coins.class, MenuBar.class, Player.class, Bag.class, Coin.class, Water.class, Floodbank.class); for(int i=0; i<=80; i++) { ...
0b4af76b-d4ff-4f22-af25-6843abd7f77d
8
public Element parseElement(Scanner in) throws IOException { in.read(); if (in.isSymbol("%")) { return parseReference(in, new IntegerElement()); } else if (in.isSymbol("$")) { return parseReference(in, new StringElement()); } else if (in.isSymbol("*")) { ...
d2c9cc0a-7d23-483e-aac0-6887d8edd518
0
@Override public String toString() { return describeNode(); }
42e08e8c-7011-45db-ab19-613f9c06b47e
6
public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); switch(key) { case KeyEvent.VK_F2 : if(!this.live) { this.live = true; this.life = 100; } break; case KeyEvent.VK_LEFT : bL = true; break; case KeyEvent.VK_UP : bU = true; break; case KeyEvent.VK_RIGHT : bR = true...
b2c5db22-d6c0-4048-8585-38fd522872e4
7
private int[] maxOneTimeShortProfit(int[] prices, int start, int end) { int bestBuy = -1, bestSell = -1, bestProfit = 0; int currentHigh = start; for (int i = start; i < end; i++) { int price = prices[i]; if (i < end - 1 && price > prices[i + 1]) { if (p...
a30a63bf-867f-4764-9266-f6c62f3f752e
0
private static void unmarshal() throws JAXBException, FileNotFoundException { JAXBContext context = JAXBContext.newInstance(AtomicValidator.class, UnaryLogicalNotOperator.class, BinaryLogicalAndOperator.class, BinaryLogicalOrOperator.class, BinaryEqualsOperator.class, BinaryValidator.class); System.out.println(...
acbfc15b-3a77-4390-ab87-e8a321069c0e
0
public void setId(int id) { this.id = id; }
bc9d01e9-a5a1-43d7-b473-12c7b0a0f5b6
1
@Override protected void processMouseMotionEvent(MouseEvent event) { mInAutoscroll = getAutoscrolls() && event.getID() == MouseEvent.MOUSE_DRAGGED; super.processMouseMotionEvent(event); mInAutoscroll = false; }
a46ff53f-5d49-4e98-9699-a331a0adcf4f
3
private void playNight() { doVoice(false); if (firstNight) { firstNight = false; bot.sendMessage(gameChan, getFromFile("FIRSTNIGHT", NARRATION)); } else { bot.sendMessage(gameChan, Colors.DARK_BLUE + getFromFile("NIGHTTIME", NARRATION)); } if (players2.numWolves() == 1) { bot.sendMessage(gameChan...
17c9955c-91f7-49f6-b540-0a9534ca089a
0
public void processMouseMotionEvent(MouseEvent event) { transformMouseEvent(event); super.processMouseMotionEvent(event); }
60aba4ef-ee5a-48a9-9cd3-c97f807edacb
4
public int removeDuplicates(int[] A) { if (A == null || A.length == 0) return 0; int current = A[0]; int step = 0; for (int i = 1; i < A.length; i++) { if(A[i] == current) step ++ ; else{ A[i -step] = A[i]; ...
3d4ccf83-751c-49d5-b1f8-f543c314e9eb
2
public int getStrength(){ int value = 0; for (Armor armor : armorList) { if(armor != null) value += armor.getStats().getStrength(); } return value; }
1d30dcdd-14bf-4691-a732-8a47068c1372
1
@Override public void onCollision(Player player) { if(canPickUp()){ pickup(); player.energy += amount; player.points += 5; player.energy = Math.min(player.energy, Constants.MAX_ENERGY); } }
d311ce40-6526-4b72-bbe6-27234b24c102
3
public static int getScaledX(int xPosition, float tileX) { float dist = Math.abs(xPosition - tileX); float pos = dist - TILE_SCALE_FACTOR * dist * (dist - 1) / 2f; if (dist > SCALE_LIMIT_DIST) if (xPosition < tileX) return scaledXDistRight + ((int) dist - SCALE_LIMIT_DIST); else return scaledXDistL...
ba8ba39e-ef43-4a73-a3ad-51bd7cf66d21
9
public static void main(String[] args) { //配置一些用到的东西 ByteBuffer byteBuffer = ByteBuffer.allocate(1024); ByteBuffer buffer = ByteBuffer.wrap("hello world chiand".getBytes()); ByteBuffer randomBuffer; CharsetDecoder charsetDecoder = Charset.defaultCharset().newDecoder(); //...
0d2ca7ed-109f-45f6-ab1a-217553610ec2
7
@Override public void processNPC() { super.processNPC(); List<WorldObject> objects = World.getRegion(getRegionId()).getSpawnedObjects(); if (objects != null) { final HunterNPC info = HunterNPC.forId(getId()); int objectId = info.getEquipment().getObjectId(); for (final WorldObject object : objects) { ...
70286086-62e0-4249-ba88-a7cfc4bf9da4
9
public TableauState (Tableau t) { dungeon = new Card[t.dungeon.length - 1]; for (int i=0; i < dungeon.length; i++) { dungeon[i] = t.dungeon[i].top(); } dungeonDeck = t.dungeon[t.dungeon.length - 1].size(); for (CardPile p : t.heroes) { if (p == null) continue; if (p.size() == 0) con...
b8dfaa76-d1e6-403b-b5f7-b7caf19b9a7d
2
private String Complement(String binaryString) { StringBuilder complementBuilder = new StringBuilder(binaryString); for(int i = 0; i < binaryString.length(); ++i) { char flip = binaryString.charAt(i) == '0' ? '1' : '0'; complementBuilder.setCharAt(i, flip); } return complementBuilder.toString(); ...
cc5d4b05-6542-463f-b640-d4c494072844
7
private void getColor() { color = new int[] { 0xFF111111, 0xFF000000, 0xFFC2FEFF }; switch (random.nextInt(8)) { case 0: { // red color color[1] = 0xFFFF0000; break; } case 1: { // gold color color[1] = 0xFFCFB53B; break; } case 2: { // blue color color[1] = 0xFF005AFF; break; ...
742e0e6a-defd-4222-a8bc-7e8915290ac5
2
public void rightMultiplyBy(Matrix that) { double[][] values = new double[3][3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) values[i][j] = this.m[i][0] * that.m[0][j] + this.m[i][1] * that.m[1][j] + this.m[i][2] * that.m[2][j]; setComponents(values); }
ce4df9de-f9f0-401b-b9b4-af7499927041
0
public MonsterAttributes() { // TODO Auto-generated constructor stub }