Created
September 4, 2015 00:17
-
-
Save adolfont/651a2826f92a87514b13 to your computer and use it in GitHub Desktop.
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
package adolfoneto; | |
public class Buracos { | |
public int contaBuracos(String frase) { | |
int somaDeBuracos = 0; | |
for (int i=0; i<frase.length();i++) | |
{ | |
if (temUmBuraco(frase.charAt(i))){ | |
somaDeBuracos++; | |
}else | |
if (temDoisBuracos(frase.charAt(i))){ | |
somaDeBuracos+=2; | |
} | |
} | |
return somaDeBuracos; | |
} | |
public boolean temDoisBuracos(char letra) { | |
if (letra == 'B') return true; | |
return false; | |
} | |
public boolean temUmBuraco(char letra) { | |
String letrasComUmBuraco = "abdegopqADOPQR"; | |
if ((letrasComUmBuraco.indexOf(letra)>-1)) return true; | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment