id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
6f236ce7-c110-453c-af7c-e179f50a2d73 | public void brew() {
} |
82d6e504-78f0-478d-9d31-9259a0c62ecc | void on(); |
7fd7946d-b9af-4814-99d4-cd3389cc8ccb | void off(); |
a43375bc-87d3-4e84-b887-5622fcd78ffe | boolean isHot(); |
60b70d87-6356-49e8-8412-fa9eef15e8d2 | void pump(); |
9b4e9583-c105-4603-adb9-b78d4976f552 | @Override public void pump() {
} |
91355a6d-08b9-4440-b22f-9948da8e496b | @Override public void run() {
} |
7096ff45-1412-436c-b490-e0be0b3b6651 | public static void main(String[] args) {
} |
c97d46ea-36ae-48ba-9f84-01f204e532d1 | @Override public void on() {
} |
d01adb08-168f-4884-a6f9-6bc144ca7d64 | @Override public void off() {
} |
ef2b8fc8-3aa6-4c27-9c67-2b61079f6f8e | @Override public boolean isHot() {
return false;
} |
bef2bd62-8cd1-41d6-8069-cd12db317abd | @Before
public void setup() {
// Here if you need it
} |
c57bc807-cb34-4e64-a6ed-f122035f1b8f | @Test
public void pump_shouldPrintPumping_whenHeaterIsHot() {
} |
dbee4def-f583-442d-bdd5-2e3e555bf2e7 | @Test
public void pump_shouldNotPrintAnything_whenHeaterIsNotHot() {
} |
0b88d175-7cec-45b3-bc85-bc87f91841c3 | @Test
public void brew_shouldBrewCoffee() {
} |
43c4c0de-f8ef-41d0-a4ef-c0899b2d505a | @Before
public void setup() {
// Here if you need it
} |
269d62ab-eef9-46a4-bc85-a8b5c952af9a | @Test
public void run_shouldBrewCoffee() {
} |
333fef89-c0ad-48b9-83c6-de41dbc6d28b | @Before
public void setup() {
// Here if you need it
} |
0f9c33db-ee56-464f-9744-8fd7d5ddf61a | @Test
public void on_shouldPrintHeating() {
} |
ddde10e4-473e-446e-b096-515910b0f290 | @Test
public void isHot_shouldBeTrue_whenHeaterIsOn() {
} |
7323632c-e026-408c-82f7-f7b37a97657d | @Test
public void isHot_shouldBeFalse_whenHeaterIsOff() {
} |
ab31e7d5-83d3-42a6-8456-54680b333c41 | public String getLastPrintedStatement() {
return outputStream.toString();
} |
0443160e-d8e7-490d-b0a2-aa18d54b3b74 | @Before
public void setupTestBase() {
MockitoAnnotations.initMocks(this);
outputStream = new ByteArrayOutputStream();
System.setOut(new PrintStream(outputStream));
} |
d360b33c-2df6-45a5-bccf-1e1026e4f847 | @After
public void tearDownTestBase() {
System.setOut(null);
} |
40402241-cff3-4356-809c-80344129f472 | public static Hashtable<String, Team> parseTeams(Reader reader, Collection<Stat> stats) {
CSVReader csvReader = new CSVReader(reader);
return parseStats(csvReader, stats);
} |
9b98d618-eb43-4cbd-8170-59225acfc62f | private static Hashtable<String, Team> parseStats(CSVReader reader, Collection<Stat> stats) {
Hashtable<String, Team> teams = new Hashtable<String, Team>();
List<String[]> lines;
try {
lines = reader.readAll();
} catch (IOException e) {
System.out.println("Error reading the CSV file.");
return null... |
13c37b77-a5be-439c-85c6-f75ac272d156 | private static Team getTeam(Hashtable<String, Team> teams, String name) {
Team team = teams.get(name);
if (team == null) {
team = new Team(name);
teams.put(name, team);
}
return team;
} |
31b3bab1-0c1e-4e3d-bf6e-e5ebcf729d4d | private static int findColumnIndex(String[] columns, String column) {
for (int i = 0; i < columns.length; i++)
if (columns[i].equals(column))
return i;
return -1;
} |
49df72d1-3e4d-4158-ba94-f6c9d20bf6d3 | public Stat(String table, String column, String name) {
this.table = table;
this.column = column;
this.name = name;
} |
60a04a1d-c4de-4e4b-b574-52999cc555b9 | public String toString() {
return name;
} |
00cc580a-ca1a-4cc7-9fd0-5799ce24f3aa | public static Round parseFirstRound(Reader reader, Hashtable<String, Team> teams) throws Exception {
Round games = new Round();
CSVReader csvReader = new CSVReader(reader);
List<String[]> lines;
try {
lines = csvReader.readAll();
} catch (IOException e) {
System.out.println("Error reading the CSV... |
ee4edce8-a08e-444f-88e6-d78c4ad6b13e | public static Hashtable<String, CompiledStat> compileStats(Vector<Stat> stats, Collection<Team> teams) {
Vector<Team> teamVector = new Vector<Team>(teams);
Hashtable<String, CompiledStat> compiledStats = new Hashtable<String, CompiledStat>();
for (Stat stat : stats) {
double[] values = new double[teams.s... |
1cdd3745-7fe2-46a6-9bc7-4b5c74c6c9c8 | public Tournament(Round firstRound, Hashtable<String, CompiledStat> compiledStats, Referee scoreable) {
if (md5 == null) {
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
this.compiledStats = compiledStats;
this.scoreable = sco... |
74d2df0d-4146-4fcf-9dea-4eded8d0bacb | public void appendNextRound(Round round) {
Round nextRound = new Round();
rounds.add(nextRound);
int roundNumber = rounds.indexOf(nextRound);
int gameCount = 0;
for (int i = 0; i < round.size(); i += 2) {
Game newGame = new Game();
newGame.referee = scoreable;
Game[] previousGames = new Gam... |
361efa41-2cb0-47e8-acfa-031ed5e2c944 | public Team play() {
return play(rounds.get(0));
} |
a5f7b88a-ebeb-4a88-9e62-24ac403cf915 | private Team play(Round round) {
for (Game game : round) {
game.compiledStats = compiledStats;
Team winner = game.play();
if (round.size() == 1)
return winner;
game.nextGame.addTeam(winner);
}
return play(rounds.get(rounds.indexOf(round) + 1));
} |
7f1367e5-1c2c-4b6c-b203-9785d84fa17f | public String toPrintableString() {
StringBuilder builder = new StringBuilder();
int maxNameLength = 0;
for (Game game : rounds.get(0))
maxNameLength = Math.max(Math.max(game.teams[0].toString().length(), game.teams[1].toString().length()), maxNameLength);
int columnWidth = maxNameLength + COLUMN_PADD... |
1b162f83-837c-4368-aed3-f7a6f48dc971 | private String teamAt(int line, int roundNumber, int columnWidth) {
Round round = rounds.get(roundNumber);
Team team = null;
String teamName = "";
int teamScore = 0;
int linesPerGame = PRINT_HEIGHT / round.size();
int lineGame = (int)Math.floor((double)line / (double)linesPerGame);
int startLine = l... |
aa6144fc-3d7b-476d-8710-fa95bd1ae604 | public String toSummaryString() {
StringWriter stringWriter = new StringWriter();
CSVWriter writer = new CSVWriter(stringWriter);
String[] columns = new String[0];
for (Round round : rounds) {
for (Game game : round) {
for (int i = 0; i < 2; i++) {
if (columns.length == 0) {
if (game.su... |
b7abf633-88f0-4da4-a291-0dddd4967f90 | public byte[] getHash() {
String id = this.rounds.toString();
return md5.digest(id.getBytes());
} |
fcf9f5cf-e8f2-435f-9f9e-0c758337200c | public Team getWinner() {
return rounds.lastElement().get(0).winner;
} |
0cc2f601-98fd-4b82-a71c-e45faafdaaed | public CompiledStat(String name, double[] values) {
this.name = name;
computeStats(values);
} |
e68e9a83-13d7-42f6-9f7f-9412b0f26091 | private void computeStats(double[] values) {
double sum = 0.0;
min = values[0];
max = values[0];
for (double value : values) {
sum += value;
min = Math.min(min, value);
max = Math.max(max, value);
}
mean = sum / (double)values.length;
dev = calculateDev(values);
} |
ef71bb47-3449-4a6d-b87b-aea767c16460 | private double calculateDev(double[] values) {
return Math.pow(calculateVar(values), 0.5);
} |
1c2bbec3-9c8c-4ccd-a403-9d2b717e94f3 | static double calculateVar(double[] values) {
double total = 0.0;
double sTotal = 0.0;
double scalar = 1.0/(double)(values.length - 1);
for (int i = 0; i < values.length; i++) {
total += values[i];
sTotal += Math.pow(values[i], 2);
}
return (scalar * (sTotal - (Math.pow(total, 2) / values.length... |
c8cf2002-49af-4839-af24-c993830e757d | public String toString() {
return name;
} |
ccc3d7da-ee1a-47f4-97b7-63f28cd0ce9e | public Team play() {
referee.playGame(this);
return winner;
} |
0e9df48f-abac-4341-b361-ac452de405ab | public Game() {}; |
e3daea68-ddc9-4e73-9640-85419546491d | public Game(Team[] teams) {
this.teams = teams;
} |
2d7e7694-8332-41e4-832c-8b012c2c8573 | public Game(Team[] teams, Referee scoreable) {
this(teams);
this.referee = scoreable;
} |
81636b37-2c4b-473a-ad3e-e1ae53e75fd6 | public void addTeam(Team team) {
for (int i = 0; i < teams.length; i++) {
if (teams[i] == null) {
teams[i] = team;
return;
}
}
} |
f07f4d3f-0f21-4aa6-a91d-128b4ea95a1c | public String toString() {
return String.format("%s (%s vs. %s)", name, teams[0].toString(), teams[1].toString());
} |
e8362d9f-e866-444d-bd3b-e92c495e51db | public static void main(String[] args) throws Exception {
if (args.length < 3 || args[0].isEmpty() || args[1].isEmpty() || args[2].isEmpty()) {
System.out.println("Too few arguments. Required arguments: [year] [men|women] [referee class name]");
return;
}
if (!args[1].equals("men") && !args[1].equals(... |
c1004516-cd05-41f1-95b1-f4f00725c7e8 | public int compare(Team o1, Team o2) {
if (o1.wins > o2.wins)
return -1;
else if (o1.wins < o2.wins)
return 1;
else
return 0;
} |
d586efa1-f8ac-4cbc-ad23-691907eff0d3 | public Team(String name) {
this.name = name;
} |
ce89f39d-3fc1-4051-9ff6-4d4cd4ea9c9e | public Team(String name, int seed) {
this.name = name;
this.seed = seed;
} |
79ad7982-3f07-4051-8d56-4ccbcddea060 | public String toString() {
if (seed >= 10)
return String.format("%d %s", seed, name);
else if (seed > 0)
return String.format(" %d %s", seed, name);
else
return name;
} |
8a7303ef-6db8-4694-9914-812afea69afa | public Double getStat(String stat) {
return this.stats.get(stat);
} |
d2c62349-a16e-417f-9596-fbea4ef9ad36 | public void playGame(Game game) {
game.summaries[0] = new Hashtable<String, String>();
game.summaries[1] = new Hashtable<String, String>();
game.summaryStats.add("Game");
game.summaries[0].put("Game", game.name);
game.summaries[1].put("Game", game.name);
game.summaryStats.add("Team");
game.s... |
0b55f556-618e-43c2-9d10-ca5d765e9b9e | private Double calculateScore(Team home, Team away,
Hashtable<String, CompiledStat> compiledStats,
Hashtable<String, String> summary) {
// Base score (30% weight)
Double basePts = 0.4 * (0.4 * home.getStat("PPG") + 0.6 * away.getStat("OPP PPG"));
Double pts = basePts;
// Shooting bonus
Double fgBo... |
801c9cc5-df5b-4173-96d8-437aa36f267a | private double randomAbout(double range) {
double sign = (Math.random() - 0.5);
sign = (sign < 0 ? -1 : 1);
return sign * range;
} |
04e3c961-f70f-460d-8882-41d147ff9449 | private double randomRange(double start, double end) {
return Math.random() * (end - start) + start;
} |
d4bac56b-2ab5-4042-bff8-3159905a0206 | public void playGame(Game game) {
game.scores[0] = calculateScore(game.teams[0], game.teams[1], game.compiledStats);
game.scores[1] = calculateScore(game.teams[1], game.teams[0], game.compiledStats);
if (game.scores[0] > game.scores[1]) {
game.winner = game.teams[0];
game.loser = game.teams[1];
} else {... |
e70fcb04-5a8a-480d-ae57-ce783514a2d8 | private double calculateScore(Team home, Team away, Hashtable<String, CompiledStat> compiledStats) {
// Base expected score
double baseScore = (0.5) * (1.0 * home.getStat("PPG") + 1.0 * away.getStat("OPP PPG")) / 2.0;
double score = baseScore + randomAbout(baseScore * VARIABILITY);
// Give a bonus for havi... |
49bb829f-81c7-4a13-a4df-c9c5f4ec82fd | private double randomAbout(double range) {
double sign = (Math.random() - 0.5);
sign = (sign < 0 ? -1 : 1);
return sign * range;
} |
7bb57925-2082-4b4e-93cc-75de539726a2 | public void playGame(Game game) {
// Potential possession outcomes:
// Made 2FG
// Made 3FG
// Missed 2FG
// Missed 3FG
// Offensive foul
// Defensive foul
// Turnover
TeamStatus[] status = new TeamStatus[2];
status[0] = new TeamStatus();
status[1] = new TeamStatus();
int timeLeft = SEC_P... |
bd49039d-fe8b-42a4-b540-0fe7c4db548d | private double gaussian(double mean, double stdDev) {
return _rand.nextGaussian() * stdDev + mean;
} |
316e2b8f-e376-4b5a-afcd-7315236a32f7 | private double constrain(double value, double min, double max) {
if (value < min) return min;
if (value > max) return max;
return value;
} |
87430e5d-3bbd-42fe-aa14-a6a015b4cab1 | private boolean happens(double percent) {
// percent ranges from 0 to 1
return _rand.nextDouble() < percent;
} |
f12d36c7-2326-47b6-9ab8-00a370a03338 | public void playGame(Game game); |
8b891c45-0683-4522-a69b-e3bd85944730 | public CSVReader(Reader reader) {
this(reader, DEFAULT_SEPARATOR);
} |
8938cb11-569e-4231-b451-3411b6e1a462 | public CSVReader(Reader reader, char separator) {
this(reader, separator, DEFAULT_QUOTE_CHARACTER);
} |
67c53d6c-d868-4ab6-a953-a6899a64e9e2 | public CSVReader(Reader reader, char separator, char quotechar) {
this(reader, separator, quotechar, DEFAULT_SKIP_LINES);
} |
82428d1e-4b1b-4698-9875-3a3c45173bfc | public CSVReader(Reader reader, char separator, char quotechar, int line) {
this.br = new BufferedReader(reader);
this.separator = separator;
this.quotechar = quotechar;
this.skipLines = line;
} |
8dad8a77-e00c-4065-912e-3b3077300365 | public List readAll() throws IOException {
List allElements = new ArrayList();
while (hasNext) {
String[] nextLineAsTokens = readNext();
if (nextLineAsTokens != null)
allElements.add(nextLineAsTokens);
}
return allElements;
} |
6e6d5bf6-dc61-4879-a123-dfc34687fda1 | public String[] readNext() throws IOException {
String nextLine = getNextLine();
return hasNext ? parseLine(nextLine) : null;
} |
1e09b27b-dbd2-4227-98e3-27f26cefb5f9 | private String getNextLine() throws IOException {
if (!this.linesSkiped) {
for (int i = 0; i < skipLines; i++) {
br.readLine();
}
this.linesSkiped = true;
}
String nextLine = br.readLine();
if (nextLine == null) {
hasNext = fal... |
e1855207-da1f-4266-ae2b-17cc89ac6c3f | private String[] parseLine(String nextLine) throws IOException {
if (nextLine == null) {
return null;
}
List tokensOnThisLine = new ArrayList();
StringBuffer sb = new StringBuffer();
boolean inQuotes = false;
do {
if (inQuotes) {
// ... |
22818b98-f3cf-420f-9313-a354baba46e1 | public void close() throws IOException{
br.close();
} |
37f4c1ea-7224-4499-9edb-3082506a42ff | public CSVWriter(Writer writer) {
this(writer, DEFAULT_SEPARATOR);
} |
014ba124-b5eb-4bb8-8fe0-06c7850e8279 | public CSVWriter(Writer writer, char separator) {
this(writer, separator, DEFAULT_QUOTE_CHARACTER);
} |
a6a2b5fe-3b3c-41c3-ac2d-6881a338d83c | public CSVWriter(Writer writer, char separator, char quotechar) {
this(writer, separator, quotechar, DEFAULT_ESCAPE_CHARACTER);
} |
280b3078-3b46-4e09-92c4-b81d34cde6c1 | public CSVWriter(Writer writer, char separator, char quotechar, char escapechar) {
this(writer, separator, quotechar, escapechar, DEFAULT_LINE_END);
} |
2fe681f1-5670-431d-87f5-442107e9c1be | public CSVWriter(Writer writer, char separator, char quotechar, String lineEnd) {
this(writer, separator, quotechar, DEFAULT_ESCAPE_CHARACTER, lineEnd);
} |
03bb1243-5dbc-412f-8296-1c204c1602ba | public CSVWriter(Writer writer, char separator, char quotechar, char escapechar, String lineEnd) {
this.rawWriter = writer;
this.pw = new PrintWriter(writer);
this.separator = separator;
this.quotechar = quotechar;
this.escapechar = escapechar;
this.lineEnd = lineEnd;
... |
76e68560-8d8b-4268-9bd2-5c7ea8842925 | public void writeAll(List allLines) {
for (Iterator iter = allLines.iterator(); iter.hasNext();) {
String[] nextLine = (String[]) iter.next();
writeNext(nextLine);
}
} |
8a2f292d-179b-4018-83d4-8351be6ddf8b | protected void writeColumnNames(ResultSetMetaData metadata)
throws SQLException {
int columnCount = metadata.getColumnCount();
String[] nextLine = new String[columnCount];
for (int i = 0; i < columnCount; i++) {
nextLine[i] = metadata.getColumnName(i + 1);
}
writeNext(nextLine);
... |
eeed4cf8-ec15-4c13-a8fe-e669d9a6aff1 | public void writeAll(java.sql.ResultSet rs, boolean includeColumnNames) throws SQLException, IOException {
ResultSetMetaData metadata = rs.getMetaData();
if (includeColumnNames) {
writeColumnNames(metadata);
}
int columnCount = metadata.getColumnCount();
while (rs.nex... |
157223fe-acb3-4c3a-bf4b-71544fe962d6 | private static String getColumnValue(ResultSet rs, int colType, int colIndex)
throws SQLException, IOException {
String value = "";
switch (colType)
{
case Types.BIT:
Object bit = rs.getObject(colIndex);
if (bit != null) {
value = String.valueOf(bit);
}
break;
case Types.... |
f8ada4b7-3f98-44f0-ac79-1e1259194620 | private static String read(Clob c) throws SQLException, IOException
{
StringBuffer sb = new StringBuffer( (int) c.length());
Reader r = c.getCharacterStream();
char[] cbuf = new char[2048];
int n = 0;
while ((n = r.read(cbuf, 0, cbuf.length)) != -1) {
if (n > 0) {
sb.append(cbuf, 0, n);
}
}
ret... |
a040ad75-4dc0-4b31-a955-ff1db6a32678 | public void writeNext(String[] nextLine) {
if (nextLine == null)
return;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < nextLine.length; i++) {
if (i != 0) {
sb.append(separator);
}
String nextElement = nextLine[i];
... |
b3da4eb3-ea19-41c5-bf76-f471ea491a41 | public void flush() throws IOException {
pw.flush();
} |
0fe3a83d-9eee-475b-8203-cdd9bc96e4a4 | public void close() throws IOException {
pw.flush();
pw.close();
rawWriter.close();
} |
afd74622-642b-4b1d-b011-2d285973cc36 | public void test_tilt_line_left() {
int[] expected = null;
int[] old = null;
int[] after = null;
Game2048Core processer = new Game2048Core();
old = new int[] { 0, 0, 2, 2 };
after = processer.tilt_line_left(old);
expected = new int[] { 2, 2, 0, 0 };
if (GameUtil.compareExpectToActualLine(expected, afte... |
b297cba1-fadd-4d9f-8816-7bfe429007e5 | public void test_combine_tiles() {
int[] expected = null;
int[] old = null;
Game2048Core processer = new Game2048Core();
old = new int[] { 1, 1, 0, 0 };
int after[] = processer.combine_tiles(old);
expected = new int[] { 2, 0, 0, 0 };
if (GameUtil.compareExpectToActualLine(expected, after)) {
GameUtil... |
9adcde4d-5eb7-4fd5-8794-5d52eecbc484 | private boolean line_vector_test(int i1, int i2, int i3, int i4,
String msg, int o1, int o2, int o3, int o4) {
Game2048Core processer = new Game2048Core();
int list[] = { i1, i2, i3, i4 };
if (null != msg) {
System.out.print(msg);
} else {
System.out.print(" Tilting "
+ GameUtil.convertLineToTxtWi... |
c305f4a1-f4f7-4a64-b494-d25f207fa74f | public void test_tilt_left() {
boolean e = true;
e &= line_vector_test(0, 0, 0, 0, "Empty list is empty after shift", 0,
0, 0, 0);
e &= line_vector_test(1, 0, 0, 0,
"Value on left stays on left after shift", 1, 0, 0, 0);
e &= line_vector_test(0, 0, 0, 1,
"Value on right shifts to left edge after shi... |
0918f7e2-3f60-4dff-89d8-3419d96e77c1 | public void test_rotate_clockWise_90degree(){
Game2048Core processer = new Game2048Core();
int[][] in = null;
int[][] out = null;
int[][] expected = new int[][] {
{ 2, 0, 2, 2 },
{ 0, 0, 0, 0 },
{ 0, 2, 0, 0 },
{ 0, 2, 0, 2 }
};
in = new int... |
0f240cfd-50f6-4a6b-ab56-3af047004d09 | public void test_rotate_clockWise_180degree(){
Game2048Core processer = new Game2048Core();
int[][] in = null;
int[][] out = null;
in = new int[][] {
{ 2, 0, 0, 2 },
{ 2, 0, 0, 0 },
{ 0, 0, 2, 2 },
{ 2, 0, 0, 0 }
};
int[][] expecte... |
9e80ab59-f6f1-4591-ae9c-c7716113201f | public void test_rotate_clockWise_270degree(){
Game2048Core processer = new Game2048Core();
int[][] in = null;
int[][] out = null;
in = new int[][] {
{ 2, 0, 0, 2 },
{ 2, 0, 0, 0 },
{ 0, 0, 2, 2 },
{ 2, 0, 0, 0 }
};
int[][] expecte... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.