Update of exercises

kts
Thomas Smits 2023-06-05 22:53:27 +02:00
parent ea1ca587f6
commit 5c448e64bd
3 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,6 @@
# Quine
[Musterlösung](solution/)
## Lernziel

View File

@ -0,0 +1,5 @@
# Lösung: Quine
Musterlösung:
[pr2.auffrischung.quine](../../solutions/src/main/java/pr2/auffrischung/quine/)

View File

@ -0,0 +1,19 @@
package pr2.auffrischung.quine;
public class Quine {
private static final String DATA = "package pr2.auffrischung.quine;%n%n"
+ "public class Quine {%n%n"
+ " private static final String DATA = \"%s\";%n%n"
+ " public static void main(String[] args) {%n"
+ " System.out.printf(data, %n"
+ " DATA.replace(\"\\\\\", \"\\\\\\\\\")%n"
+ " .replace(\"\\\"\", \"\\\\\\\"\"));%n }%n}";
public static void main(String[] args) {
System.out.printf(DATA,
DATA.replace("\\", "\\\\")
.replace("\"", "\\\""));
}
}