Skip to content

Instantly share code, notes, and snippets.

View jasongorman's full-sized avatar

Jason Gorman jasongorman

View GitHub Profile
if(length < 8 && length > 50){
throw new IllegalArgumentException();
}
if(length < 8 && length > 50){
throw new IllegalArgumentException();
}
@Test
public void cannotRequestSequencesShorterThanEight() throws Exception {
try
{
new FibonacciGenerator().getSequenceOfLength(7);
fail();
}
catch(Exception e)
{
if(length < 8){
throw new RuntimeException();
}
@Test(expected=IllegalArgumentException.class)
public void cannotRequestSequencesShorterThanEight() throws Exception {
new FibonacciGenerator().getSequenceOfLength(7);
}
def tick(cell, number_of_neighbors)
if number_of_neighbors < 2 || number_of_neighbors > 3
cell.setAlive false
end
if number_of_neighbors == 3
cell.setAlive true
end
end
public class CustomerServices
{
public string FetchCustomerXmlById(int customerId)
{
Customer customer = DataRepository.GetCustomer(customerId);
string xml = "<Error>Customer not found</Error>";
if(customer != null)
{
xml = "<Customer id='" + customerId + "'>" + customer.Name + "</Customer>";
}
public class CustomerServices
{
public string FetchCustomerXmlById(int customerId)
{
Customer customer = new DataRepository().GetCustomer(customerId);
string xml = "<Error>Customer not found</Error>";
if(customer != null)
{
xml = "<Customer id='" + customerId + "'>" + customer.Name + "</Customer>";
}
public interface IDataRepository
{
Customer GetCustomer(int customerId);
IList<Customer> FindCustomers(string nameToMatch);
}
public class CustomerServices
{
private readonly IDataRepository dataRepository;
public CustomerServices(IDataRepository repository)
{
dataRepository = repository;
}
public string FetchCustomerXmlById(int customerId)