File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
JavaCodingBat/src/codingbat Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,18 @@ public class Main {
4
4
public static void main (String [] args ) {
5
5
6
6
}
7
+
8
+ public String helloName (String name ) {
9
+ return "Hello " + name + "!" ;
10
+ }
11
+
12
+ public String makeAbba (String a , String b ) {
13
+ return a + b + b + a ;
14
+ }
15
+
16
+ public String makeTags (String tag , String word ) {
17
+ return "<" + tag + ">" + word + "</" + tag + ">" ;
18
+ }
19
+
20
+
7
21
}
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public int countXX(String str) {
36
36
public boolean doubleX (String str ) {
37
37
for (int i = 0 ; i < str .length () - 1 ; i ++) {
38
38
if (str .charAt (i ) == 'x' ) {
39
- if (str .charAt (i + 1 ) == 'x' ){
39
+ if (str .charAt (i + 1 ) == 'x' ) {
40
40
return true ;
41
41
}
42
42
return false ;
@@ -45,4 +45,32 @@ public boolean doubleX(String str) {
45
45
return false ;
46
46
}
47
47
48
+ public String stringBits (String str ) {
49
+ String resultString = "" ;
50
+ for (int i = 0 ; i < str .length (); i += 2 ) {
51
+ resultString += str .charAt (i );
52
+ }
53
+ return resultString ;
54
+ }
55
+
56
+ public String stringSplosion (String str ) {
57
+ String resultString = "" ;
58
+ for (int i = 0 ; i < str .length (); i ++) {
59
+ resultString += str .substring (0 , i + 1 );
60
+ }
61
+ return resultString ;
62
+ }
63
+
64
+ public int last2 (String str ) {
65
+ int counter = 0 ;
66
+ String pattern = str .substring (0 , 1 );
67
+ for (int i = 0 ; i < str .length () - 1 ; i ++) {
68
+ if (str .substring (i , i + 1 ).equals (pattern )) {
69
+ counter ++;
70
+ }
71
+ }
72
+ return counter ;
73
+ }
74
+
75
+
48
76
}
You can’t perform that action at this time.
0 commit comments