Skip to content

Instantly share code, notes, and snippets.

@Muirrum
Created September 4, 2019 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Muirrum/80adb42a21b80b863e036c5f7468c74d to your computer and use it in GitHub Desktop.
Save Muirrum/80adb42a21b80b863e036c5f7468c74d to your computer and use it in GitHub Desktop.
AP Compsci A Summer Work - CodingBat
public String notString(String str) {
// If the arg starts with not... (https://howtodoinjava.com/java/string/java-string-startswith-example/)
if (str.startsWith("not")) {
return str;
// Otherwise...
} else {
return "not " + str;
}
}
public boolean sleepIn(boolean weekday, boolean vacation) {
// If it's not a weekday, OR it's vacation...
if (!weekday || vacation) {
return true;
// Otherwise
} else {
return false;
}
}
public boolean startHi(String str) {
// if arg starts with hi...
if (str.startsWith("hi")) {
return true;
// Otherwise...
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment