import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.DisplayName; import java.util.Random; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testWords() { assertEquals("PR", Encrypt.encryptByVowels("PR")); assertEquals("bc", Encrypt.encryptByVowels("ab")); } @Test void testWrap(){ assertEquals("ab", Encrypt.encryptByVowels("Za")); assertEquals("Ab", Encrypt.encryptByVowels("za")); } @Test void testEmptyOrBlank(){ assertEquals("", Encrypt.encryptByVowels("")); assertEquals(" ", Encrypt.encryptByVowels(" ")); } @Test void sentences(){ assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal")); } @DisplayName("Random tests") @RepeatedTest(40) void randomTests() { Random rand = new Random(); String str = ""; for(int j = 0; j < rand.nextInt(1, 5); j++){ for(int i = 0; i < rand.nextInt(1, 100); i++){ int randomNumber = rand.nextInt(65, 122); if(randomNumber > 90 && randomNumber < 97) randomNumber+=(97-randomNumber); str+=""+(char)randomNumber; } str+=" "; } assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1))); } public static String sol(String s) { StringBuilder sb = new StringBuilder(); int cont = 0; for(char c: s.toLowerCase().toCharArray()) { if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cont++; } for(char c: s.toCharArray()) { int newChar = (int) c; if(c != ' '){ newChar = c+cont; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); while(newChar > 122) { newChar = 64 + newChar%122; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); } } sb.append((char)newChar); } return sb.toString(); } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.DisplayName;
- import java.util.Random;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void testWords() {
- assertEquals("PR", Encrypt.encryptByVowels("PR"));
- assertEquals("bc", Encrypt.encryptByVowels("ab"));
- }
- @Test
- void testWrap(){
- assertEquals("ab", Encrypt.encryptByVowels("Za"));
- assertEquals("Ab", Encrypt.encryptByVowels("za"));
- }
- @Test
- void testEmptyOrBlank(){
- assertEquals("", Encrypt.encryptByVowels(""));
- assertEquals(" ", Encrypt.encryptByVowels(" "));
- }
- @Test
- void sentences(){
- assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal"));
- }
- @DisplayName("Random tests")
- @RepeatedTest(40)
- void randomTests() {
- Random rand = new Random();
- String str = "";
- for(int j = 0; j < rand.nextInt(1, 5); j++){
- for(int i = 0; i < rand.nextInt(1, 100); i++){
- int randomNumber = rand.nextInt(65, 122);
- if(randomNumber > 90 && randomNumber < 97)
- randomNumber+=(97-randomNumber);
- str+=""+(char)randomNumber;
- }
- str+=" ";
- }
- assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1)));
- }
- public static String sol(String s) {
String newS = "";int cont = 0;for(char c: s.toLowerCase().toCharArray()) {if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')cont++;}for(char c: s.toCharArray()) {int newChar = (int) c;if(c != ' '){newChar = c+cont;if(newChar > 90 && newChar < 97)newChar+=(97-newChar);if(newChar > 122) {newChar = 64 + newChar%122;if(newChar > 90 && newChar < 97)newChar+=(97-newChar);- StringBuilder sb = new StringBuilder();
- int cont = 0;
- for(char c: s.toLowerCase().toCharArray()) {
- if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
- cont++;
- }
- for(char c: s.toCharArray()) {
- int newChar = (int) c;
- if(c != ' '){
- newChar = c+cont;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- while(newChar > 122) {
- newChar = 64 + newChar%122;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- }
- }
- sb.append((char)newChar);
- }
newS+=""+(char)newChar;}return newS;- return sb.toString();
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.DisplayName; import java.util.Random; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testWords() { assertEquals("PR", Encrypt.encryptByVowels("PR")); assertEquals("bc", Encrypt.encryptByVowels("ab")); } @Test void testWrap(){ assertEquals("ab", Encrypt.encryptByVowels("Za")); assertEquals("Ab", Encrypt.encryptByVowels("za")); } @Test void testEmptyOrBlank(){ assertEquals("", Encrypt.encryptByVowels("")); assertEquals(" ", Encrypt.encryptByVowels(" ")); } @Test void sentences(){ assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal")); } @DisplayName("Random tests") @RepeatedTest(40) void randomTests() { Random rand = new Random(); String str = ""; for(int j = 0; j < rand.nextInt(1, 5); j++){ for(int i = 0; i < rand.nextInt(1, 100); i++){ int randomNumber = rand.nextInt(65, 122); if(randomNumber > 90 && randomNumber < 97) randomNumber+=(97-randomNumber); str+=""+(char)randomNumber; } str+=" "; } assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1))); } public static String sol(String s) { String newS = ""; int cont = 0; for(char c: s.toLowerCase().toCharArray()) { if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cont++; } for(char c: s.toCharArray()) { int newChar = (int) c; if(c != ' '){ newChar = c+cont; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); if(newChar > 122) { newChar = 64 + newChar%122; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); } } newS+=""+(char)newChar; } return newS; } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.DisplayName;
- import java.util.Random;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void testWords() {
- assertEquals("PR", Encrypt.encryptByVowels("PR"));
- assertEquals("bc", Encrypt.encryptByVowels("ab"));
- }
- @Test
- void testWrap(){
- assertEquals("ab", Encrypt.encryptByVowels("Za"));
- assertEquals("Ab", Encrypt.encryptByVowels("za"));
- }
- @Test
- void testEmptyOrBlank(){
- assertEquals("", Encrypt.encryptByVowels(""));
- assertEquals(" ", Encrypt.encryptByVowels(" "));
- }
- @Test
- void sentences(){
- assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal"));
- }
- @DisplayName("Random tests")
- @RepeatedTest(40)
- void randomTests() {
- Random rand = new Random();
- String str = "";
- for(int j = 0; j < rand.nextInt(1, 5); j++){
- for(int i = 0; i < rand.nextInt(1, 100); i++){
- int randomNumber = rand.nextInt(65, 122);
- if(randomNumber > 90 && randomNumber < 97)
- randomNumber+=(97-randomNumber);
- str+=""+(char)randomNumber;
- }
- str+=" ";
- }
- assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1)));
- }
- public static String sol(String s) {
return s;- String newS = "";
- int cont = 0;
- for(char c: s.toLowerCase().toCharArray()) {
- if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
- cont++;
- }
- for(char c: s.toCharArray()) {
- int newChar = (int) c;
- if(c != ' '){
- newChar = c+cont;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- if(newChar > 122) {
- newChar = 64 + newChar%122;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- }
- }
- newS+=""+(char)newChar;
- }
- return newS;
- }
- }
public class Encrypt { public static String encryptByVowels(String str) { String newS = ""; int cont = 0; for(char c: str.toLowerCase().toCharArray()) { if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cont++; } for(char c: str.toCharArray()) { int newChar = (int) c; if(c != ' '){ newChar = c+cont; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); if(newChar > 122) { newChar = 64 + newChar%122; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); } } newS+=""+(char)newChar; } return newS; } }
- public class Encrypt {
- public static String encryptByVowels(String str) {
return null;- String newS = "";
- int cont = 0;
- for(char c: str.toLowerCase().toCharArray()) {
- if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
- cont++;
- }
- for(char c: str.toCharArray()) {
- int newChar = (int) c;
- if(c != ' '){
- newChar = c+cont;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- if(newChar > 122) {
- newChar = 64 + newChar%122;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- }
- }
- newS+=""+(char)newChar;
- }
- return newS;
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.DisplayName; import java.util.Random; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testWords() { assertEquals("PR", Encrypt.encryptByVowels("PR")); assertEquals("bc", Encrypt.encryptByVowels("ab")); assertEquals("", Encrypt.encryptByVowels("")); } @Test void testWrap(){ assertEquals("ab", Encrypt.encryptByVowels("Za")); assertEquals("Ab", Encrypt.encryptByVowels("za")); } @Test void testEmptyOrBlank(){ assertEquals("", Encrypt.encryptByVowels("")); assertEquals(" ", Encrypt.encryptByVowels(" ")); } @Test void sentences(){ assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal")); } @DisplayName("Random tests") @RepeatedTest(40) void randomTests() { Random rand = new Random(); String str = ""; for(int j = 0; j < rand.nextInt(1, 5); j++){ for(int i = 0; i < rand.nextInt(1, 100); i++){ int randomNumber = rand.nextInt(65, 122); if(randomNumber > 90 && randomNumber < 97) randomNumber+=(97-randomNumber); str+=""+(char)randomNumber; } str+=" "; } assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1))); } public static String sol(String str) { String newS = ""; int cont = 0; for(char c: str.toLowerCase().toCharArray()) { if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cont++; } for(char c: str.toCharArray()) { int newChar = (int) c; if(c != ' '){ newChar = c+cont; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); if(newChar > 122) { newChar = 64 + newChar%122; if(newChar > 90 && newChar < 97) newChar+=(97-newChar); } } newS+=""+(char)newChar; } return newS; } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.DisplayName;
- import java.util.Random;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
void testSomething() {- void testWords() {
- assertEquals("PR", Encrypt.encryptByVowels("PR"));
- assertEquals("bc", Encrypt.encryptByVowels("ab"));
- assertEquals("", Encrypt.encryptByVowels(""));
- }
- @Test
- void testWrap(){
- assertEquals("ab", Encrypt.encryptByVowels("Za"));
- assertEquals("Ab", Encrypt.encryptByVowels("za"));
- }
- @Test
- void testEmptyOrBlank(){
- assertEquals("", Encrypt.encryptByVowels(""));
- assertEquals(" ", Encrypt.encryptByVowels(" "));
- }
- @Test
- void sentences(){
- assertEquals("Mtqf vzj yfq", Encrypt.encryptByVowels("Hola que tal"));
- }
- @DisplayName("Random tests")
- @RepeatedTest(40)
- void randomTests() {
- Random rand = new Random();
- String str = "";
for(int i = 0; i < rand.nextInt(1, 100); i++){int randomNumber = rand.nextInt(65, 122);if(randomNumber > 90 && randomNumber < 97)randomNumber+=(97-randomNumber);str+=""+(char)randomNumber;- for(int j = 0; j < rand.nextInt(1, 5); j++){
- for(int i = 0; i < rand.nextInt(1, 100); i++){
- int randomNumber = rand.nextInt(65, 122);
- if(randomNumber > 90 && randomNumber < 97)
- randomNumber+=(97-randomNumber);
- str+=""+(char)randomNumber;
- }
- str+=" ";
- }
assertEquals(Encrypt.encryptByVowels(str) ,sol(str));- assertEquals(Encrypt.encryptByVowels(str.substring(0, str.length()-1)) ,sol(str.substring(0, str.length()-1)));
- }
public static String sol(String s) {return s;- public static String sol(String str) {
- String newS = "";
- int cont = 0;
- for(char c: str.toLowerCase().toCharArray()) {
- if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
- cont++;
- }
- for(char c: str.toCharArray()) {
- int newChar = (int) c;
- if(c != ' '){
- newChar = c+cont;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- if(newChar > 122) {
- newChar = 64 + newChar%122;
- if(newChar > 90 && newChar < 97)
- newChar+=(97-newChar);
- }
- }
- newS+=""+(char)newChar;
- }
- return newS;
- }
- }
public class Encrypt { public static String encryptByVowels(String str) { return null; } }
- public class Encrypt {
public static String encryptByVocals(String str) {- public static String encryptByVowels(String str) {
- return null;
- }
- }
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.DisplayName; import java.util.Random; // TODO: Replace examples and use TDD by writing your own tests class SolutionTest { @Test void testSomething() { // assertEquals("expected", "actual"); } @DisplayName("Random tests") @RepeatedTest(40) void randomTests() { Random rand = new Random(); String str = ""; for(int i = 0; i < rand.nextInt(1, 100); i++){ int randomNumber = rand.nextInt(65, 122); if(randomNumber > 90 && randomNumber < 97) randomNumber+=(97-randomNumber); str+=""+(char)randomNumber; } assertEquals(Encrypt.encryptByVowels(str) ,sol(str)); } public static String sol(String s) { return s; } }
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertEquals;
- import org.junit.jupiter.api.RepeatedTest;
- import org.junit.jupiter.api.DisplayName;
- import java.util.Random;
- // TODO: Replace examples and use TDD by writing your own tests
- class SolutionTest {
- @Test
- void testSomething() {
- // assertEquals("expected", "actual");
- }
- @DisplayName("Random tests")
- @RepeatedTest(40)
- void randomTests() {
- Random rand = new Random();
- String str = "";
- for(int i = 0; i < rand.nextInt(1, 100); i++){
- int randomNumber = rand.nextInt(65, 122);
- if(randomNumber > 90 && randomNumber < 97)
- randomNumber+=(97-randomNumber);
- str+=""+(char)randomNumber;
- }
- assertEquals(Encrypt.encryptByVowels(str) ,sol(str));
- }
- public static String sol(String s) {
- return s;
- }
- }