From 5c448e64bd9e62f3ebb3a0a081fc77f16674fb1f Mon Sep 17 00:00:00 2001 From: Thomas Smits Date: Mon, 5 Jun 2023 22:53:27 +0200 Subject: [PATCH] Update of exercises --- Assignment_007/readme.md | 2 +- Assignment_007/solution/readme.md | 5 +++++ .../java/pr2/auffrischung/quine/Quine.java | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Assignment_007/solution/readme.md create mode 100644 solutions/src/main/java/pr2/auffrischung/quine/Quine.java diff --git a/Assignment_007/readme.md b/Assignment_007/readme.md index dd2b729..c37b8bc 100644 --- a/Assignment_007/readme.md +++ b/Assignment_007/readme.md @@ -1,6 +1,6 @@ # Quine - + [Musterlösung](solution/) ## Lernziel diff --git a/Assignment_007/solution/readme.md b/Assignment_007/solution/readme.md new file mode 100644 index 0000000..4ac7e2a --- /dev/null +++ b/Assignment_007/solution/readme.md @@ -0,0 +1,5 @@ +# Lösung: Quine + +Musterlösung: + +[pr2.auffrischung.quine](../../solutions/src/main/java/pr2/auffrischung/quine/) diff --git a/solutions/src/main/java/pr2/auffrischung/quine/Quine.java b/solutions/src/main/java/pr2/auffrischung/quine/Quine.java new file mode 100644 index 0000000..6ee66d9 --- /dev/null +++ b/solutions/src/main/java/pr2/auffrischung/quine/Quine.java @@ -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("\"", "\\\"")); + } +}