method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
---|---|---|
526a40f0-d3ab-45de-9387-839f88071664 | 6 | @Override
public void mouseDragged(MouseEvent arg0) {
//Deplacement du plateau
if(arg0.getSource() == this.board && isBoardSelected) {
arg0.translatePoint(arg0.getComponent().getLocation().x-cX, arg0.getComponent().getLocation().y-cY);
//On ne change la position du plateau que si il ne sort pas de l'ecran
if ( arg0.getX() < 0 && arg0.getY() < 0 &&
arg0.getX() + board.getWidth() > this.getWidth() &&
arg0.getY() + board.getHeight() > this.getHeight()) {
this.board.setLocation(arg0.getX(), arg0.getY());
client.repaint();
}
}
} |
4c495687-a05b-4ba4-87c7-4fe55d0bb348 | 2 | public void genererFichierResultat(String JsonFichier) {
JSONArray jsonerreurs = new JSONArray();
JSONObject jsonsortie = new JSONObject();
for (int i = 0; i < erreurs.size(); i++)
{
jsonerreurs.add(erreurs.get(i));
}
jsonsortie.put("complet", complet);
jsonsortie.put("erreurs", jsonerreurs);
try {
FileWriter sortie = new FileWriter(JsonFichier);
sortie.write(jsonsortie.toString(2));
sortie.flush();
sortie.close();
}
catch (Exception e) {}
} |
0870b3a6-c870-4358-b049-85abbccdf3cc | 7 | public void init() {
if (book == null && bookId != 0) {
book = bookService.findBook(bookId);
} else if (book == null && bookId == 0) {
if (comics) {
book = new Comics();
} else {
book = new Book();
}
}
if (book == null) {
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("error/404.xhtml");
} catch (IOException ex) {
log.log(Level.SEVERE, null, ex);
}
}
} |
6b4d0ca2-f5ce-4fcb-8da4-e73e0bc9fd24 | 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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(TelaFecharEvento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(TelaFecharEvento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(TelaFecharEvento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(TelaFecharEvento.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new TelaFecharEvento().setVisible(true);
}
});
} |
23b60a6e-dfec-4100-ba36-7c766446115d | 2 | public void fillMatrix() {
Random generator = new Random();
for (int i = 0; i < column.length; i++) {
for (int j = 0; j <column.length; j++) {
column[i].push(generator.nextInt(9) + 1);
}
}
} |
48158290-f637-4fa1-aeff-fec3700fe45b | 5 | public static void keyPressed(KeyEvent e) {
key.set(e.getKeyCode());
if (key.get(KeyEvent.VK_SPACE)) {
AudioManager.shooting();
setFire(true);
}
if (key.get(KeyEvent.VK_LEFT)) {
setX(-1);
}
if (key.get(KeyEvent.VK_RIGHT)) {
setX(1);
}
if (key.get(KeyEvent.VK_UP)) {
setY(-1);
}
if (key.get(KeyEvent.VK_DOWN)) {
setY(1);
}
} |
01ab41c0-a8b8-41e8-8ed8-fd3ca26557ae | 3 | public void paint(Graphics g)
{
if (cellStates != null && cellStates.size() > 0)
{
mxGraphics2DCanvas canvas = graphComponent.getCanvas();
// Sets antialiasing
if (graphComponent.isAntiAlias())
{
mxUtils.setAntiAlias((Graphics2D) g, true, true);
}
Graphics2D previousGraphics = canvas.getGraphics();
Point previousTranslate = canvas.getTranslate();
double previousScale = canvas.getScale();
try
{
canvas.setScale(graphComponent.getGraph().getView().getScale());
canvas.setTranslate(0, 0);
canvas.setGraphics((Graphics2D) g);
paintPreview(canvas);
}
finally
{
canvas.setScale(previousScale);
canvas.setTranslate(previousTranslate.x, previousTranslate.y);
canvas.setGraphics(previousGraphics);
}
}
} |
a78d129f-2541-4b90-92bd-cdfda04cdfb3 | 0 | public Move(int s1, int s2) {
this.state1 = s1;
this.state2 = s2;
} |
9c725640-a80e-4a3c-bf68-50ebfad57779 | 3 | public ThetaEquation(String equation, double tstart, double tend, double dt){
this.tstart = tstart;
this.tend = tend;
this.dt = dt;
equ = new Equation(equation);
Vector<Variable> variables = equ.getVariables();
if(variables.size()==0){
theta = new Variable("t");
}
else{
if(variables.size()!=1)
throw new EquationException("Invalid Theta Equation: " + equation);
theta = variables.firstElement();
if(!theta.getName().equals("t"))
throw new EquationException("Invalid Theta Equation: " + equation);
}
} |
50787e29-7a3b-4023-9243-2f63b8b96b4e | 7 | @Override
public final void sendSpawnData(final MapleClient client) {
if (target.getId() == client.getPlayer().getMapId() || owner == client.getPlayer() && owner.getParty() == null) {
client.getSession().write(MaplePacketCreator.spawnDoor(owner.getId(), town.getId() == client.getPlayer().getMapId() ? townPortal.getPosition() : targetPosition, true));
if (owner.getParty() != null && (owner == client.getPlayer() || owner.getParty().containsMembers(new MaplePartyCharacter(client.getPlayer())))) {
client.getSession().write(MaplePacketCreator.partyPortal(town.getId(), target.getId(), targetPosition));
}
client.getSession().write(MaplePacketCreator.spawnPortal(town.getId(), target.getId(), targetPosition));
}
} |
6c7a1e02-e218-408c-8515-b2c8181c1b0f | 8 | public Socket makeConnection(String ipAddress, int port) {
//The socket used to connect to the server
socket=null;
//The PrintWriter
out = null;
//The BufferedReader
in = null;
//The string that represents the messages coming from this class/from the cleint machine
String fromPlayer=null;
//The string that represents the messages coming from the host machine/from the machine that this class would be connecting to
String fromHost=null;
try{
//This is where we actually connect to the host machine
socket= new Socket(ipAddress, port);
//Initializing the PrintWriter
out= new PrintWriter(socket.getOutputStream(),true);
//Initializing the BufferedReader
in= new BufferedReader(new InputStreamReader(socket.getInputStream()));
}catch(UnknownHostException e){
print("The host is unknown!");
}catch(IOException e){
print("There was an ioException");
}
print("The connection was accepted, starting the communications");
try{
//Tricky. If the host is not responding or sending blank messages, we don't have to handle them, and we break out of this and close the connection
//We set the fromHost variable to whatever the BufferedReader reads in from the connection
while((fromHost=in.readLine())!=null){
//We then proccess the message, but first we filter the message using the gamePlayMessages to make sure that it is not an erroneous message
if(gamePlayMessages(fromHost) || !turnSet){
print("From Host: "+fromHost);
//If the message is not erroneous, then we can process it. Passing the socket, BufferedReader or PrintWriter may not not be necessary
//The processMessage will respond to the message by interacting with the UI through the UIBridge and/or sending a message back to the
//host machine.
fromPlayer=processMessage(fromHost,in,out,socket);
print("FromPlayer: "+fromPlayer);
//We then write whatever if coming from the process message to the socket, which transmits it to the host machine.
out.println(fromPlayer);
}
//If we say "bye" to the host, or the host says "bye" to us, we break from the while loop, which will close all of our socket connections.
if(fromPlayer.equals("bye") || fromHost.equals("bye")){
break;
}
}
//Closing the socket connection, the BufferedReader, and the PrintWriter
destroyConnection();
}catch(IOException e){
//Close the connections, and then we tell the UI that the game has been terminated..
destroyConnection();
uiBridge.gameTerminated();
print("IOException:"+e);
}
return socket;
} |
414c316c-95ff-4691-87f6-d8e4c8901bbe | 4 | public void riichi(String[] split, String command)
{
if (split.length != 3)
{
PrintMessage("Syntax:!riichi [game] [player]");
return;
}
TournyGame m = (TournyGame) games.get(split[1]);
if (m == null)
{
PrintMessage(split[1] + "is not a game");
return;
}
String p = split[2];
if (!m.exists(new String[]
{ p }))
{
return;
}
if (m.riichi(p))
{
m.updatedetail(command);
}
} |
d19650c5-0c73-46ed-af78-997e4bcb34d0 | 6 | private static <E> Result<E> isPalindrome_Recurse_Internal(Node<E> head, int length) {
if (head == null || length == 0) {
//empty list is considered to be true;
return new Result<>(true, null);
} else if (length == 1) {
return new Result<>(true, head);
} else if (length == 2) {
return new Result<>(head.data.equals(head.next.data), head.next);
}
Result<E> res = isPalindrome_Recurse_Internal(head.next, length - 2);
if (!res.isSame || res.node == null) {
return res;
} else {
res.isSame = head.data.equals(res.node.next.data);
res.node = res.node.next;
return res;
}
} |
fcefdf3e-e5ec-44f7-9eaf-0c1570caa45d | 9 | protected Object invokeReadFromXML(Element node) throws Exception {
Method method;
Class[] methodClasses;
Object[] methodArgs;
boolean array;
boolean useDefault;
useDefault = false;
method = null;
m_CurrentNode = node;
try {
// special handling of null values
if (stringToBoolean(node.getAttribute(ATT_NULL)))
useDefault = true;
if (!useDefault) {
array = stringToBoolean(node.getAttribute(ATT_ARRAY));
// display name?
if (m_CustomMethods.read().contains(node.getAttribute(ATT_NAME)))
method = (Method) m_CustomMethods.read().get(node.getAttribute(ATT_NAME));
else
// class name?
if ( (!array) && (m_CustomMethods.read().contains(determineClass(node.getAttribute(ATT_CLASS)))) )
method = (Method) m_CustomMethods.read().get(determineClass(node.getAttribute(ATT_CLASS)));
else
method = null;
useDefault = (method == null);
}
// custom method
if (!useDefault) {
methodClasses = new Class[1];
methodClasses[0] = Element.class;
methodArgs = new Object[1];
methodArgs[0] = node;
return method.invoke(this, methodArgs);
}
// standard
else {
return readFromXML(node);
}
}
catch (Exception e) {
if (DEBUG)
e.printStackTrace();
if (m_CurrentNode != null) {
System.out.println("Happened near: " + getPath(m_CurrentNode));
// print it only once!
m_CurrentNode = null;
}
System.out.println("PROBLEM (read): " + node.getAttribute("name"));
throw (Exception) e.fillInStackTrace();
}
} |
a8fa117a-db91-4c04-a931-c851bb668ae8 | 7 | private SingleTypeFactory(Object typeAdapter, TypeToken<?> exactType, boolean matchRawType,
Class<?> hierarchyType) {
serializer = typeAdapter instanceof JsonSerializer
? (JsonSerializer<?>) typeAdapter
: null;
deserializer = typeAdapter instanceof JsonDeserializer
? (JsonDeserializer<?>) typeAdapter
: null;
$Gson$Preconditions.checkArgument(serializer != null || deserializer != null);
this.exactType = exactType;
this.matchRawType = matchRawType;
this.hierarchyType = hierarchyType;
} |
51fa7887-004b-430e-8c9a-510112a4311f | 4 | private static ArrayList<MapEdge> createTree(int type, MapEdge start, MapEdge end) throws NullPointerException {
MapNode fn1 = DataLoader.nodes.get(start.getFNode());
Point2D.Double xy1 = new Point2D.Double(fn1.getX(), fn1.getY());
MapNode tn2 = DataLoader.nodes.get(end.getTNode());
Point2D.Double xy2 = new Point2D.Double(tn2.getX(), tn2.getY());
Integer idStart;
Integer idEnd;
EdgeWeightedDigraph graph;
if (type == 0) {
graph = theGraph;
idStart = nodesCar.get(xy1);
idEnd = nodesCar.get(xy2);
} else {
graph = theGraph;
idStart = nodesWalk.get(xy1);
idEnd = nodesWalk.get(xy2);
}
if (idStart == null || idEnd == null || graph == null) {
throw new NullPointerException("Could not find nodes in the HashMap.");
}
tree = new AstarSP(graph, idStart, idEnd);
return shortestPath(idEnd);
} |
51d70d1b-ebaf-48b2-908b-5f229c0dff57 | 1 | public String getInChat(String chat){
String inChat = "";
List<Player> list = getPlayersInChat(Bukkit.getWorld(chat).getPlayers(), chat);
for (Player playeren : list){
inChat += playeren.getName() + ", ";
}
return inChat;
} |
a1c44385-49fd-4e91-a53e-88b168adb9d4 | 5 | public void run() {
System.out.println("Server Starting..") ;
synchronized(this){
this.runningThread = Thread.currentThread();
}
try {
this.serverSocket = new ServerSocket(this.serverPort);
System.out.println("Server Started.");
System.out.println("This Machine (" + InetAddress.getLocalHost() + ") is now waiting for incomming device connection.");
} catch (IOException e) {
throw new RuntimeException("Cannot open port " + this.serverPort, e);
}
while(! isStopped()){
try {
Socket clientSocket = this.serverSocket.accept();
System.out.println("Client connected through Wifi");
if (!this.client.isConnected()) {
this.client.bind(clientSocket);
new Thread(new WorkerRunnable(this.client)).start();
} else {
System.out.println("Client connection has been denied, other device already connected.");
clientSocket.close();
}
} catch (IOException e) {
if(isStopped()) {
System.out.println("Server Stopped.") ;
return;
}
throw new RuntimeException("Error accepting client connection", e);
}
}
System.out.println("Server Stopped.") ;
} |
65334d5d-8388-4b79-a873-636d39f66e44 | 0 | @Override
public void focusGained(FocusEvent e) {
handleUpdate();
} |
f5df2cef-d56b-42b2-b369-cc14c5410365 | 6 | public int sumNumbers(TreeNode root) {
int sum = 0;
if(root == null){
return 0;
}
Stack<TreeNode> nextNode = new Stack<TreeNode>();
Stack<String> nextPath = new Stack<String>();
nextNode.push(root);
nextPath.push("");
while(!nextNode.empty()) {
TreeNode currentNode = nextNode.pop();
String currentPath = nextPath.pop();
currentPath = currentPath + String.valueOf(currentNode.val);
if(currentNode.right != null) {
nextNode.add(currentNode.right);
nextPath.add(currentPath);
}
if(currentNode.left != null) {
nextNode.add(currentNode.left);
nextPath.add(currentPath);
}
if(currentNode.right == null && currentNode.left == null) {
int currentSum = Integer.valueOf(currentPath);
sum = sum + currentSum;
}
}
return sum;
} |
bdae67c6-7ccb-4610-b58d-7736e3e35617 | 3 | @Test
public void testIntersectSingleStep() {
System.out.println(abcde);
for (char c : "abcde".toCharArray()) {
Assert.assertTrue(abcde.acceptIn(fstP,c));
}
System.out.println(cdefg);
for (char c : "cdefg".toCharArray()) {
Assert.assertTrue(cdefg.acceptIn(fstP,c));
}
Fst<Pair<Character, Character>> cde = Fst.intersect(abcde, cdefg,fstP);
System.out.println(cde);
for (char c : "cde".toCharArray()) {
Assert.assertTrue(cde.acceptIn(fstP,c));
}
} |
235492b8-cee1-44ef-be93-22f8cf4b40ab | 7 | private void processArguments(final String[] args)
throws CommandException
{
log.debug("processing arguments: " + Strings.join(args, ","));
if (args.length == 0)
{
throw new CommandException("Command requires arguments");
}
String sopts = "-:c";
LongOpt[] lopts =
{
new LongOpt("count", LongOpt.NO_ARGUMENT, null, 'c'),
};
Getopt getopt = new Getopt(null, args, sopts, lopts);
getopt.setOpterr(false);
int code;
int argidx = 0;
while ((code = getopt.getopt()) != -1)
{
switch (code)
{
case ':':
throw new CommandException
("Option requires an argument: " + args[getopt.getOptind() - 1]);
case '?':
throw new CommandException
("Invalid (or ambiguous) option: " + args[getopt.getOptind() - 1]);
// non-option arguments
case 1:
{
String arg = getopt.getOptarg();
switch (argidx++)
{
case 0:
query = arg;
log.debug("query: " + query);
break;
default:
throw new CommandException("Unused argument: " + arg);
}
break;
}
// Show count
case 'c':
displayCount = true;
break;
}
}
} |
84bc6258-bf6c-4a02-8b6c-706114068b14 | 0 | public Node getParent() {return parent;} |
b82b125e-ce66-448c-af52-27c6c7e96dae | 4 | @Test
public void testMap() {
ExecutorService threadPool = Executors.newSingleThreadExecutor();
Map<String, Integer> _map = new HashMap<>();
_map.put("1", 1);
_map.put("22", 22);
map = _map;
threadPool.execute(new Runnable() {
@Override
public void run() {
for (Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.printf(entry + " ");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println();
}
});
_map = new HashMap<>();
_map.put("a", 1323);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
_map.put("bb", 33);
map = _map;
System.err.println(map);
threadPool.shutdown();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} |
792dccc8-9f0a-402b-9bad-e77bd19fbc46 | 7 | public Col(HtmlMidNode parent, HtmlAttributeToken[] attrs){
super(parent, attrs);
for(HtmlAttributeToken attr:attrs){
String v = attr.getAttrValue();
switch(attr.getAttrName()){
case "align":
align = Align.parse(this, v);
break;
case "char":
charr = Char.parse(this, v);
break;
case "charoff":
charoff = Charoff.parse(this, v);
break;
case "span":
span = Span.parse(this, v);
break;
case "valign":
valign = Valign.parse(this, v);
break;
case "width":
width = Width.parse(this, v);
break;
}
}
} |
77640088-3981-45d3-9aea-4371397997e5 | 6 | @Override
public GameObject getGame(int gameID) {
switch (gameID) {
case 0: // Intro Menu
return new IntroMenu(this);
case 1: // Level 1
return new GameFrame1(this);
case 2: // Level 2
return new GameFrame2(this);
case 3: // Level 3
return new GameFrame3(this);
case 4: // Level 4
return new GameFrame4(this);
case 5: // Game Over
return new GameOverFrame(this);
}
return null;
} |
2ecd0076-e975-46a7-be9f-df6921a478d0 | 1 | public static double[] add( double[] vec1, double[] vec2 )
{
int m = vec1.length;
double[] res = new double[m];
for ( int i = 0; i < m; ++i )
{
res[i] = vec1[i] + vec2[i];
}
return(res);
} |
6abca9ec-2d3e-4c2b-83b0-3cbda7bd5284 | 6 | @Override
public void keyPressed(KeyEvent e)
{
if(e.isControlDown() && e.getKeyChar() != 's' && e.getKeyCode() == KeyEvent.VK_S)
createScreenShot();
else if(e.isControlDown() && e.getKeyChar() != 'c' && e.getKeyCode() == KeyEvent.VK_C)
copyScreenShot();
} |
613ba6e9-9727-4edf-9020-5c7f7c72f626 | 0 | public CheckResultMessage check1(int day) {
return checkReport.check1(day);
} |
a0fd3e6e-31d3-4122-92ca-cb9706207e22 | 9 | @Override
public CMObject newInstance()
{
if(!ID().equals("Sword"))
{
try
{
return this.getClass().newInstance();
}
catch(final Exception e)
{
}
return new Sword();
}
final Random randomizer = new Random(System.currentTimeMillis());
final int swordType = Math.abs(randomizer.nextInt() % 6);
switch (swordType)
{
case 0:
return new Rapier();
case 1:
return new Katana();
case 2:
return new Longsword();
case 3:
return new Scimitar();
case 4:
return new Claymore();
case 5:
return new Shortsword();
default:
try
{
return this.getClass().newInstance();
}
catch(final Exception e)
{
}
return new Sword();
}
} |
228ee1d2-6c19-4701-a475-046e42a22061 | 8 | void setStateOfComboBox(JComboBox cb, int index) {
Action a = cb.getAction();
ActionListener[] al = cb.getActionListeners();
ItemListener[] il = cb.getItemListeners();
cb.setAction(null);
if (al != null) {
for (ActionListener x : al)
cb.removeActionListener(x);
}
if (il != null) {
for (ItemListener x : il)
cb.removeItemListener(x);
}
cb.setSelectedIndex(index);
cb.setAction(a);
if (al != null) {
for (ActionListener x : al)
cb.addActionListener(x);
}
if (il != null) {
for (ItemListener x : il)
cb.addItemListener(x);
}
} |
b2e58d72-5439-4e8c-9597-33c5f32427fa | 7 | public void run()
{
try
{
byte[] byteBuf = new byte[20000];
boolean tryAgain = false;
// Keep going while the manager thread says so
while (manager.notifyThreadReady(this, (int) (currentPosition - startPosition)))
{
do
{
try
{
tryAgain = false;
lastMeasuredPosition = currentPosition;
// log.debug("Dl thread start: " + currentPosition + " -> " + (endPosition));
// Execute the Http request to get the block of data that the manager thread told this thread to download.
HttpResponse response = request.execute(currentPosition, endPosition - 1, 1000);
InputStream in = response.getInputStream();
int bytesRead = -2;
while (currentPosition < endPosition && !manager.isFinished() && (bytesRead = in.read(byteBuf)) >= 0)
{
buffer.write(byteBuf, bytesRead, currentPosition);
currentPosition += bytesRead;
}
response.close();
}
catch(SocketTimeoutException e)
{
log.debug("Dl thread trying again after timeout startPosition: " + startPosition + " currentPosition: " + currentPosition);
tryAgain = true;
}
} while(tryAgain);
}
}
catch (Exception e)
{
e.printStackTrace();
}
} |
23a36f6a-13fe-458a-b371-f09d7724d7b9 | 7 | private void parseInterNodeConnection ( Node currentNode )
{
if (null != this.nodeInfo)
{
for (int i = 0; i < currentNode.getAttributes().getLength(); i++)
{
if ("type".equals(currentNode.getAttributes().item(i).getNodeName()))
{
if (null != currentNode.getAttributes().item(i).getNodeValue())
{
nodeInfo.setInstance ( currentNode.getAttributes().item(i).getNodeValue());
}
}
if ("direction".equals(currentNode.getAttributes().item(i).getNodeName()))
{
nodeInfo.setDirection ( currentNode.getAttributes().item(i).getNodeValue());
}
if ("otherNode".equals(currentNode.getAttributes().item(i).getNodeName()))
{
nodeInfo.setConnectToNode ( currentNode.getAttributes().item(i).getNodeValue() );
}
}
}
if (currentNode.hasChildNodes ( ))
{
isInterConnect = true;
parseInterConnectNodeChildren(currentNode.getChildNodes ( ));
}
this.codeGenerator.writeNodePattern(this.nodeInfo);
} |
ff10f844-2c73-4eda-b641-4a05cef96790 | 3 | public void updateSubTypes() {
argType = (type instanceof ArrayType) ? Type
.tSubType(((ArrayType) type).getElementType()) : Type.tError;
for (int i = 0; i < subExpressions.length; i++)
if (subExpressions[i] != null)
subExpressions[i].setType(argType);
} |
e0d43292-f5ef-4924-80c0-cb97ffaacb28 | 9 | private byte[] wrapCommandAPDU(byte[] capdu, int len)
throws GeneralSecurityException, IOException {
if (capdu == null || capdu.length < 4 || len < 4) {
throw new IllegalArgumentException("Invalid type");
}
/* Determine lc and le... */
int lc = 0;
int le = capdu[len - 1] & 0x000000FF;
if (len == 4) {
lc = 0;
le = 0;
} else if (len == 5) {
/* No command data, byte at index 5 is le. */
lc = 0;
} else if (len > 5) {
/* Byte at index 5 is not le, so it must be lc. */
lc = capdu[ISO7816.OFFSET_LC] & 0x000000FF;
}
if (4 + lc >= len) {
/* Value of lc covers rest of apdu length, there is no le. */
le = 0;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] maskedHeader = new byte[4];
System.arraycopy(capdu, 0, maskedHeader, 0, 4);
maskedHeader[ISO7816.OFFSET_CLA] = (byte) (capdu[ISO7816.OFFSET_CLA] | 0x0C);
byte[] paddedHeader = CryptoUtils.pad(maskedHeader);
byte[] do87 = new byte[0];
byte[] do8E = new byte[0];
byte[] do97 = new byte[0];
if (le > 0) {
out.reset();
out.write((byte) 0x97);
out.write((byte) 0x01);
out.write((byte) le);
do97 = out.toByteArray();
}
if (lc > 0) {
byte[] data = CryptoUtils.pad(capdu, ISO7816.OFFSET_CDATA, lc);
cipher.init(Cipher.ENCRYPT_MODE, ksEnc, ZERO_IV_PARAM_SPEC);
byte[] ciphertext = cipher.doFinal(data);
out.reset();
out.write((byte) 0x87);
out.write(BERTLVObject.getLengthAsBytes(ciphertext.length + 1));
out.write(0x01);
out.write(ciphertext, 0, ciphertext.length);
do87 = out.toByteArray();
}
out.reset();
out.write(paddedHeader, 0, paddedHeader.length);
out.write(do87, 0, do87.length);
out.write(do97, 0, do97.length);
byte[] m = out.toByteArray();
out.reset();
DataOutputStream dataOut = new DataOutputStream(out);
ssc++;
dataOut.writeLong(ssc);
dataOut.write(m, 0, m.length);
dataOut.flush();
byte[] n = CryptoUtils.pad(out.toByteArray());
/* Compute cryptographic checksum... */
mac.init(ksMac);
byte[] cc = mac.doFinal(n);
// ssc++; // TODO dit snappen
out.reset();
out.write((byte) 0x8E);
out.write(cc.length);
out.write(cc, 0, cc.length);
do8E = out.toByteArray();
/* Construct protected apdu... */
out.reset();
out.write(maskedHeader, 0, 4);
out.write((byte) (do87.length + do97.length + do8E.length));
out.write(do87, 0, do87.length);
out.write(do97, 0, do97.length);
out.write(do8E, 0, do8E.length);
out.write(0x00);
return out.toByteArray();
} |
dbc6b373-e070-4473-a313-e61b2dc2ace6 | 4 | public List<Integer> getProvsWithBuilding(String building) {
final List<Integer> provs = new ArrayList<Integer>();
final String tag = getTag();
for (int i = 1; /* loop until broken */; i++) {
GenericObject prov = dataSource.getProvince(i);
if (prov == null)
break;
if (prov.getString("owner").equals(tag) && prov.getString(building).equals("yes"))
provs.add(i);
}
return provs;
} |
82e855fa-46bf-46d0-83fe-b382e4f59286 | 1 | public void addPath(List<Position> coords, String tooltip) {
Path shape = new Path(coords);
shape.setAttributes(attrPoly);
shape.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
shape.setPathType(AVKey.GREAT_CIRCLE);
shape.setFollowTerrain(true);
shape.setTerrainConformance(40);
if (tooltip != null) {
shape.setValue(AVKey.HOVER_TEXT, "hover: " + tooltip);
shape.setValue(AVKey.ROLLOVER_TEXT, "rollover: " + tooltip);
}
addRenderable(shape);
} |
6cc9e548-4b87-4427-bdf4-eeeb9e781934 | 1 | public void renderManyLines(String text, int lineLength, int line) {
if(text.length() <= lineLength) {
Renderer.get().drawText(text, x+38, y+40+line*26, 0.75f);
}
else {
int cut = findSpace(text, lineLength);
Renderer.get().drawText(text.substring(0, cut+1), x+38, y+40+line*26, 0.75f);
renderManyLines(text.substring(cut+1, text.length()), lineLength, line+1);
}
} |
5912a019-9078-41ba-811b-b92e0e2f9825 | 5 | @Override
public void mousePressed(MouseEvent e) {
// Iterate through all of the objects that are registered with the
// system and check if the mouse has been clicked within the bounds of
// the IMouseEventable
synchronized (registeredListeningObjects) {
for (IMouseEventable eventable : registeredListeningObjects) {
// Check if the mouse is within the bounds of the object
// Also check that the object is wanting to recieve the events
if (eventable.getDimensions().contains(e.getPoint())
&& !eventable.isEventsDisabled()) {
synchronized (waitingEventLists) {
waitingEventLists.get(MouseEventType.MOUSE_FOCUS).add(eventable);
}
synchronized (currentMouseFocus) {
currentMouseFocus.add(eventable);
}
}
}
}
// When a mouse is clicked we will iterate over the list of objects
// which were already clicked, if we find an object in which the mouse
// position is no longer within the bounds of we will fire the
// MOUSE_BLUR event
for (IMouseEventable eventable : currentMouseFocus) {
if (!eventable.getDimensions().contains(e.getPoint())) {
synchronized (waitingEventLists) {
waitingEventLists.get(MouseEventType.MOUSE_BLUR).add(eventable);
}
synchronized (currentMouseFocus) {
currentMouseFocus.remove(eventable);
}
}
}
leftClickDown = e.getButton() == MouseEvent.BUTTON1;
rightClickDown = e.getButton() == MouseEvent.BUTTON3;
mouseClickPosX = e.getX();
mouseClickPosY = e.getY();
} |
f78ac4b3-8144-459d-b669-072f7485b848 | 9 | void transpose(char c1, char c2, State state, StateQueue nextQ,
double positionalEditPenalty) {
double transposeWeight = mEditDistance.transposeWeight(c1,c2);
if (transposeWeight == Double.NEGATIVE_INFINITY) return;
if (c2 == ' ' && !state.tokenComplete()) return;
TokenTrieNode midNode
= (c2 == ' ')
? mTokenPrefixTrie
: daughter(state.mTokenTrieNode,c2);
if (c1 == ' ' && midNode != null && !midNode.mIsToken) return;
int nextContextIndex = mLM.nextContext(state.mContextIndex,c2);
int nextContextIndex2 = mLM.nextContext(nextContextIndex,c1);
double score = state.mScore
+ mLM.log2Estimate(state.mContextIndex,c2)
+ mLM.log2Estimate(nextContextIndex,c1)
+ mEditDistance.transposeWeight(c1,c2)
+ positionalEditPenalty;
if (score == Double.NEGATIVE_INFINITY) return;
TokenTrieNode nextNode
= (c1 == ' ')
? mTokenPrefixTrie
: daughter(midNode,c1);
addToQueue(nextQ,
new State2(score,true,nextNode,
state,c2,c1,
nextContextIndex2),
positionalEditPenalty);
} |
0b0dd69b-cde9-4de2-936c-c386adcc69cb | 8 | public QRDecomposition(Matrix A) {
// Initialize.
QR = A.getArrayCopy();
m = A.getRowDimension();
n = A.getColumnDimension();
Rdiag = new double[n];
// Main loop.
for (int k = 0; k < n; k++) {
// Compute 2-norm of k-th column without under/overflow.
double nrm = 0;
for (int i = k; i < m; i++) {
nrm = Maths.hypot(nrm,QR[i][k]);
}
if (nrm != 0.0) {
// Form k-th Householder vector.
if (QR[k][k] < 0) {
nrm = -nrm;
}
for (int i = k; i < m; i++) {
QR[i][k] /= nrm;
}
QR[k][k] += 1.0;
// Apply transformation to remaining columns.
for (int j = k+1; j < n; j++) {
double s = 0.0;
for (int i = k; i < m; i++) {
s += QR[i][k]*QR[i][j];
}
s = -s/QR[k][k];
for (int i = k; i < m; i++) {
QR[i][j] += s*QR[i][k];
}
}
}
Rdiag[k] = -nrm;
}
} |
05aa4b53-067c-478f-aa48-591fefa304d7 | 7 | public int callProbLogicEval(boolean addRules, boolean poTypedWD, Report report, int numberPo,
String parameters, String goalExpression) {
exitVal = 0;
try {
Runtime rt = Runtime.getRuntime();
String tmpPath = System.getProperty("java.io.tmpdir");
String tmpFileName = tmpPath + File.separator + moduleName + "_"
+ expressionName + ".goal";
writeFile(tmpFileName, goalExpression);
long initial_time = System.currentTimeMillis();
//JOptionPane.showMessageDialog(null,goalExpression);
//JOptionPane.showMessageDialog(null, this.getExecutablePath() + " "+ parameters.replace("\n", " ") + " --eval_rule_file "+ tmpFileName);
Process proc = rt.exec(this.getExecutablePath() + " "
+ parameters.replace("\n", " ") + " --eval_rule_file "
+ tmpFileName);
// any error message?
StreamGobbler errorGobbler = new StreamGobbler(
proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new StreamGobbler(
proc.getInputStream(), "OUTPUT"); // Can add a new parameter , System.out
// kick them off
errorGobbler.start();
outputGobbler.start();
exitVal = proc.waitFor();
// Final time
total_time = System.currentTimeMillis() - initial_time;
Result res_out, res_error;
res_out = outputGobbler.getResult();
res_error = errorGobbler.getResult();
//It is used to identify when the evaluation is individual
String stateProB="";
if(numberPo!=0)
stateProB = posManager.getProofState(numberPo);
report.add(numberPo,
parameters,
POWD.Common,
PoGenerated.Full,
goalExpression,
stateProB,
res_error,
res_out,
total_time);
if (res_out != Result.ERROR && res_error != Result.ERROR) {
printSuccessFullyMsg();
result = res_out;
if (result == Result.TRUE && addRules) {
if(numberPo==0){ // It is used only in interactive prover -
posManager.addOneRuleInPMMFile(poTypedWD,goal+"==btrue",expressionName,total_time);
}else{
// This rule is used to add true rules of component
String name = stateAndNames[numberPo-1];//.replaceAll(" ", "").replaceAll("\n", "").substring(stateAndNames[numberPo-1].indexOf("-")).substring(0, stateAndNames[numberPo-1].indexOf("(") );
String userPass= "Operation("+name.substring(0,name.lastIndexOf("_"))+") & mp(Tac(RulesProB" +name+"))";
String addedRule = new String( "THEORY RulesProB"
+ name+ " IS \n\n"
+ "\n\t /* Expression from (" + name
+ "), it was added in " + new Date()
+ "\n\t evaluated with ProB in " + total_time + " milliseconds"
+ "\n\t Module Path:" + modulePath + " */" + "\n\n\t " + posManager.getProofObligationsWithLocalHypotheses(numberPo)
+ "\nEND\n");
posManager.addTheoryAndUserPassInList(addedRule , userPass);
}
}
} else {
result = res_error;
exitVal = 1;
}
System.out.println("Time spent: " + total_time);
System.out.println("Process exit value: " + exitVal);
} catch (Throwable t) {
t.printStackTrace();
}
return exitVal;
} |
1a5d9c08-d42f-4aa5-aba1-5f2d7c421bb2 | 1 | public void testWithField_unknownField() {
YearMonth test = new YearMonth(2004, 6);
try {
test.withField(DateTimeFieldType.hourOfDay(), 6);
fail();
} catch (IllegalArgumentException ex) {}
} |
85b3084a-8e6f-4201-acff-75c023431e8b | 8 | public Debug()
{
if (GameApplet.thisApplet != null)
{
debugFlag = Debug.AWT_DEBUG = GameApplet.thisApplet.getParameter("AWT_DEBUG") == null ? false : true;
if (!debugFlag)
debugFlag = GameApplet.thisApplet.getParameter("DEBUG") != null;
}
else
{
try {
debugFlag = Debug.AWT_DEBUG = System.getProperty("AWT_DEBUG") == null ? false : true;
if (!debugFlag)
debugFlag = System.getProperty("DEBUG") != null;
}
catch (Exception localException)
{
debugFlag = false;
}
}
if (AWT_DEBUG)
{
debugFrame = new Frame("Debug Output");
if (debugFlag)
{
handler = new ActionAdapter();
text = new TextArea();
debugFrame.setLayout(new BorderLayout());
debugFrame.add(text, "Center");
Panel localPanel = new Panel();
debugFrame.add(localPanel, "South");
Button localButton1 = new Button("Clear"); Button localButton2 = new Button("Close");
localButton1.addActionListener(handler);
localButton2.addActionListener(handler);
localPanel.add(localButton1);
localPanel.add(localButton2);
debugFrame.pack();
debugFrame.setVisible(true);
Dimension localDimension = Toolkit.getDefaultToolkit().getScreenSize();
debugFrame.setLocation(0, localDimension.height - debugFrame.getSize().height - 12);
debugFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { Debug.debugFrame.setVisible(false); Debug.debugFrame.dispose(); } } );
}
}
} |
cfbf9f7c-5abe-48bd-89a5-b9ead5383711 | 6 | public float[] getNormals( float x, float y, float z )
{
switch( this )
{
case LEFT:
return new float[] { x - 1, y, z };
case RIGHT:
return new float[] { x + 1, y, z };
case BOTTOM:
return new float[] { x, y - 1, z };
case TOP:
return new float[] { x, y + 1, z };
case FRONT:
return new float[] { x, y, z - 1 };
case BACK:
return new float[] { x, y, z + 1 };
}
throw new UnsupportedOperationException( "Something's wrong about this face; index: " + value );
} |
67d77592-88b9-436e-afb3-bec721b5606f | 1 | public String getExpression() {
String collector = "(";
collector += function;
for (String arg : arguments)
collector += arg + " ";
collector += ")";
return collector;
} |
64c8d2e2-1b62-482f-b2fc-4606a6452c05 | 6 | protected void renderScreen(Graphics renderer, IScreen screen, GameContainer window)
{
if (screen.getBackColor() != null)
renderer.setBackground(screen.getBackColor());
RenderImage backImage = screen.getBackImage();
if (backImage != null)
{
if (screen.tileBackground())
{
for (int x = 0; x < window.getWidth(); x += backImage.getWidth())
for (int y = 0; y < window.getHeight(); y += backImage.getHeight())
backImage.setDrawX(x).setDrawY(y).render(renderer);
}
else
{
backImage.render(renderer);
}
}
for (IRenderable renderable : screen.getComponents())
renderable.render(renderer);
} |
a673725c-84ce-4d1e-889d-241426e66f4e | 2 | public static Achievement getAchievementByID(int aid) {
String statement = new String("SELECT * FROM " + DBTable + " WHERE aid = ?");
PreparedStatement stmt;
try {
stmt = DBConnection.con.prepareStatement(statement);
stmt.setInt(1, aid);
ResultSet rs = stmt.executeQuery();
Achievement achievement = null;
if (rs.next()) {
achievement = new Achievement(rs.getInt("aid"), rs.getInt("type"), rs.getString("name"),
rs.getString("url"), rs.getString("description"), rs.getInt("threshold"));
} else {
System.out.println("Achievement " + aid + " NOT FOUND");
}
rs.close();
return achievement;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
} |
29d3c3d0-0d4a-448c-b935-520d852c17b7 | 3 | public void setExp(PExp node)
{
if(this._exp_ != null)
{
this._exp_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
this._exp_ = node;
} |
d9527c21-1968-4f90-8174-00d72ffef680 | 3 | public final boolean subIDEqualsAndNewer(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof UniqueID) {
UniqueID other = (UniqueID) obj;
return mSubID == other.mSubID && mTimeStamp < other.mTimeStamp;
}
return false;
} |
9622cd6e-cc88-401b-a5d4-2d5a6ee95d54 | 4 | public void onPrivateMessage(String sender, String login, String hostname, String message) {
// check if exist
if (sender.equalsIgnoreCase(DarkIRC.currentChan.name)) {
GUIMain.add_line("<" + sender + ">:" + message);
} else {
boolean Noexist = true;
for (int i = 0; i < DarkIRC.channelsList.size(); i++) {
if (DarkIRC.channelsList.get(i).name.equalsIgnoreCase(sender)) {
Noexist = false;
Logs.makeLog(DarkIRC.channelsList.get(i) + ".log", Logs.readLog(DarkIRC.channelsList.get(i) + ".log") + "<" + sender + ">:" + message + "\n");
GUIMain.jTabbedPane2.setForegroundAt(i, Color.RED);
// GUIMain.jTabbedPane2.setIconAt(i, new
// ImageIcon(this.getClass().getResource("Black-Internet-icon.png")));
}
}
if (Noexist) {
DarkIRC.channelsList.add(new Channel(sender, Channel.PRIVATE));
Logs.makeLog(sender + ".log", "<" + sender + ">:" + message + "\n");
GUIMain.jTabbedPane2.addTab(sender, null);
GUIMain.jTabbedPane2.setForegroundAt((DarkIRC.channelsList.size() - 1), Color.RED);
}
}
} |
b134cfda-78a2-4d49-b030-69792b2fa39a | 6 | public MainMenu(RoomDisplay rd) {
super(rd);
// Material 0, Blank
materials.addElement(new Material(true, false));
// Material 1, White Wall
materials.addElement(new Material(new Color(255, 255, 255), false, true));
// Material 2, Green Wall
materials.addElement(new Material(new Color(0, 255, 0), false, true));
// Material 3, Red Wall
materials.addElement(new Material(new Color(255, 0, 0), false, true));
// Material 4, Blue Wall
materials.addElement(new Material(new Color(0, 0, 255), false, true));
// Material 5, Portal to RO game
materials.addElement(new Portal("RO1.lvl", false, true));
// Material 6, Portal to RO Lab
materials.addElement(new Portal("ROLab.lvl", false, true));
// Material 7, Portal to RO tutorial A
materials.addElement(new Portal("ROTutA.lvl", false, true));
// Material 8, Portal to RO tutorial B
materials.addElement(new Portal("ROTutB.lvl", false, true));
// Material 9, Portal to RO tutorial C
materials.addElement(new Portal("ROTutC.lvl", false, true));
// Material 10, Portal to RO tutorial D
materials.addElement(new Portal("ROTutD.lvl", false, true));
// Material 11, Portal to RO tutorial E
materials.addElement(new Portal("ROTutE.lvl", false, true));
// Material 12, Portal to RO tutorial F
materials.addElement(new Portal("ROTutF.lvl", false, true));
// Material 13, Portal to RO Tutorial 3
materials.addElement(new Portal("ROTut3.lvl", false, true));
// Material 14, Portal to EndGame 1
materials.addElement(new Portal("ROEndGame.lvl", true, true));
// Material 15, Portal to RO Level 6
materials.addElement(new Portal("RO6.lvl", true, true));
// Room 0, Help Screen
// Room 1, Credits
// Room 2, Credits part 2
// Room 3, Credits part 3
// Room 4, Title, Entry Point
// Room 5, Saved Games List
// Room 6, New Games List
for (int a = 0; a < 10; a++) {
rooms.addElement(new Room());
}
{ // Room 0: Help Screen
Room room = rooms.elementAt(0);
room.AddTextBox("Droid Quest Temporary Cheats", 4 * 28, 2 * 32, 500);
room.AddTextBox("Q = Quicken the Animation Timer", 2 * 28, 4 * 32, 500);
room.AddTextBox("W = Slow the Animation Timer", 2 * 28, 5 * 32, 500);
room.AddTextBox("M = Memory Report", 2 * 28, 6 * 32, 500);
room.AddTextBox("(To go to Main Menu, press Return.)", 70, 11 * 32, 500);
}
{ // Room 1: Credits
Room room = rooms.elementAt(1);
room.AddTextBox("Credits:", 7 * 28, 2 * 32, 500);
room.AddTextBox("Original Robot Odyssey by Mike Wallace and Leslie Grimm, (C) The Learning Company",
2 * 28, 3 * 32, 500);
room.AddTextBox("Original Atari Adventure by Warren Robinett, (C) Atari International",
2 * 28, 6 * 32, 500);
room.AddTextBox("DroidQuest (C) 2000 Thomas Foote", 2 * 28, 8 * 32, 500);
room.RoomArray = new int[][]{
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2}
};
}
{ // Room 2: Credits 2
Room room = rooms.elementAt(2);
room.AddTextBox("Special thanks to...", 2 * 28, 2 * 32, 500);
room.AddTextBox("Eric Welsh Eric Jacobs Vladimir Dimitrov Nathan Woods John Isidoro Derek Pechel Jeffery Hanke Matheww Russo Jim Veneskey Erik Santiso Michael Mol", 2 * 28, 4 * 32, 220);
room.AddTextBox("Che Fox illuvius lexspoon shuffles Locklainn samdroid", 12 * 28, 4 * 32, 200);
room.RoomArray = new int[][]{
{2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2}
};
LinkRoomsUpDown(1, 2);
}
{ // Room 3: Credits 3
Room room = rooms.elementAt(3);
room.AddTextBox("Christopher Walkup, age 6 Billy Leete, age 5", 2 * 28, 4 * 32, 350);
room.RoomArray = new int[][]{
{2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}
};
LinkRoomsUpDown(2, 3);
}
{ // Room 4: Title
Room room = rooms.elementAt(4);
room.AddGraphix("DQlogo.gif", 2 * 28, 1 * 32);
room.AddTextBox("Credits", 2 * 28, 6 * 32 + 8, 500);
room.AddArrow(0, 6 * 32, Arrow.DIR_LEFT, 28, Color.white);
room.AddTextBox("Saved Games", 9 * 28, 10 * 32, 80);
room.AddTextBox("Games", 450, 6 * 32 + 8, 500);
room.AddArrow(559, 6 * 32, Arrow.DIR_RIGHT, 28, Color.white);
room.AddTextBox("{000,000,000} Version 2.7", 0, 16, 500);
if (cheatmode) {
room.AddTextBox("{BIG} CHEAT ENABLED!", 91, 8 * 32, 500);
}
room.RoomArray = new int[][]{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1}
};
LinkRoomsLeftRight(1, 4);
}
{ // Room 5: Save games
Room room = rooms.elementAt(5);
room.RoomArray = new int[][]{
{3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
};
LinkRoomsUpDown(4, 5);
}
{ // Room 6: Robot Odyssey
Room room = rooms.elementAt(6);
room.AddTextBox("{BIG} ROBOT ODYSSEY I", 2 * 28, 2 * 32, 600);
room.AddTextBox("The Original Game", 2 * 28, 3 * 32, 500);
room.AddTextBox("Robotropolis", 8 * 28, 6 * 32, 500);
room.AddTextBox("Innovation Lab", 8 * 28, 8 * 32, 500);
room.AddTextBox("Tutorials", 8 * 28, 11 * 32, 300);
room.AddArrow(10 * 28, 383, Arrow.DIR_DOWN, 32, Color.white);
room.RoomArray = new int[][]{
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4}
};
LinkRoomsLeftRight(4, 6);
}
{ // Room 7: RO Tutorials
Room room = rooms.elementAt(7);
room.RoomArray = new int[][]{
{4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4}
};
room.AddTextBox("Robot Anatomy", 3 * 28, 4 * 32, 500);
room.AddTextBox("Robot Wiring", 3 * 28, 6 * 32, 500);
room.AddTextBox("Sensors", 3 * 28, 8 * 32, 500);
room.AddTextBox("Toolkit", 3 * 28, 10 * 32, 500);
LinkRoomsUpDown(6, 7);
}
{ // Room 8: RO Tutorials
Room room = rooms.elementAt(8);
room.RoomArray = new int[][]{
{4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4},
{4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}
};
room.AddTextBox("Robot Circuits", 3 * 28, 4 * 32, 500);
room.AddTextBox("Robot Teamwork", 3 * 28, 6 * 32, 500);
room.AddTextBox("Chip Design", 3 * 28, 8 * 32, 500);
LinkRoomsUpDown(7, 8);
}
{ // Room 9: Secret Room
Room room = rooms.elementAt(9);
room.SetMaterialOutline(0, 0, 19, 11, 1);
room.SetMaterial(2, 2, 14);
room.SetMaterial(2, 4, 15);
LinkRoomsUpDown(9, 4);
items.addElement(new BlueRobot(2 * 28, 6 * 32, room));
items.addElement(new Crystal(5 * 28, 6 * 32, room, 100000));
}
gameCursor = new GameCursor(9 * 28, 6 * 32, rooms.elementAt(4));
helpCam = new HelpCam(rooms.elementAt(0));
items.addElement(gameCursor);
items.addElement(helpCam);
player = gameCursor;
currentViewer = player;
File f = new File("ROlevels/");
if (!f.exists()) {
f.mkdir();
}
String[] files = f.list();
int pageIndex = 5;
for (int a = 0; a < files.length; a++) {
if (a > 4 && a % 5 == 0) {
// Add a new room
Room oldRoom = rooms.elementAt(pageIndex);
oldRoom.RoomArray[11][8] = 0;
oldRoom.RoomArray[11][9] = 0;
oldRoom.RoomArray[11][10] = 0;
oldRoom.RoomArray[11][11] = 0;
Room newRoom = new Room();
rooms.addElement(newRoom);
newRoom.RoomArray = new int[][]{
{3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3},
{3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}
};
int newPageIndex = rooms.indexOf(newRoom);
LinkRoomsUpDown(pageIndex, newPageIndex);
pageIndex = newPageIndex;
}
materials.addElement(new Portal("ROlevels/" + files[a], false, false));
int matIndex = materials.size() - 1;
int y = 1 + (a % 5) * 2;
Room room = rooms.elementAt(pageIndex);
room.RoomArray[y][2] = matIndex;
room.AddTextBox(files[a], 3 * 28 + 14, y * 32 + 32, 400);
}
} |
498976fc-90b2-4b1c-b5a4-dab97b2255bb | 1 | public void fitAABB(AABB other) {
if (aabb == null) {
aabb = other;
} else {
aabb = aabb.combine(other);
}
getEntity().fitAABB(aabb);
} |
d316f400-f3c8-4a0c-a926-98889c43da52 | 6 | @Override
public void run() {
ArrayList<ArrayList<String>> arreglos = null;
try {
DataInputStream ois = new DataInputStream(
socketCliente.getInputStream());
DataOutputStream oos = new DataOutputStream(
socketCliente.getOutputStream());
System.out.println("DEBUG: A punto de leer la consulta!");
String consultaJSON = ois.readUTF();
System.out.println("DEBUG: Consulta leida!");
List<String> listaDeConsulta = QueryManager
.decodificarQuery(consultaJSON);
System.out.println("DEBUG: Consulta decodificada!");
String respuesta;
if (crearConexion(listaDeConsulta.get(0))) {
System.out.println("DEBUG: Conexion creada!");
String consulta = listaDeConsulta.get(1);
ResultSet resultado = enviarConsulta(consulta);
if (resultado != null) {
arreglos = respuestaDeQueryAListas(resultado);
}
if (error)
respuesta = QueryManager.crearError(msgError);
else if (esConsulta)
respuesta = QueryManager.crearRespuesta(arreglos.get(0),
arreglos.get(1));
else
respuesta = QueryManager
.crearRespuestaDeActualizacion(String
.valueOf(filasActualizadas));
} else {
respuesta = QueryManager.crearError(ERROR_DB);
}
oos.writeUTF(respuesta);
ois.close();
oos.close();
if (query != null)
query.close();
} catch (Exception e) {
e.printStackTrace();
}
} |
d1f00933-4e8e-4df9-83c2-e014a18f1785 | 3 | private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
if (estaModoEdicao() && exclusaoConfirmada()) {
try {
excluir();
} catch (ValidacaoException ex) {
_unitOfWork.rollback();
JOptionPane.showMessageDialog(this, ex.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE);
}
}
}//GEN-LAST:event_btnExcluirActionPerformed |
455c809e-1fd6-45c7-83ae-d82fad044494 | 4 | public List<cheque> retriveChequeinfo() throws SQLException{
List<cheque> chequeInfo=new ArrayList();
try{
databaseConnector=myConnector.getConnection();
stmnt=(Statement) databaseConnector.createStatement();
SQLQuery="SELECT * FROM familydoctor.cheque";
dataSet=stmnt.executeQuery(SQLQuery);
while(dataSet.next()){
chequeID=dataSet.getInt("chequeID");
bankName=dataSet.getString("bankName");
inputDate=dataSet.getString("chequeDate");
chequeAmount=dataSet.getFloat("chequeAmount");
tempCheque=new cheque(chequeID,bankName, inputDate, chequeAmount);
chequeInfo.add(tempCheque);
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}
finally{
if(stmnt!=null)
stmnt.close();
if(databaseConnector!=null)
databaseConnector.close();
}
return chequeInfo;
} |
766c907c-e525-4b96-81d9-517b213a0747 | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final PeopleCP other = (PeopleCP) obj;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
return false;
}
return true;
} |
c9fcde54-b9b6-469c-941a-1f7949f637ca | 4 | public static Map<String,String> parseDigestAuthorizationChallenge( String line ) {
Map<String,String> map = new TreeMap<String,String>( CaseInsensitiveComparator.sharedInstance );
// This regex works but includes the quotes in the final result.
// The line will be splitted into the single '<key>=<value>' elements by this regex.
Pattern regex = Pattern.compile( "[^\\s]+=([^\\s\"']+|\"[^\"]*\"|'[^']*')" );
Matcher regexMatcher = regex.matcher( line );
while( regexMatcher.find() ) {
String token = regexMatcher.group();
// Remove comma?
if( token.endsWith(",") )
token = token.substring(0,token.length()-1);
// Split at '='
int index = token.indexOf("=");
if( index == -1 ) {
// A single '<key>' (without '=<value>')
map.put( token, null );
} else if( index+1 >= token.length() ) {
// A '<key>' with '=' but without '<value>'
map.put( token.substring(0,index).trim(), "" );
} else {
// A full '<key>=<value>' pair.
String key = token.substring(0,index).trim();
String value = token.substring(index+1,token.length()).trim();
// Remove quotes?
/*if( value.length() >= 2
&& ( ( value.startsWith("\"") && value.endsWith("\"") )
||
( value.startsWith("'") && value.endsWith("'") )
) ) {
value = value.substring( 1, value.length()-1 );
}
*/
value = stripQuotes( value );
map.put( key, value );
}
}
return map;
} |
97c9ed44-dfe1-4eca-9ca3-218d396a4a45 | 8 | protected File getPreviousOutputDirectory() {
File dir = previousOutputDirectory;
if (dir == null && !IOSImageUtil.isNullOrWhiteSpace(subdir.getText())) {
dir = new File(subdir.getText());
if (!dir.isAbsolute()) {
dir = null;
}
}
if (dir == null && previousTargetDirectory != null) {
dir = previousTargetDirectory;
if (!IOSImageUtil.isNullOrWhiteSpace(subdir.getText())) {
dir = new File(dir, subdir.getText());
}
}
if (dir != null && dir.exists()) {
return dir;
}
return null;
} |
fbd499b5-0e4f-47ff-8cfb-850843806ddc | 8 | public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
switch (keyCode) {
case KeyEvent.VK_LEFT : left = true; break;
case KeyEvent.VK_RIGHT : right = true; break;
case KeyEvent.VK_UP : up = true; break;
case KeyEvent.VK_DOWN : down = true; break;
case KeyEvent.VK_X : jump = true; break;
case KeyEvent.VK_Z : lift = true; break;
case KeyEvent.VK_ESCAPE : escape = !escape; break;
case KeyEvent.VK_PLUS : cheat = true; break;
}
} |
7711f7e1-4673-467d-82aa-a6dbc896dfb2 | 8 | public static void main(String[] args) {
boolean sortir = false;
int opcio;
while (!sortir) {
menu();
opcio = llegirNum("\n\n\tInserir opció: ");
switch (opcio) {
case 1:
FitxerJugadorsOut jugador = new FitxerJugadorsOut("fitxers/jugadors.dat");
int num = llegirNum("\nQuants jugadors vols introduir? ");
for (int i = 1; i <= num; i++) {
String nom = llegirCadena("Nom jugador: ");
TipusEquip equip = llegirEquip("Equip (1)ESPASES, (2)OROS, (3)COPES, (4) BASTOS: ");
int trofeus = llegirNum("Nombre de trofeus: ");
Jugador j = new Jugador(nom, equip, trofeus);
jugador.escriu(j);
}
jugador.tancaJugadors();
break;
case 2:
FitxerJugadorsIn fji = new FitxerJugadorsIn("fitxers/jugadors.dat");
System.out.print("Contingut del fitxer de jugadors\n" + fji.mostrarJugardors());
fji.tancarJugadors();
break;
case 3:
FitxerJugadorsIn estadistiques = new FitxerJugadorsIn("fitxers/jugadors.dat");
System.out.print("Estadistiques dels jugadors:\n" + estadistiques.mostrarEstadistiques());
break;
case 4:
FitxerJugadorsIn grups = new FitxerJugadorsIn("fitxers/jugadors.dat");
FitxerJugadorsOut espases = new FitxerJugadorsOut("fitxers/espases.dat");
FitxerJugadorsOut oros = new FitxerJugadorsOut("fitxers/oros.dat");
FitxerJugadorsOut copes = new FitxerJugadorsOut("fitxers/copes.dat");
FitxerJugadorsOut bastos = new FitxerJugadorsOut("fitxers/bastos.dat");
grups.crearGrups(espases, oros, copes, bastos);
System.out.print("Grups creats");
espases.tancaJugadors();
oros.tancaJugadors();
copes.tancaJugadors();
bastos.tancaJugadors();
grups.tancarJugadors();
break;
case 5:
FitxerJugadorsIn espasa = new FitxerJugadorsIn("fitxers/espases.dat");
FitxerJugadorsIn oro = new FitxerJugadorsIn("fitxers/oros.dat");
FitxerJugadorsIn cope = new FitxerJugadorsIn("fitxers/copes.dat");
FitxerJugadorsIn basto = new FitxerJugadorsIn("fitxers/bastos.dat");
System.out.print("Grup Espases\n" + espasa.mostrarJugardors());
System.out.print("\nGrup Oros\n" + oro.mostrarJugardors());
System.out.print("\nGrup Copes\n" + cope.mostrarJugardors());
System.out.print("\nGrup Bastos\n" + basto.mostrarJugardors());
espasa.tancarJugadors();
oro.tancarJugadors();
cope.tancarJugadors();
basto.tancarJugadors();
break;
case 6:
FitxerJugadorsIn estaEspases = new FitxerJugadorsIn("fitxers/espases.dat");
System.out.print("Grup Espases\n" + estaEspases.mostrarEstadistiques());
FitxerJugadorsIn estaOros = new FitxerJugadorsIn("fitxers/oros.dat");
System.out.print("\nGrup Oros\n" + estaOros.mostrarEstadistiques());
FitxerJugadorsIn estaCopes = new FitxerJugadorsIn("fitxers/copes.dat");
System.out.print("\nGrup Copes\n" + estaCopes.mostrarEstadistiques());
FitxerJugadorsIn estaBastos = new FitxerJugadorsIn("fitxers/bastos.dat");
System.out.print("\nGrup Bastos\n" + estaBastos.mostrarEstadistiques());
break;
default:
sortir = true;
break;
}
}
} |
c7967f21-c8b9-4d6c-ab6a-e56b57cba154 | 4 | @Override
public void clicked(final int x, final int z) {
for(int i = -dr; i <= dr; ++i) {
final int isq = i * i;
for(int j = -dr; j <= dr; ++j) {
if(circle && (isq + j * j > 4 * r2)) {
continue;
}
final int posX = x + i;
final int posZ = z + j;
viewer.editChunk(new ScreenPosition(posX, posZ), edit);
}
}
viewer.editFinished();
} |
0bede754-f0ee-43a7-a6f1-a397353437c1 | 9 | @Override
protected void paintComponent(Graphics g1) {
super.paintComponent(g1);
Graphics2D g = (Graphics2D) g1;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
if (getHistoryItems().isEmpty())
return;
HistoryItem currentItem = getHistoryItems().get(currentIndex);
int valueAmount = currentItem.values.length;
int width = getWidth();
int height = getHeight();
int i = 0;
int diff = width / 2 / valueAmount;
for (int value : currentItem.values) {
BufferedImage cardImage;
if (value < 0 || value > cardImages.length) {
cardImage = this.awesomeImage;
} else {
cardImage = cardImages[value];
}
int x = (width / 4) + (i * diff) - cardImage.getWidth() / 8;
int y = height / 2 - cardImage.getHeight() / 2 / 2;
int imgWidth = cardImage.getWidth() / 2;
int imgHeight = cardImage.getHeight() / 2;
g.setStroke(new BasicStroke(3));
for(int cardIndex = 0; cardIndex < currentItem.index.length; cardIndex++) {
if (i == currentItem.index[cardIndex])
g.drawRect(x, y, imgWidth, imgHeight);
}
g.drawImage(cardImage, x, y, imgWidth, imgHeight, null);
i++;
}
if (currentIndex > 0) {
int[] arrayDiff = ArrayDiff.getArrayDiff(
getHistoryItems().get(currentIndex - 1).values,
currentItem.values);
if (arrayDiff == null)
return;
for (int j = 0; j < arrayDiff.length / 2; j += 2) {
int from = arrayDiff[j];
int to = arrayDiff[j + 1];
int y = height / 2 - cardImages[0].getHeight() / 2 / 2;
int xFrom = (width / 4) + (from * diff)
- cardImages[0].getWidth() / 8 + diff / 2;
int xTo = (width / 4) + (to * diff) - cardImages[0].getWidth()
/ 8 + diff / 2;
Point p1 = new Point(xFrom, y);
Point p2 = new Point(xTo, y);
double angle = Math.atan2(0, xTo - xFrom);
int diameter = (int) Math.round(p1.distance(p2));
g.setStroke(new BasicStroke(1));
Graphics2D g2d = (Graphics2D) g;
g2d.translate(p1.x, p1.y);
g2d.rotate(angle);
g2d.drawArc(0, -25, diameter, 50, 0, 180);
g2d.fill(new Polygon(new int[] { 0, 5, -5 }, new int[] { 0, -5,
-5 }, 3));
g2d.translate(-p1.x, -p1.y);
g2d.translate(p2.x, p2.y);
g2d.fill(new Polygon(new int[] { 0, 5, -5 }, new int[] { 0, -5,
-5 }, 3));
g.translate(-p2.x, -p2.y);
}
}
} |
170b814f-443a-4f35-8c59-3f37bf791549 | 5 | private Vector2f lineIntersects(Vector2f lineStart1, Vector2f lineEnd1, Vector2f lineStart2, Vector2f lineEnd2)
{
Vector2f line1 = lineEnd1.sub(lineStart1);
Vector2f line2 = lineEnd2.sub(lineStart2);
float cross = crossVector(line1, line2);
if(cross == 0)
{
return null;
}
Vector2f dBLStarts = lineStart2.sub(lineStart1);
float a = crossVector(dBLStarts, line2)/cross;
float b = crossVector(dBLStarts, line1)/cross;
if(0.0f < a && a < 1.0f && 0.0f < b && b < 1.0f)
{
return lineStart1.add(line1.mul(a));
}
return null;
} |
f349239b-ccfd-4ca4-9e1a-dec3e52a58ff | 5 | public CheckResultMessage check25(int day) {
int r1 = get(6, 5);
int c1 = get(7, 5);
int r2 = get(39, 5);
int c2 = get(40, 5);
BigDecimal b = new BigDecimal(0);
if (checkVersion(file).equals("2003")) {
try {
in = new FileInputStream(file);
hWorkbook = new HSSFWorkbook(in);
b = getValue(r1 + day, c1 + 1, 1).subtract(
getValue(r1 + day, c1 + 3, 1)).subtract(
getValue(r1 + day, c1 + 4, 1));
if (0 != getValue(r2 + 11, c2 + day, 10).compareTo(b)) {
return error("支付机构汇总报表<" + fileName
+ ">本期备付金银行已增加备付金银行账户余额,支付机构未增加客户资金余额 :" + day
+ "日错误");
}
} catch (Exception e) {
}
} else {
try {
in = new FileInputStream(file);
xWorkbook = new XSSFWorkbook(in);
b = getValue1(r1 + 1 + day, c1 + 9, 0).subtract(
getValue1(r1 + 1 + day, c1 + 10, 0)
.add(getValue1(r1 + 1 + day, c1 + 11, 0))
.add(getValue1(r1 + 1 + day, c1 + 12, 0))
.add(getValue1(r1 + 1 + day, c1 + 13, 0)));
if (0 != getValue1(r2 + 10, c2 + day, 10).compareTo(b)) {
return error("支付机构汇总报表<" + fileName
+ ">本期备付金银行已增加备付金银行账户余额,支付机构未增加客户资金余额 :" + day
+ "日错误");
}
} catch (Exception e) {
}
}
return pass("支付机构汇总报表<" + fileName
+ ">本期备付金银行已增加备付金银行账户余额,支付机构未增加客户资金余额 :" + day + "日正确");
} |
fb2648be-8210-4444-bc09-bc264d8fa117 | 0 | @SuppressWarnings("rawtypes")
@Override
public Class getObjectType() {
return Blog.class;
} |
234bf346-444f-4e24-aa80-ef2fb758c748 | 4 | private ArrayList<FilmBean> createListOfFilmBeans(ResultSet rs) {
try {
if (rs == null || rs.getFetchSize() < 0) {
return null;
} else {
ArrayList<FilmBean> films = new ArrayList<FilmBean>();
FilmBean film = new FilmBean();
while (rs.next()) {
film = this.createFilmBean(rs);
films.add(film);
}
return films;
}
} catch (SQLException ex) {
Logger.getLogger(FilmothekModel.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
} |
d5fda287-4a99-4a00-89d7-9f2e8f5372b1 | 2 | public static boolean isNumero(String valor) {
final String NUMEROS = "0123456789";
for (int i = 0; i < valor.length(); i++) {
char caracter = valor.charAt(i);
if (NUMEROS.indexOf(caracter) == -1) {
return false;
}
}
return true;
} |
eb860ec7-0ed3-400c-b5c2-a2cebecc247a | 6 | public RemoteController()
{
//Misc Intializers
serverAddress = null;
intPort = 5252;
dicernType = 0;
charCount = 0;
autoSave = 0;
selected = null;
conv = new byteConvertor(this);
control = new RCControls();
strName = "null";
//Initializes the name list
head = null;
tail = head;
//Generate the device specific information from the saved file
loadInfo("RemoteInfo");
if(strName == null)
strName = "null";
if(strName.equals("null")||strName.equals(""))
loadInfo("RemoteInfoBackup");
//Start the USB search thread
USBGen = new USBAddressGenerator();
Runnable run = USBGen;
Thread tr = new Thread(run);
tr.start();
//Wait before loading the boot file
String hld = strName;
try
{
Thread.sleep(500);
}
catch(InterruptedException ex)
{}
USBGen.attemptUpdate("RemoteController");
//Search for Wifi connections
conProt = new RCEstablishConnection(false);
conProt.setRemote(this);
conProt.setName(strName);
loadBoot();
saveInfo("RemoteInfo");
saveInfo("RemoteInfoBackup");
vid = new PiVideoReader(USBGen);
Runnable runnable = vid;
Thread thread = new Thread(runnable);
thread.start();
if(!strName.equals(hld))
{
conProt.killCurrent();
conProt = new RCEstablishConnection(false);
conProt.setRemote(this);
conProt.setName(strName);
}
//Search for servers
if(intPort == 0)
intPort = 5252;
internetCon = new DroneClient(serverAddress, intPort);
internetCon.setRemote(this);
//Begin the update timer
Timer tmr = new Timer();
tmr.schedule(new upDate(),0,50);
vid.saveImage();
} |
4eb26d55-bcd4-405a-98a2-d6a87e231875 | 1 | private URL getURL(String filename) {
URL url = null;
try {
url = this.getClass().getResource(filename);
}
catch (Exception e) {
}
return url;
} |
b095b0dc-d97a-42ad-85c6-c62e2504a5c9 | 3 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Course other = (Course) obj;
if (!Objects.equals(this.name, other.name)) {
return false;
}
return true;
} |
102a9ad2-82e1-4b18-8eae-a93eb83e99bd | 1 | public void testConstructor_ObjectStringEx3() throws Throwable {
try {
new YearMonthDay("10:20:30.040");
fail();
} catch (IllegalArgumentException ex) {
// expected
}
} |
d355ff07-77ee-4098-ab09-8a8ab53eb58f | 8 | private void appendShapeInternal(StringBuilder sb) {
if (type == ShapeType.RECTANGLE && shield > 0) {
throw new UnsupportedOperationException();
} else if (type == ShapeType.RECTANGLE) {
sb.append("shape=rect");
} else if (type == ShapeType.DIAMOND) {
sb.append("shape=diamond");
} else if (type == ShapeType.CIRCLE) {
sb.append("shape=circle");
} else if (type == ShapeType.CIRCLE_IN_RECT) {
sb.append("shape=circle");
} else if (type == ShapeType.OVAL) {
sb.append("shape=ellipse");
} else if (type == ShapeType.ROUND_RECTANGLE) {
sb.append("shape=rect,style=rounded");
} else {
throw new IllegalStateException(type.toString());
}
} |
018893da-b462-4161-bf50-720d324038d2 | 0 | public void mouseEntered(MouseEvent e) // not used
{
} |
360fe4e4-9555-428c-813f-997017918bc1 | 3 | @EventHandler(ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent broken) {
if (broken instanceof KioskRemove) return;
if (!Kiosk.SIGN_BLOCKS.contains(broken.getBlock().getTypeId())) return;
final Sign state = (Sign) broken.getBlock().getState();
if (!this.hasTitle(state)) return;
broken.setCancelled(true);
state.update();
} |
d78285ff-0b02-4dfc-b999-16b91e9bdffd | 8 | private MoveResult dealWithSpecialCases(StrategyBoard gameBoard, PlayerColor currentTurn,
PieceType pieceMoving, Location fromLocation, Location toLocation) {
final MoveResult result;
if(gameBoard.getPieceAt(fromLocation) == null && gameBoard.getPieceAt(toLocation) == null){
return new MoveResult(currentTurn == PlayerColor.BLUE ? MoveResultStatus.RED_WINS : MoveResultStatus.BLUE_WINS,
new PieceLocationDescriptor(null,null));
}
final Piece enemyPiece = gameBoard.getPieceAt(toLocation);
if (enemyPiece != null && pieceMoving == PieceType.SPY && enemyPiece.getType() == PieceType.MARSHAL){
result = dealWithSpyMarshall(gameBoard, currentTurn, pieceMoving, fromLocation, toLocation);
} else if (enemyPiece != null && enemyPiece.getType() == PieceType.BOMB) {
result = dealWithBomb(gameBoard, currentTurn, pieceMoving, fromLocation, toLocation);
} else {
result = null;
}
return result;
} |
74d5888d-8990-40a1-b281-74b53064babb | 7 | @Override
public void unInvoke()
{
// undo the affects of this spell
if(!(affected instanceof MOB))
return;
final MOB mob=(MOB)affected;
super.unInvoke();
if((canBeUninvoked())&&(!mob.amDead())&&(mob.location()!=null))
{
if(mob.amFollowing()!=null)
CMLib.commands().postFollow(mob,null,false);
CMLib.commands().postStand(mob,true);
if((mob.isMonster())&&(!CMLib.flags().isMobile(mob)))
CMLib.tracking().wanderAway(mob,true,true);
}
} |
c60e9ed8-c7fc-48dd-8c1e-fb08ac3a7480 | 5 | public static void makeUnbreakable(ItemStack stack) {
if (stack == null) return;
try {
Object craft = getHandle(stack);
if (craft == null) return;
Object tagObject = getTag(craft);
if (tagObject == null) return;
Object unbreakableFlag = null;
if (class_NBTTagByte_constructor != null) {
unbreakableFlag = class_NBTTagByte_constructor.newInstance((byte) 1);
} else {
unbreakableFlag = class_NBTTagByte_legacy_constructor.newInstance("", (byte) 1);
}
class_NBTTagCompound_setMethod.invoke(tagObject, "Unbreakable", unbreakableFlag);
} catch (Throwable ex) {
}
} |
7154d8fb-adba-4a41-95c1-f73f421ea416 | 0 | public UndoTool(AutomatonPane view, AutomatonDrawer drawer) {
super(view, drawer);
} |
890d7f3b-128e-4000-bccc-f229492d0480 | 7 | public Stmts() {
// while (true) {
/* The program may have already reach it's end. */
int lexResult = 0;
boolean breakLoop = false;
if (Lexer.nextToken == Token.KEY_END || GlobalAttributes.braceEncounteredPreviously) {
lexResult = Lexer.nextToken;
GlobalAttributes.braceEncounteredPreviously = false;
} else {
lexResult = Lexer.lex();
}
if (lexResult != Token.KEY_END && lexResult != Token.RIGHT_BRACE) {
stmt = new Stmt(lexResult);
} else if (lexResult == Token.RIGHT_BRACE) {
breakLoop = true;
} else if (lexResult == Token.KEY_END) {
breakLoop = true;
}
if (!breakLoop)
stmts = new Stmts();
} |
ce2f9c40-8996-4200-a9b3-8426ad3dcf07 | 2 | public void setNextCell(ProcessedCell c){
nextCell = c;
if(c != null && c.getPrevCell() != this){
c.setPrevCell(this);
}
} |
cb4fd198-ba74-46fa-bdb4-bd61d5aa091b | 2 | public String getTaytteetString() {
String tayteStr = "";
for (int i = 0; i < this.taytteet.size(); i++) {
if(tayteStr.isEmpty()) {
tayteStr = this.taytteet.get(i).toString();
}
else {
tayteStr = tayteStr + ", " + this.taytteet.get(i);
}
}
return tayteStr;
} |
16437f3c-45e3-48c1-87ff-1dd1e8586076 | 5 | public void deplacer(int orig, int dest, int nbrCartes)
{
orig--;
dest--;
if (orig < 0 || orig >= this.table.size())
throw new IllegalArgumentException(
"Pile d'origine invalide: " + (orig + 1));
else if (dest < 0 || dest >= this.table.size())
throw new IllegalArgumentException(
"Pile de destination invalide: " + (dest + 1));
else if (nbrCartes < 0)
throw new IllegalArgumentException(
"Impossible de déplacer " + nbrCartes + " cartes");
Util.deplacer(this.table.get(orig), this.table.get(dest), nbrCartes);
} |
e7a4b9de-4489-47c9-9cf3-37aef3685119 | 5 | public void handleReleasedKeys(ArrayList<KeyButtons> keyReleased)
{
if (keyReleased.contains(KeyButtons.LEFT))
{
left = false;
}
if (keyReleased.contains(KeyButtons.RIGHT))
{
right = false;
}
if (keyReleased.contains(KeyButtons.UP))
{
up = false;
}
if (keyReleased.contains(KeyButtons.DOWN))
{
down = false;
}
if (keyReleased.contains(KeyButtons.CONFIRM))
{
confirm = false;
}
} |
b94c3c02-470a-4702-88ee-ca6f621badaf | 3 | public boolean login() {
boolean loggedIn = false;
try {
while(loggedIn == false) {
System.out.println("Username: ");
_username = _scanner.next();
System.out.println("Password: ");
_password = _scanner.next();
loggedIn = _remoteObj.login(_username, _password, new Client(), ServerInterface.CLIENT);
}
} catch(Exception ex){
if(connect())
return login();
System.out.println("A Login-Error occured: " + ex.getMessage());
return false;
}
return true;
} |
f970fb25-1349-4818-84ad-3b46a8a2a8a8 | 0 | @XmlAttribute
public String getClient() {
return client;
} |
430b7076-2581-44c0-9a46-e52b1417c248 | 6 | public void loop() {
if (!MUSIC_ON && (name.equals("music1") || name.equals("music2")))
return;
if (!SOUND_ON && !name.equals("music1") && !name.equals("music2"))
return;
new Thread() {
public void run() {
clip.loop();
}
}.start();
} |
f8e98352-1058-4b6c-b992-b310a23017fb | 9 | public void boostMessage(String pokeString,String stat,String amounts, String from)
{
int which = getStatIndex(stat);
int amount = Integer.parseInt(amounts);
Pokemon pokemon = getPokemon(pokeString);
String level = ""; //sharply for 2, drastically for 3-6, nothing for 1
if(amount == 2 || amount == -2)
level = " sharply";
else if (amount >= 3 || amount <= -3)
level = " drastically";
String direction = " raised ";
if(amount < 0)
direction = " lowered ";
if(from != null && !from.equals(""))
{
if(from.contains("item"))
{
rawMessage("The "+from.substring(4)+ level + direction+pokemon.getName()
+"'s "+battlestats.get(stat)+"!");
}
else rawMessage(pokemon.getName()+"'s "+cleanEffect(from)+level+direction+"its "+
battlestats.get(stat)+"!");
}
else if(amount > 0 )
{
rawMessage(pokemon.getName() + "'s " + battlestats.get(stat) + level + " rose!");
}
else rawMessage(pokemon.getName() + "'s " + battlestats.get(stat) + level + " fell!");
pokemon.changeStat(which,amount);
} |
5bb46c05-2aad-424d-a924-ae7ed9646712 | 2 | public void setJump(String[] src) {
charJump = new Image[src.length];
for (int i = 0; i < src.length; i++) {
try {
charJump[i] = new Image(src[i]);
} catch (SlickException e) {
System.out.println(e);
}
}
} |
829c45e4-d9c4-483a-965f-3f99df1854be | 8 | private void setupGui() {
setTitle("Enter Password!");
setModal(true);
setSize(324, 91);
setResizable(false);
setUndecorated(true);
close.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
dispose();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
try {
close.setIcon(new ImageIcon(new URL("http://modpacks.minebook.co.uk/images/closeOver.png")));
} catch (MalformedURLException ex) {
Logger.getLogger(MinebookLauncher.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void mouseExited(MouseEvent e) {
try {
close.setIcon(new ImageIcon(new URL("http://modpacks.minebook.co.uk/images/close.png")));
} catch (MalformedURLException ex) {
Logger.getLogger(MinebookLauncher.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
try {
close.setIcon(new ImageIcon(new URL("http://modpacks.minebook.co.uk/images/close.png")));
} catch (MalformedURLException ex) {
Logger.getLogger(enterCode.class.getName()).log(Level.SEVERE, null, ex);
}
close.setBounds(new Rectangle(20, 20));
Container panel = getContentPane();
SpringLayout layout = new SpringLayout();
panel.setLayout(layout);
passwordLbl = new JLabel("Enter Access Code: ");
passwordLbl.setForeground(Color.WHITE);
password = new JPasswordField(16);
login = new JButton("Submit");
login.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
try {
String sessionContent = LoginHandler.getContentResult(new URL("http://modpacks.minebook.co.uk/isPackCodeCorrect.php?id=" + packID + "&code=" + new String(password.getPassword()) + "&user=" + MinebookLauncher.loggedInUser));
System.out.println("Pack ID: " + packID );
System.out.println("Pack Code: " + new String(password.getPassword()) );
if( sessionContent.equals("yes") ) {
String data = ProtectedLoginFile.main(new String(password.getPassword()), "encrypt");
FileWriter fstream = new FileWriter(System.getenv("APPDATA") + "\\.MinebookLauncher\\accessCodes\\" + packID);
BufferedWriter out = new BufferedWriter(fstream);
out.write(data);
out.close();
dispose();
Console.log("Code for pack " + packID.replace("_", " ") + " is Correct!");
File f = new File(System.getenv("APPDATA") + "\\.MinebookLauncher\\packs\\" + packID + "\\version");
if(f.exists()) {
Scanner sc = new Scanner(new File(System.getenv("APPDATA") + "\\.MinebookLauncher\\packs\\" + packID + "\\version"));
String v = sc.toString();
String vn = LoginHandler.getContentResult(new URL("http://modpacks.minebook.co.uk/getCurrentPackVersion.php?id=" + packID));
if( !v.equals(vn) ) {
new launchModPack(packID);
}else{
new updateAvailable(MinebookLauncher.frame, packID, mcver, true);
}
}else{
new downloadPack(packID, mcver, false);
}
}else if( sessionContent.equals("not-allowed") ) {
Console.log("You are not on the " + packID.replace("_", " ") + " whitelist!");
}else{
Console.log("Code for pack " + packID.replace("_", " ") + " is Incorrect!");
}
} catch (Exception ex) {
Logger.getLogger(MinebookLauncher.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
});
panel.add(close);
panel.add(passwordLbl);
panel.add(password);
panel.add(login);
Spring hSpring;
hSpring = Spring.constant(0);
layout.putConstraint(SpringLayout.EAST, close, hSpring, SpringLayout.EAST, panel);
hSpring = Spring.constant(10);
layout.putConstraint(SpringLayout.WEST, passwordLbl, hSpring, SpringLayout.WEST, panel);
hSpring = Spring.sum(hSpring, Spring.width(passwordLbl));
hSpring = Spring.sum(hSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.WEST, password, hSpring, SpringLayout.WEST, panel);
hSpring = Spring.sum(hSpring, Spring.width(password));
hSpring = Spring.sum(hSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.EAST, panel, hSpring, SpringLayout.WEST, panel);
layout.putConstraint(SpringLayout.HORIZONTAL_CENTER, login, 0, SpringLayout.HORIZONTAL_CENTER, panel);
Spring vSpring;
Spring rowHeight;
vSpring = Spring.constant(-5);
layout.putConstraint(SpringLayout.BASELINE, close, vSpring, SpringLayout.BASELINE, panel);
vSpring = Spring.constant(25);
layout.putConstraint(SpringLayout.BASELINE, passwordLbl, 0, SpringLayout.BASELINE, password);
layout.putConstraint(SpringLayout.NORTH, password, vSpring, SpringLayout.NORTH, panel);
rowHeight = Spring.height(passwordLbl);
rowHeight = Spring.max(rowHeight, Spring.height(password));
vSpring = Spring.sum(vSpring, rowHeight);
vSpring = Spring.sum(vSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.NORTH, login, vSpring, SpringLayout.NORTH, panel);
vSpring = Spring.sum(vSpring, Spring.height(login));
vSpring = Spring.sum(vSpring, Spring.constant(10));
layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);
layout.putConstraint(SpringLayout.SOUTH, panel, vSpring, SpringLayout.NORTH, panel);
pack();
getRootPane().setOpaque(false);
getContentPane().setBackground (new Color (0, 0, 0));
setBackground (new Color (0, 0, 0));
getRootPane().setBorder(BorderFactory.createLineBorder(new Color(128, 128, 128)));
setLocationRelativeTo(getOwner());
setVisible(true);
} |
3a1a4aae-2ef8-4963-9568-1ed57396f659 | 0 | public String getEmail() {
return email;
} |
dff78c45-7ae5-4a0c-8e7d-8f81bd93fa5b | 5 | public SecurityEditDialog(JDialog parent, String title, DBElementListModel listModel, SecurityRecord security) {
super(parent, title, Dialog.ModalityType.DOCUMENT_MODAL);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
//
// Save the security information
//
this.listModel = listModel;
this.security = security;
//
// Create the edit pane
//
// Security Type: <combo-box>
// Security Name: <text-field>
// Ticker Symbol: <text-field>
// Income Payments: <combo-box>
// Security Hidden: <check-box>
//
JPanel editPane = new JPanel(new GridLayout(0, 2, 5, 5));
editPane.add(new JLabel("Security Type:", JLabel.RIGHT));
securityTypeModel = new DBElementTypeComboBoxModel(SecurityRecord.getTypes(),
SecurityRecord.getTypeStrings());
securityType = new JComboBox(securityTypeModel);
if (security != null)
securityTypeModel.setSelectedItem(SecurityRecord.getTypeString(security.getType()));
else
securityTypeModel.setSelectedItem(null);
editPane.add(securityType);
editPane.add(new JLabel("Security Name:", JLabel.RIGHT));
if (security != null)
securityName = new JTextField(security.getName());
else
securityName = new JTextField(15);
editPane.add(securityName);
editPane.add(new JLabel("Ticker Symbol:", JLabel.RIGHT));
if (security != null)
tickerSymbol = new JTextField(security.getSymbol());
else
tickerSymbol = new JTextField(15);
editPane.add(tickerSymbol);
editPane.add(new JLabel("Income Payments:", JLabel.RIGHT));
incomePaymentModel = new DBElementTypeComboBoxModel(SecurityRecord.getPaymentTypes(),
SecurityRecord.getPaymentTypeStrings());
incomePayment = new JComboBox(incomePaymentModel);
if (security != null)
incomePaymentModel.setSelectedItem(SecurityRecord.getPaymentTypeString(security.getPaymentType()));
else
incomePaymentModel.setSelectedItem(SecurityRecord.getPaymentTypeString(SecurityRecord.NO_PAYMENTS));
editPane.add(incomePayment);
editPane.add(Box.createGlue());
securityHidden = new JCheckBox("Security Hidden");
if (security != null)
securityHidden.setSelected(security.isHidden());
else
securityHidden.setSelected(false);
editPane.add(securityHidden);
//
// Create the buttons (OK, Cancel, Help)
//
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
JButton button = new JButton("OK");
button.setActionCommand("ok");
button.addActionListener(this);
buttonPane.add(button);
getRootPane().setDefaultButton(button);
buttonPane.add(Box.createHorizontalStrut(10));
button = new JButton("Cancel");
button.setActionCommand("cancel");
button.addActionListener(this);
buttonPane.add(button);
buttonPane.add(Box.createHorizontalStrut(10));
button = new JButton("Help");
button.setActionCommand("help");
button.addActionListener(this);
buttonPane.add(button);
//
// Set up the content pane
//
JPanel contentPane = new JPanel();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.setOpaque(true);
contentPane.setBorder(BorderFactory.createEmptyBorder(30, 30, 30, 30));
contentPane.add(editPane);
contentPane.add(Box.createVerticalStrut(15));
contentPane.add(buttonPane);
setContentPane(contentPane);
} |
ad1ab9b3-ce06-4f41-9481-9d376e423ef6 | 3 | private void parsePacket(byte[] data, InetAddress address, int port) {
String message = new String(data).trim();
Packets type = PacketUtils.getPacketByID(Integer.parseInt((message.substring(0, 2))));
Packets packet = null;
switch (type) {
case INXPAMOUNT:
packet = Packets.INXPAMOUNT;
break;
case INDONOR:
packet = Packets.INDONOR;
break;
case TEST:
packet = Packets.TEST;
break;
default:
packet = Packets.UNKNOWN;
break;
}
} |
d7822207-f315-455d-b43e-055042221964 | 7 | public int[] getOneFileLines(File file) {
int codeSum = 0;// 代码行数
int blankSum = 0;// 空白行数
int commentSum = 0;// 注释行数
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(file));
String line = null;
while((line = br.readLine()) != null) {
line = line.trim();
if (line.matches("^[\\s&&[^\\n]]*$")) {
blankSum++;
} else if (line.startsWith("//")) {
commentSum++;
} else if (line.startsWith("/*")) {
commentSum++;
} else if (line.startsWith("*")) {
commentSum++;
} else if (line.endsWith("*/")) {
commentSum++;
} else {
codeSum++;
}
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return new int[]{codeSum, blankSum, commentSum};
} |
0219d8e3-31df-4c6c-ba6b-fc674d0b29aa | 9 | private boolean isValid(String s) {
if (s.length() == 3 && s.charAt(0) == '0')
return false;
if (s.length() == 3 && (Integer.valueOf(s) > 255 || Integer.valueOf(s) == 0))
return false;
if (s.length() == 2 && s.charAt(0) == '0')
return false;
if (s.length() == 2 && Integer.valueOf(s) == 0)
return false;
return true;
} |
dafdcccc-0dcb-48db-9543-0b0069878e91 | 9 | public void execute() {
clearConsole();
Deck deck = new Deck();
// TURNO PLAYER1
Player player1 = new Player();
player1.setScore(0);
do {
Card card = deck.getCard(); //dai carta
System.out.println(deck.getCardsList().size());
player1.setScore( player1.getScore() + deck.calcValue(card) );
if ( isSballato(player1) ) {
System.out.println(card.getNumero()+" di "+card.getSeme()+". Punti: "+deck.calcValue(card));
System.out.println( "TOTALE: " + player1.getScore() );
System.out.println( "HAI SBALLATO!!!" );
return;
} else {
System.out.println(card.getNumero()+" di "+card.getSeme()+". Punti: "+deck.calcValue(card));
System.out.println( "TOTALE: " + player1.getScore() );
System.out.println("CARTA (C) | STO BENE (S)");
}
} while ( moreCards() && !isSballato(player1) );
if ( !isSballato(player1) ) {
// TURNO DEALER
Player dealer = new Player();
dealer.setScore(0);
System.out.println("TURNO DEALER");
do {
Card carta2 = deck.getCard(); //dai carta
System.out.println(deck.getCardsList().size());
dealer.setScore( dealer.getScore() + deck.calcValue(carta2) );
if ( isSballato(dealer) ) {
System.out.println(carta2.getNumero()+" di "+carta2.getSeme()+". Punti: "+deck.calcValue(carta2));
System.out.println( "TOTALE: " + dealer.getScore() );
System.out.println( "IL DEALER HA SBALLATO! HAI VINTO!!!" );
} else {
System.out.println(carta2.getNumero()+" di "+carta2.getSeme()+". Punti: "+deck.calcValue(carta2));
System.out.println( "TOTALE DEALER: " + dealer.getScore() );
}
} while ( ( dealer.getScore() < player1.getScore()-2 ) && !isSballato(dealer) );
if (player1.getScore() > dealer.getScore() ) {
System.out.println( "HAI VINTO!!!" ); // VINCE PLAYER1
} else if(!isSballato(dealer)) {
System.out.println( "HAI PERSO!!!" ); // VINCE DEALER
}
// if (deck.getReShuffle()==true) {
// deck = new Deck();
// }
return;
}
} |
dac18f2f-ad2d-4501-9552-7fb7110861a3 | 9 | public boolean isTall()
{
switch (eType)
{
case ENDERMAN:
case ENDER_DRAGON:
case GHAST:
case GIANT:
case HORSE:
case IRON_GOLEM:
case MAGMA_CUBE:
case SLIME:
case WITHER:
return true;
default:
return false;
}
} |
3a2415d3-c811-4069-906b-89036c0995b2 | 8 | private static Map<Integer, Double> getRankedTagList(BookmarkReader reader, Map<Integer, Double> userMap, double userDenomVal,
Map<Integer, Double> resMap, double resDenomVal, boolean sorting, boolean smoothing, boolean topicCreation) {
Map<Integer, Double> resultMap = new LinkedHashMap<Integer, Double>();
if (userMap != null) {
for (Map.Entry<Integer, Double> entry : userMap.entrySet()) {
resultMap.put(entry.getKey(), entry.getValue().doubleValue());
}
}
if (resMap != null) {
for (Map.Entry<Integer, Double> entry : resMap.entrySet()) {
double resVal = entry.getValue().doubleValue();
Double val = resultMap.get(entry.getKey());
resultMap.put(entry.getKey(), val == null ? resVal : val.doubleValue() + resVal);
}
}
if (sorting) {
Map<Integer, Double> sortedResultMap = new TreeMap<Integer, Double>(new DoubleMapComparator(resultMap));
sortedResultMap.putAll(resultMap);
Map<Integer, Double> returnMap = new LinkedHashMap<Integer, Double>(MAX_RECOMMENDATIONS);
int i = 0;
for (Map.Entry<Integer, Double> entry : sortedResultMap.entrySet()) {
if (i++ < MAX_RECOMMENDATIONS) {
returnMap.put(entry.getKey(), entry.getValue());
} else {
break;
}
}
return returnMap;
}
return resultMap;
/*
double size = (double)reader.getTagAssignmentsCount();
double tagSize = (double)reader.getTags().size();
Map<Integer, Double> resultMap = new LinkedHashMap<Integer, Double>();
for (int i = 0; i < tagSize; i++) {
double pt = (double)reader.getTagCounts().get(i) / size;
Double userVal = 0.0;
if (userMap != null && userMap.containsKey(i)) {
userVal = userMap.get(i);//Math.exp(userMap.get(i)) / userDenomVal;
}
Double resVal = 0.0;
if (resMap != null && resMap.containsKey(i)) {
resVal = resMap.get(i);//Math.exp(resMap.get(i)) / resDenomVal;
}
if (userVal > 0.0 || resVal > 0.0) { // TODO
if (smoothing) {
resultMap.put(i, Utilities.getSmoothedTagValue(userVal, userDenomVal, resVal, resDenomVal, pt));
} else {
resultMap.put(i, userVal + resVal);
}
}
}
if (sorting) {
Map<Integer, Double> sortedResultMap = new TreeMap<Integer, Double>(new DoubleMapComparator(resultMap));
sortedResultMap.putAll(resultMap);
if (topicCreation) {
return sortedResultMap;
} else { // otherwise filter
Map<Integer, Double> returnMap = new LinkedHashMap<Integer, Double>(MAX_RECOMMENDATIONS);
int i = 0;
for (Map.Entry<Integer, Double> entry : sortedResultMap.entrySet()) {
if (i++ < MAX_RECOMMENDATIONS) {
returnMap.put(entry.getKey(), entry.getValue());
} else {
break;
}
}
return returnMap;
}
}
return resultMap;
*/
} |
47bdf46a-a82d-4520-b90c-171504cbc3c7 | 2 | public void shutdown() {
// System.out.println("trying to shut down");
synchronized (accptsoc) {
if (!listen) {
return;
}
listen = false;
try {
accptsoc.close();
this.closeall();
} catch (IOException e) {
System.err.println("ajserver: could not shutdown properly");
}
}
} |
330c7064-dee9-4ba2-b437-023e563aaf8b | 9 | private String fixBadChars(String s) {
if (s == null || s.length() == 0) return s;
Pattern p = Pattern.compile("[<>\"&]");
Matcher m = p.matcher(s);
StringBuffer b = null;
while (m.find()) {
if (b == null) b = new StringBuffer();
switch (s.charAt(m.start())) {
case '<': m.appendReplacement(b,"<");
break;
case '>': m.appendReplacement(b,">");
break;
case '&': m.appendReplacement(b,"&");
break;
case '"': m.appendReplacement(b,""");
break;
default: m.appendReplacement(b,"&#"+((int)s.charAt(m.start()))+';');
}
}
if (b == null) return s;
m.appendTail(b);
return b.toString();
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.