id
stringlengths
36
36
text
stringlengths
1
1.25M
5f0520c6-e377-4af2-827e-2a11935995e4
public void setWebStranica(Resource webStranica) { this.webStranica = webStranica; }
fdb1e627-c3ff-4677-b1ba-f33a92f15884
public int getMax() { return max; }
e176359b-7ade-4311-9f30-23f7b97ced67
public void setMax(int max) { this.max = max; }
691e144e-37ee-4e57-8c5b-74578efd0289
public String getNazivSpremista() { return nazivSpremista; }
a2617cef-ecef-43b1-a65c-1e7aeb52484e
public void setNazivSpremista(String nazivSpremista) { this.nazivSpremista = nazivSpremista; }
c52bf4f4-b5fe-4d8d-bda2-53fa9ffb27d4
public Cache getC() { return c; }
b0f2bdd0-2bec-4b60-8ab3-1aee0efa9f09
public void setC(Cache c) { this.c = c; }
b26d8595-4e8a-447a-8168-3a673aed8024
public int getInterval() { return interval; }
6cb6c3c0-5694-4dcc-98b7-f39e25559eee
public void setInterval(int interval) { this.interval = interval; }
9fc95bd8-6af0-4cf0-8ee1-c86bf1136fa3
public boolean isOcisti() { return ocisti; }
5cb99a1c-14c5-4e03-a35e-6103e0f638c9
public void setOcisti(boolean ocisti) { this.ocisti = ocisti; }
c6f5a5f2-d010-4056-99e8-4042ed5fe183
public int getOgranicenje() { return ogranicenje; }
1e305f4d-e50b-4125-a86f-b36a7d47ad53
public void setOgranicenje(int ogranicenje) { this.ogranicenje = ogranicenje; }
f350e102-6262-49dc-92a5-9cef7af2c48e
public boolean isKb() { return kb; }
7e1bd684-cc93-4e5e-b1da-393a39a20e9c
public void setKb(boolean kb) { this.kb = kb; }
ba8558c9-7726-417b-b5dd-8c6e590cd202
public boolean isStrategija() { return strategija; }
4575de98-f34c-457f-8637-d1761c6ff635
public void setStrategija(boolean strategija) { this.strategija = strategija; }
4726d67d-7c24-4f0a-84b5-3b29cda5ebb2
public View(Model model) { this.m = model; }
9a454b64-ecd7-40ba-8cfb-e13732acb676
public void ispisiUpute() { System.out.println("----------KOMANDE-------------"); System.out.println("-I - ispis adresa poveznica s rednim brojem"); System.out.println("-J n - prijelaz na poveznicu s rednim brojem n te ucitavanje web stranice"); System.out.println("-S - prikaži sadrzaj s...
43220b83-c3de-452e-a6cc-7614c3f3983d
public void ispisPoveznica() { m.dohvatiListupoveznica(); System.out.println("---------POVEZNICE-------------"); ispisiLinije(m.getMax()); for (int i = 0; i < m.getWebStranica().getListaURLa().size(); i++) { System.out.print("| " + (i + 1) + "."); ispisipraznineBr...
92c3fbf0-47b1-42c8-8a03-e877b113523d
public void ispisiLinije(int broj) { for (int a = 0; a < broj + 12; a++) { System.out.print("-"); } System.out.println(""); }
f76f0bae-5baf-4f53-b0d9-e9751978b0da
public void ispisipraznineURLa(int broj) { for (int a = 0; a < broj; a++) { System.out.print(" "); } System.out.println(" |"); }
b3d5c637-e278-4306-8eaf-6e328e9f52d7
public void ispisipraznineBroja(int broj) { for (int a = 0; a < broj; a++) { System.out.print(" "); } }
2836cb89-fea4-4b38-99f7-65937201675d
public void novaStranica(String redniBroj) { m.promjeniStranicu(redniBroj); System.out.println("---------------Nova stranica------------"); System.out.println(Ztintor_zadaca_4.pocetniLink.toString()); }
9778806f-173c-4851-8e0e-2d2a0105394d
public void ispisiStatistiku() { Resource r; System.out.println("--------------STATISTIKA--------------"); System.out.println(m.getNazivSpremista()); for (int i = 0; i < cac.getLista().size(); i++) { r = (Resource) cac.getLista().get(i); if (r.isSpremljen()) { ...
dc4c96f3-8268-4165-aaa8-a0987f704913
public void izadi() { System.out.printf("Serijalizirani podatci spremljeni u: " + m.getNazivSpremista() + "\\serijalizacija.ser"); m.serijaliziraj(); }
81759458-4f06-443c-9c32-15f488c61f1a
public void brisiNaZahtjev() { m.setOcisti(true); m.brisiSpremiste(); System.out.println("Obrisano spremiste " + m.getNazivSpremista()); }
90998cb3-7542-4c6d-8ea3-7d303c8716c3
public Cache getCac() { return cac; }
a7ca1b17-4bf9-47e4-a114-3364e5e73c7e
public void setCac(Cache cac) { this.cac = cac; }
f7e684ea-7c8c-4852-97cc-bc4a89a3b627
@Override public void update(Observable o, Object arg) { System.out.println(arg); }
2d81bd6c-cc5a-436a-9d0b-121cfff2db0b
public Controller(View view) { this.v = view; }
9758108d-6178-4895-bc9a-f724d228644f
public void provjeriUnos() { Console c = System.console(); if (c == null) { System.exit(1); } v.ispisiUpute(); petlja = true; while (petlja) { input = c.readLine(); String split[] = input.split(" "); switch (split[0]) { ...
343b8835-176c-4280-90c8-c8629cdf4517
public Board(int width, int height) { this.width = width; this.height = height; starfield = new Starfield(this.width, this.height, 50); // Start listening for key input addKeyListener(new TAdapter()); // Prepare JPanel setFocusable(true); setDoubleBuffered(true); setBackground(Color.black);...
d4c8ae0f-1d5b-4b66-8dd7-dfea48352e4f
private void loadResources() { ClassLoader classLoader = getClass().getClassLoader(); // Load images rock32Image = new ImageIcon(classLoader.getResource("resources/asteroid2-32.png")).getImage(); rock48Image = new ImageIcon(classLoader.getResource("resources/asteroid2-48.png")).getImage(); rock64Image = ne...
0ba66e62-cf52-41e0-9156-338852d85d10
private void resetGame() { // Reset movements moveLeft = false; moveRight = false; moveUp = false; moveDown = false; isFiring = false; enterPressed = false; // Re-created game objects ship = new Ship(shipImage, shipBounds, width, height); rocks = new ArrayList<Rock>(); bullets = new ArrayList<B...
0d0632d0-0dab-4d37-a0b2-418ce525b637
private void doLogic() { starfield.doLogic(); if(gameState == 0) { // Main Menu doMenuLogic(); } else if(gameState == 1) { // Game Play doGameLogic(); } else { // Game Over doGameOverLogic(); } }
94086911-d910-4a5d-84a4-9110bc6fe493
private void doMenuLogic() { if(menuControlsBuffer.isEmpty()) { return; } int key = 0; try { key = menuControlsBuffer.dequeue(); } catch (InterruptedException e) { e.printStackTrace(); } if(key == KeyEvent.VK_UP) { if(selectedMenuItem == 0) { selectedMenuItem = 2; } else { ...
5f661682-c236-4600-90f8-cf687ed461a8
private void doGameLogic() { handleObjectCreations(); handleObjectMovements(); handleObjectCollisions(); handleObjectEndings(); handleExplosions(); }
1acb8c81-f7d8-49b9-8077-197d1fc8a306
private void handleObjectCreations() { Date now = new Date(); // Create new rock if possible if(now.getTime() - lastRockCreatedAt.getTime() > rockCreatingRate) { int rnd = GameObject.randomWithRange(2, 4); Image imageToPass = null; ObjectBounds boundsToPass = null; if(rnd == 2) { imageT...
06c5c969-7877-435f-bcb1-7df7a521a57e
private void handleObjectMovements() { for(Rock rock : rocks) { rock.advanceY(Direction.DOWN); } for(Bullet bullet : bullets) { bullet.advanceY(Direction.UP); } if(moveUp) { ship.advanceY(GameObject.Direction.UP); } if(moveDown) { ship.advanceY(GameObject.Direction.DOWN); } if(...
0bebecbd-16c4-4b3c-b8a3-1ef338cfb7b3
private void handleObjectCollisions() { for(Rock rock : rocks) { if(rock.getBounds().isInside(ship.getBounds())) { // Collision with ship detected gameState = 2; break; } for(Bullet bullet : bullets) { if(rock.getBounds().isInside(bullet.getBounds())) { rocks.remove(rock); bulle...
60455845-a7ca-4ee3-bf1a-d6bd1afbb1d6
private void handleObjectEndings() { for(Rock rock : rocks) { if(rock.isOutsideScreen(Direction.DOWN)) { rocks.remove(rock); handleObjectEndings(); return; } } for(Bullet bullet : bullets) { if(bullet.isOutsideScreen(Direction.UP)) { bullets.remove(bullet); handleObjectEndings(); ...
8f173001-828a-428a-aacb-33e4d846a6e9
private void handleExplosions() { handleExplosionRemoval(); for(Explosion explosion : explosions) { explosion.stepInto(); } }
a71c7074-b227-4349-9d6b-e92743d4a1bc
private void handleExplosionRemoval() { for(Explosion explosion : explosions) { if(explosion.isDone()) { explosions.remove(explosion); handleExplosionRemoval(); return; } } }
87f8a4c3-13c7-4d80-9695-98ca1cd458a2
private void doGameOverLogic() { if(enterPressed) { resetGame(); gameState = 1; } }
da434900-a618-4c53-bbeb-93e654b9bc7a
@Override public void paintComponent(Graphics g) { super.paintComponent(g); starfield.draw(g); //g.drawImage(backgroundImage, 0, 0, width, height, null); if(gameState == 0) { // Main Menu paintMenu(g); } else if(gameState == 1) { // Game Play paintGame(g); } else { // Game Over paintGame(...
20e3269b-a005-4734-be67-866a9f6f9869
private void paintMenu(Graphics g) { String menuStartName= "START"; Rectangle2D menuStartBounds = g.getFontMetrics().getStringBounds(menuStartName, g); String menuSettingsName = "SETTINGS"; Rectangle2D menuSettingsBounds = g.getFontMetrics().getStringBounds(menuSettingsName, g); String menuExitName = "QUIT...
e1ea3cc7-0bd1-40f2-b6f0-364b45834693
private void paintGame(Graphics g) { for(Rock rock : rocks) { Image img = null; if(rock.getType() == GameObject.Type.ROCK32) { img = rock32Image; } else if(rock.getType() == GameObject.Type.ROCK48) { img = rock48Image; } else if(rock.getType() == GameObject.Type.ROCK64) { img = rock64Image...
9941d058-8feb-4f6e-8111-12733214b708
private void paintGameOver(Graphics g) { g.setColor(Color.WHITE); g.setFont(new Font("Helvetica", Font.PLAIN, 48)); String gameOverText = "GAME OVER"; Rectangle2D gameOverBounds = g.getFontMetrics().getStringBounds(gameOverText, g); int startX = (int)((width / 2) - (gameOverBounds.getWidth() / 2)-2);...
a91bc0d9-34fc-4da4-9b34-0ea8b71e606d
@Override public void actionPerformed(ActionEvent e) { Date loopStart = new Date(); doLogic(); repaint(); Date loopEnd = new Date(); if(gameTicks.size() < 30) { gameTicks.add(loopEnd.getTime() - loopStart.getTime()); } else { Long total = new Long(0L); for(Long one : gameTicks) { ...
187dd206-fbc0-4b61-895d-f279db13bddd
@Override public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if(gameState == 0) { // Main Menu menuControlsBuffer.enqueue(key); return; } if(key == KeyEvent.VK_LEFT) { moveRight = false; moveLeft = true; } else if(key == KeyEvent.VK_RIGHT) { moveLeft = false;...
22494799-f915-4cc6-9c15-5b8d65e4d9a3
@Override public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); if(key == KeyEvent.VK_LEFT) { moveLeft = false; } else if(key == KeyEvent.VK_RIGHT) { moveRight = false; } else if(key == KeyEvent.VK_UP) { moveUp = false; } else if(key == KeyEvent.VK_DOWN) { moveDown = f...
3013aa5a-3ea3-4c04-9375-619181a35866
public Starfield(int width, int height, int density) { this.width = width; this.height = height; this.density = density; this.stars = new ArrayList<Star>(); for(int i = 0; i < density; i++) { this.stars.add(Star.createRandomWithin(width, height)); } }
7c850984-3536-4b63-9bf5-190e901570af
public void doLogic() { handleStarCreation(); handleStarMovement(); handleStarRemoval(); }
97fe86fb-f012-4d4b-897c-b98962d450c1
public void handleStarCreation() { for(int i = stars.size(); i < density; i++) { stars.add(Star.createRandomWithin(width, 5)); } }
8885d2fa-dac1-4e6c-b223-fbde150fcc50
public void handleStarMovement() { for(Star star : stars) { star.move(); } }
2922d10d-8c86-46d2-b1d0-6e725f69a03b
public void handleStarRemoval() { for(Star star : stars) { if(star.isOutside(width, height)) { stars.remove(star); handleStarRemoval(); return; } } }
2d509649-f109-4283-aea0-81f0e6a84223
public void draw(Graphics g) { for(Star star : stars) { g.setColor(Color.WHITE); g.fillOval(star.getX(), star.getY(), star.getSize(), star.getSize()); //g.drawLine(star.getX(), star.getY(), star.getX(), star.getY()); } }
272968b8-2300-4467-b2d0-cd3190eb3835
public static final byte[] fileToByteArray(URL fileUrl) { try { // Create instances to start reading File file = new File(fileUrl.toURI()); FileInputStream fileInputStream = new FileInputStream(new File(fileUrl.toURI())); // Create a temporary byte array byte[] tmpByteArray = new byte[(int)file.len...
81aeb68a-c0cc-4606-a959-1c2a8aa8cbb8
public static final void playSoundFromByteArray(byte[] soundBytes) { try { // Open an audio input stream from the soundBytes array AudioInputStream inputStream = AudioSystem.getAudioInputStream(new ByteArrayInputStream(soundBytes)); // Create a sound clip from the audio input stream, and play the sound ...
1a5a8a25-5e45-49bd-ad53-b3b4c6a92f00
public ObjectBounds(ArrayList<Point> points) { this.points = points; }
084e1b55-b622-4b56-a6dc-de219a225bd4
public void setXElevation(int xElevation) { this.xElevation = xElevation; }
c97ff733-9717-4690-9993-0994d34be3ea
public int getXElevation() { return this.xElevation; }
ef872439-4abe-4f2b-9cd7-a04e9f156d4b
public void setYElevation(int yElevation) { this.yElevation = yElevation; }
fb32622d-999f-44d2-b791-4e9acc0dbc58
public int getYElevation() { return this.yElevation; }
80748019-cc12-44dd-b627-b19bebf2d5d0
public void setElevation(int xElevation, int yElevation) { this.xElevation = xElevation; this.yElevation = yElevation; }
e88c3daa-a69a-49f0-b27b-0a11dea2edee
public ArrayList<Point> getPoints() { return this.points; }
42a02231-cd8d-4857-a2a7-7a9ddd364e63
public boolean isInside(ObjectBounds objectBounds2) { for(Point point : points) { for(Point point2 : objectBounds2.getPoints()) { if(point.getX() + xElevation == point2.getX() + objectBounds2.xElevation) { if(point.getY() + yElevation == point2.getY() + objectBounds2.yElevation) { return true; ...
29744373-a2ea-4f5b-adc1-e2ee11d37581
public static ObjectBounds parseFromFile(URL fileUrl) { try { ArrayList<Point> points = new ArrayList<Point>(); BufferedReader bReader = new BufferedReader(new InputStreamReader(fileUrl.openStream())); String fileContent = bReader.readLine(); String[] rawPoints = fileContent.split("\\|"); f...
bee90fa2-e741-4cff-9215-ef018a5fdea5
public Object clone() { try { return super.clone(); } catch(Exception ex) { ex.printStackTrace(); } return null; }
f330016e-53f8-4ad2-b8e1-22960cdb60cc
public Ship(Image image, ObjectBounds bounds, int panelWidth, int panelHeight) { setPanelSize(panelWidth, panelHeight); setType(GameObject.Type.SHIP); setImage(image); setBounds(bounds); setSizeByImage(); setSpeed(5); // Position the spaceship at the bottom center of the screen setX((int)((pane...
6dd4b033-4bd0-4a32-a0e1-d810b114620c
public Star() { this(0, 0, 1, 1); }
10bf6f45-d222-4b70-9b1a-71542d9db688
public Star(int x, int y, int size, int speed) { this.x = x; this.y = y; this.size = size; this.speed = speed; }
44610193-e2f5-4668-8c88-6f073bbe6e9e
public int getX() { return this.x; }
aceb10ff-8c90-4391-b9b6-612683ffc87c
public void setX(int x) { this.x = x; }
e8308f68-233b-4ecd-bfa1-af375aa66825
public int getY() { return this.y; }
0d51a8b1-5434-47ae-a03d-7a572b539bb7
public void setY(int y) { this.y = y; }
97125d6e-5743-4ba7-8519-3c65174c6f67
public int getSize() { return this.size; }
5ef04ff6-210b-43a3-9685-d319c4565cd9
public void setSize(int radius) { this.size = radius; }
f30fedcc-4be3-4dd3-842c-9d838fbd6a91
public int getSpeed() { return this.speed; }
101a0d09-1e22-4c01-99c3-0066334c16e7
public void setSpeed(int speed) { this.speed = speed; }
458f9019-9d61-406e-938d-2dccf36daba9
public void move() { this.y += speed; }
0b150adf-4c62-4976-b2df-75710d3f95cc
public boolean isOutside(int width, int height) { if(this.y > height) { return true; } return false; }
3bbf65f7-3b6f-4d48-8204-c11930d2192b
public static Star createRandomWithin(int width, int height) { int ranRadius = GameObject.randomWithRange(1, 2); int ranX = GameObject.randomWithRange(0, width-1-(ranRadius*2)); int ranY = GameObject.randomWithRange(0, height-1-(ranRadius*2)); int ranSpeed = ranRadius; return new Star(ranX, ranY, ranRadius...
7994eb4d-0584-4764-a00f-50409a611602
public Spaceship() { setTitle("Spaceship Game by Erik Kralj"); setSize(WIDTH, HEIGHT); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); add(new Board(getContentPane().getWidth(), getContentPane().getHeight())); }
c8401844-f2bb-4884-9d93-d824dcfc3447
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { new Spaceship(); } }); }
fb345b95-77f9-4540-9463-4d7f2dec55a0
@Override public void run() { new Spaceship(); }
83715a06-a510-435c-b984-42cde58b2c21
public Explosion(int locationX, int locationY, int size) { this.locationX = locationX; this.locationY = locationY; this.size = size; }
80e5889a-be24-4283-8bb2-e1e1afbc1c9e
public int getX() { return this.locationX; }
3535a102-2f32-4e6d-80b6-accc3f4c6a05
public int getY() { return this.locationY; }
62d8fcf8-e4c9-43e5-82e9-699c2fc8bb3d
public int getSize() { return this.size; }
9f893dc5-4488-4f27-bbc9-29c6cfc336b6
public boolean isDone() { return this.done; }
0736f406-7e4f-4bfb-b8c3-9c48a111563f
public void stepInto() { if(animationStep == animationStopAt) { done = true; return; } animationStep++; }
d730ca20-ef4d-49e9-92ab-16feb2933681
public int getAnimationStep() { return this.animationStep; }
dfce595f-96b2-467b-8a11-607d0e33dc38
public Rock(int type, Image image, ObjectBounds bounds, int panelWidth, int panelHeight) { setPanelSize(panelWidth, panelHeight); setType(GameObject.Type.values()[type]); setImage(image); setBounds(bounds); setSizeByImage(); setSpeed(3); setX(GameObject.randomWithRange(0, panelWidth - getWidth())); setY...
12908fba-c071-4783-8552-c97879482916
public Bullet(int locationX, int locationY, int panelWidth, int panelHeight, Image image, ObjectBounds bounds) { setPanelSize(panelWidth, panelHeight); setType(GameObject.Type.BULLET); setX(locationX); setY(locationY); setImage(image); setBounds(bounds); setSizeByImage(); setSpeed(8); getBounds().setE...
55815a3c-7dbf-4a6a-a636-7e7b3999b742
public Type getType() { return this.type; }
726711f2-09cb-45c2-905e-2943e0b3c87e
public void setType(Type type) { this.type = type; }
8805e3bd-7c6c-48e2-be17-d3ac1d043e10
public int getX() { return this.x; }
587a5223-823a-4a7c-8f5a-ff58699d19ff
public void setX(int x) { this.x = x; }