id
stringlengths
36
36
text
stringlengths
1
1.25M
6b77cb56-bf6a-40b5-ae06-e32328bb1023
@Override public void act() { setLocation((int) x - (SIZE / 2) + 1, (int) y - (SIZE / 2) + 1); // vectors to target vx = setpointX - x; vy = setpointY - y; // move ball to target x += vx * 0.1; y += vy * 0.1; }
df86ffd1-b110-4c9f-91d6-ff107f95f98c
public void setTarget(int setpointX, int setpointY) { this.setpointX = setpointX - (SIZE / 2); this.setpointY = setpointY - (SIZE / 2); }
8efd701b-df12-46a2-8d02-dcb08b4c7231
public HumanPlayer() { // super(SIZE, SIZE); setBounds((int) x, (int) y, SIZE, SIZE); setLocation((int) x, (int) y); randomGenerator = new Random(); }
a19b287f-484a-42c3-a01e-5790baa1b477
@Override public void act() { setLocation((int) x, (int) y); }
f38f782b-020d-49a4-b827-583f6b18d605
@Override public void draw(Graphics g) { g.setColor(hasBall ? Color.green : Color.red); g.drawRect((int) x, (int) y, SIZE, SIZE); }
21df25e1-1836-46db-939c-7a39d043f016
public int setHasBall(boolean hasBall) { this.hasBall = hasBall; if (randomGenerator.nextDouble() >= 0.5) { return AIPlayer.LEFT; } else { return AIPlayer.RIGHT; } }
8737a67c-7188-480b-9dfa-22584419db9e
public AIPlayer(int player) { super(); setBounds((int) x, (int) y, SIZE, SIZE); THIS_PLAYER = player; // set the player to the correct side if (player == RIGHT) x = ((Main.WIDTH / 4) * 3) - (SIZE / 2); randomSelector = new Random(); }
19a4e975-cabc-4c9c-8b8e-fbaa5094dd21
@Override public void act() { setLocation((int) x, (int) y); }
24bb76dc-5ce6-4302-a029-ad53d66de3a4
@Override public void draw(Graphics g) { g.setColor(hasBall ? Color.green : Color.red); g.drawRect((int) x, (int) y, SIZE, SIZE); }
c4f8efa2-4ff5-4bfd-9898-8b3b9e50cbea
public int setHasBall(boolean hasBall) { this.hasBall = hasBall; double randomDouble = randomSelector.nextDouble(); if (THIS_PLAYER == LEFT) { if (randomDouble >= 0.5) { // toss right return RIGHT; } else { // toss to human...
cd1814ce-1593-47c6-a489-14b46a82d072
public GameStats(List<String> p) { players = p; int len = players.size() - 1; matchups = new PlayerMatchup[len][len]; for (int i = 0; i < len; i++) { for (int j = 0; j < len; j++) { if (j >= i) { matchups[i][j] = new PlayerMatchup(players.get(i), players.get(j + 1)); ...
27754c81-de4a-4790-8562-2e75fdb9bc75
public void addMatch(Match m) { verifyPlayer(m.player1); verifyPlayer(m.player2); verifyGameRace(m.race1); verifyGameRace(m.race2); int[] indices = getPlayerIndices(m.player1, m.player2); matchups[indices[0]][indices[1]].addMatch(m); }
b5795a1e-237d-431c-ae2a-5d84cf548f48
public List<String> getPlayers() { return players; }
581a756c-f824-41d9-92d5-b72c64b91bff
public Integer[] getSpecificMatchup(String p1, String p2, char r1, char r2) { verifyPlayer(p1); verifyPlayer(p2); verifyGameRace(r1); verifyGameRace(r2); int[] indices = getPlayerIndices(p1, p2); return matchups[indices[0]][indices[1]].getRecordForMatchup(r1, r2); }
2390abb6-5991-46e7-adf5-cdac1b7548e0
public int[] getOverallRecord(String p) { return null; }
f927cad4-c4c1-4280-85ab-c562ca10bfb7
private int[] getPlayerIndices(String p1, String p2) { if (p1.equals(p2)) { return null; } else if (p1.compareTo(p2) < 0) { int[] ar = {players.indexOf(p1), players.indexOf(p2) - 1}; return ar; } else { int[] ar = {players.indexOf(p2), players.indexOf(p1) - 1}; return ar; }...
59e6282b-a935-4108-8af5-5ff467c9e701
private void verifyPlayer(String p) { if (!players.contains(p)) { throw new IllegalArgumentException("Illegal player names"); } }
4c6af734-dc7c-4856-b68e-e4e7b11e64da
private void verifyGameRace(char r) { if (PlayerMatchup.RACES.indexOf(Character.toUpperCase(r)) == -1) { throw new IllegalArgumentException("Illegal player race"); } }
668da6b7-1e4c-495a-b2fa-8d606e3ffe65
public static void main(String[] args) { //PlayerMatchup p = new PlayerMatchup("Milan", "Don"); }
ed4f9ad1-3485-4a4f-9889-fa45698ff6fe
public static void main(String[] args) throws IOException { if (args.length != 1) { usage(); } System.out.println("Welcome to the Starcraft Stats application! Version " + VERSION); GameStats gs = populateGameStats(args[0]); Scanner console = new Scanner(System.in); while (executeCommand(gs, co...
73884bc5-bb56-4666-a748-4bfacbc8ddf9
private static void usage() { System.out.println("USAGE: StarcraftStats FILENAME"); }
b4a1f2c4-f566-4c99-87dd-bd32460b94c7
private static GameStats populateGameStats(String fileName) throws IOException { Scanner file = new Scanner(new File(fileName)); GameStats gs = null; boolean processPlayerLine = false; int numGames = 0; while (file.hasNextLine()) { String line = file.nextLine(); if (!line.startsWith(COM...
de8c910d-c211-48e0-90c2-b53ed570eb1c
private static boolean executeCommand(GameStats gs, Scanner console) { System.out.print("Which command? (h)elp (e)xit "); String choice = console.nextLine().toLowerCase(); if (choice.startsWith("h")) { displayCommands(); } else if (choice.startsWith("s")) { getSpecificMatchup(gs, console); ...
ef03808e-5980-4052-b358-895b112e2125
private static void displayCommands() { System.out.println("Possible commands:"); for (int i = 0; i < commands.length; i++) { System.out.println("\t" + commands[i]); } }
9bbe1844-01b3-485d-8a75-f17b6a48fb12
private static void getSpecificMatchup(GameStats gs, Scanner console) { System.out.print("Which matchup? (P1 P2 R1 R2): "); String p1 = console.next(); String p2 = console.next(); char r1 = console.next().charAt(0); char r2 = console.next().charAt(1); Integer[] ret = gs.getSpecificMatchup(p1, p2, r1, ...
bebaf0ce-cb25-4c74-ba62-532a25a97f78
public PlayerMatchup(String p1, String p2) { player1 = p1; player2 = p2; p1Wins = 0; p2Wins = 0; raceMatchupMap = new HashMap<String, Integer[]>(); for (int r1 = 0; r1 < RACES.length(); r1++) { for (int r2 = 0; r2 < RACES.length(); r2++) { String key = RACES.charAt(r1) + "v" +...
1d280e04-eb0d-48e0-9c5f-f0fce8bc05be
public void addMatch(Match m) { if (!player1.equals(m.player1) || !player2.equals(m.player2)) { throw new IllegalArgumentException("Illegal player for this matchup"); } String key = m.race1 + "v" + m.race2; int winnerIndex; if (m.p1Won) { winnerIndex = 0; p1Wins++; } else { ...
ce07a107-6e9e-434d-b11b-a911bfe93b9b
public Integer[] getRecord() { return new Integer[] {p1Wins, p2Wins}; }
a3f8a97f-bcb2-4470-bd61-b8b58aa43bda
public Integer[] getRecordForMatchup(char r1, char r2) { String key = r1 + "v" + r2; return raceMatchupMap.get(key); }
ef4c51ce-a63c-4449-a5c8-9be718385043
public Match(String p1, String p2, char r1, char r2, String winner) { if(p1.equals(p2)) { throw new IllegalArgumentException("Illegal players for this game!"); } if (p1.compareTo(p2) < 0) { player1 = p1; player2 = p2; race1 = r1; race2 = r2; } else { player1 = p2...
b9ca185b-d853-4ad4-97da-dcd257b81bae
public void addUnit(){ unitList.add(new Tank(2,3)); unitList.add(new Infantry(2,4)); }
ad2eba7f-581c-4741-886e-c7e39ad561ea
public Unit(int y, int x){ this.xLocation = x; this.yLocation = y; }
fc3ee394-fe5c-4fe4-9ffe-9966a4dc2e54
public int getxLocation() { return xLocation; }
e48c4567-95b4-474c-9eeb-50e7f3f3a2e8
public void setxLocation(int xLocation) { this.xLocation = xLocation; }
601d4fb1-7972-4083-989b-a8c671d50a2e
public int getyLocation() { return yLocation; }
91e959e2-d26e-4db3-abd5-93d4c80f3dc2
public void setyLocation(int yLocation) { this.yLocation = yLocation; }
00ab295c-5ccd-4a68-a76e-d5f84fdc82cd
public Tank(int y, int x) { super(y, x); }
3e04cb2d-69df-4a4c-9376-82fbd6db6a23
@Override public void move() { }
814b8f4d-4b79-43b4-8c5b-f48d1760c3c9
@Override public String getType() { return type; }
3108e2c0-432f-4e79-bd4b-da47fa3a7162
public void move();
3b7ac15c-797b-48e6-b45f-d2d115bf3f62
public String getType();
282a639b-681b-4f99-877a-ef0dc75108f7
public Infantry(int y, int x) { super(y ,x); }
8aac2cec-e168-4d98-aac8-595bbdfe5380
@Override public void move() { }
32826bc5-845d-4b39-95e3-f172da30777a
@Override public String getType() { return type; }
9e0eaf73-570c-447b-a16c-6f87e948d18a
@Test public void testLoadMap() { fail("Not yet implemented"); }
28e8042f-5b28-428d-8e03-3d84491f930b
@Test public void testCreateMap() { fail("Not yet implemented"); }
e1806e62-9a10-4565-9b72-1cb48cfc6077
@Test public void testConvertEmptyHex() { fail("Not yet implemented"); }
365b0b0e-f2d4-455e-ad55-bd8c00da40ad
public Mouse(World world){ this.world = world; popup.add(menu); }
cff922d8-0cb9-4277-a408-64aea5e6a8c6
@Override public void mouseClicked(MouseEvent e) { if(e.getButton()==MouseEvent.BUTTON3){ popup.setLocation(e.getX(), e.getY()); popup.setVisible(true); } }
583c6f6f-134b-4be1-809b-7ab230097310
@Override public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); for(int i = 0; i<world.world.size(); i++) world.world.get(i).selectHex(x, y); }
e1d642ce-9cd8-4929-a90a-9f2afc4fa196
@Override public void mouseReleased(MouseEvent e) { }
f495c0cd-54fa-44c1-ae7e-a04c3a228ea2
@Override public void mouseEntered(MouseEvent e) { }
bd1874db-8775-43d4-94de-e9733f5856a1
@Override public void mouseExited(MouseEvent e) { }
f4adaf78-18d0-433f-a684-ef719014440e
public BoardController(){ world = new World(); bf = new BattleField(); addMouseListener(new Mouse(world)); //Kehitystestit: bf.addUnit(); for(int i =0; i<bf.unitList.size();i++) System.out.println(bf.unitList.get(i).getType() + " Y:"+bf.unitList.get(i).getyLocation() + " X:" + bf.unitList.get(i).getxLo...
767e08eb-5976-4d09-b40c-923342843944
public void paint(Graphics g){ super.paint(g); Graphics2D g2d = (Graphics2D)g; g2d.setStroke(new BasicStroke(2)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); world.paint(g2d); }
df9270b3-472e-44c0-a624-87d677026f67
public void updateGameLogic(){ }
1381f18a-b1c6-403d-b620-da2d8d228c46
public MainFrame() throws InterruptedException{ new JFrame("HexBoard"); setSize(1000, 700); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(bC); setVisible(true); while(true){ bC.updateGameLogic(); bC.repaint(); Thread.sleep(1000); } }
8548cd9a-2129-4abc-8414-6b41c52f1d76
public static void main(String arg[]) throws InterruptedException{ new MainFrame(); }
95561170-3771-4889-9fd7-6c38a59b5cc1
public static void main(String[] args) { try { BufferedReader indexFile = null; BufferedReader dataFile = null; BufferedWriter binaryDataFile = null; BufferedWriter itemsBinaryFile = null; // indexFile = new BufferedReader(new FileReader(new File(args[0]))); indexFile = new BufferedReader(new FileR...
907d604b-4b5b-4354-b181-ec1139c1abce
public static int frequency (BigInteger pattern, int classId) { int count = 0; if (classId == 1) { for (BigInteger transaction : class1TransactionsList) { if (transaction.and(pattern).equals(pattern)) { count++; } } } else if (classId == 2) { for (BigInteger transaction : class2TransactionsL...
eb0ec562-2b1c-4954-b6d6-19868f73c175
public static double support (int freq, int classId) { double sup = 0.0; if (classId == 1) { return (double) (freq*1.00 /class1TransactionsList.size()); } else if (classId == 2) { return (double) (freq*1.00 /class2TransactionsList.size()); } return sup; }
ea162701-d846-44d0-bb0c-7afa628e152f
public static double supportRatio (double supp1, double supp2, int classId) { double suppRatio = 0.0; if (classId == 1) { if (supp2 > 0) { suppRatio = supp1/supp2; } else { suppRatio = Double.MAX_VALUE; } } else if (classId == 2) { if (supp1 > 0) { suppRatio = supp2/supp1; } else { ...
c2dbbbd7-ede5-4329-bf7a-57890f662c71
public static void extractPatterns(int classId) { if (classId == 1) { int baseSize1 = baseItemMap1.size(); for (int i=1;i<baseSize1; i++) { Set <BigInteger> previousCandidateSet1 = frequentPatternMap1.get(i).keySet(); HashMap <BigInteger,Integer> currentCandidateMap1 = new HashMap <BigInteger,Integer> (...
7c98ef75-cb10-4ff9-bcb5-67fd4e8bd4e3
public static void main(String[] args) { Long startTime = System.nanoTime(); BufferedReader dataReader1 = null; BufferedReader dataReader2 = null; BufferedReader baseItemReader = null; System.out.println("Support Threshold = "+threshold); System.out.println("Support Threshold Rate = "+threshold); ...
ea947460-c6eb-410b-877b-c5d35e0b8862
public static void main(String[] args) { BufferedReader dataReader = null; BufferedWriter dataWriter = null; try { // dataReader = new BufferedReader(new FileReader(new File(args[0]))); // dataReader = new BufferedReader(new FileReader(new File("item-index-binary"))); // dataReader = new BufferedReader(ne...
ec101dae-13e6-4606-9c1e-40129b0278d0
public static void main(String[] args) { try { BufferedReader br1 = new BufferedReader(new FileReader(new File(args[0]))); BufferedReader br2 = new BufferedReader(new FileReader(new File(args[1]))); } catch (IOException e) { e.printStackTrace(); } }
d6290666-9747-4ee4-a2b0-148acd94f971
public static void main(String[] args) { try { BufferedReader br1 = new BufferedReader(new FileReader(new File(args[0]))); BufferedWriter bw_poisonous = new BufferedWriter(new FileWriter(new File(args[1]))); BufferedWriter bw_edible = new BufferedWriter(new FileWriter(new File(args[2]))); BufferedWriter ...
e7cec834-783c-4320-b723-c26863431ac1
public static void main(String[] args) { String num = "00000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000"; String bum = "1125899906842624"; System.out.println(new BigInteger(num,2)); BigInteger big = new BigInteger(bum,10); System.out.print...
b09eca62-90fe-46e4-a713-ec4304c9e0d7
@Override public void start(Stage primaryStage) throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL skeletonResource = classLoader.getResource("main.fxml"); Parent root = FXMLLoader.load(skeletonResource); primaryStage.setScene(new Scene(root)); primaryStage...
b06aad89-9bdf-471c-b855-7d23e3154cb1
public static void main(String[] args) { launch(args); }
abd802df-75af-48fa-9e18-c8f45506a840
@FXML @Override public void initialize(URL location, ResourceBundle resources) { url.setText("http://zhuzhi1.asiapacific.hpqcorp.net:8888/rest/private/v2/community/document/upload?communityId=id666&currentPortal=hpes&currentFolder=&topicId=abc"); // url.setText("http://ZHUZHI1.asiapacific.hpqcorp.net:8080/rest/pr...
749fc3d3-2c46-40a2-b892-d92a8e7d3b74
@FXML void setAction() { System.out.println("action"); }
c93a2bf4-51a8-4b61-9c50-555d6e47eb91
@FXML void sendRequest() throws URISyntaxException, InterruptedException, ExecutionException { String url_ = url.getText(); RequestExecutor executor = new RequestExecutor(url_, "POST", Integer.valueOf(threadNum.getText()), ""); Platform.runLater(executor); }
7a3dd4f8-89cc-4e7f-a3f9-9c4704d39450
@FXML void chooseFile() { FileChooser choose = new FileChooser(); Window window = new PopupControl(); File file = choose.showOpenDialog(window); String path = file.getAbsolutePath(); fileField.setText(path); }
9383c397-7d32-403d-9de7-c3e73dfde48f
public static Header getBasicAuthHeader() { // return new BasicHeader("Authorization", "Basic cm9vdDpndG4="); // TODO return new BasicHeader("Authorization", "Basic c2xwZXhvOjEyMzQ1Ng=="); // TODO }
cfc8c710-856b-4205-a81e-666943b2776c
public static HttpContext getHttpContext() { return context; }
91fcd579-f24a-4f8f-92db-d5416da8f298
public static HttpClient getHttpClient() { return client; }
ec158dfa-1be9-4a14-b338-e1075f7626a9
public RequestAction(String url, String action, String filePath) { this.url = url; this.action = action; this.filePath = filePath; }
8ba1c382-049f-4694-bd4c-ab618623f8f0
@Override public HttpResponse call() throws Exception { HttpClient client = HttpClientHolder.getHttpClient(); double r = Math.random(); int topicId = (int) (r * 1000000000); String url = "http://zhuzhi1.asiapacific.hpqcorp.net:8080/rest/private/v2/community/document/upload?communityId=id666&currentPortal=hpes&...
ba8c997d-fbe5-4ac3-a5ec-23529ba753d3
private String inputStream2String(InputStream in) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i; while ((i = in.read()) != -1) { baos.write(i); } return baos.toString(); }
22cdbcf2-f0a4-4425-a12e-38373731b2ad
public RequestExecutor(String url, String action, int threadNum, String filePath) { this.url = url; this.action = action; this.threadNum = threadNum; this.filePath = filePath; }
140d0708-fc0b-4bce-b0f8-0182ed4025c6
public List<HttpResponse> concurrentExecute() throws InterruptedException, ExecutionException { ExecutorService executorService = Executors.newFixedThreadPool(20); Set<RequestAction> callables = new HashSet<>(); // temp List<HttpResponse> resList = new ArrayList<>(); File f = new File("C:/Users/zouz/Desktop...
4a958a97-3030-430c-b84b-78abe8ff421f
@Override public void run() { try { this.concurrentExecute(); } catch (InterruptedException | ExecutionException e) { LOG.error(e.getMessage(), e); } }
8dc02cc2-cf68-4bb0-a54e-38ebb369592f
public Client() { createMainMenu(); }
89afdf13-9f31-48ee-a64f-d998477f446c
public static void main(String[] args) { Client myClient = new Client(); myClient.clientEngine(); }
f65eb034-1960-4553-bc44-cdc4f885f255
private void clientEngine() { running = true; verified = false; connect(); while (running) { if (verified) { System.out.println("Logged in as "+ verifiedEmail); } MenuItem selected = mainMenu.askUser(); char choice = sel...
9fa854de-6fa7-44f4-861d-96ada733f70a
private void createMainMenu(){ MenuNode mainMenu = new MenuNode("Event DB",">"); mainMenu.addMenuItem(new MenuLeaf('1',"Create A New User")); mainMenu.addMenuItem(new MenuLeaf('2',"Create A New Event")); mainMenu.addMenuItem(new MenuLeaf('3',"Purchase a Ticket")); mainMenu.addMe...
14427a59-75c7-4002-829c-eaa93c8c996b
private void HandleSelection(char select) { switch (select) { case '1': query1(); break; case '2': query2(); break; case '3': query3(); break; case '4': query4(); break; case '5': query5(); break; case '6': query6(); break; ...
1b79e9d6-fd4d-4914-a83c-3cbf56ac7112
private void query1() { MenuNode Query1menu = new MenuNode("New Account Menu",">"); Query1menu.addMenuItem(new MenuLeaf('1',"New Account")); Query1menu.addMenuItem(new MenuLeaf('2',"Existing Account")); MenuNode Query1SubMenu = new MenuNode("Select Type of Account to Create",">"); ...
d1c73760-1868-42d1-a056-71a00b296838
private void query2() { DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); try { //System.out.print("Please Input Organizer Email: "); String organizerEmail =login(); // TODO: Check if Organizer exists Account acc = new Account(organizerEmail,con); ...
004e51fd-8c53-42ec-a126-2f724bd0b716
private void query3() { String userEmail; int ticketID; Ticket bTicket; Transaction trans; double processingFee = 1.00; try { //System.out.println("Please enter a user email: "); userEmail = login(); System.out.println("Please enter the ticket ID: ");...
90a4a442-51a6-4152-9353-7a2252a16271
private void query4() { String userEmail; //System.out.println("Please enter a user email: "); try { userEmail = login(); Account acc = new Account(userEmail,con); acc.getAttendingEvents(); } catch (SQLException e) { System.out.println("S...
63286b7f-40ea-405d-8b22-b92ed47ea322
private void query5() { String userEmail; //System.out.println("Please enter a user email: "); try { userEmail = login(); Account acc = new Account(userEmail,con); acc.getCreatedEvents(); } catch (SQLException e) { System.out.println("SQL Err...
0e2a656d-9468-4bd0-a200-090ed50208f0
private void query6() { System.out.println("You are now quitting"); running = false; }
df30e92a-939c-4835-8f3c-642b7a60039e
public void connect() { try { DriverManager.registerDriver ( new com.ibm.db2.jcc.DB2Driver() ) ; } catch (Exception cnfe){ System.out.println("Unable to register db2 driver"); return; } String url = "jdbc:db2://db2.cs.mcgill.ca:50000/cs421"; ...
7af0d2aa-29bb-411d-b92b-fa0e5b9168da
public static Connection getConnection() { try { DriverManager.registerDriver ( new com.ibm.db2.jcc.DB2Driver() ) ; } catch (SQLException e){ System.out.println("Unable to register db2 driver"); return null; } String url = "jdbc:db2://db2.cs.mcgill...
35240326-9442-40c5-8d2b-76218ddfcb38
private String readInput() throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); return br.readLine(); }
74a6c13e-3742-4afa-ac99-4601444480f7
private String login() throws verificationException{ String pw; if (this.verified) { return this.verifiedEmail; } System.out.println("Please Input your Email: "); try { this.verifiedEmail = readInput(); System.out.println("Please Input your Pas...
b1c47712-e7b4-412a-9c52-48490a28b131
public static void main (String [] args) throws SQLException { // Unique table names. Either the user supplies a unique identifier as a command line argument, or the program makes one up. String tableName = ""; int sqlCode=0; // Variable to hold SQLCODE String sqlState="00000"; // Var...
bee3fc91-2e0e-4f7f-83c3-1e7a059f6d75
public static void main (String [] args) throws SQLException { // Unique table names. Either the user supplies a unique identifier as a command line argument, or the program makes one up. String tableName = ""; int sqlCode=0; // Variable to hold SQLCODE String sqlState="00000"; // Var...