id
stringlengths
36
36
text
stringlengths
1
1.25M
ad2b2445-0bdd-46b4-9cd3-596d7af1daf9
public InputStream( java.io.InputStream in ) { this( in, DECODE ); } // end constructor
8b12e152-cd0a-403e-b2e9-5178424efc12
public InputStream( java.io.InputStream in, int options ) { super( in ); this.options = options; // Record for later this.breakLines = (options & DO_BREAK_LINES) > 0; this.encode = (options & ENCODE) > 0; this.bufferLength = encode ? 4 : 3; this.buffer = new byte[ bufferLength ]; this.position = -1; this.lineLength = 0; this.decodabet = getDecodabet(options); } // end constructor
487000f1-557a-46ba-b448-24dadbd02638
@Override public int read() throws java.io.IOException { // Do we need to get data? if( position < 0 ) { if( encode ) { byte[] b3 = new byte[3]; int numBinaryBytes = 0; for( int i = 0; i < 3; i++ ) { int b = in.read(); // If end of stream, b is -1. if( b >= 0 ) { b3[i] = (byte)b; numBinaryBytes++; } else { break; // out of for loop } // end else: end of stream } // end for: each needed input byte if( numBinaryBytes > 0 ) { encode3to4( b3, 0, numBinaryBytes, buffer, 0, options ); position = 0; numSigBytes = 4; } // end if: got data else { return -1; // Must be end of stream } // end else } // end if: encoding // Else decoding else { byte[] b4 = new byte[4]; int i = 0; for( i = 0; i < 4; i++ ) { // Read four "meaningful" bytes: int b = 0; do{ b = in.read(); } while( b >= 0 && decodabet[ b & 0x7f ] <= WHITE_SPACE_ENC ); if( b < 0 ) { break; // Reads a -1 if end of stream } // end if: end of stream b4[i] = (byte)b; } // end for: each needed input byte if( i == 4 ) { numSigBytes = decode4to3( b4, 0, buffer, 0, options ); position = 0; } // end if: got four characters else if( i == 0 ){ return -1; } // end else if: also padded correctly else { // Must have broken out from above. throw new java.io.IOException( "Improperly padded Base64 input." ); } // end } // end else: decode } // end else: get data // Got data? if( position >= 0 ) { // End of relevant data? if( /*!encode &&*/ position >= numSigBytes ){ return -1; } // end if: got data if( encode && breakLines && lineLength >= MAX_LINE_LENGTH ) { lineLength = 0; return '\n'; } // end if else { lineLength++; // This isn't important when decoding // but throwing an extra "if" seems // just as wasteful. int b = buffer[ position++ ]; if( position >= bufferLength ) { position = -1; } // end if: end return b & 0xFF; // This is how you "cast" a byte that's // intended to be unsigned. } // end else } // end if: position >= 0 // Else error else { throw new java.io.IOException( "Error in Base64 code reading stream." ); } // end else } // end read
bcc905b8-dd95-416f-873d-651f2b7e0cda
@Override public int read( byte[] dest, int off, int len ) throws java.io.IOException { int i; int b; for( i = 0; i < len; i++ ) { b = read(); if( b >= 0 ) { dest[off + i] = (byte) b; } else if( i == 0 ) { return -1; } else { break; // Out of 'for' loop } // Out of 'for' loop } // end for: each byte read return i; } // end read
093a61d8-f513-419f-8dbb-187cae313cf7
public OutputStream( java.io.OutputStream out ) { this( out, ENCODE ); } // end constructor
c96f51f3-de9d-459f-97b1-340829be580c
public OutputStream( java.io.OutputStream out, int options ) { super( out ); this.breakLines = (options & DO_BREAK_LINES) != 0; this.encode = (options & ENCODE) != 0; this.bufferLength = encode ? 3 : 4; this.buffer = new byte[ bufferLength ]; this.position = 0; this.lineLength = 0; this.suspendEncoding = false; this.b4 = new byte[4]; this.options = options; this.decodabet = getDecodabet(options); } // end constructor
4bfdb4e9-6b7b-4b84-9dcd-b77933009afe
@Override public void write(int theByte) throws java.io.IOException { // Encoding suspended? if( suspendEncoding ) { this.out.write( theByte ); return; } // end if: supsended // Encode? if( encode ) { buffer[ position++ ] = (byte)theByte; if( position >= bufferLength ) { // Enough to encode. this.out.write( encode3to4( b4, buffer, bufferLength, options ) ); lineLength += 4; if( breakLines && lineLength >= MAX_LINE_LENGTH ) { this.out.write( NEW_LINE ); lineLength = 0; } // end if: end of line position = 0; } // end if: enough to output } // end if: encoding // Else, Decoding else { // Meaningful Base64 character? if( decodabet[ theByte & 0x7f ] > WHITE_SPACE_ENC ) { buffer[ position++ ] = (byte)theByte; if( position >= bufferLength ) { // Enough to output. int len = Base64.decode4to3( buffer, 0, b4, 0, options ); out.write( b4, 0, len ); position = 0; } // end if: enough to output } // end if: meaningful base64 character else if( decodabet[ theByte & 0x7f ] != WHITE_SPACE_ENC ) { throw new java.io.IOException( "Invalid character in Base64 data." ); } // end else: not white space either } // end else: decoding } // end write
9c3a7fcb-d79a-4d2d-a225-4671f4cd3821
@Override public void write( byte[] theBytes, int off, int len ) throws java.io.IOException { // Encoding suspended? if( suspendEncoding ) { this.out.write( theBytes, off, len ); return; } // end if: supsended for( int i = 0; i < len; i++ ) { write( theBytes[ off + i ] ); } // end for: each byte written } // end write
f27afc7f-ff4a-4c06-8a72-4671ee48dfc0
public void flushBase64() throws java.io.IOException { if( position > 0 ) { if( encode ) { out.write( encode3to4( b4, buffer, position, options ) ); position = 0; } // end if: encoding else { throw new java.io.IOException( "Base64 input not properly padded." ); } // end else: decoding } // end if: buffer partially full } // end flush
e2014df7-273a-4054-a8b0-a5d096529ac7
@Override public void close() throws java.io.IOException { // 1. Ensure that pending characters are written flushBase64(); // 2. Actually close the stream // Base class both flushes and closes. super.close(); buffer = null; out = null; } // end close
6886c8fc-5e76-4c1e-8b14-69c7a899d55c
public void suspendEncoding() throws java.io.IOException { flushBase64(); this.suspendEncoding = true; } // end suspendEncoding
d260d3a0-bdfd-4e06-8f4e-ee78746bf716
public void resumeEncoding() { this.suspendEncoding = false; } // end resumeEncoding
db3dd6a1-1c66-49ee-b5bb-b8237ae6d38f
private AndroidApplication() { }
66032583-ead6-41ba-9cc5-d45e83858ee9
public AndroidApplication(String name, String image, String packageName, String description, String category, String currency, Double price, Long fileBytes, String minAnddroidVersion) { this.image = image; this.name = name; this.packageName = packageName; this.description = description; this.detailsUrl = AndroidMarketHandler.MARKET_URL_DETAILS_PAGE + packageName; this.category = category; this.currency = currency; this.price = price; this.fileBytes = fileBytes; this.minAndroidVersion = minAnddroidVersion; }
777848b5-d8c4-48eb-b3db-716e43d5b9d8
public String getImage() { return this.image; }
65e2e0da-e18a-4cb8-bb3f-4e16e549f09a
public String getPackageName() { return this.packageName; }
cb3ebae8-9893-4c55-b0bf-4e20efc00668
public String getName() { return this.name; }
1c3848bc-b7f4-4060-b106-3825e80be13e
public String getDescription() { return this.description; }
96358618-526d-4fb6-9871-b28eca46b371
public String getCategory() { return this.category; }
20c9442c-b1b2-463e-b8c5-eb0f2b27cea8
public String getDetailsUrl() { return this.detailsUrl; }
b146bb66-d9b9-4276-87d9-5b0b439c8a51
public Double getPrice() { return this.price; }
be4a0967-0df6-46bf-a89d-e7b32d07cf15
public String getCurrency() { return this.currency; }
a3e156ac-0b11-4f71-b4a1-c2577b8373fc
public Long getFileBytes() { return fileBytes; }
d0a92a43-7219-446b-bf1f-816f6c7e6156
public String getMinAndroidVersion() { return this.minAndroidVersion; }
e26f7a54-4a9f-4ab1-aecb-1e7c0cee79c2
public String toString() { return String.format("{\"name\": \"%s\", \"image\": \"%s\", \"packageName\": \"%s\", " + "\"description\": \"%s\", \"detailsUrl\": \"%s\", \"category\": \"%s\", \"currency\": \"%s\"," + "\"minAndroidVersion\": \"%s\", \"price\": \"%s\", \"fileBytes\": \"%s\"}", name, image, packageName, description, detailsUrl, category, currency, minAndroidVersion, price, fileBytes); }
49cb6977-6f53-4b46-b3f7-29a26af03f0c
public static void main(String[] args) throws Exception { if (args.length<1) { System.out.println("java -jar AndoidMarketParser.jar <searchQuery>"); return; } String request = args[0]; List<AndroidApplication> returnData = AndroidMarketHandler.marketSearch(request); if (returnData == null) { System.out.println("request return 0 applications"); return; } for (AndroidApplication app : returnData) { System.out.println("Name: " + app.getName()); System.out.println("Image: " + app.getImage()); System.out.println("packageName: " + app.getPackageName()); System.out.println("description: " + app.getDescription()); System.out.println("category: " + app.getCategory()); System.out.println("detailSrc: " + app.getDetailsUrl()); System.out.println("currency: " + app.getCurrency()); System.out.println("price: " + app.getPrice()); System.out.println("fileSize: " + app.getFileBytes()); System.out.println("minAndroidVersion: " + app.getMinAndroidVersion()); } System.out.println("Total finded: " + returnData.size()); }
6c0af0b9-f711-451f-a053-b03d607ef2f5
@Test public void longNameInRequestTest() { String request = "UFO hotseat"; List<AndroidApplication> returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertEquals(returnData.size(), 1); }
6e06b8e6-c987-4e10-819e-888fa36e0b74
@Test public void getRequest() { String request = "pname:com.fullfat.android.agentdash"; List<AndroidApplication> returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertEquals(returnData.size(), 1); }
99a9c009-faba-4e07-9813-a6970df403be
@Test public void getSize() { String request = "pname:com.fullfat.android.agentdash"; List<AndroidApplication> returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertFalse(returnData.isEmpty()); assertEquals(returnData.size(), 1); AndroidApplication app = returnData.get(0); assertNotNull(app); assertTrue(app.getFileBytes().equals(25165824L)); request = "pname:com.kamagames.notepad"; returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertFalse(returnData.isEmpty()); assertEquals(returnData.size(), 1); app = returnData.get(0); assertNotNull(app); assertTrue(app.getFileBytes().equals(51200l)); request = "pname:mobi.firedepartment"; returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertFalse(returnData.isEmpty()); assertEquals(returnData.size(), 1); app = returnData.get(0); assertNotNull(app); assertTrue(app.getFileBytes().equals(2831155l)); }
82da4330-6a99-4de8-af9a-e480d48876e1
@Test public void badRequest() { String request = "pname:net.cachapa.libra31231231231231231"; List<AndroidApplication> returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertTrue(returnData.isEmpty()); }
a133aba3-15dc-46db-bcb7-5a2e1111b7e2
@Test public void requestWithoutSize() { String request = "pname:net.cachapa.libra"; List<AndroidApplication> returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertFalse(returnData.isEmpty()); assertEquals(returnData.size(), 1); AndroidApplication app = returnData.get(0); assertNotNull(app); assertTrue(app.getFileBytes() >= 0); }
44c3dd58-a180-4ea2-a575-8c7ceefd2d14
@Test public void parserTest() { String request = "pname:ru.yulagroup.book"; List<AndroidApplication> returnData = AndroidMarketHandler.marketSearch(request); assertNotNull(returnData); assertFalse(returnData.isEmpty()); assertEquals(returnData.size(), 1); AndroidApplication app = returnData.get(0); assertNotNull(app); assertEquals(app.getPackageName(), "ru.yulagroup.book"); assertNotNull(app.getFileBytes()); assertNotNull(app.getCategory()); assertNotNull(app.getCurrency()); assertNotNull(app.getDescription()); assertNotNull(app.getDetailsUrl()); assertNotNull(app.getImage()); assertNotNull(app.getMinAndroidVersion()); assertEquals(app.getMinAndroidVersion(), "2.2"); }
58cd6ed5-13ee-4a92-97d6-3e3988e619e7
public HelloWorldResource(String template, String defaultName) { this.template = template; this.defaultName = defaultName; this.counter = new AtomicLong(); }
830581ee-1019-4085-bbfe-cdfb617e542e
@GET @Timed public Saying sayHello(@QueryParam("name") Optional<String> name) { return new Saying(counter.incrementAndGet(), String.format(template, name.or(defaultName))); }
e3b52e69-a9f5-4e19-a24f-03612f2ca9d5
public static void main(String[] args) throws Exception { new HelloWorldService().run(args); }
080ec78b-3a2c-4d44-8ec2-688bde857405
@Override public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) { bootstrap.setName("hello-world"); }
a252f996-c1a5-43e0-b77f-337195d29ceb
@Override public void run(HelloWorldConfiguration configuration, Environment environment) { final String template = configuration.getTemplate(); final String defaultName = configuration.getDefaultName(); environment.addResource(new HelloWorldResource(template, defaultName)); environment.addHealthCheck(new TemplateHealthCheck(template)); }
5cbaa07a-24f2-43da-a7a8-42f2c61d9742
public TemplateHealthCheck(String template) { super("template"); this.template = template; }
ec849b94-460f-4d7b-b1d7-4751148584f0
@Override protected Result check() throws Exception { final String saying = String.format(template, "TEST"); if (!saying.contains("TEST")) { return Result.unhealthy("template doesn't include a name"); } return Result.healthy(); }
2010390f-088c-473f-852e-7f1524ef55aa
public String getTemplate() { return template; }
3651ed13-14e5-4acd-b07f-2274825e99e7
public String getDefaultName() { return defaultName; }
d0413d96-86f0-4e0e-84b6-302b67c3cc6b
public Saying(long id, String content) { this.id = id; this.content = content; }
a75f134d-05d5-4db9-a4ac-f339786325c2
public long getId() { return id; }
dcc3ced1-07da-4739-b299-b23c5aee08b1
public String getContent() { return content; }
c1eda9d3-2aae-4ac4-bd2d-a6a06d428b01
public static void main(String[] args) throws Exception { // The simple Jetty config here will serve static content from the // webapp directory String webappDirLocation = "src/main/webapp/"; // The port that we should run on can be set into an environment // variable // Look for that variable and default to 8080 if it isn't there. String webPort = System.getenv("PORT"); if (webPort == null || webPort.isEmpty()) { webPort = "8090"; } Server server = new Server(Integer.valueOf(webPort)); WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); webapp.setDescriptor(webappDirLocation + "/WEB-INF/web.xml"); webapp.setResourceBase(webappDirLocation); server.setHandler(webapp); server.start(); server.join(); }
9febec93-6320-4aa2-bdf4-62273a5d8c31
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter out = resp.getWriter(); out.println("hello, world"); out.close(); }
8e197dc9-6b42-4557-b984-0e37fe552775
public ControleUniversal(InterfaceControleUniversal controle){ controle.executaSolicitacao(); }
600d2887-c08f-4011-9932-be1c3e0741f0
public static void main(String[] args) { ControleUniversal controla; controla = new ControleUniversal(new ComandCarroLigar()); controla = new ControleUniversal(new ComandCarroDesligar()); controla = new ControleUniversal(new CommandPortaoAbrir()); controla = new ControleUniversal(new CommandPortaoFechar()); }
ed30a516-0041-4937-8bbe-c37cdd53cd92
public void DesligarCarro() { System.out.println("babahbahbah - Carro Desligado"); }
04447053-78ef-4374-b6c1-a7fe1472e4a9
@Override public void executaSolicitacao() { this.DesligarCarro(); }
87c865ff-24c0-406b-91a4-723811082417
public void AbrirPortao(){ System.out.println("pi pi pi pi - Portão Aberto"); }
9b4c96e6-807f-45cb-83fd-b2483a3ac469
@Override public void executaSolicitacao() { this.AbrirPortao(); }
5535fb3f-f22e-4610-aed2-2a4a056f7ce3
public void executaSolicitacao();
a220499f-4ef3-46a9-bd9c-f050c2d61f4f
public void ligarExecutar() { System.out.println("VRUMMMMMMMM - Caro Ligado"); }
e42c11bd-5636-480b-879e-e593ed322b78
@Override public void executaSolicitacao() { this.ligarExecutar(); }
0ed062c8-6e24-4c1f-bc57-6f8aaf530315
public void FecharPortao(){ System.out.println("Tan tan tan - Portão Fechado"); }
43bea861-7afd-4512-a8a5-34318f280811
@Override public void executaSolicitacao() { this.FecharPortao(); }
bf6775ed-6052-4a96-9e4e-905117220ada
SlidingPuzzleBoard(final int colCount, final int rowCount) { setStyle("-fx-background-color: #f3f3f3; " + "-fx-border-color: #f3f3f3; "); cols = colCount; rows = rowCount; double gameBoardWidth = SlidingPuzzlePiece.getPuzzleSize() * colCount; double gameBoardHeigth = SlidingPuzzlePiece.getPuzzleSize() * rowCount; setPrefSize(gameBoardWidth, gameBoardHeigth); setMaxSize(gameBoardWidth, gameBoardHeigth); autosize(); final int i70 = 70; Path gameBoardGrid = new Path(); gameBoardGrid.setStroke(Color.rgb(i70, i70, i70)); getChildren().add(gameBoardGrid); final int i5 = 5; for (int spalte = 0; spalte < colCount - 1; spalte++) { gameBoardGrid.getElements().addAll( new MoveTo(SlidingPuzzlePiece.getPuzzleSize() + SlidingPuzzlePiece.getPuzzleSize() * spalte, i5), new LineTo(SlidingPuzzlePiece.getPuzzleSize() + SlidingPuzzlePiece.getPuzzleSize() * spalte, SlidingPuzzlePiece.getPuzzleSize() * rowCount - i5)); } for (int zeile = 0; zeile < rowCount - 1; zeile++) { gameBoardGrid.getElements().addAll( new MoveTo(i5, SlidingPuzzlePiece.getPuzzleSize() + SlidingPuzzlePiece.getPuzzleSize() * zeile), new LineTo(SlidingPuzzlePiece.getPuzzleSize() * colCount - i5, SlidingPuzzlePiece.getPuzzleSize() + SlidingPuzzlePiece.getPuzzleSize() * zeile)); } }
a9896f06-2b4a-452c-a141-bb701e53c20f
public final int getCols() { return cols; }
ffcf7b4a-642a-48be-82b5-8b99fc58ec3c
public final int getRows() { return rows; }
41abd634-2ce8-49a8-a6ca-f89af407dfef
SlidingPuzzleField(final int col, final int row, final double coordX, final double coordY) { this.fieldCol = col; this.fieldRow = row; this.fieldCoordX = coordX; this.fieldCoordY = coordY; this.isFree = false; }
243c7efb-f4b3-44cc-8665-29ac113a8570
public final int getFieldCol() { return fieldCol; }
90f4ff76-1228-4c25-8447-fd08b188d24a
public final double getFieldCoordX() { return fieldCoordX; }
839ac017-0105-4527-99de-83be935d89a0
public final double getFieldCoordY() { return fieldCoordY; }
8e04efd8-accb-4e95-9330-9bb808e167cb
public final int getFieldRow() { return fieldRow; }
47b9b2ed-3181-4499-90ea-b9997ddd415d
public final boolean getFree() { return isFree; }
aaf9738c-d30e-4691-8e91-cbcad2132c4e
public final void setFieldCol(final int newFieldCol) { this.fieldCol = newFieldCol; }
58aefcb9-d08f-48d2-beed-f53a2ae7b05e
public final void setFieldCoordX(final double newFieldCoordX) { this.fieldCoordX = newFieldCoordX; }
3e908086-3f5d-4476-af1f-789595622e91
public final void setFieldCoordY(final double newFieldCoordY) { this.fieldCoordY = newFieldCoordY; }
be16d397-9ff4-405b-9837-df404379941b
public final void setFieldRow(final int newFieldRow) { this.fieldRow = newFieldRow; }
d086c9a0-e09b-49d1-8f0e-77f6a7a8a275
public final void setFree(final boolean free) { this.isFree = free; }
aa65db58-150d-4a99-9c89-e6dbbac9d715
public static Vector<SlidingPuzzleHighscore> getPuzzleHighscores() { return puzzleHighscores; }
3230d010-2f95-4892-9e11-969481110b62
public static void readXML() throws Exception { puzzleHighscores = new Vector<SlidingPuzzleHighscore>(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new File("highscore.xml")); Element rootElement = doc.getDocumentElement(); System.out.println("root element: " + rootElement.getNodeName()); NodeList list = rootElement.getElementsByTagName("user"); for (int i = 0; i < list.getLength(); i++) { Node userNode = list.item(i); new SlidingPuzzleHighscore(userNode.getAttributes() .getNamedItem("name").getNodeValue(), userNode .getAttributes().getNamedItem("score").getNodeValue()); } }
4d1ed2f4-e7b9-4db0-8d2b-c5545b9d5e2a
public static final void setPuzzleHighscores( final Vector<SlidingPuzzleHighscore> newPuzzleHighscores) { SlidingPuzzleHighscore.puzzleHighscores = newPuzzleHighscores; }
82d874fa-55e0-4b0d-8217-f16eac0fab19
public static void writeXML() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document highScoreListe = builder.newDocument(); Element root = highScoreListe.createElement("root"); for (SlidingPuzzleHighscore thisScore : puzzleHighscores) { Element userElement = highScoreListe.createElement("user"); userElement.setAttribute("name", thisScore.getUserName()); userElement.setAttribute("score", thisScore.getUserScore()); root.appendChild(userElement); } highScoreListe.appendChild(root); DOMSource source = new DOMSource(highScoreListe); PrintStream ps = new PrintStream("highscore.xml"); StreamResult result = new StreamResult(ps); TransformerFactory transformerFactory = TransformerFactory .newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.transform(source, result); }
4f475fbb-92b3-4543-b992-3346bf012c3e
SlidingPuzzleHighscore(final String newUserName, final String newUserScore) { this.userName = newUserName; this.userScore = newUserScore; puzzleHighscores.add(this); }
9933f644-2b5e-419c-b231-41c8ec2b5865
public final String getUserName() { return userName; }
ce10e6f0-84c6-4d97-8d5b-b731b42163e6
public final String getUserScore() { return userScore; }
284c8212-fba0-4852-b09a-4132c6c92171
public final void setUserName(final String newUserName) { this.userName = newUserName; }
52fc28d8-40fa-4606-a2d0-1ba6bcd8bd7d
public final void setUserScore(final String newUserScore) { this.userScore = newUserScore; }
50d38809-4a14-4499-b6a7-0d63efdf8628
public static void activateFields() { for (final SlidingPuzzlePiece puzzleTeil : SlidingPuzzlePiece .getPuzzlePiece()) { puzzleTeil.setActive(); } }
c2fcec43-72ed-433d-b188-9a344df11b8c
public static Timeline getFlow() { return flow; }
3b914e6d-7402-423f-ab4e-0155f1514f43
public static SlidingPuzzleBoard getGameBoard() { return gameBoard; }
62b11a26-3d89-4f20-b67b-3948ac65a5b3
public static int getMergeProcedures() { return mergeProcedures; }
1ab2c733-9098-4002-bdb9-2e215411cbcc
public static int getMoveCount() { return moveCount; }
9bbbb897-68c1-4ee6-af9f-a04afa6c9dcc
public static Stage getThisStage() { return thisStage; }
5c5e9f12-0184-4db3-9e80-807c42944011
public static String getUserName() { return userName; }
88e1a566-020a-4203-b6b1-453c9eda4986
public static void hideOneField() { int emptyIndex = randomDigit(1, SlidingPuzzlePiece.getPuzzlePiece() .size()); SlidingPuzzlePiece.getPuzzlePiece().get(emptyIndex).setVisible(false); SlidingPuzzlePiece.getPuzzlePiece().get(emptyIndex).getField() .setFree(true); }
d164296c-beb8-4405-8a36-8df40184634f
public static void main(final String[] args) { Application.launch(args); }
615aef40-ff88-452a-9144-f96f3f0473a9
public static void puzzleReady() { boolean isWin = true; for (SlidingPuzzlePiece thisPiece : SlidingPuzzlePiece.getPuzzlePiece()) { if (thisPiece.getField().getFieldCoordX() != thisPiece.getRootX()) { isWin = false; } if (thisPiece.getField().getFieldCoordY() == thisPiece.getRootY()) { isWin = false; } } if (isWin) { System.out.println("Game won."); try { SlidingPuzzleHighscore.readXML(); new SlidingPuzzleHighscore(userName, String.valueOf(moveCount)); SlidingPuzzleHighscore.writeXML(); } catch (Exception e) { e.printStackTrace(); } } }
920ebc17-b548-4e22-8435-31d49d4a2eeb
public static int randomDigit(final int a, final int b) { return (int) (Math.random() * (b - a) + a); }
8598e6f4-91b3-46fa-aa98-60fc54e347ae
public static void resetGameBoard() { for (SlidingPuzzlePiece puzzleTeil : SlidingPuzzlePiece .getPuzzlePiece()) { if (puzzleTeil.getVisible() == null) { puzzleTeil.setVisible(true); } } }
39ef2ada-7be7-4864-b5f9-0b983c8e3709
public static void setFlow(final Timeline newFlow) { SlidingPuzzleGame.flow = newFlow; }
e61025ac-7bce-46b5-99d3-5de5b1c96060
public static void setGameBoard(final SlidingPuzzleBoard newGameBoard) { SlidingPuzzleGame.gameBoard = newGameBoard; }
3e881671-a805-46b3-89b9-c663854e175d
public static void setMergeCount(final int mergeCount) { SlidingPuzzleGame.mergeProcedures = mergeCount; }
462960f5-467d-48a1-940b-d382e35f3bf0
public static void setMergeProcedures(final int newMergeProcedures) { SlidingPuzzleGame.mergeProcedures = newMergeProcedures; }
ab77634a-e487-42bd-92af-8f472aab96e7
public static void setMoveCount(final int newMoveCount) { SlidingPuzzleGame.moveCount = newMoveCount; }
d6f2a5ef-b63d-471e-bf7b-07e5ce1897f8
public static void setThisStage(final Stage newStage) { SlidingPuzzleGame.thisStage = newStage; }
4b976145-f655-4769-8b3e-fda020d11258
public static void setUserName(final String newUserName) { SlidingPuzzleGame.userName = newUserName; }
90c63f12-9ebb-4d6a-aaf1-6c78703b4773
public final Group createGameBoard() { flow = new Timeline(); Group group = new Group(); Image image = new Image(getClass(). getResourceAsStream("socialite.jpg")); int colCount = (int) (image.getWidth() / SlidingPuzzlePiece.getPuzzleSize()); int rowCount = (int) (image.getHeight() / SlidingPuzzlePiece.getPuzzleSize()); gameBoard = new SlidingPuzzleBoard(colCount, rowCount); for (int col = 0; col < colCount; col++) { for (int row = 0; row < rowCount; row++) { int rootX = col * SlidingPuzzlePiece.getPuzzleSize(); int rootY = row * SlidingPuzzlePiece.getPuzzleSize(); new SlidingPuzzlePiece(image, rootX, rootY, gameBoard.getWidth(), gameBoard.getHeight(), new SlidingPuzzleField(col, row, rootX, rootY)); } } gameBoard.getChildren().addAll(SlidingPuzzlePiece.getPuzzlePiece()); resetGameBoard(); mergePuzzlePieces(gameBoard, SlidingPuzzlePiece.getPuzzlePiece()); hideOneField(); activateFields(); final int i10 = 10; VBox displayField = new VBox(i10); displayField.setPadding(new Insets(i10, i10, i10, i10)); displayField.getChildren().addAll(createMenu(), gameBoard); group.getChildren().addAll(displayField); return group; }