Skip to content

Commit ec61946

Browse files
author
alopalka
committed
Added few more completed tasks
1 parent 203f35d commit ec61946

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

JavaCodingBat/src/codingbat/string1/Main.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,18 @@ public class Main {
44
public static void main(String[] args) {
55

66
}
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+
721
}

JavaCodingBat/src/codingbat/warmup2/Main.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public int countXX(String str) {
3636
public boolean doubleX(String str) {
3737
for (int i = 0; i < str.length() - 1; i++) {
3838
if (str.charAt(i) == 'x') {
39-
if (str.charAt(i+1) == 'x'){
39+
if (str.charAt(i + 1) == 'x') {
4040
return true;
4141
}
4242
return false;
@@ -45,4 +45,32 @@ public boolean doubleX(String str) {
4545
return false;
4646
}
4747

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+
4876
}

0 commit comments

Comments
 (0)