Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. /**
  2. * TODO Put here a description of what this class does.
  3. *
  4. * @author Jake. Created Apr 25, 2019.
  5. */
  6. public class Main {
  7. private booleanWrapper bool;
  8. private booleanWrapper bool2;
  9.  
  10. public static void main(String[] args) {
  11. new Main();
  12.  
  13. }
  14.  
  15. /**
  16. * TODO Put here a description of what this method does.
  17. *
  18. */
  19. private Main() {
  20. this.bool = new booleanWrapper();
  21. this.bool2 = new booleanWrapper();
  22. boolean boo1 = true;
  23. boolean boo2 = true;
  24. String s = "jkmnb";
  25. String d = "jake";
  26.  
  27. noVowels2(s, bool);
  28. noVowels2(d, bool2);
  29.  
  30. System.out.println("noVowels1(s): " + noVowels1(s));
  31. System.out.println("noVowels1(s): " + noVowels1(d));
  32. System.out.println("noVowels2(s, bool): " + bool.noVowels);
  33. System.out.println("noVowels2(d, bool2): " + bool2.noVowels);
  34. System.out.println("noVowels3(s, boo1): " + noVowels3(s, boo1));
  35. System.out.println("noVowels3(d, boo2): " + noVowels3(d, boo2));
  36.  
  37. }
  38.  
  39. public boolean noVowels1(String s) {
  40. if(s.length() == 0) {
  41. return true;
  42. } else if(s.charAt(0)=='a' || s.charAt(0)=='e' || s.charAt(0)=='i' || s.charAt(0)=='o' || s.charAt(0)=='u') {
  43. return false;
  44. } else {
  45. return noVowels1(s.substring(1));
  46. }
  47. }
  48.  
  49. public void noVowels2(String s, booleanWrapper bool) {
  50. if(s.length() == 0 || s == null) {
  51. bool.noVowels = true;
  52. return;
  53. }
  54.  
  55. if(s.charAt(0) == 'a' || s.charAt(0) == 'e' || s.charAt(0) == 'i' || s.charAt(0) == 'o' || s.charAt(0) == 'u') {
  56. bool.noVowels = false;
  57. return;
  58. } else {
  59. noVowels2(s.substring(1), bool);
  60. }
  61. }
  62.  
  63. public boolean noVowels3(String s, boolean bool) {
  64. if(s.length() == 0 || s == null) {
  65. bool = true;
  66. return bool;
  67. }
  68.  
  69. if(s.charAt(0) == 'a' || s.charAt(0) == 'e' || s.charAt(0) == 'i' || s.charAt(0) == 'o' || s.charAt(0) == 'u') {
  70. bool = false;
  71. return bool;
  72. } else {
  73. return noVowels3(s.substring(1), bool);
  74. }
  75. }
  76.  
  77. public class booleanWrapper {
  78. public boolean noVowels = true;
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement