Created
May 7, 2011 10:43
-
-
Save RobertoRodrigues/960400 to your computer and use it in GitHub Desktop.
Problema de conversão de Digital para Decimal
This file contains hidden or 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
//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