This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AccountTest { | |
@Test public void contains() throws Exception { | |
SortedSet<Account> set = new TreeSet<Account>(Account.NAME_COMPARATOR); | |
Account first = new Account("first", 1); | |
set.add(first); | |
Account otherFirst = new Account("first", 2); | |
assertFalse(set.contains(otherFirst)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comparator<Account> NAME_COMPARATOR = new Comparator<Account>() { | |
@Override public int compare(Account a1, Account a2) { | |
if (a1.name == null) { | |
if (a2.name == null) { | |
return 0; | |
} | |
return -1; | |
} | |
return a1.name.compareTo(a2.name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Account { | |
private final String name; | |
private final int id; | |
public Account(String name, int id) { | |
this.name = name; | |
this.id = id; | |
} | |
public int getId() { return id; } | |
public String getName() { return name; } | |
@Override public int hashCode() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if isStrike(frameIndex): | |
score += FULL_FRAME_SCORE + strikeFrameBonus(frameIndex) | |
frameIndex++ | |
elif isSpare(frameIndex): | |
score += FULL_FRAME_SCORE + spareFrameBonus(frameIndex) | |
frameIndex += 2 | |
else: | |
score += frameScore(frameIndex) | |
frameIndex += 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if rolls[frameIndex] == 10: | |
score += rolls[frameIndex] + rolls[frameIndex + 1] + rolls[frameIndex + 2] | |
frameIndex++ | |
elif rolls[frameIndex] + rolls[frameIndex + 1] == 10: | |
score += rolls[frameIndex] + rolls[frameIndex + 1] + rolls[frameIndex + 2] | |
frameIndex += 2 | |
else: | |
score += rolls[frameIndex] + rolls[frameIndex + 1] | |
frameIndex += 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if cell.is_alive? and cell.neighbours in (2,3) then | |
cell.stay_alive | |
elsif cell.is_dead? and cell.neighbours == 2 then | |
cell.live! | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < array.lenth; i++) | |
if (array[i] == 0) | |
bad_ones++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Game { | |
private static final int MAX_ROLLS_IN_GAME = 21; | |
private static final int FRAMES_IN_GAME = 10; | |
private int rolls[] = new int [MAX_ROLLS_IN_GAME]; | |
private int currRoll; | |
public void roll(int pins) { | |
rolls[currRoll] = pins; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<listener> | |
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> | |
</listener> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> | |
<encoder name="enc" class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> | |
<layout class="com.crowdspot.logging.PatternLayoutWithUserContext"> | |
<param name="Pattern" value="%d{HH:mm:ss.SSS} %-5level %logger{10} [%user %session] - %msg%n" /> | |
</layout> | |
</encoder> | |
</appender> |