Skip to content

Instantly share code, notes, and snippets.

@RobertoRodrigues
Created May 7, 2011 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertoRodrigues/960400 to your computer and use it in GitHub Desktop.
Save RobertoRodrigues/960400 to your computer and use it in GitHub Desktop.
Problema de conversão de Digital para Decimal
//importa biblioteca JUnit para testes
import junit.framework.TestCase;
public class Dojo extends TestCase {
public static String zero = " _ \n| |\n|_|";
public static String um = " \n | \n | ";
public static String dois = " _ \n _|\n|_ ";
public static String tres = " _ \n _|\n _|";
//****metodo****
int retornaDigito(String digito) {
System.out.println(digito);
if(digito.charAt(4)=='|') return 0;
if(digito.charAt(1)=='_') return 2;
return 1;
}
//****testes****
public void test_zero() throws Exception {
assertEquals(0,retornaDigito(zero));
}
public void test_um() throws Exception{
assertEquals(1, retornaDigito(um));
}
public void test_dois() throws Exception{
assertEquals(2, retornaDigito(dois));
}
public void test_tres() throws Exception{
assertEquals (3, retornaDigito (tres));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment