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 FibonacciGenerator { | |
public int getNumberAtPosition(int positionInSequence){ | |
if(positionInSequence > 1){ | |
return getNumberAtPosition(positionInSequence - 1) + | |
getNumberAtPosition(positionInSequence - 2); | |
} | |
return positionInSequence; | |
} | |
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(length < 8 || false){ | |
throw new IllegalArgumentException(); | |
} |
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(length < 8 && length > 50){ | |
throw new IllegalArgumentException(); | |
} |
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
@Test | |
public void cannotRequestSequencesShorterThanEight() throws Exception { | |
try | |
{ | |
new FibonacciGenerator().getSequenceOfLength(7); | |
fail(); | |
} | |
catch(Exception e) | |
{ | |
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(length < 8 && length > 50){ | |
throw new RuntimeException(); | |
} |
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(length < 8){ | |
throw new RuntimeException(); | |
} |
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 FibonacciGenerator { | |
public int getNumberAtPosition(int positionInSequence){ | |
if(positionInSequence > 1){ | |
return getNumberAtPosition(positionInSequence - 1) + | |
getNumberAtPosition(positionInSequence - 2); | |
} | |
return positionInSequence; | |
} | |
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(length < 8 || false){ | |
throw new IllegalArgumentException(); | |
} |
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 FibonacciGenerator { | |
public int getNumberAtPosition(int positionInSequence){ | |
if(positionInSequence > 1){ | |
return getNumberAtPosition(positionInSequence - 1) + | |
getNumberAtPosition(positionInSequence - 2); | |
} | |
return positionInSequence; | |
} | |
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 FibonacciGenerator { | |
public int getNumberAtPosition(int positionInSequence){ | |
if(positionInSequence > 1){ | |
return getNumberAtPosition(positionInSequence - 1) + | |
getNumberAtPosition(positionInSequence - 2); | |
} | |
return positionInSequence; | |
} | |
OlderNewer