Advertisement
advictoriam

Untitled

Jan 15th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. public class ColorCodes
  2. {
  3.    /**
  4.       Returns the code of the given image when doubled in size
  5.       @param img the codes of an image
  6.       @return the color codes of the doubled image
  7.    */
  8.    public String doubleImage(String img)
  9.    {  
  10.       String result = "";
  11.       String buffer = "";
  12.       for (int i = 0; i < img.length(); i++)
  13.       {
  14.           char ch = img.charAt(i);
  15.           if (ch == '\n')
  16.           {
  17.              result += buffer + '\n' + buffer + '\n';
  18.              buffer = "";
  19.           }
  20.           else
  21.           {
  22.              buffer += ch;
  23.              buffer += ch;
  24.           }          
  25.       }
  26.       return result;
  27.    }  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement