id
stringlengths
36
36
text
stringlengths
1
1.25M
725eff3f-e531-4c63-940d-64dca72e83dd
public Date getModificationDatetime() { return modificationDatetime; }
9309d67c-8f64-437d-a034-8badf673976e
public void setId(int id) { this.id = id; }
e6e6f258-01e9-42fe-be8d-757b850895ac
public void setDeleted(boolean deleted) { this.deleted = deleted; }
f2198206-6cfb-42ac-9775-02ec5884e8b7
public void setCreationDatetime(Date creationDatetime) { this.creationDatetime = creationDatetime; }
8fdf05f6-5ea2-456c-8873-900d840ed1b5
public void setModificationDatetime(Date modificationDatetime) { this.modificationDatetime = modificationDatetime; }
2c0cd95b-abc9-4eff-b903-6be1d155f5f0
public String getTitle() { return title; }
7c225398-d331-4afd-bf8d-02770fe3b32a
public String getContent() { return content; }
e298b704-335e-4f20-8e3a-035c3a9cd8be
public void setTitle(String title) { this.title = title; }
791c5ceb-a5a2-42b2-9f08-584b6cf4ab53
public void setContent(String content) { this.content = content; }
59ec2250-31af-40c3-a806-3886d1f62fb4
public List<Post> findAll(){ return postMapper.findAll(); }
d73683aa-87d4-4d02-bbfe-6c6546dbbbeb
@RequestMapping("/") public String index(ModelMap model) throws Exception { model.addAttribute("posts", postService.findAll()); return "post/index"; }
2fc4d108-1984-421e-91c0-51230eb4ed7d
public WarGame(){ //create both half decks from the getDeck method player1deck = deck.getDeckOne(); player2deck = deck.getDeckTwo(); JFrame window = new JFrame(); window.setLayout(new BorderLayout()); window.setTitle("Let's play war!"); ...
14456a23-17ba-41e3-956f-0a6053eb66c7
public void buttonPanel(){ flipButton.setText("Flip next Card"); flipButton.addActionListener(new FlipButtonListener()); quitButton.setText("Quit Game"); quitButton.addActionListener(new QuitButtonListener()); resetButton.setText("Reset Game"); ...
0f1ac98d-3dcb-4cdf-ac4c-93e94ae77dc6
public void playerOnePanel(){ player1.setText("Player 1"); panel = new JPanel(); panel.setLayout(new GridLayout(2,1)); back1.setIcon(backside); panel.add(back1); panel.add(player1); }
e526740b-82f3-4f15-94f2-fa5916a69922
public void playerTwoPanel(){ player2.setText("Player 2"); panel = new JPanel(); panel.setLayout(new GridLayout(2,1)); back2.setIcon(backside); panel.add(back2); panel.add(player2); }
baa685f9-c352-4475-b4ea-56cf07fcb232
public void cardImagePanel(){ panel = new JPanel(); panel.setLayout(new GridLayout(2,2)); panel.setPreferredSize(new Dimension(500,500)); cardOne.setIcon(player1Card); cardTwo.setIcon(player2Card); panel.add(cardOne); panel.add(cardTwo); ...
4828eacb-ad08-4696-b98b-5f6312bc0931
public void actionPerformed(ActionEvent e){ //take next Card from array of Cards playerOneFlip = player1deck.get(0); playerTwoFlip = player2deck.get(0); player1deck.remove(0); player2deck.remove(0); // set String image to name...
b58bd374-bf8d-43d5-a05a-70f3233d7973
public void actionPerformed(ActionEvent e){ System.out.println("Thanks for playing!"); System.exit(0); }
8c066dcd-7cf9-400b-a66f-65dc8f972553
public void actionPerformed(ActionEvent e){ deck = new DeckBuild(); player1deck = deck.getDeckOne(); player2deck = deck.getDeckTwo(); image1 = ""; image2 = ""; player1Card = new ImageIcon(image1); ...
f8123a66-9a1d-4d1a-90ae-1a9e63cd8690
public static void main(String[]args){ WarGame gameBoard = new WarGame(); }
cbff76f2-7cb0-4257-8ecb-d5087ec6a26a
public DeckBuild(){ for(int r = 0;r < 13;r++){ for(int s = 0;s < 4;s++){ rank = r+1; suit = s+1; deck.add(new Card(suit,rank)); } } for(int j = 0;j < deck.siz...
d35ec2f2-1998-4726-b34c-f7e8bf781a4c
public ArrayList<Card> getDeckOne(){ return deckHalfOne; }
236dcaff-fa9a-4204-ac0f-3748dfecd523
public ArrayList<Card> getDeckTwo(){ return deckHalfTwo; }
290daeb4-307d-4d3d-99ee-e97466c453fe
public ArrayList<Card> shuffle(ArrayList<Card> deck){ for(int h = 0; h < deck.size();h++){ int randPos = rand.nextInt(deck.size()); Card temp = deck.get(h); this.deck.set(h,deck.get(randPos)); this.deck.set(randPos,temp); ...
e401e8b5-0e67-4703-ba03-d57eeb2a3de6
public Card(int suitIn, int rankIn){ suit = suitIn; rank = rankIn; }
9ec2d38c-6867-4d85-a362-22d81baf8ed9
public int getSuit(){ return suit; }
201f3be3-baa8-4b72-b2d6-023dd136b50e
public int getRank(){ return rank; }
82b2b03d-5bd2-423c-b6f1-d14f3f44b773
public String toString(){ String outputString = ""; String rankString = ""; String suitString = ""; switch(rank){ case 1: rankString = "Ace"; break; case 2: rankString = "Two"; break; case 3: ran...
26e0064b-8d75-40e2-a072-afa11a6de253
public boolean equals(Card otherCard){ if(otherCard.rank == this.rank){ return true; } else return false; }
d1b16433-2815-47b1-b54a-258638ce5b99
public boolean lessThan(Card otherCard){ if(otherCard.rank > this.rank){ return true; } else return false; }
128e19c3-ac85-49f8-adb7-20e1312f71cf
public boolean greaterThan(Card otherCard){ if(otherCard.rank < this.rank) return true; else return false; }
3c219acd-8b5e-44f7-a70f-b323de3b4751
public String getCardFile(){ switch(rank){ case 1: fileRank = "ace"; break; case 2: fileRank = "2"; break; case 3: fileRank = "3"; break; case 4: fileRank = "4"; br...
61b651d6-c8d4-4f72-8321-1245c6981ba2
abstract boolean equals(Card a);
a06cc1bd-3c95-4373-80ee-73e42327a00c
abstract boolean greaterThan(Card b);
fa45ce47-560a-41cd-b054-871b250712ea
abstract boolean lessThan(Card c);
510d7267-60a2-4726-b39a-63b3f6ceb059
public TimeClient() throws UnknownHostException, IOException { this.cliSock = new Socket(SERVER,SERVER_PORT); }
07ee09aa-51b3-4643-b518-92cdbccb21ee
public static void main(String[] args) throws UnknownHostException, IOException { System.out.println("Enter date: "); TimeClient client= new TimeClient(); InputStream input = System.in; InputStreamReader inputStreamReader = new InputStreamReader(input); BufferedReader in = new BufferedReader(inputStreamReade...
933ba2f1-9135-488d-b825-a9925a8092d2
public void send(String mess) throws IOException{ OutputStream outStream = cliSock.getOutputStream(); PrintWriter out = new PrintWriter(outStream); out.println(mess); out.flush(); }
e68fe244-5b9a-4e47-af8b-b66d14aa6b1a
public String getMessage() throws IOException{ InputStream inputStream = cliSock.getInputStream(); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader in = new BufferedReader(inputStreamReader); String response = in.readLine(); cliSock.close(); return response; }
f6fb58a3-5034-4b8d-9e64-4df85cb9c54b
public ClientHandler(Socket socket) { this.cliSock = socket; }
4a920f95-6787-4759-9cad-06f0f8b499a4
@Override public void run() { try{ handleClient(); }catch(IOException e){ e.printStackTrace(); } }
6ca946c6-49ab-468e-a398-3a6137e65e2b
private void handleClient() throws IOException{ InputStream inStream = cliSock.getInputStream(); OutputStream outStream = cliSock.getOutputStream(); InputStreamReader inputStreamReader = new InputStreamReader(inStream); BufferedReader in = new BufferedReader(inputStreamReader); PrintWriter out = new...
040f2198-bac6-488a-a5cc-0548b17fc121
public static void main(String[] args) throws IOException{ System.out.println("The server is started..."); new TimeServer().run(); }
20382434-d6e8-4ed3-b42d-52ce1b2cb21e
public void run() throws IOException{ ServerSocket sc = new ServerSocket(SERVER_PORT); int i=0; while(i<5){ i++; final Socket clientSock = sc.accept(); new ClientHandler(clientSock).start(); } sc.close(); }
fa11f719-4f51-4104-87c0-eccac31c4058
public String getStatusLine() { return statusLine; }
4060876b-d750-4b51-8d50-9d9ff09067b4
public void setStatusLine(String statusLine) { this.statusLine = statusLine; }
79f61788-22a1-4f73-985f-afadbd50f308
public List<HttpHeader> getHeaders() { return headers; }
a8ca7495-5dbd-40d6-8ad8-c2b739644db8
public char[] getBody(BufferedReader in) throws IOException { if (body == null) { body = new char[getContentLength()]; } in.read(body); return body; }
323c496f-cf04-4bc9-bcbd-4f9ae63891b1
private int getContentLength() { for (HttpHeader next : headers) { if (next.getName().toLowerCase().equals(HEADER_CONTENT_LENGTH)) { final int result = Integer.parseInt(next.getValue()); return Math.min(MAX_REQUEST_SIZE, result); } } return 0; }
8b2165d2-e173-45fa-b452-e215b9a9e687
public static void main(String[] args) throws UnknownHostException, IOException { final HttpGet example = new HttpGet(); boolean quit = false; final InputStream inputStream = System.in; final InputStreamReader inputStreamReader = new InputStreamReader(inputStream); final BufferedReader in = new Buf...
4714d676-3386-4e45-900b-d5b768551a1e
public boolean createRequest(String host, String method, String path) throws UnknownHostException, IOException{ Socket clientSocket = new Socket(host, HTTP_PORT); final InputStream inputStream = clientSocket.getInputStream(); final OutputStream outputStream = clientSocket.getOutputStream(); final InputStr...
02f158a2-a582-4dda-b91f-92100648dfbc
private boolean parseResponse(BufferedReader in) throws IOException{ final HttpResponse result = new HttpResponse(); String statusline = in.readLine(); result.setStatusLine(statusline); Pattern p = Pattern.compile("\\d\\d\\d"); Matcher m = p.matcher(statusline); while(m.find()){ int statuscode = I...
50571bb7-7c45-4e92-860d-a1476b9ca5e7
private void writeRequest(PrintWriter out, String host, String method, String path){ out.printf("%s %s %s\n", method, path, HTTP_VERSION); out.printf("Host: %s\n", host); out.printf("\n"); }
6c525d2a-3bb3-4251-bd17-781e74e85970
public static HttpHeader createFromHeaderLine(String headerLine) { final Pattern p = Pattern.compile("([^:]+):\\s?(.+)"); final Matcher m = p.matcher(headerLine); if (!m.matches()) { throw new IllegalArgumentException( "Header line must be properly formatted, not " + headerLine); } return new HttpHea...
9fec0423-a52d-4277-82df-8883820ac3da
public HttpHeader(String name, String value) { if (name == null || value == null) { throw new IllegalArgumentException( "Name or value is not set: " + name + ", " + value); } this.name = name; this.value = value; }
39835919-0fb2-4ecc-915e-750d4b5d35ad
public String getName() { return name; }
4f530cfa-7858-4af0-ba6e-bf113b49f8a5
public String getValue() { return value; }
d07f2991-592c-42c4-a8bc-a71fb0d641f6
public static void main(String[] args) throws IOException { InputStream input = System.in; final InputStreamReader inputStreamReader = new InputStreamReader(input); final BufferedReader reader = new BufferedReader(inputStreamReader); String line; while( !(line = reader.readLine()).equals("end")) { Syste...
01313d8a-ce11-413f-84fd-69655dc7f5bf
public static void main(String[] args) { final Map<String, Integer> m = new HashMap<String, Integer>(); m.put(KEY_BULGARIA, 7); m.put(KEY_GERMANY, 80); m.put(KEY_GREECE, 7); m.put(KEY_NETHERLAND, 10); m.put(KEY_RUSSIA, 145); m.put(KEY_FRANCE, 60); for(String key : m.keySet()){ if(m.get(key) > 1...
da6e424e-9cca-40e0-89c3-1068b2eb8a7d
public static void main( String[] args ) { System.out.println( "Hello World!" ); }
3a8b65b2-2ad1-43c9-9dbf-4f7fa192daa7
public CuentaAtras (String id, int inicio){ IDThread=id; init=inicio; }
f5b78125-0ca3-4521-b749-41908febfbd2
public synchronized void UltimaEscritura(){ System.out.println(IDThread+" - "+init+" - última escritura: "+UltimaEscritura); UltimaEscritura=IDThread; }
013a441e-dc79-4275-b8cd-3101ebaf389f
public void run() { try{ while(init!=0){ UltimaEscritura(); Thread.sleep(1000); init--; } numThreads=Thread.activeCount(); System.out.println("Ultima escritura "+IDThread+" - "+numThreads+" Threads Activos."); }catch(InterruptedException ie){ ie.printStackTrace(); } }
c343db56-591b-4bb8-9b1c-41d17c4361d6
public static void main(String args[]) { try{ //instanciamos los Threads de la subclase Threads CuentaAtras contador1 = new CuentaAtras("ID1", 4); CuentaAtras contador2 = new CuentaAtras("ID2", 7); CuentaAtras contador3 = new CuentaAtras("ID3", 8); //Instanciaos los Threads de la interfaz Runnable new Thr...
154947ce-f48f-42ca-ab93-460dc6dabeaa
public AppTest( String testName ) { super( testName ); }
718f741b-b232-4d4f-b10c-f030288c26ee
public static Test suite() { return new TestSuite( AppTest.class ); }
61a5f595-f73c-4c8b-8bf6-02758194d919
public void testApp() { assertTrue( true ); }
0923e5b3-8eb8-4bb0-8ebb-f6dff490ead6
public CuentaAtrasR (int init){ inicial=init; }
100ffd1e-5b8c-4e66-8edf-46447de7911d
public synchronized void UltimaEscritura(){ System.out.println(Thread.currentThread().getName()+" - "+inicial+" - última escritura: "+UltimaEscritura); UltimaEscritura=Thread.currentThread().getName(); }
517fd59a-778b-4c07-b274-cc7e02ceb989
public void run() { try{ while(inicial!=0){ UltimaEscritura(); Thread.sleep(1000); inicial--; } numThreads=Thread.activeCount(); System.out.println("Ultima escritura "+Thread.currentThread().getName()+" - "+numThreads+" Threads activos."); }catch(InterruptedException ie){ ie.printSt...
2a5ed82e-d142-4b90-afbd-5d669e93231b
public static void main(String[] args) { int number = DEFAULT_NUMBER; int range = DEFAULT_RANGE; int experiments = DEFAULT_EXPERIMENTS; int lookFor = -1; int[] randomnumbers; // Read args try { if (args.length > 0) number = Integer.getInteger(args[0]); if (number < 0) throw new Exception(...
480b1187-3357-4ec8-80ee-b0e2a3deff49
private static String runAndPrintSearch(Search search) { Result result = search.run(); StringBuilder sb = new StringBuilder(); sb.append("A search was conducted using : " + search.getName() + "\n"); sb.append("looked for: " + result.getLookedFor()); if (result.getPosition() >= 0) { sb.append(" position: "...
d864ef32-eb9f-4fbc-9b8d-a50bc63b246d
public InterpolationSearch(int[] list, int lookFor, int range) { super(list, lookFor, range); }
f2195d51-6f4c-47f3-b330-45ffe4080557
@Override public int search(int l, int r) { if (l <= r) { _count++; int k = interpolatePosition(l, r); int locelem = getElement(k); if (locelem == _element) { _count++; return k; } else { _count += 2; if (locelem > _element) { return search(l, k - 1); } else { return sear...
97c14827-7e3a-4e34-ae7a-ff8c00536279
@Override public String getName() { return "interpolation search"; }
48ef36e9-dd2e-4f34-987a-7fb55223e528
public Result(int position, int comparrisons, int lookedFor, int actual) { _lookedFor = lookedFor; _actual = actual; _position = position; _comparissons = comparrisons; }
5d4eaf15-8d15-4b76-b289-57ada8f701ae
public int getComparissons() { return _comparissons; }
b0eec70d-767b-492d-999c-b465199693af
public int getPosition() { return _position; }
15b124b6-0da4-4006-9e6c-2bb54a6df6fe
public int getLookedFor() { return _lookedFor; }
a8a34c27-bdd8-4cfb-ac87-30b523e9c21f
public int getActual() { return _actual; }
cfc18acc-cea3-4224-949f-ca9c59ce46c5
public Search(int[] list, int lookFor, int range) { _list = list; _element = lookFor; _range = range; }
9861d2d1-66f8-45cc-a19b-2d9865b56ada
public Result run(){ _count = 0; int position = search(0, _list.length-1); return new Result(position, _count, _element, position >= 0 ? _list[position] : -1); }
63b145c9-9b72-4637-be2a-8175b9c7db72
public abstract int search(int l, int r);
c19f9b68-05c1-46ab-94f3-fbb8a63121ab
protected int interpolatePosition(int l, int r) { Double divisor = new Double(_element - getElement(l)); Double dividend = new Double(getElement(r) - getElement(l)); return Math.min(_list.length-1, l + (int) (divisor / dividend * (r-l))); }
e74ef3a5-194f-4c46-b879-29667f19a6c6
protected int getElement(int index){ if (index < 0) return 0; else if (index >= _list.length) return _range; return _list[index]; }
406fdccc-4a11-444e-9eaa-642f65ee5fa8
public abstract String getName();
b91f6aba-fd9d-4c84-b062-eee9873219dd
public QuadraticBinarySearch(int[] list, int lookFor, int range) { super(list, lookFor, range); }
32c46ba3-f3e6-4ca6-ac3e-235be69bf96d
@Override public int search(int l, int r) { if (l <= r) { _count++; int k = interpolatePosition(l, r); int locelem = _list[k]; if (locelem == _element) { _count++; return k; } else { int m = (int) Math.ceil(Math.sqrt(r - l + 1)); int i = 1; _count += 2; if (locelem > _element) ...
30a59357-1770-488e-8678-3c5c940ba873
@Override public String getName() { return "quadratic binary search"; }
16e85c69-2d28-4fb6-9c8d-c2f4900b7c27
public Gallery(HashMap filesMap) { this.filesMap = filesMap; }
5c32933c-6fec-4506-aabf-32df919b6151
synchronized File lockPicture() throws InterruptedException { return hasState("raw"); }
8c68d59d-cec1-4246-993c-0c2c757e0ab6
synchronized void unlockPicture(File key) throws InterruptedException { filesMap.put(key, "resized"); notifyAll(); }
1a585754-af03-4c24-9d85-0627a4c33ad7
synchronized File hasState(String state) { synchronized (filesMap) { for (File f : filesMap.keySet()) { if (filesMap.get(f).equals(state)) { filesMap.put(f, "processing"); return f; } } return null; ...
6c5dbb65-7930-4c59-bf5d-2136f6e4529d
public void addPanel() { JTextField readField = new JTextField(5); JTextField writeField = new JTextField(5); JComboBox res = new JComboBox(resolutions); JComboBox thr = new JComboBox(threads); JPanel myPanel = new JPanel(); myPanel.setLayout(new GridLayout(5, 2)); ...
88aa095d-ef1f-471d-b3e7-a9169fb56e90
public HashMap<File, String> readFilesInDirectory(String filePath) { try { HashMap<File, String> filesMap = new HashMap<File, String>(); File[] files = new File(filePath).listFiles(); for (File file : files) { if (file.isFile()) { filesMap....
6d26f33a-7c21-41a4-bb58-9527e66e93c2
public void clearDirectory(String filePath) { try { File[] files2 = new File(filePath).listFiles(); for (File f : files2) f.delete(); } catch (NullPointerException e) { System.out.println("Nothing to clear"); } }
3e9824fd-6160-466b-978d-b508d4fac227
public int fileCounter(String filePath) { try { File[] files2 = new File(filePath).listFiles(); return files2.length; } catch (NullPointerException e) { System.out.println("Nothing found in directory"); return 0; } }
5d1ef674-375a-4f5a-8b81-0b5227d2aa33
public void log(String message) { PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter("D:\\test1\\log.txt", true))); out.println(message); out.close(); } catch (FileNotFoundException e) { System.out.println("Niezap...
4e5b92d7-545d-4125-9375-db64bc8d2a93
public static void main(String[] args) throws InterruptedException { long start = System.currentTimeMillis(); System.out.println("Start"); String filePath; String filePathSave; int threadsCount; int imgHeight; int imgWidth; HashMap<File, String> filesMap;...
153e74a0-0f7b-4b81-8f2a-badfa2479cfd
private static BufferedImage resizeImage(BufferedImage originalImage, int type, int IMG_WIDTH, int IMG_HEIGHT) { BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type); Graphics2D g = resizedImage.createGraphics(); g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null...