Warmup-1
Sleep In: Show ▼
public boolean sleepIn(boolean weekday, boolean vacation) {
if(!weekday || vacation){
return true;
}
return false;
}
Monkey Trouble: Show ▼
public boolean monkeyTrouble(boolean aSmile, boolean bSmile) {
return (aSmile == bSmile);
}
Warmup-2
String Times: Show ▼
public String stringTimes(String str, int n) {
String newString = "";
for(int i = 1; i <= n; i++){
newString += str;
}
return newString;
}
Front Times: Show ▼
public String frontTimes(String str, int n) {
String newString = "";
int gui = 3;
for(int i = 1; i <= n; i++){
if(str.length() < 3){
gui = str.length();
}
newString += str.substring(0,gui);
}
return newString;
}
String-1
Hello Name: Show ▼
public String helloName(String name) {
return "Hello " + name + "!";
}
Make ABBA: Show ▼
public String makeAbba(String a, String b) {
return a+b+b+a;
}
Make Tags: Show ▼
public String makeTags(String tag, String word) {
return "<" + tag + ">" + word + "</" + tag + ">";
}
Make Out Word: Show ▼
public String makeOutWord(String out, String word) {
return out.substring(0,2)+word+out.substring(2,4);
}
Extra End: Show ▼
public String extraEnd(String str) {
return str.substring(str.length()-2)+str.substring(str.length()-2)+str.substring(str.length()-2);
}
First Two: Show ▼
public String firstTwo(String str) {
if(str.length() < 2) {
if(str.length() == 0){
return "";
}
return str;
}else{
return str.substring(0,2);
}
}
First Half: Show ▼
public String firstHalf(String str) {
return str.substring(0, str.length()/2);
}
Without End: Show ▼
public String withoutEnd(String str) {
return str.substring(1, str.length()-1);
}
Combo String: Show ▼
public String comboString(String a, String b) {
if(a.length() < b.length()){
return a + b + a;
}
if(a.length() > b.length()){
return b + a + b;
}
return "";
}