Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Application {
- public static void main(String[] args) {
- Application app = new Application();
- String word = app.askUserFor("word");
- String[] letters = word.split("");
- String stringOfColors = app.askUserFor("colors split by comma in hex value, ie: 084CFB,ADF3FD,F3FDAB and " + "press ENTER");
- String[] colors = stringOfColors.split(",");
- System.out.println("\n" + app.doColorization(letters, colors));
- }
- private String getNextColor(String[] colors, int idx) {
- return colors[idx];
- }
- private String askUserFor(String st) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Please input a " + st + " and press ENTER:");
- return scanner.next();
- }
- private String doColorization(String[] letters, String[] colors) {
- int idx = 0;
- StringBuilder result = new StringBuilder();
- for (String l : letters) {
- result.append(getNextColor(colors, idx) + l);
- idx = idx + 1;
- if (idx == colors.length) idx = 0;
- }
- return result.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement