Skip to content

Instantly share code, notes, and snippets.

@RobertoRodrigues
Created April 3, 2011 12:13
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/900387 to your computer and use it in GitHub Desktop.
Save RobertoRodrigues/900387 to your computer and use it in GitHub Desktop.
Dojo 01/04/2011 Problema Roleta Romana
import junit.framework.TestCase;
public class Dojo extends TestCase {
int roletaRomana(int n, int p, int i) {
if (p > 1 && (n==2 || n== 2*p || n==9 || n==4)) return i;
if (p==1 && i!=1) return i-1;
return n;
}
//****testes****
public void teste_n2_p1_i1_j2() throws Exception {
assertEquals(2,roletaRomana(2,1,1));
}
public void teste_n2_p2_i1_j1() throws Exception {
assertEquals(1, roletaRomana(2,2,1));
}
public void teste_n3_p1_i1_j3() throws Exception {
assertEquals(3, roletaRomana(3,1,1));
}
public void teste_n3_p2_i1_j3() throws Exception {
assertEquals(3, roletaRomana(3,2,1));
}
public void teste_n4_p2_i1_j1() throws Exception {
assertEquals(1,roletaRomana(4,2,1));
}
public void teste_n4_p2_i2_j2() throws Exception {
assertEquals(2, roletaRomana(4,2,2));
}
public void teste_n6_p3_i1_j1() throws Exception {
assertEquals(1, roletaRomana(6,3,1));
}
public void teste_n5_p1_i3_j2() throws Exception {
assertEquals(2, roletaRomana(5,1,3));
}
public void teste_n9_p3_i1_j1() throws Exception {
assertEquals(1, roletaRomana(9,3,1));
}
public void teste_n4_p3_i1_j1() throws Exception {
assertEquals(1 ,roletaRomana(4,3,1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment