Skip to content
Snippets Groups Projects
Commit 35deba7b authored by Juuso Rytilahti's avatar Juuso Rytilahti
Browse files

updated exercise 2 and unified prints

parent b0f8ead8
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
}
......
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();
}
}
......
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();
}
};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment