From ea95781ebc26b7f38ae20e313d0dbacbb9b5f8f4 Mon Sep 17 00:00:00 2001 From: Sabina Grisi Date: Thu, 9 Nov 2023 17:48:55 +0100 Subject: [PATCH] mein zweiter commit --- Lerntagebuch.md | 3 ++- Uebung1.java | 51 ------------------------------------------------- Uebung2.java | 48 ---------------------------------------------- 3 files changed, 2 insertions(+), 100 deletions(-) delete mode 100644 Uebung1.java delete mode 100644 Uebung2.java diff --git a/Lerntagebuch.md b/Lerntagebuch.md index ce105c2..99ffdb7 100644 --- a/Lerntagebuch.md +++ b/Lerntagebuch.md @@ -18,7 +18,7 @@ ### Kritik - Mir gefiel die langsame und freundliche Art, wie sie die Dinge erklärten. - +--- ## SU 02 (03.11.2023) @@ -34,6 +34,7 @@ ### Wiederholung - Die Imperative Programmierung ist so, als würdest du der Computer Schritt für Schritt Anweisungen geben. Es ist, als würdest du ihm genau sagen, was er in jedem Moment tun soll. Also, anstatt ihm zu sagen "löse dieses Problem", sagst du ihm "nimm diese Werte, mach diese Operation, speichere dann das Ergebnis". + --- ## SU 03 (10.11.2023) diff --git a/Uebung1.java b/Uebung1.java deleted file mode 100644 index 2ef9308..0000000 --- a/Uebung1.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.edu.hsfulda.pmut.debugging; - -import java.io.InputStream; -import java.io.PrintStream; -import java.util.Scanner; - -public class Uebung1 { - private InputStream in; - private PrintStream out; - - public Uebung1(InputStream in, PrintStream out) { - this.in = in; - this.out = out; - } - - public static void main(String[] args) { - new Uebung1(System.in, System.out).run(); - } - - private void run() { - try (Scanner input = new Scanner(in)) { - int nextInt = aquireUserInput(input, "enter an integer number: "); - boolean isCheckPassed = checkNumber(nextInt); - reportResult(String.format("number %d passed check: %b", nextInt, - isCheckPassed)); - } ; - } - - private void reportResult(String message) { - out.print(message); - } - - private boolean checkNumber(int nextInt) { - for (int i = 2; i < nextInt; i++) { - int result = nextInt % i; - out.println(String.format( - "input: %d, Schleifenvariable: %d, Ergebnis %d", nextInt, i, - result)); - if (0 == result) { - return false; - } - } - return true; - } - - private int aquireUserInput(Scanner input, String message) { - reportResult(message); - int nextInt = input.nextInt(); - return nextInt; - } -} diff --git a/Uebung2.java b/Uebung2.java deleted file mode 100644 index d9c9b7c..0000000 --- a/Uebung2.java +++ /dev/null @@ -1,48 +0,0 @@ -//package de.edu.hsfulda.pmut.debugging; - -import java.io.InputStream; -import java.io.PrintStream; -import java.util.Scanner; - -public class Uebung2 { - private InputStream in; - private PrintStream out; - private int count = 2; - public Uebung2(InputStream in, PrintStream out) { - this.in = in; - this.out = out; - } - - public static void main(String[] args) { - new Uebung2(System.in, System.out).run(); - } - - private void run() { - try (Scanner input = new Scanner(in)) { - int nextInt = aquireUserInput(input, "enter an integer number: "); - boolean isCheckPassed = checkNumber(nextInt); - reportResult(String.format("number %d passed check: %b", nextInt, - isCheckPassed)); - } ; - } - - private void reportResult(String message) { - out.print(message); - } - - private boolean checkNumber(int nextInt) { - if (count > nextInt) - return true; - if (nextInt % count == 0) - return false; - nextInt = nextInt - (nextInt / count); - count++; - return checkNumber(nextInt); - } - - private int aquireUserInput(Scanner input, String message) { - reportResult(message); - int nextInt = input.nextInt(); - return nextInt; - } -}