-
-
Save PaulBGD/7064922 to your computer and use it in GitHub Desktop.
Smaller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ScrollingString { | |
private String original; | |
private int position; | |
public ScrollingString(String original) { | |
this.original = original; | |
} | |
public void scroll() { | |
position++; | |
if (position == original.length()) | |
position = 0; | |
} | |
public String getScrolledString() { | |
int e = position + original.length(); | |
return e > original.length() ? original.substring(position, original.length()) + original.substring(0, width - (original.length() - position)) : original.substring(position, e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment