Java - 1331 bytes, 618 bytes and 504 bytes
Here it is in java. The cool thing is that it is pretty legible and flexible. You may experiment to change the SHIFT
variable to 0 and it will be a quine. You may change it to whatever value you want, including negative values and it will shift the code accordingly.
public class Quinex {
private static final int SHIFT = 1;
private static String next(String now, boolean mangles) {
String sb = "";
for (char c : now.toCharArray()) {
if (!mangles && c == 87) {
sb += next(String.valueOf(SHIFT), true);
} else {
sb += (char) ((mangles ? c : c == 94 ? 10 : c == 64 ? 34 : c) + SHIFT);
}
}
return sb;
}
public static void main(String... args) {
System.out.println(next(TEXT, false) + next(TEXT, true) + new String(new char[] { 34, 59, 10, 125 }));
}
private static final String TEXT = "public class Quinex {^^ private static final int SHIFT = W;^^ private static String next(String now, boolean mangles) {^ String sb = @@;^ for (char c : now.toCharArray()) {^ if (!mangles && c == 87) {^ sb += next(String.valueOf(SHIFT), true);^ } else {^ sb += (char) ((mangles ? c : c == 94 ? 10 : c == 64 ? 34 : c) + SHIFT);^ }^ }^ return sb;^ }^^ public static void main(String... args) {^ System.out.println(next(TEXT, false) + next(TEXT, true) + new String(new char[] { 34, 59, 10, 125 }));^ }^^ private static final String TEXT = @";
}
However, the only drawback in the previous class are the line breaks, which are not permited in the question spec (are outside the range 32 to 125). So I give here a golfed version that is free of line breaks (and free of the quirks to handle them). You may edit the value of the S
variable to change the shift. This has 618 bytes:
class Q{static String g(String p,int m){int S=1;String u="";for(char c:p.toCharArray()){if(m==0&&c==87){u+=g(String.valueOf(S),1);}else{u+=(char)((m>0?c:c==64?34:c)+S);}}return u;}public static void main(String[]y){System.out.println(g(T,0)+g(T,1)+new String(new char[]{34,59,125}));}static final String T="class Q{static String g(String p,int m){int S=W;String u=@@;for(char c:p.toCharArray()){if(m==0&&c==87){u+=g(String.valueOf(S),1);}else{u+=(char)((m>0?c:c==64?34:c)+S);}}return u;}public static void main(String[]y){System.out.println(g(T,0)+g(T,1)+new String(new char[]{34,59,125}));}static final String T=@";}
Surely, if we drop the fine adjustment of the offset and hardcode the value of the shift, we can do a completely golfed version with 504 bytes:
class Q{static String g(String p,int m){String u="";for(char c:p.toCharArray()){u+=(char)((m>0?c:c==64?34:c)+1);}return u;}public static void main(String[]y){System.out.println(g(T,0)+g(T,1)+new String(new char[]{34,59,125}));}static final String T="class Q{static String g(String p,int m){String u=@@;for(char c:p.toCharArray()){u+=(char)((m>0?c:c==64?34:c)+1);}return u;}public static void main(String[]y){System.out.println(g(T,0)+g(T,1)+new String(new char[]{34,59,125}));}static final String T=@";}
~
really sucks for GolfScript. Bet you did that on purpose. :-) \$\endgroup\$