diff --git a/Exercise1/Exercise1.java b/Exercise1/Exercise1.java index 36deaa100db2e348c50690d7c2f5b2ef10c280f8..a6a8c66054c75f5715cb5544a92e1b3b29569a01 100644 --- a/Exercise1/Exercise1.java +++ b/Exercise1/Exercise1.java @@ -9,7 +9,7 @@ public class Exercise1 { try (var zipper = new TestZipper("books.zip")) { zipper.run(); } catch (IOException e) { - System.err.println("A failure occurred"); + System.err.println("Execution failed!"); e.printStackTrace(); } } diff --git a/Exercise2/Exercise2.java b/Exercise2/Exercise2.java index 7cd408ad9be94ab2255a889560042529efecde66..c91e8f2d4578e6cde19eaa7442acb8466892b6a0 100644 --- a/Exercise2/Exercise2.java +++ b/Exercise2/Exercise2.java @@ -1,15 +1,15 @@ -package fi.utu.tech.ooj.exercise2.teht2; +package fi.utu.tech.ooj.exercise4.exercise2; import java.io.IOException; -public class Teht2 { - public Teht2() { - System.out.println("Tehtävä 2"); +public class Exercise2 { + public Exercise2() { + System.out.println("Exercise 2"); try (var zipper = new TestZipper2("books.zip")) { zipper.run(); } catch (IOException e) { - System.err.println("Ajo epäonnistui!"); + System.err.println("Execution failed!"); e.printStackTrace(); } } diff --git a/Exercise2/TestZipper.java b/Exercise2/TestZipper.java new file mode 100644 index 0000000000000000000000000000000000000000..a0a47665cf7dc898284c2188b89142b116d6a3b9 --- /dev/null +++ b/Exercise2/TestZipper.java @@ -0,0 +1,40 @@ +package fi.utu.tech.ooj.exercise4.exercise2; + +import fi.utu.tech.ooj.exercise4.exercise1.Zipper; + +import java.io.IOException; +import java.nio.file.Path; + +class Book { +} + +class TestZipper2 extends Zipper { + Book[] books = new Book[100]; + int idx = 0; + + TestZipper2(String zipFile) throws IOException { + super(zipFile); + } + + @Override + public void run() throws IOException { + super.run(); + + System.out.printf(""" + + Handled %d Books. + Now we could sort it out a bit. + + """, idx); + } + + @Override + protected Handler createHandler(Path file) { + return new Handler(file) { + @Override + public void handle() { + books[idx++] = new Book(); + } + }; + } +}