From 6a44b074f0169a1b0f9e92347af929c5e471746e Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Sat, 18 Apr 2015 13:44:44 +0200
Subject: Reorganised projects
---
.gitignore | 12 -
Week4 Drawing loipes/.gitignore | 3 +
Week4 Drawing loipes/Assignment (in Dutch).pdf | Bin 0 -> 170933 bytes
Week4 Drawing loipes/build.xml | 73 +
Week4 Drawing loipes/build/classes/no.png | Bin 0 -> 3662 bytes
Week4 Drawing loipes/build/classes/nw.png | Bin 0 -> 3646 bytes
Week4 Drawing loipes/build/classes/nz.png | Bin 0 -> 199 bytes
Week4 Drawing loipes/build/classes/nzow.png | Bin 0 -> 214 bytes
.../build/classes/oo15loipe/AsciiArt$1.class | Bin 0 -> 952 bytes
.../build/classes/oo15loipe/AsciiArt.class | Bin 0 -> 1645 bytes
.../build/classes/oo15loipe/Fragment.class | Bin 0 -> 1138 bytes
.../build/classes/oo15loipe/InfoLoipe.class | Bin 0 -> 303 bytes
.../build/classes/oo15loipe/Loipe.class | Bin 0 -> 4137 bytes
.../build/classes/oo15loipe/LoipePlaatje$1.class | Bin 0 -> 910 bytes
.../build/classes/oo15loipe/LoipePlaatje.class | Bin 0 -> 5312 bytes
.../build/classes/oo15loipe/Punt.class | Bin 0 -> 1295 bytes
.../build/classes/oo15loipe/TekenLoipe.class | Bin 0 -> 219 bytes
Week4 Drawing loipes/build/classes/ow.png | Bin 0 -> 3273 bytes
.../build/classes/week4/Week4.class | Bin 0 -> 1120 bytes
Week4 Drawing loipes/build/classes/zo.png | Bin 0 -> 3662 bytes
Week4 Drawing loipes/build/classes/zw.png | Bin 0 -> 3641 bytes
Week4 Drawing loipes/manifest.mf | 3 +
Week4 Drawing loipes/nbproject/build-impl.xml | 1413 ++++++++++++++++++++
Week4 Drawing loipes/nbproject/genfiles.properties | 8 +
.../nbproject/private/config.properties | 0
.../nbproject/private/private.properties | 6 +
Week4 Drawing loipes/nbproject/private/private.xml | 6 +
Week4 Drawing loipes/nbproject/project.properties | 75 ++
Week4 Drawing loipes/nbproject/project.xml | 15 +
Week4 Drawing loipes/src/no.png | Bin 0 -> 3662 bytes
Week4 Drawing loipes/src/nw.png | Bin 0 -> 3646 bytes
Week4 Drawing loipes/src/nz.png | Bin 0 -> 199 bytes
Week4 Drawing loipes/src/nzow.png | Bin 0 -> 214 bytes
Week4 Drawing loipes/src/oo15loipe/AsciiArt.java | 51 +
Week4 Drawing loipes/src/oo15loipe/Fragment.java | 8 +
Week4 Drawing loipes/src/oo15loipe/InfoLoipe.java | 35 +
Week4 Drawing loipes/src/oo15loipe/Loipe.java | 226 ++++
.../src/oo15loipe/LoipePlaatje.java | 191 +++
Week4 Drawing loipes/src/oo15loipe/Punt.java | 73 +
Week4 Drawing loipes/src/oo15loipe/TekenLoipe.java | 19 +
Week4 Drawing loipes/src/ow.png | Bin 0 -> 3273 bytes
Week4 Drawing loipes/src/week4/Week4.java | 36 +
Week4 Drawing loipes/src/zo.png | Bin 0 -> 3662 bytes
Week4 Drawing loipes/src/zw.png | Bin 0 -> 3641 bytes
Week4 Drawing loipes/week4-retake.tar.gz | Bin 0 -> 4863 bytes
Week4 Drawing loipes/week4.tar.gz | Bin 0 -> 4766 bytes
Week4/Assignment (in Dutch).pdf | Bin 170933 -> 0 bytes
Week4/build.xml | 73 -
Week4/manifest.mf | 3 -
Week4/nbproject/build-impl.xml | 1413 --------------------
Week4/nbproject/genfiles.properties | 8 -
Week4/nbproject/project.properties | 75 --
Week4/nbproject/project.xml | 15 -
Week4/src/no.png | Bin 3662 -> 0 bytes
Week4/src/nw.png | Bin 3646 -> 0 bytes
Week4/src/nz.png | Bin 199 -> 0 bytes
Week4/src/nzow.png | Bin 214 -> 0 bytes
Week4/src/oo15loipe/AsciiArt.java | 51 -
Week4/src/oo15loipe/Fragment.java | 8 -
Week4/src/oo15loipe/InfoLoipe.java | 35 -
Week4/src/oo15loipe/Loipe.java | 226 ----
Week4/src/oo15loipe/LoipePlaatje.java | 191 ---
Week4/src/oo15loipe/Punt.java | 73 -
Week4/src/oo15loipe/TekenLoipe.java | 19 -
Week4/src/ow.png | Bin 3273 -> 0 bytes
Week4/src/week4/Week4.java | 36 -
Week4/src/zo.png | Bin 3662 -> 0 bytes
Week4/src/zw.png | Bin 3641 -> 0 bytes
Week4/week4-retake.tar.gz | Bin 4863 -> 0 bytes
Week4/week4.tar.gz | Bin 4766 -> 0 bytes
Week5 Quiz/.gitignore | 3 +
Week5 Quiz/Assignment (in Dutch).pdf | Bin 0 -> 143371 bytes
Week5 Quiz/build.xml | 73 +
Week5 Quiz/manifest.mf | 3 +
Week5 Quiz/nbproject/build-impl.xml | 1413 ++++++++++++++++++++
Week5 Quiz/nbproject/genfiles.properties | 8 +
Week5 Quiz/nbproject/project.properties | 75 ++
Week5 Quiz/nbproject/project.xml | 15 +
Week5 Quiz/src/week5/MCQuestion.java | 81 ++
Week5 Quiz/src/week5/OpenQuestion.java | 32 +
Week5 Quiz/src/week5/Question.java | 56 +
Week5 Quiz/src/week5/TCQuestion.java | 40 +
Week5 Quiz/src/week5/Week5.java | 106 ++
Week5 Quiz/week5.tar.gz | Bin 0 -> 2562 bytes
Week5/Assignment (in Dutch).pdf | Bin 143371 -> 0 bytes
Week5/build.xml | 73 -
Week5/manifest.mf | 3 -
Week5/nbproject/build-impl.xml | 1413 --------------------
Week5/nbproject/genfiles.properties | 8 -
Week5/nbproject/project.properties | 75 --
Week5/nbproject/project.xml | 15 -
Week5/src/week5/MCQuestion.java | 81 --
Week5/src/week5/OpenQuestion.java | 32 -
Week5/src/week5/Question.java | 56 -
Week5/src/week5/TCQuestion.java | 40 -
Week5/src/week5/Week5.java | 106 --
Week5/week5.tar.gz | Bin 2562 -> 0 bytes
Week6 Sliding game solver/.gitignore | 3 +
.../Assignment (in Dutch).pdf | Bin 0 -> 223530 bytes
Week6 Sliding game solver/build.xml | 73 +
Week6 Sliding game solver/manifest.mf | 3 +
Week6 Sliding game solver/nbproject/build-impl.xml | 1413 ++++++++++++++++++++
.../nbproject/genfiles.properties | 8 +
.../nbproject/project.properties | 75 ++
Week6 Sliding game solver/nbproject/project.xml | 15 +
Week6 Sliding game solver/src/Configuration.java | 21 +
Week6 Sliding game solver/src/Direction.java | 26 +
Week6 Sliding game solver/src/Main.java | 35 +
Week6 Sliding game solver/src/Node.java | 92 ++
Week6 Sliding game solver/src/SlidingGame.java | 205 +++
Week6 Sliding game solver/src/Solver.java | 55 +
Week6 Sliding game solver/week6.tar.gz | Bin 0 -> 5434 bytes
Week6/Assignment (in Dutch).pdf | Bin 223530 -> 0 bytes
Week6/build.xml | 73 -
Week6/manifest.mf | 3 -
Week6/nbproject/build-impl.xml | 1413 --------------------
Week6/nbproject/genfiles.properties | 8 -
Week6/nbproject/project.properties | 75 --
Week6/nbproject/project.xml | 15 -
Week6/src/Configuration.java | 21 -
Week6/src/Direction.java | 26 -
Week6/src/Main.java | 35 -
Week6/src/Node.java | 92 --
Week6/src/SlidingGame.java | 205 ---
Week6/src/Solver.java | 55 -
Week6/week6.tar.gz | Bin 5434 -> 0 bytes
Week7 Polynomials/.gitignore | 3 +
Week7 Polynomials/Assignment (in Dutch).pdf | Bin 0 -> 132898 bytes
Week7 Polynomials/Week7.tar.gz | Bin 0 -> 5487 bytes
Week7 Polynomials/build.xml | 73 +
Week7 Polynomials/nbproject/build-impl.xml | 1413 ++++++++++++++++++++
Week7 Polynomials/nbproject/genfiles.properties | 8 +
Week7 Polynomials/nbproject/project.properties | 73 +
Week7 Polynomials/nbproject/project.xml | 15 +
Week7 Polynomials/src/main/Main.java | 23 +
Week7 Polynomials/src/polynomial/Polynomial.java | 189 +++
Week7 Polynomials/src/polynomial/Term.java | 145 ++
.../test/polynomial/PolynomialTest.java | 226 ++++
Week7/Assignment (in Dutch).pdf | Bin 132898 -> 0 bytes
Week7/Week7.tar.gz | Bin 5487 -> 0 bytes
Week7/build.xml | 73 -
Week7/nbproject/build-impl.xml | 1413 --------------------
Week7/nbproject/genfiles.properties | 8 -
Week7/nbproject/private/private.properties | 2 -
Week7/nbproject/private/private.xml | 7 -
Week7/nbproject/project.properties | 72 -
Week7/nbproject/project.xml | 15 -
Week7/src/main/Main.java | 23 -
Week7/src/polynomial/Polynomial.java | 189 ---
Week7/src/polynomial/Term.java | 145 --
Week7/test/polynomial/PolynomialTest.java | 226 ----
Week8 Quadtrees/.gitignore | 3 +
Week8 Quadtrees/Assignment (in Dutch).pdf | Bin 0 -> 147901 bytes
Week8 Quadtrees/Week8.tar.gz | Bin 0 -> 4059 bytes
Week8 Quadtrees/build.xml | 73 +
.../build/classes/.netbeans_automatic_build | 0
.../build/classes/.netbeans_update_resources | 0
Week8 Quadtrees/build/classes/qtrees/Bitmap.class | Bin 0 -> 1317 bytes
.../build/classes/qtrees/BlackLeaf.class | Bin 0 -> 369 bytes
.../build/classes/qtrees/GreyNode.class | Bin 0 -> 1715 bytes
Week8 Quadtrees/build/classes/qtrees/QTNode.class | Bin 0 -> 1388 bytes
Week8 Quadtrees/build/classes/qtrees/QTree.class | Bin 0 -> 2259 bytes
Week8 Quadtrees/build/classes/qtrees/Qtrees.class | Bin 0 -> 1404 bytes
.../build/classes/qtrees/WhiteLeaf.class | Bin 0 -> 369 bytes
Week8 Quadtrees/nbproject/build-impl.xml | 1413 ++++++++++++++++++++
Week8 Quadtrees/nbproject/genfiles.properties | 8 +
.../nbproject/private/private.properties | 2 +
Week8 Quadtrees/nbproject/private/private.xml | 7 +
Week8 Quadtrees/nbproject/project.properties | 72 +
Week8 Quadtrees/nbproject/project.xml | 15 +
Week8 Quadtrees/src/qtrees/Bitmap.java | 73 +
Week8 Quadtrees/src/qtrees/BlackLeaf.java | 13 +
Week8 Quadtrees/src/qtrees/GreyNode.java | 59 +
Week8 Quadtrees/src/qtrees/QTNode.java | 63 +
Week8 Quadtrees/src/qtrees/QTree.java | 102 ++
Week8 Quadtrees/src/qtrees/Qtrees.java | 54 +
Week8 Quadtrees/src/qtrees/WhiteLeaf.java | 13 +
Week8/Assignment (in Dutch).pdf | Bin 147901 -> 0 bytes
Week8/Week8.tar.gz | Bin 4059 -> 0 bytes
Week8/build.xml | 73 -
Week8/nbproject/build-impl.xml | 1413 --------------------
Week8/nbproject/genfiles.properties | 8 -
Week8/nbproject/project.properties | 72 -
Week8/nbproject/project.xml | 15 -
Week8/src/qtrees/Bitmap.java | 73 -
Week8/src/qtrees/BlackLeaf.java | 13 -
Week8/src/qtrees/GreyNode.java | 59 -
Week8/src/qtrees/QTNode.java | 63 -
Week8/src/qtrees/QTree.java | 102 --
Week8/src/qtrees/Qtrees.java | 54 -
Week8/src/qtrees/WhiteLeaf.java | 13 -
Week9 Webshop/.gitignore | 9 +
Week9 Webshop/Assignment (in Dutch).pdf | Bin 0 -> 84105 bytes
Week9 Webshop/Assignment appendix (in Dutch).pdf | Bin 0 -> 43076 bytes
Week9 Webshop/build.xml | 73 +
.../build/classes/.netbeans_automatic_build | 0
.../build/classes/.netbeans_update_resources | 0
.../classes/com/camilstaps/shop/Article.class | Bin 0 -> 1947 bytes
.../com/camilstaps/shop/CLIInteraction.class | Bin 0 -> 2655 bytes
.../build/classes/com/camilstaps/shop/Cart.class | Bin 0 -> 1836 bytes
.../classes/com/camilstaps/shop/Category.class | Bin 0 -> 492 bytes
.../classes/com/camilstaps/shop/Command.class | Bin 0 -> 479 bytes
.../classes/com/camilstaps/shop/Database.class | Bin 0 -> 9959 bytes
.../classes/com/camilstaps/shop/DatabaseItem.class | Bin 0 -> 329 bytes
.../camilstaps/shop/DuplicateEntryException.class | Bin 0 -> 337 bytes
.../camilstaps/shop/InputRequiredException.class | Bin 0 -> 334 bytes
.../camilstaps/shop/ItemNotFoundException.class | Bin 0 -> 331 bytes
.../build/classes/com/camilstaps/shop/Order.class | Bin 0 -> 1776 bytes
.../classes/com/camilstaps/shop/Shell$1.class | Bin 0 -> 203 bytes
.../classes/com/camilstaps/shop/Shell$2.class | Bin 0 -> 203 bytes
.../shop/Shell$AdminRequiredException.class | Bin 0 -> 748 bytes
.../shop/Shell$LoginRequiredException.class | Bin 0 -> 748 bytes
.../build/classes/com/camilstaps/shop/Shell.class | Bin 0 -> 11192 bytes
.../build/classes/com/camilstaps/shop/Shop.class | Bin 0 -> 612 bytes
.../build/classes/com/camilstaps/shop/User.class | Bin 0 -> 4178 bytes
.../com/camilstaps/shop/UserInteraction.class | Bin 0 -> 4438 bytes
Week9 Webshop/docs/Makefile | 7 +
.../Activity_diagram_adding_article_to_cart.png | Bin 0 -> 119492 bytes
.../Sequence_diagram_adding_article_to_cart.png | Bin 0 -> 173558 bytes
Week9 Webshop/docs/png/com.camilstaps.shop.png | Bin 0 -> 585627 bytes
Week9 Webshop/docs/solution.tex | 126 ++
Week9 Webshop/manifest.mf | 3 +
Week9 Webshop/nbproject/build-impl.xml | 1396 +++++++++++++++++++
Week9 Webshop/nbproject/genfiles.properties | 8 +
Week9 Webshop/nbproject/private/private.properties | 2 +
Week9 Webshop/nbproject/private/private.xml | 7 +
Week9 Webshop/nbproject/project.properties | 73 +
Week9 Webshop/nbproject/project.xml | 13 +
Week9 Webshop/src/com/camilstaps/shop/Article.java | 89 ++
.../src/com/camilstaps/shop/CLIInteraction.java | 94 ++
Week9 Webshop/src/com/camilstaps/shop/Cart.java | 67 +
.../src/com/camilstaps/shop/Category.java | 28 +
Week9 Webshop/src/com/camilstaps/shop/Command.java | 25 +
.../src/com/camilstaps/shop/Database.java | 393 ++++++
.../src/com/camilstaps/shop/DatabaseItem.java | 15 +
.../camilstaps/shop/DuplicateEntryException.java | 18 +
.../camilstaps/shop/InputRequiredException.java | 13 +
.../com/camilstaps/shop/ItemNotFoundException.java | 14 +
Week9 Webshop/src/com/camilstaps/shop/Order.java | 67 +
Week9 Webshop/src/com/camilstaps/shop/Shell.java | 476 +++++++
Week9 Webshop/src/com/camilstaps/shop/Shop.java | 23 +
Week9 Webshop/src/com/camilstaps/shop/User.java | 143 ++
.../src/com/camilstaps/shop/UserInteraction.java | 198 +++
Week9 Webshop/uml-project.vpp | Bin 0 -> 737280 bytes
Week9/.gitignore | 9 -
Week9/Assignment (in Dutch).pdf | Bin 84105 -> 0 bytes
Week9/Assignment appendix (in Dutch).pdf | Bin 43076 -> 0 bytes
Week9/build.xml | 73 -
Week9/docs/Makefile | 7 -
.../Activity_diagram_adding_article_to_cart.png | Bin 119492 -> 0 bytes
.../Sequence_diagram_adding_article_to_cart.png | Bin 173558 -> 0 bytes
Week9/docs/png/com.camilstaps.shop.png | Bin 585627 -> 0 bytes
Week9/docs/solution.tex | 126 --
Week9/manifest.mf | 3 -
Week9/nbproject/build-impl.xml | 1396 -------------------
Week9/nbproject/genfiles.properties | 8 -
Week9/nbproject/project.properties | 73 -
Week9/nbproject/project.xml | 13 -
Week9/src/com/camilstaps/shop/Article.java | 89 --
Week9/src/com/camilstaps/shop/CLIInteraction.java | 94 --
Week9/src/com/camilstaps/shop/Cart.java | 67 -
Week9/src/com/camilstaps/shop/Category.java | 28 -
Week9/src/com/camilstaps/shop/Command.java | 25 -
Week9/src/com/camilstaps/shop/Database.java | 393 ------
Week9/src/com/camilstaps/shop/DatabaseItem.java | 15 -
.../camilstaps/shop/DuplicateEntryException.java | 18 -
.../camilstaps/shop/InputRequiredException.java | 13 -
.../com/camilstaps/shop/ItemNotFoundException.java | 14 -
Week9/src/com/camilstaps/shop/Order.java | 67 -
Week9/src/com/camilstaps/shop/Shell.java | 476 -------
Week9/src/com/camilstaps/shop/Shop.java | 23 -
Week9/src/com/camilstaps/shop/User.java | 143 --
Week9/src/com/camilstaps/shop/UserInteraction.java | 198 ---
Week9/uml-project.vpp | Bin 737280 -> 0 bytes
274 files changed, 13688 insertions(+), 13663 deletions(-)
delete mode 100644 .gitignore
create mode 100644 Week4 Drawing loipes/.gitignore
create mode 100644 Week4 Drawing loipes/Assignment (in Dutch).pdf
create mode 100644 Week4 Drawing loipes/build.xml
create mode 100644 Week4 Drawing loipes/build/classes/no.png
create mode 100644 Week4 Drawing loipes/build/classes/nw.png
create mode 100644 Week4 Drawing loipes/build/classes/nz.png
create mode 100644 Week4 Drawing loipes/build/classes/nzow.png
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt$1.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/Fragment.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/InfoLoipe.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/Loipe.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje$1.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/Punt.class
create mode 100644 Week4 Drawing loipes/build/classes/oo15loipe/TekenLoipe.class
create mode 100644 Week4 Drawing loipes/build/classes/ow.png
create mode 100644 Week4 Drawing loipes/build/classes/week4/Week4.class
create mode 100644 Week4 Drawing loipes/build/classes/zo.png
create mode 100644 Week4 Drawing loipes/build/classes/zw.png
create mode 100644 Week4 Drawing loipes/manifest.mf
create mode 100644 Week4 Drawing loipes/nbproject/build-impl.xml
create mode 100644 Week4 Drawing loipes/nbproject/genfiles.properties
create mode 100644 Week4 Drawing loipes/nbproject/private/config.properties
create mode 100644 Week4 Drawing loipes/nbproject/private/private.properties
create mode 100644 Week4 Drawing loipes/nbproject/private/private.xml
create mode 100644 Week4 Drawing loipes/nbproject/project.properties
create mode 100644 Week4 Drawing loipes/nbproject/project.xml
create mode 100644 Week4 Drawing loipes/src/no.png
create mode 100644 Week4 Drawing loipes/src/nw.png
create mode 100644 Week4 Drawing loipes/src/nz.png
create mode 100644 Week4 Drawing loipes/src/nzow.png
create mode 100644 Week4 Drawing loipes/src/oo15loipe/AsciiArt.java
create mode 100644 Week4 Drawing loipes/src/oo15loipe/Fragment.java
create mode 100644 Week4 Drawing loipes/src/oo15loipe/InfoLoipe.java
create mode 100644 Week4 Drawing loipes/src/oo15loipe/Loipe.java
create mode 100644 Week4 Drawing loipes/src/oo15loipe/LoipePlaatje.java
create mode 100644 Week4 Drawing loipes/src/oo15loipe/Punt.java
create mode 100644 Week4 Drawing loipes/src/oo15loipe/TekenLoipe.java
create mode 100644 Week4 Drawing loipes/src/ow.png
create mode 100644 Week4 Drawing loipes/src/week4/Week4.java
create mode 100644 Week4 Drawing loipes/src/zo.png
create mode 100644 Week4 Drawing loipes/src/zw.png
create mode 100644 Week4 Drawing loipes/week4-retake.tar.gz
create mode 100644 Week4 Drawing loipes/week4.tar.gz
delete mode 100644 Week4/Assignment (in Dutch).pdf
delete mode 100644 Week4/build.xml
delete mode 100644 Week4/manifest.mf
delete mode 100644 Week4/nbproject/build-impl.xml
delete mode 100644 Week4/nbproject/genfiles.properties
delete mode 100644 Week4/nbproject/project.properties
delete mode 100644 Week4/nbproject/project.xml
delete mode 100644 Week4/src/no.png
delete mode 100644 Week4/src/nw.png
delete mode 100644 Week4/src/nz.png
delete mode 100644 Week4/src/nzow.png
delete mode 100644 Week4/src/oo15loipe/AsciiArt.java
delete mode 100644 Week4/src/oo15loipe/Fragment.java
delete mode 100644 Week4/src/oo15loipe/InfoLoipe.java
delete mode 100644 Week4/src/oo15loipe/Loipe.java
delete mode 100644 Week4/src/oo15loipe/LoipePlaatje.java
delete mode 100644 Week4/src/oo15loipe/Punt.java
delete mode 100644 Week4/src/oo15loipe/TekenLoipe.java
delete mode 100644 Week4/src/ow.png
delete mode 100644 Week4/src/week4/Week4.java
delete mode 100644 Week4/src/zo.png
delete mode 100644 Week4/src/zw.png
delete mode 100644 Week4/week4-retake.tar.gz
delete mode 100644 Week4/week4.tar.gz
create mode 100644 Week5 Quiz/.gitignore
create mode 100644 Week5 Quiz/Assignment (in Dutch).pdf
create mode 100644 Week5 Quiz/build.xml
create mode 100644 Week5 Quiz/manifest.mf
create mode 100644 Week5 Quiz/nbproject/build-impl.xml
create mode 100644 Week5 Quiz/nbproject/genfiles.properties
create mode 100644 Week5 Quiz/nbproject/project.properties
create mode 100644 Week5 Quiz/nbproject/project.xml
create mode 100644 Week5 Quiz/src/week5/MCQuestion.java
create mode 100644 Week5 Quiz/src/week5/OpenQuestion.java
create mode 100644 Week5 Quiz/src/week5/Question.java
create mode 100644 Week5 Quiz/src/week5/TCQuestion.java
create mode 100644 Week5 Quiz/src/week5/Week5.java
create mode 100644 Week5 Quiz/week5.tar.gz
delete mode 100644 Week5/Assignment (in Dutch).pdf
delete mode 100644 Week5/build.xml
delete mode 100644 Week5/manifest.mf
delete mode 100644 Week5/nbproject/build-impl.xml
delete mode 100644 Week5/nbproject/genfiles.properties
delete mode 100644 Week5/nbproject/project.properties
delete mode 100644 Week5/nbproject/project.xml
delete mode 100644 Week5/src/week5/MCQuestion.java
delete mode 100644 Week5/src/week5/OpenQuestion.java
delete mode 100644 Week5/src/week5/Question.java
delete mode 100644 Week5/src/week5/TCQuestion.java
delete mode 100644 Week5/src/week5/Week5.java
delete mode 100644 Week5/week5.tar.gz
create mode 100644 Week6 Sliding game solver/.gitignore
create mode 100644 Week6 Sliding game solver/Assignment (in Dutch).pdf
create mode 100644 Week6 Sliding game solver/build.xml
create mode 100644 Week6 Sliding game solver/manifest.mf
create mode 100644 Week6 Sliding game solver/nbproject/build-impl.xml
create mode 100644 Week6 Sliding game solver/nbproject/genfiles.properties
create mode 100644 Week6 Sliding game solver/nbproject/project.properties
create mode 100644 Week6 Sliding game solver/nbproject/project.xml
create mode 100644 Week6 Sliding game solver/src/Configuration.java
create mode 100644 Week6 Sliding game solver/src/Direction.java
create mode 100644 Week6 Sliding game solver/src/Main.java
create mode 100644 Week6 Sliding game solver/src/Node.java
create mode 100644 Week6 Sliding game solver/src/SlidingGame.java
create mode 100644 Week6 Sliding game solver/src/Solver.java
create mode 100644 Week6 Sliding game solver/week6.tar.gz
delete mode 100644 Week6/Assignment (in Dutch).pdf
delete mode 100644 Week6/build.xml
delete mode 100644 Week6/manifest.mf
delete mode 100644 Week6/nbproject/build-impl.xml
delete mode 100644 Week6/nbproject/genfiles.properties
delete mode 100644 Week6/nbproject/project.properties
delete mode 100644 Week6/nbproject/project.xml
delete mode 100644 Week6/src/Configuration.java
delete mode 100644 Week6/src/Direction.java
delete mode 100644 Week6/src/Main.java
delete mode 100644 Week6/src/Node.java
delete mode 100644 Week6/src/SlidingGame.java
delete mode 100644 Week6/src/Solver.java
delete mode 100644 Week6/week6.tar.gz
create mode 100644 Week7 Polynomials/.gitignore
create mode 100644 Week7 Polynomials/Assignment (in Dutch).pdf
create mode 100644 Week7 Polynomials/Week7.tar.gz
create mode 100644 Week7 Polynomials/build.xml
create mode 100644 Week7 Polynomials/nbproject/build-impl.xml
create mode 100644 Week7 Polynomials/nbproject/genfiles.properties
create mode 100644 Week7 Polynomials/nbproject/project.properties
create mode 100644 Week7 Polynomials/nbproject/project.xml
create mode 100644 Week7 Polynomials/src/main/Main.java
create mode 100644 Week7 Polynomials/src/polynomial/Polynomial.java
create mode 100644 Week7 Polynomials/src/polynomial/Term.java
create mode 100644 Week7 Polynomials/test/polynomial/PolynomialTest.java
delete mode 100644 Week7/Assignment (in Dutch).pdf
delete mode 100644 Week7/Week7.tar.gz
delete mode 100644 Week7/build.xml
delete mode 100644 Week7/nbproject/build-impl.xml
delete mode 100644 Week7/nbproject/genfiles.properties
delete mode 100644 Week7/nbproject/private/private.properties
delete mode 100644 Week7/nbproject/private/private.xml
delete mode 100644 Week7/nbproject/project.properties
delete mode 100644 Week7/nbproject/project.xml
delete mode 100644 Week7/src/main/Main.java
delete mode 100644 Week7/src/polynomial/Polynomial.java
delete mode 100644 Week7/src/polynomial/Term.java
delete mode 100644 Week7/test/polynomial/PolynomialTest.java
create mode 100644 Week8 Quadtrees/.gitignore
create mode 100644 Week8 Quadtrees/Assignment (in Dutch).pdf
create mode 100644 Week8 Quadtrees/Week8.tar.gz
create mode 100644 Week8 Quadtrees/build.xml
create mode 100644 Week8 Quadtrees/build/classes/.netbeans_automatic_build
create mode 100644 Week8 Quadtrees/build/classes/.netbeans_update_resources
create mode 100644 Week8 Quadtrees/build/classes/qtrees/Bitmap.class
create mode 100644 Week8 Quadtrees/build/classes/qtrees/BlackLeaf.class
create mode 100644 Week8 Quadtrees/build/classes/qtrees/GreyNode.class
create mode 100644 Week8 Quadtrees/build/classes/qtrees/QTNode.class
create mode 100644 Week8 Quadtrees/build/classes/qtrees/QTree.class
create mode 100644 Week8 Quadtrees/build/classes/qtrees/Qtrees.class
create mode 100644 Week8 Quadtrees/build/classes/qtrees/WhiteLeaf.class
create mode 100644 Week8 Quadtrees/nbproject/build-impl.xml
create mode 100644 Week8 Quadtrees/nbproject/genfiles.properties
create mode 100644 Week8 Quadtrees/nbproject/private/private.properties
create mode 100644 Week8 Quadtrees/nbproject/private/private.xml
create mode 100644 Week8 Quadtrees/nbproject/project.properties
create mode 100644 Week8 Quadtrees/nbproject/project.xml
create mode 100644 Week8 Quadtrees/src/qtrees/Bitmap.java
create mode 100644 Week8 Quadtrees/src/qtrees/BlackLeaf.java
create mode 100644 Week8 Quadtrees/src/qtrees/GreyNode.java
create mode 100644 Week8 Quadtrees/src/qtrees/QTNode.java
create mode 100644 Week8 Quadtrees/src/qtrees/QTree.java
create mode 100644 Week8 Quadtrees/src/qtrees/Qtrees.java
create mode 100644 Week8 Quadtrees/src/qtrees/WhiteLeaf.java
delete mode 100644 Week8/Assignment (in Dutch).pdf
delete mode 100644 Week8/Week8.tar.gz
delete mode 100644 Week8/build.xml
delete mode 100644 Week8/nbproject/build-impl.xml
delete mode 100644 Week8/nbproject/genfiles.properties
delete mode 100644 Week8/nbproject/project.properties
delete mode 100644 Week8/nbproject/project.xml
delete mode 100644 Week8/src/qtrees/Bitmap.java
delete mode 100644 Week8/src/qtrees/BlackLeaf.java
delete mode 100644 Week8/src/qtrees/GreyNode.java
delete mode 100644 Week8/src/qtrees/QTNode.java
delete mode 100644 Week8/src/qtrees/QTree.java
delete mode 100644 Week8/src/qtrees/Qtrees.java
delete mode 100644 Week8/src/qtrees/WhiteLeaf.java
create mode 100644 Week9 Webshop/.gitignore
create mode 100644 Week9 Webshop/Assignment (in Dutch).pdf
create mode 100644 Week9 Webshop/Assignment appendix (in Dutch).pdf
create mode 100644 Week9 Webshop/build.xml
create mode 100644 Week9 Webshop/build/classes/.netbeans_automatic_build
create mode 100644 Week9 Webshop/build/classes/.netbeans_update_resources
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Article.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/CLIInteraction.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Cart.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Category.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Command.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Database.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/DatabaseItem.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/DuplicateEntryException.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/InputRequiredException.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/ItemNotFoundException.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Order.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Shell$1.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Shell$2.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Shell$AdminRequiredException.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Shell$LoginRequiredException.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Shell.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/Shop.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/User.class
create mode 100644 Week9 Webshop/build/classes/com/camilstaps/shop/UserInteraction.class
create mode 100644 Week9 Webshop/docs/Makefile
create mode 100644 Week9 Webshop/docs/png/Activity_diagram_adding_article_to_cart.png
create mode 100644 Week9 Webshop/docs/png/Sequence_diagram_adding_article_to_cart.png
create mode 100644 Week9 Webshop/docs/png/com.camilstaps.shop.png
create mode 100644 Week9 Webshop/docs/solution.tex
create mode 100644 Week9 Webshop/manifest.mf
create mode 100644 Week9 Webshop/nbproject/build-impl.xml
create mode 100644 Week9 Webshop/nbproject/genfiles.properties
create mode 100644 Week9 Webshop/nbproject/private/private.properties
create mode 100644 Week9 Webshop/nbproject/private/private.xml
create mode 100644 Week9 Webshop/nbproject/project.properties
create mode 100644 Week9 Webshop/nbproject/project.xml
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Article.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/CLIInteraction.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Cart.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Category.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Command.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Database.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/DatabaseItem.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/DuplicateEntryException.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/InputRequiredException.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/ItemNotFoundException.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Order.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Shell.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/Shop.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/User.java
create mode 100644 Week9 Webshop/src/com/camilstaps/shop/UserInteraction.java
create mode 100644 Week9 Webshop/uml-project.vpp
delete mode 100644 Week9/.gitignore
delete mode 100644 Week9/Assignment (in Dutch).pdf
delete mode 100644 Week9/Assignment appendix (in Dutch).pdf
delete mode 100644 Week9/build.xml
delete mode 100644 Week9/docs/Makefile
delete mode 100644 Week9/docs/png/Activity_diagram_adding_article_to_cart.png
delete mode 100644 Week9/docs/png/Sequence_diagram_adding_article_to_cart.png
delete mode 100644 Week9/docs/png/com.camilstaps.shop.png
delete mode 100644 Week9/docs/solution.tex
delete mode 100644 Week9/manifest.mf
delete mode 100644 Week9/nbproject/build-impl.xml
delete mode 100644 Week9/nbproject/genfiles.properties
delete mode 100644 Week9/nbproject/project.properties
delete mode 100644 Week9/nbproject/project.xml
delete mode 100644 Week9/src/com/camilstaps/shop/Article.java
delete mode 100644 Week9/src/com/camilstaps/shop/CLIInteraction.java
delete mode 100644 Week9/src/com/camilstaps/shop/Cart.java
delete mode 100644 Week9/src/com/camilstaps/shop/Category.java
delete mode 100644 Week9/src/com/camilstaps/shop/Command.java
delete mode 100644 Week9/src/com/camilstaps/shop/Database.java
delete mode 100644 Week9/src/com/camilstaps/shop/DatabaseItem.java
delete mode 100644 Week9/src/com/camilstaps/shop/DuplicateEntryException.java
delete mode 100644 Week9/src/com/camilstaps/shop/InputRequiredException.java
delete mode 100644 Week9/src/com/camilstaps/shop/ItemNotFoundException.java
delete mode 100644 Week9/src/com/camilstaps/shop/Order.java
delete mode 100644 Week9/src/com/camilstaps/shop/Shell.java
delete mode 100644 Week9/src/com/camilstaps/shop/Shop.java
delete mode 100644 Week9/src/com/camilstaps/shop/User.java
delete mode 100644 Week9/src/com/camilstaps/shop/UserInteraction.java
delete mode 100644 Week9/uml-project.vpp
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 5a0c41f..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-/Week4/nbproject/private/
-/Week4/build/
-/Week5/nbproject/private/
-/Week6/nbproject/private/
-/Week6/build/
-/Week7/build/
-/Week5/build/
-/Week4/dist/
-/Week8/nbproject/private/
-/Week8/build/
-/Week9/nbproject/private/
-/Week9/build/
\ No newline at end of file
diff --git a/Week4 Drawing loipes/.gitignore b/Week4 Drawing loipes/.gitignore
new file mode 100644
index 0000000..4523fc2
--- /dev/null
+++ b/Week4 Drawing loipes/.gitignore
@@ -0,0 +1,3 @@
+nbproject/private/
+build/
+dist/
diff --git a/Week4 Drawing loipes/Assignment (in Dutch).pdf b/Week4 Drawing loipes/Assignment (in Dutch).pdf
new file mode 100644
index 0000000..6a8e377
Binary files /dev/null and b/Week4 Drawing loipes/Assignment (in Dutch).pdf differ
diff --git a/Week4 Drawing loipes/build.xml b/Week4 Drawing loipes/build.xml
new file mode 100644
index 0000000..74b5c8d
--- /dev/null
+++ b/Week4 Drawing loipes/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Week4 Drawing loipes.
+
+
+
diff --git a/Week4 Drawing loipes/build/classes/no.png b/Week4 Drawing loipes/build/classes/no.png
new file mode 100644
index 0000000..daaec27
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/no.png differ
diff --git a/Week4 Drawing loipes/build/classes/nw.png b/Week4 Drawing loipes/build/classes/nw.png
new file mode 100644
index 0000000..2699df3
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/nw.png differ
diff --git a/Week4 Drawing loipes/build/classes/nz.png b/Week4 Drawing loipes/build/classes/nz.png
new file mode 100644
index 0000000..c4eeb9c
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/nz.png differ
diff --git a/Week4 Drawing loipes/build/classes/nzow.png b/Week4 Drawing loipes/build/classes/nzow.png
new file mode 100644
index 0000000..96ab874
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/nzow.png differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt$1.class b/Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt$1.class
new file mode 100644
index 0000000..50cde3e
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt$1.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt.class b/Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt.class
new file mode 100644
index 0000000..cb460b6
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/AsciiArt.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/Fragment.class b/Week4 Drawing loipes/build/classes/oo15loipe/Fragment.class
new file mode 100644
index 0000000..1ad49c9
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/Fragment.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/InfoLoipe.class b/Week4 Drawing loipes/build/classes/oo15loipe/InfoLoipe.class
new file mode 100644
index 0000000..81712b0
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/InfoLoipe.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/Loipe.class b/Week4 Drawing loipes/build/classes/oo15loipe/Loipe.class
new file mode 100644
index 0000000..c958db1
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/Loipe.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje$1.class b/Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje$1.class
new file mode 100644
index 0000000..9b8d107
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje$1.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje.class b/Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje.class
new file mode 100644
index 0000000..0fd80a3
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/LoipePlaatje.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/Punt.class b/Week4 Drawing loipes/build/classes/oo15loipe/Punt.class
new file mode 100644
index 0000000..f3e2794
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/Punt.class differ
diff --git a/Week4 Drawing loipes/build/classes/oo15loipe/TekenLoipe.class b/Week4 Drawing loipes/build/classes/oo15loipe/TekenLoipe.class
new file mode 100644
index 0000000..7eb406b
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/oo15loipe/TekenLoipe.class differ
diff --git a/Week4 Drawing loipes/build/classes/ow.png b/Week4 Drawing loipes/build/classes/ow.png
new file mode 100644
index 0000000..8d35019
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/ow.png differ
diff --git a/Week4 Drawing loipes/build/classes/week4/Week4.class b/Week4 Drawing loipes/build/classes/week4/Week4.class
new file mode 100644
index 0000000..5a31a59
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/week4/Week4.class differ
diff --git a/Week4 Drawing loipes/build/classes/zo.png b/Week4 Drawing loipes/build/classes/zo.png
new file mode 100644
index 0000000..1b578c0
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/zo.png differ
diff --git a/Week4 Drawing loipes/build/classes/zw.png b/Week4 Drawing loipes/build/classes/zw.png
new file mode 100644
index 0000000..702e57d
Binary files /dev/null and b/Week4 Drawing loipes/build/classes/zw.png differ
diff --git a/Week4 Drawing loipes/manifest.mf b/Week4 Drawing loipes/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Week4 Drawing loipes/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Week4 Drawing loipes/nbproject/build-impl.xml b/Week4 Drawing loipes/nbproject/build-impl.xml
new file mode 100644
index 0000000..234e2fa
--- /dev/null
+++ b/Week4 Drawing loipes/nbproject/build-impl.xml
@@ -0,0 +1,1413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week4 Drawing loipes/nbproject/genfiles.properties b/Week4 Drawing loipes/nbproject/genfiles.properties
new file mode 100644
index 0000000..7634919
--- /dev/null
+++ b/Week4 Drawing loipes/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=38586266
+build.xml.script.CRC32=67e1167d
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=38586266
+nbproject/build-impl.xml.script.CRC32=ea775b21
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week4 Drawing loipes/nbproject/private/config.properties b/Week4 Drawing loipes/nbproject/private/config.properties
new file mode 100644
index 0000000..e69de29
diff --git a/Week4 Drawing loipes/nbproject/private/private.properties b/Week4 Drawing loipes/nbproject/private/private.properties
new file mode 100644
index 0000000..aae1ca7
--- /dev/null
+++ b/Week4 Drawing loipes/nbproject/private/private.properties
@@ -0,0 +1,6 @@
+compile.on.save=true
+do.depend=false
+do.jar=true
+javac.debug=true
+javadoc.preview=true
+user.properties.file=/home/camilstaps/.netbeans/8.0.2/build.properties
diff --git a/Week4 Drawing loipes/nbproject/private/private.xml b/Week4 Drawing loipes/nbproject/private/private.xml
new file mode 100644
index 0000000..2eee429
--- /dev/null
+++ b/Week4 Drawing loipes/nbproject/private/private.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/Week4 Drawing loipes/nbproject/project.properties b/Week4 Drawing loipes/nbproject/project.properties
new file mode 100644
index 0000000..d614a8d
--- /dev/null
+++ b/Week4 Drawing loipes/nbproject/project.properties
@@ -0,0 +1,75 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=Week4 Drawing loipes
+application.vendor=camilstaps
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Week4_Drawing_loipes.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.7
+javac.target=1.7
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=week4.Week4
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Week4 Drawing loipes/nbproject/project.xml b/Week4 Drawing loipes/nbproject/project.xml
new file mode 100644
index 0000000..9539ab9
--- /dev/null
+++ b/Week4 Drawing loipes/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Week4 Drawing loipes
+
+
+
+
+
+
+
+
+
diff --git a/Week4 Drawing loipes/src/no.png b/Week4 Drawing loipes/src/no.png
new file mode 100644
index 0000000..daaec27
Binary files /dev/null and b/Week4 Drawing loipes/src/no.png differ
diff --git a/Week4 Drawing loipes/src/nw.png b/Week4 Drawing loipes/src/nw.png
new file mode 100644
index 0000000..2699df3
Binary files /dev/null and b/Week4 Drawing loipes/src/nw.png differ
diff --git a/Week4 Drawing loipes/src/nz.png b/Week4 Drawing loipes/src/nz.png
new file mode 100644
index 0000000..c4eeb9c
Binary files /dev/null and b/Week4 Drawing loipes/src/nz.png differ
diff --git a/Week4 Drawing loipes/src/nzow.png b/Week4 Drawing loipes/src/nzow.png
new file mode 100644
index 0000000..96ab874
Binary files /dev/null and b/Week4 Drawing loipes/src/nzow.png differ
diff --git a/Week4 Drawing loipes/src/oo15loipe/AsciiArt.java b/Week4 Drawing loipes/src/oo15loipe/AsciiArt.java
new file mode 100644
index 0000000..4072d54
--- /dev/null
+++ b/Week4 Drawing loipes/src/oo15loipe/AsciiArt.java
@@ -0,0 +1,51 @@
+package oo15loipe;
+
+/**
+ * A class that draws the loipe as ascii-art.
+ *
+ * @author Thijs Heijligenberg, s4451414, Camil Staps, s4498062
+ */
+public class AsciiArt implements TekenLoipe{
+ private InfoLoipe L;
+ private Punt man;
+
+ /**
+ * Create the instance based on a loipe
+ *
+ * @param s
+ */
+ public AsciiArt(InfoLoipe s){
+ this.L = s;
+ this.man = new Punt(null);
+ }
+
+ @Override
+ public void setPosition(Punt p){
+ this.man = p;
+ }
+
+ @Override
+ public void teken(){
+ for(int j = 0; j < L.getHeight(); j++){
+ for(int i = 0; i < L.getWidth(); i++){
+ Fragment f = L.getFragment(i,j);
+ if(i == man.getX() && j == man.getY()){
+ System.out.print('*');
+ } else if (f == null) {
+ System.out.print(' ');
+ } else {
+ switch (f){
+ case KR: System.out.print('+'); break;
+ case NZ: System.out.print('|'); break;
+ case OW: System.out.print('-'); break;
+ case NO: System.out.print('`'); break;
+ case NW: System.out.print(','); break;
+ case ZO: System.out.print(','); break;
+ case ZW: System.out.print('.'); break;
+ }
+ }
+ }
+ System.out.print("\n");
+ }
+ }
+}
diff --git a/Week4 Drawing loipes/src/oo15loipe/Fragment.java b/Week4 Drawing loipes/src/oo15loipe/Fragment.java
new file mode 100644
index 0000000..a4668da
--- /dev/null
+++ b/Week4 Drawing loipes/src/oo15loipe/Fragment.java
@@ -0,0 +1,8 @@
+package oo15loipe;
+
+/**
+ * enum to describe a fragment of path by its direction (or as a crossing)
+ *
+ * @author Thijs Heijligenberg, s4451414, Camil Staps, s4498062
+ */
+public enum Fragment {NZ, OW, NO,NW, ZO, ZW, KR};
diff --git a/Week4 Drawing loipes/src/oo15loipe/InfoLoipe.java b/Week4 Drawing loipes/src/oo15loipe/InfoLoipe.java
new file mode 100644
index 0000000..a1cf182
--- /dev/null
+++ b/Week4 Drawing loipes/src/oo15loipe/InfoLoipe.java
@@ -0,0 +1,35 @@
+package oo15loipe;
+
+/**
+ * Interface for a class describing a Loipe
+ *
+ * @author Camil Staps, s4498062, Thijs Heijligenberg, s4451414
+ */
+public interface InfoLoipe {
+
+ public int getWidth( ) ; // grootte in oostwest r i cht ing
+ public int getHeight( ) ; // grootte in noordzuid r i cht ing
+
+ /**
+ * Get the fragment at position (x, y)
+ *
+ * @param x
+ * @param y
+ * @return
+ */
+ public Fragment getFragment( int x, int y) ; // fragment van de loipe op po s i t i e (x , y)
+
+ /**
+ * Get the first position of the loipe
+ *
+ * @return
+ */
+ public Punt start( ) ; // Het startpunt op de kaart
+
+ /**
+ * Get the next position in the loipe
+ * @return
+ */
+ public Punt stap( ) ; // het volgende punt op de route
+}
+
diff --git a/Week4 Drawing loipes/src/oo15loipe/Loipe.java b/Week4 Drawing loipes/src/oo15loipe/Loipe.java
new file mode 100644
index 0000000..9155988
--- /dev/null
+++ b/Week4 Drawing loipes/src/oo15loipe/Loipe.java
@@ -0,0 +1,226 @@
+package oo15loipe;
+
+/**
+ * Loipe class
+ *
+ * @author Camil Staps, s4498062 // Thijs Heijligenberg, s4451414
+ */
+public class Loipe implements InfoLoipe {
+
+ /**
+ * Class constants for direction (for readability)
+ */
+ private final static int
+ DIRECTION_EAST = 0,
+ DIRECTION_SOUTH = 1,
+ DIRECTION_WEST = 2,
+ DIRECTION_NORTH = 3;
+
+ /**
+ * The height and width of the loipe
+ */
+ private int height = 0, width = 0;
+
+ /**
+ * Start point
+ * The path in coordinates
+ * The current position
+ * The map as 2D array of Fragments
+ */
+ private Punt start;
+ private Punt[] path;
+ private int path_pointer = 0;
+ private Fragment[][] loipe;
+
+ /**
+ * Construct the loipe based on a path
+ *
+ * @param pad
+ */
+ public Loipe (String pad) {
+ setLoipe(pad);
+ }
+
+ /**
+ * Refresh everything based on a new path
+ *
+ * @param pad
+ */
+ public final void setLoipe(String pad) {
+ setWidthAndHeight(pad);
+ fillLoipe(pad);
+
+ path_pointer = 0;
+ }
+
+ /**
+ * Set the width and height of the loipe based on a path
+ *
+ * @param pad
+ */
+ private void setWidthAndHeight(String pad) {
+ int direction = DIRECTION_NORTH;
+
+ int maxX = 0, maxY = 0, minX = 0, minY = 0;
+ Punt current_point = new Punt(0,0);
+
+ for (int i = 0; i < pad.length(); i++) {
+ if (current_point.getX() < minX)
+ minX = current_point.getX();
+ if (current_point.getX() > maxX)
+ maxX = current_point.getX();
+ if (current_point.getY() < minY)
+ minY = current_point.getY();
+ if (current_point.getY() > maxY)
+ maxY = current_point.getY();
+
+ switch (pad.charAt(i)) {
+ case 'r':
+ switch (direction) {
+ case DIRECTION_EAST: direction = DIRECTION_SOUTH; break;
+ case DIRECTION_SOUTH: direction = DIRECTION_WEST; break;
+ case DIRECTION_WEST: direction = DIRECTION_NORTH; break;
+ case DIRECTION_NORTH: direction = DIRECTION_EAST; break;
+ }
+ break;
+ case 'l':
+ switch (direction) {
+ case DIRECTION_EAST: direction = DIRECTION_NORTH; break;
+ case DIRECTION_SOUTH: direction = DIRECTION_EAST; break;
+ case DIRECTION_WEST: direction = DIRECTION_SOUTH; break;
+ case DIRECTION_NORTH: direction = DIRECTION_WEST; break;
+ }
+ }
+
+ switch (direction) {
+ case DIRECTION_EAST: current_point = new Punt(current_point.getX() + 1, current_point.getY()); break;
+ case DIRECTION_SOUTH: current_point = new Punt(current_point.getX(), current_point.getY() + 1); break;
+ case DIRECTION_WEST: current_point = new Punt(current_point.getX() - 1, current_point.getY()); break;
+ case DIRECTION_NORTH: current_point = new Punt(current_point.getX(), current_point.getY() - 1); break;
+ }
+ }
+
+ height = maxY - minY + 1;
+ width = maxX - minX + 1;
+
+ start = new Punt(-minX, -minY);
+ }
+
+ /**
+ * Fill the loipe with fragments based on a path.
+ * Assumes the width, height and start attributes to be correct.
+ *
+ * @param pad
+ */
+ private void fillLoipe(String pad) {
+ loipe = new Fragment[width + 1][height + 1];
+ path = new Punt[pad.length()];
+ Punt current_point = start;
+ int direction = DIRECTION_NORTH;
+
+ for (int i = 0; i < pad.length(); i++) {
+ path[i] = current_point;
+
+ if (loipe[current_point.getX()][current_point.getY()] != null) {
+ loipe[current_point.getX()][current_point.getY()] = Fragment.KR;
+ } else {
+ switch (pad.charAt(i)) {
+ case 'r':
+ switch (direction) {
+ case DIRECTION_EAST: loipe[current_point.getX()][current_point.getY()] = Fragment.ZW; break;
+ case DIRECTION_SOUTH: loipe[current_point.getX()][current_point.getY()] = Fragment.NW; break;
+ case DIRECTION_WEST: loipe[current_point.getX()][current_point.getY()] = Fragment.NO; break;
+ case DIRECTION_NORTH: loipe[current_point.getX()][current_point.getY()] = Fragment.ZO; break;
+ }
+ break;
+ case 'l':
+ switch (direction) {
+ case DIRECTION_EAST: loipe[current_point.getX()][current_point.getY()] = Fragment.NW; break;
+ case DIRECTION_SOUTH: loipe[current_point.getX()][current_point.getY()] = Fragment.NO; break;
+ case DIRECTION_WEST: loipe[current_point.getX()][current_point.getY()] = Fragment.ZO; break;
+ case DIRECTION_NORTH: loipe[current_point.getX()][current_point.getY()] = Fragment.ZW; break;
+ }
+ break;
+ case 's':
+ switch (direction) {
+ case DIRECTION_EAST:
+ case DIRECTION_WEST:
+ loipe[current_point.getX()][current_point.getY()] = Fragment.OW;
+ break;
+ case DIRECTION_SOUTH:
+ case DIRECTION_NORTH:
+ loipe[current_point.getX()][current_point.getY()] = Fragment.NZ;
+ }
+ }
+ }
+
+ switch (pad.charAt(i)) {
+ case 'r':
+ switch (direction) {
+ case DIRECTION_EAST: direction = DIRECTION_SOUTH; break;
+ case DIRECTION_SOUTH: direction = DIRECTION_WEST; break;
+ case DIRECTION_WEST: direction = DIRECTION_NORTH; break;
+ case DIRECTION_NORTH: direction = DIRECTION_EAST; break;
+ }
+ break;
+ case 'l':
+ switch (direction) {
+ case DIRECTION_EAST: direction = DIRECTION_NORTH; break;
+ case DIRECTION_SOUTH: direction = DIRECTION_EAST; break;
+ case DIRECTION_WEST: direction = DIRECTION_SOUTH; break;
+ case DIRECTION_NORTH: direction = DIRECTION_WEST; break;
+ }
+ }
+
+ switch (direction) {
+ case DIRECTION_EAST: current_point = new Punt(current_point.getX() + 1, current_point.getY()); break;
+ case DIRECTION_SOUTH: current_point = new Punt(current_point.getX(), current_point.getY() + 1); break;
+ case DIRECTION_WEST: current_point = new Punt(current_point.getX() - 1, current_point.getY()); break;
+ case DIRECTION_NORTH: current_point = new Punt(current_point.getX(), current_point.getY() - 1); break;
+ }
+ }
+ }
+
+ @Override
+ public int getHeight() {
+ return height;
+ }
+
+ @Override
+ public int getWidth() {
+ return width;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for (Punt p : path) {
+ sb.append(p).append(" -> ");
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public Fragment getFragment(int x, int y) {
+ return loipe[x][y];
+ }
+
+ @Override
+ public Punt start() {
+ return start;
+ }
+
+ /**
+ * We chose to have the man go back to the start when he has finished the loipe.
+ */
+ @Override
+ public Punt stap() {
+ if (path_pointer >= path.length) {
+ path_pointer = 0;
+ }
+ Punt result = path[path_pointer];
+ path_pointer++;
+ return result;
+ }
+
+}
diff --git a/Week4 Drawing loipes/src/oo15loipe/LoipePlaatje.java b/Week4 Drawing loipes/src/oo15loipe/LoipePlaatje.java
new file mode 100644
index 0000000..db70d28
--- /dev/null
+++ b/Week4 Drawing loipes/src/oo15loipe/LoipePlaatje.java
@@ -0,0 +1,191 @@
+package oo15loipe;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.net.URL;
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author Pieter Koopman
+ */
+public class LoipePlaatje extends JFrame implements TekenLoipe
+{
+ /** Used for painting the tiles.
+ * We assume that all tiles have same width and height.
+ */
+ private final int UNIT;
+
+ /** Color for painting the background. */
+ private static final Color SNOW = new Color(0xF0,0xF0,0xFF);
+
+ /**
+ * The icons for drawing
+ */
+ private final ImageIcon nz, ow, no, nw, zo, zw, nzow;
+
+ private JPanel panel;
+
+ /**
+ * the loipe to be painted and a boolean indicating whether it is okay
+ */
+ private InfoLoipe loipe;
+ private boolean loipeOK = true;
+ /**
+ * previous position for walking the loipe
+ */
+ private Punt previousPos = null;
+
+ /**
+ * Constructor. Fill all icons.
+ */
+ public LoipePlaatje(InfoLoipe s) {
+ super("Loipe");
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ nz = plaatje("nz");
+ ow = plaatje("ow");
+ no = plaatje("no");
+ nw = plaatje("nw");
+ zo = plaatje("zo");
+ zw = plaatje("zw");
+ nzow = plaatje("nzow");
+ UNIT = nz.getIconWidth();
+ setLoipe(s);
+ if (loipeOK) {
+ panel = new JPanel();
+ add(panel);
+ }
+ }
+
+ /**
+ * Creates a LoipePlaatje object based on the track information in Loipe
.
+ * @param s this Loipe contains the 2D track information
+ */
+ public void setLoipe (InfoLoipe s) {
+ loipe = s;
+ checkLoipe();
+ setBackground(SNOW);
+ }
+
+ /**
+ * Checks validity of the input track description. Terminates normally
+ * when the track is valid, prints a message otherwise.
+ */
+ private void checkLoipe() {
+ if (loipe == null)
+ {
+ System.err.println("Illegale loipe: null pointer");
+ loipeOK = false;
+ }
+ else if (loipe.getHeight() == 0)
+ {
+ System.err.println("Illegale loipe: height should be at least 1");
+ loipeOK = false;
+ }
+ else if (loipe.getWidth() == 0)
+ {
+ System.err.println("Illegale loipe: width should be at least 1");
+ loipeOK = false;
+ }
+ }
+ /**
+ * Gets the preferred size of this component.
+ *
+ * @return a dimension object indicating this component's preferred size.
+ */
+ @Override
+ public Dimension getPreferredSize() {
+ return new Dimension(loipe.getWidth() * UNIT, loipe.getHeight() * UNIT);
+ }
+
+ /**
+ * try to read a picture with the given name
+ * @param naam "name.png" is filename of picture
+ * @return the picture
+ * @throws IllegalArgumentexception if file is not found
+ */
+ private ImageIcon plaatje (String name) {
+ name += ".png";
+ URL resource = getClass().getClassLoader().getResource(name);
+ if (resource != null) {
+ return new ImageIcon (resource);
+ } else {
+ System.err.printf ("ERROR: Resource \"%s\" not found... aborting...\n", name);
+ System.err.println("For NetBeans the file should be placed in the src folder.");
+ throw new IllegalArgumentException ("Image " + name + " not found!");
+ }
+ }
+
+ /**
+ * Update graphics according to stored track.
+ * @param g the graphics context to use for painting.
+ */
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+ g = panel.getGraphics();
+ for (int i = 0; i < loipe.getWidth(); i += 1) {
+ for (int j = 0; j < loipe.getHeight(); j += 1) {
+ tekenFragment(g, i, j);
+ }
+ }
+ if (previousPos != null) {
+ g.setColor(Color.RED);
+ g.fillOval(previousPos.getX() * UNIT + UNIT / 4, previousPos.getY() * UNIT + UNIT / 4, UNIT / 2, UNIT / 2);
+ }
+ }
+
+ /**
+ * Draw the fragment from the loipe at the given position
+ * @param g
+ * @param x
+ * @param y
+ */
+ private void tekenFragment(Graphics g, int x, int y) {
+ Fragment f = loipe.getFragment(x, y);
+ ImageIcon plaatje;
+ if (f != null) {
+ switch (f) {
+ case NZ: plaatje = nz; break;
+ case OW: plaatje = ow; break;
+ case NO: plaatje = no; break;
+ case NW: plaatje = nw; break;
+ case ZO: plaatje = zo; break;
+ case ZW: plaatje = zw; break;
+ default: plaatje = nzow;
+ }
+ if (plaatje != null) {
+ plaatje.paintIcon(this, g, x * UNIT, y * UNIT);
+ }
+ }
+ }
+ /**
+ * The method to call in order to draw a window with the given track.
+ * You are supposed to use this method once for each object.
+ */
+ @Override
+ public void teken() {
+ if (loipeOK) {
+ setSize(loipe.getWidth() * UNIT, loipe.getHeight() * UNIT + UNIT / 2);
+ setVisible(true); // make frame visible
+ }
+ else
+ System.err.println("LoipePlaatje kan niet tekenen. Loipe is ongeldig of plaatjes niet gevonden");
+ }
+
+ @Override
+ public void setPosition(Punt p) {
+ Graphics g = panel.getGraphics();
+ if (previousPos != null) {
+ g.setColor(SNOW);
+ g.fillRect(previousPos.getX() * UNIT, previousPos.getY() * UNIT, UNIT, UNIT);
+ tekenFragment(g,previousPos.getX(), previousPos.getY());
+ }
+ g.setColor(Color.RED);
+ g.fillOval(p.getX() * UNIT + UNIT / 4, p.getY() * UNIT + UNIT / 4, UNIT / 2, UNIT / 2);
+ previousPos = p;
+ }
+}
\ No newline at end of file
diff --git a/Week4 Drawing loipes/src/oo15loipe/Punt.java b/Week4 Drawing loipes/src/oo15loipe/Punt.java
new file mode 100644
index 0000000..2c94f1f
--- /dev/null
+++ b/Week4 Drawing loipes/src/oo15loipe/Punt.java
@@ -0,0 +1,73 @@
+package oo15loipe;
+
+/**
+ * Een Punt in 2D
+ * @author pieter koopman
+ */
+
+public class Punt {
+ private int x, y;
+
+ /**
+ * de gewone constructor
+ * @param i: x
+ * @param j; y
+ */
+ public Punt(int i, int j) {
+ x = i;
+ y = j;
+ }
+
+ /**
+ * copy constructor
+ * @param p
+ */
+ public Punt (Punt p) {
+ if (p != null) {
+ x = p.x;
+ y = p.y;
+ } else {
+ x = y = 0;
+ }
+ }
+
+ /**
+ * getter voor x
+ * @return x
+ */
+ public int getX (){
+ return x;
+ }
+
+ /**
+ * getter voor y
+ * @return y
+ */
+ public int getY (){
+ return y;
+ }
+
+ /**
+ * equals methode vergelijkt x en y
+ * @param o
+ * @return
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o != null && o instanceof Punt) {
+ Punt p = (Punt) o;
+ return x == p.x && y == p.y;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Punt naar String conversie
+ * @return Strin met waarde van x en y
+ */
+ @Override
+ public String toString () {
+ return "(" + x + "," + y + ")";
+ }
+}
diff --git a/Week4 Drawing loipes/src/oo15loipe/TekenLoipe.java b/Week4 Drawing loipes/src/oo15loipe/TekenLoipe.java
new file mode 100644
index 0000000..8c9386f
--- /dev/null
+++ b/Week4 Drawing loipes/src/oo15loipe/TekenLoipe.java
@@ -0,0 +1,19 @@
+package oo15loipe;
+
+/**
+ * Interface for a class that can show a loipe on the screen
+ *
+ * @author Thijs Heijligenberg s4451414, Camil Staps, s4498062
+ */
+public interface TekenLoipe {
+ /**
+ * Draw the loipe
+ */
+ public void teken() ; // teken de gegeven loipe
+
+ /**
+ * Set the current position of the skier
+ * @param p
+ */
+ public void setPosition(Punt p) ; // teken de spor ter op de gegeven po s i t i e
+}
diff --git a/Week4 Drawing loipes/src/ow.png b/Week4 Drawing loipes/src/ow.png
new file mode 100644
index 0000000..8d35019
Binary files /dev/null and b/Week4 Drawing loipes/src/ow.png differ
diff --git a/Week4 Drawing loipes/src/week4/Week4.java b/Week4 Drawing loipes/src/week4/Week4.java
new file mode 100644
index 0000000..e523a54
--- /dev/null
+++ b/Week4 Drawing loipes/src/week4/Week4.java
@@ -0,0 +1,36 @@
+package week4;
+
+import java.util.Scanner;
+import oo15loipe.AsciiArt;
+import oo15loipe.Loipe;
+import oo15loipe.LoipePlaatje;
+
+/**
+ * Solutions for assignment 4
+ *
+ * @author Thijs Heijligenberg, s4451414, Camil Staps, s4498062
+ */
+public class Week4 {
+
+ /**
+ * Create a Loipe, draw it using LoipePlaatje and AsciiArt
+ *
+ * @param args the command line arguments (are ignored)
+ */
+ public static void main(String[] args) {
+ Scanner sc = new Scanner(System.in);
+
+ Loipe l = new Loipe("srssrsslsllsss");
+
+ LoipePlaatje lp = new LoipePlaatje(l);
+ lp.teken();
+
+ AsciiArt aa = new AsciiArt(l);
+ do {
+ aa.setPosition(l.stap());
+ aa.teken();
+ } while (sc.nextLine() != null);
+
+ }
+
+}
diff --git a/Week4 Drawing loipes/src/zo.png b/Week4 Drawing loipes/src/zo.png
new file mode 100644
index 0000000..1b578c0
Binary files /dev/null and b/Week4 Drawing loipes/src/zo.png differ
diff --git a/Week4 Drawing loipes/src/zw.png b/Week4 Drawing loipes/src/zw.png
new file mode 100644
index 0000000..702e57d
Binary files /dev/null and b/Week4 Drawing loipes/src/zw.png differ
diff --git a/Week4 Drawing loipes/week4-retake.tar.gz b/Week4 Drawing loipes/week4-retake.tar.gz
new file mode 100644
index 0000000..265e68a
Binary files /dev/null and b/Week4 Drawing loipes/week4-retake.tar.gz differ
diff --git a/Week4 Drawing loipes/week4.tar.gz b/Week4 Drawing loipes/week4.tar.gz
new file mode 100644
index 0000000..1afbf84
Binary files /dev/null and b/Week4 Drawing loipes/week4.tar.gz differ
diff --git a/Week4/Assignment (in Dutch).pdf b/Week4/Assignment (in Dutch).pdf
deleted file mode 100644
index 6a8e377..0000000
Binary files a/Week4/Assignment (in Dutch).pdf and /dev/null differ
diff --git a/Week4/build.xml b/Week4/build.xml
deleted file mode 100644
index 7276049..0000000
--- a/Week4/build.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Week4.
-
-
-
diff --git a/Week4/manifest.mf b/Week4/manifest.mf
deleted file mode 100644
index 328e8e5..0000000
--- a/Week4/manifest.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-X-COMMENT: Main-Class will be added automatically by build
-
diff --git a/Week4/nbproject/build-impl.xml b/Week4/nbproject/build-impl.xml
deleted file mode 100644
index f959e8c..0000000
--- a/Week4/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1413 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Week4/nbproject/genfiles.properties b/Week4/nbproject/genfiles.properties
deleted file mode 100644
index 93b534e..0000000
--- a/Week4/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=acf70bd4
-build.xml.script.CRC32=34a0b591
-build.xml.stylesheet.CRC32=8064a381@1.75.2.48
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=acf70bd4
-nbproject/build-impl.xml.script.CRC32=455b29da
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week4/nbproject/project.properties b/Week4/nbproject/project.properties
deleted file mode 100644
index 4de8e61..0000000
--- a/Week4/nbproject/project.properties
+++ /dev/null
@@ -1,75 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=Week4
-application.vendor=camilstaps
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# Files in build.classes.dir which should be excluded from distribution jar
-dist.archive.excludes=
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Week4.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.7
-javac.target=1.7
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=week4.Week4
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project.
-# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
-# To set system properties for unit tests define test-sys-prop.name=value:
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/Week4/nbproject/project.xml b/Week4/nbproject/project.xml
deleted file mode 100644
index 98cc646..0000000
--- a/Week4/nbproject/project.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Week4
-
-
-
-
-
-
-
-
-
diff --git a/Week4/src/no.png b/Week4/src/no.png
deleted file mode 100644
index daaec27..0000000
Binary files a/Week4/src/no.png and /dev/null differ
diff --git a/Week4/src/nw.png b/Week4/src/nw.png
deleted file mode 100644
index 2699df3..0000000
Binary files a/Week4/src/nw.png and /dev/null differ
diff --git a/Week4/src/nz.png b/Week4/src/nz.png
deleted file mode 100644
index c4eeb9c..0000000
Binary files a/Week4/src/nz.png and /dev/null differ
diff --git a/Week4/src/nzow.png b/Week4/src/nzow.png
deleted file mode 100644
index 96ab874..0000000
Binary files a/Week4/src/nzow.png and /dev/null differ
diff --git a/Week4/src/oo15loipe/AsciiArt.java b/Week4/src/oo15loipe/AsciiArt.java
deleted file mode 100644
index 4072d54..0000000
--- a/Week4/src/oo15loipe/AsciiArt.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package oo15loipe;
-
-/**
- * A class that draws the loipe as ascii-art.
- *
- * @author Thijs Heijligenberg, s4451414, Camil Staps, s4498062
- */
-public class AsciiArt implements TekenLoipe{
- private InfoLoipe L;
- private Punt man;
-
- /**
- * Create the instance based on a loipe
- *
- * @param s
- */
- public AsciiArt(InfoLoipe s){
- this.L = s;
- this.man = new Punt(null);
- }
-
- @Override
- public void setPosition(Punt p){
- this.man = p;
- }
-
- @Override
- public void teken(){
- for(int j = 0; j < L.getHeight(); j++){
- for(int i = 0; i < L.getWidth(); i++){
- Fragment f = L.getFragment(i,j);
- if(i == man.getX() && j == man.getY()){
- System.out.print('*');
- } else if (f == null) {
- System.out.print(' ');
- } else {
- switch (f){
- case KR: System.out.print('+'); break;
- case NZ: System.out.print('|'); break;
- case OW: System.out.print('-'); break;
- case NO: System.out.print('`'); break;
- case NW: System.out.print(','); break;
- case ZO: System.out.print(','); break;
- case ZW: System.out.print('.'); break;
- }
- }
- }
- System.out.print("\n");
- }
- }
-}
diff --git a/Week4/src/oo15loipe/Fragment.java b/Week4/src/oo15loipe/Fragment.java
deleted file mode 100644
index a4668da..0000000
--- a/Week4/src/oo15loipe/Fragment.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package oo15loipe;
-
-/**
- * enum to describe a fragment of path by its direction (or as a crossing)
- *
- * @author Thijs Heijligenberg, s4451414, Camil Staps, s4498062
- */
-public enum Fragment {NZ, OW, NO,NW, ZO, ZW, KR};
diff --git a/Week4/src/oo15loipe/InfoLoipe.java b/Week4/src/oo15loipe/InfoLoipe.java
deleted file mode 100644
index a1cf182..0000000
--- a/Week4/src/oo15loipe/InfoLoipe.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package oo15loipe;
-
-/**
- * Interface for a class describing a Loipe
- *
- * @author Camil Staps, s4498062, Thijs Heijligenberg, s4451414
- */
-public interface InfoLoipe {
-
- public int getWidth( ) ; // grootte in oostwest r i cht ing
- public int getHeight( ) ; // grootte in noordzuid r i cht ing
-
- /**
- * Get the fragment at position (x, y)
- *
- * @param x
- * @param y
- * @return
- */
- public Fragment getFragment( int x, int y) ; // fragment van de loipe op po s i t i e (x , y)
-
- /**
- * Get the first position of the loipe
- *
- * @return
- */
- public Punt start( ) ; // Het startpunt op de kaart
-
- /**
- * Get the next position in the loipe
- * @return
- */
- public Punt stap( ) ; // het volgende punt op de route
-}
-
diff --git a/Week4/src/oo15loipe/Loipe.java b/Week4/src/oo15loipe/Loipe.java
deleted file mode 100644
index 9155988..0000000
--- a/Week4/src/oo15loipe/Loipe.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package oo15loipe;
-
-/**
- * Loipe class
- *
- * @author Camil Staps, s4498062 // Thijs Heijligenberg, s4451414
- */
-public class Loipe implements InfoLoipe {
-
- /**
- * Class constants for direction (for readability)
- */
- private final static int
- DIRECTION_EAST = 0,
- DIRECTION_SOUTH = 1,
- DIRECTION_WEST = 2,
- DIRECTION_NORTH = 3;
-
- /**
- * The height and width of the loipe
- */
- private int height = 0, width = 0;
-
- /**
- * Start point
- * The path in coordinates
- * The current position
- * The map as 2D array of Fragments
- */
- private Punt start;
- private Punt[] path;
- private int path_pointer = 0;
- private Fragment[][] loipe;
-
- /**
- * Construct the loipe based on a path
- *
- * @param pad
- */
- public Loipe (String pad) {
- setLoipe(pad);
- }
-
- /**
- * Refresh everything based on a new path
- *
- * @param pad
- */
- public final void setLoipe(String pad) {
- setWidthAndHeight(pad);
- fillLoipe(pad);
-
- path_pointer = 0;
- }
-
- /**
- * Set the width and height of the loipe based on a path
- *
- * @param pad
- */
- private void setWidthAndHeight(String pad) {
- int direction = DIRECTION_NORTH;
-
- int maxX = 0, maxY = 0, minX = 0, minY = 0;
- Punt current_point = new Punt(0,0);
-
- for (int i = 0; i < pad.length(); i++) {
- if (current_point.getX() < minX)
- minX = current_point.getX();
- if (current_point.getX() > maxX)
- maxX = current_point.getX();
- if (current_point.getY() < minY)
- minY = current_point.getY();
- if (current_point.getY() > maxY)
- maxY = current_point.getY();
-
- switch (pad.charAt(i)) {
- case 'r':
- switch (direction) {
- case DIRECTION_EAST: direction = DIRECTION_SOUTH; break;
- case DIRECTION_SOUTH: direction = DIRECTION_WEST; break;
- case DIRECTION_WEST: direction = DIRECTION_NORTH; break;
- case DIRECTION_NORTH: direction = DIRECTION_EAST; break;
- }
- break;
- case 'l':
- switch (direction) {
- case DIRECTION_EAST: direction = DIRECTION_NORTH; break;
- case DIRECTION_SOUTH: direction = DIRECTION_EAST; break;
- case DIRECTION_WEST: direction = DIRECTION_SOUTH; break;
- case DIRECTION_NORTH: direction = DIRECTION_WEST; break;
- }
- }
-
- switch (direction) {
- case DIRECTION_EAST: current_point = new Punt(current_point.getX() + 1, current_point.getY()); break;
- case DIRECTION_SOUTH: current_point = new Punt(current_point.getX(), current_point.getY() + 1); break;
- case DIRECTION_WEST: current_point = new Punt(current_point.getX() - 1, current_point.getY()); break;
- case DIRECTION_NORTH: current_point = new Punt(current_point.getX(), current_point.getY() - 1); break;
- }
- }
-
- height = maxY - minY + 1;
- width = maxX - minX + 1;
-
- start = new Punt(-minX, -minY);
- }
-
- /**
- * Fill the loipe with fragments based on a path.
- * Assumes the width, height and start attributes to be correct.
- *
- * @param pad
- */
- private void fillLoipe(String pad) {
- loipe = new Fragment[width + 1][height + 1];
- path = new Punt[pad.length()];
- Punt current_point = start;
- int direction = DIRECTION_NORTH;
-
- for (int i = 0; i < pad.length(); i++) {
- path[i] = current_point;
-
- if (loipe[current_point.getX()][current_point.getY()] != null) {
- loipe[current_point.getX()][current_point.getY()] = Fragment.KR;
- } else {
- switch (pad.charAt(i)) {
- case 'r':
- switch (direction) {
- case DIRECTION_EAST: loipe[current_point.getX()][current_point.getY()] = Fragment.ZW; break;
- case DIRECTION_SOUTH: loipe[current_point.getX()][current_point.getY()] = Fragment.NW; break;
- case DIRECTION_WEST: loipe[current_point.getX()][current_point.getY()] = Fragment.NO; break;
- case DIRECTION_NORTH: loipe[current_point.getX()][current_point.getY()] = Fragment.ZO; break;
- }
- break;
- case 'l':
- switch (direction) {
- case DIRECTION_EAST: loipe[current_point.getX()][current_point.getY()] = Fragment.NW; break;
- case DIRECTION_SOUTH: loipe[current_point.getX()][current_point.getY()] = Fragment.NO; break;
- case DIRECTION_WEST: loipe[current_point.getX()][current_point.getY()] = Fragment.ZO; break;
- case DIRECTION_NORTH: loipe[current_point.getX()][current_point.getY()] = Fragment.ZW; break;
- }
- break;
- case 's':
- switch (direction) {
- case DIRECTION_EAST:
- case DIRECTION_WEST:
- loipe[current_point.getX()][current_point.getY()] = Fragment.OW;
- break;
- case DIRECTION_SOUTH:
- case DIRECTION_NORTH:
- loipe[current_point.getX()][current_point.getY()] = Fragment.NZ;
- }
- }
- }
-
- switch (pad.charAt(i)) {
- case 'r':
- switch (direction) {
- case DIRECTION_EAST: direction = DIRECTION_SOUTH; break;
- case DIRECTION_SOUTH: direction = DIRECTION_WEST; break;
- case DIRECTION_WEST: direction = DIRECTION_NORTH; break;
- case DIRECTION_NORTH: direction = DIRECTION_EAST; break;
- }
- break;
- case 'l':
- switch (direction) {
- case DIRECTION_EAST: direction = DIRECTION_NORTH; break;
- case DIRECTION_SOUTH: direction = DIRECTION_EAST; break;
- case DIRECTION_WEST: direction = DIRECTION_SOUTH; break;
- case DIRECTION_NORTH: direction = DIRECTION_WEST; break;
- }
- }
-
- switch (direction) {
- case DIRECTION_EAST: current_point = new Punt(current_point.getX() + 1, current_point.getY()); break;
- case DIRECTION_SOUTH: current_point = new Punt(current_point.getX(), current_point.getY() + 1); break;
- case DIRECTION_WEST: current_point = new Punt(current_point.getX() - 1, current_point.getY()); break;
- case DIRECTION_NORTH: current_point = new Punt(current_point.getX(), current_point.getY() - 1); break;
- }
- }
- }
-
- @Override
- public int getHeight() {
- return height;
- }
-
- @Override
- public int getWidth() {
- return width;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- for (Punt p : path) {
- sb.append(p).append(" -> ");
- }
- return sb.toString();
- }
-
- @Override
- public Fragment getFragment(int x, int y) {
- return loipe[x][y];
- }
-
- @Override
- public Punt start() {
- return start;
- }
-
- /**
- * We chose to have the man go back to the start when he has finished the loipe.
- */
- @Override
- public Punt stap() {
- if (path_pointer >= path.length) {
- path_pointer = 0;
- }
- Punt result = path[path_pointer];
- path_pointer++;
- return result;
- }
-
-}
diff --git a/Week4/src/oo15loipe/LoipePlaatje.java b/Week4/src/oo15loipe/LoipePlaatje.java
deleted file mode 100644
index db70d28..0000000
--- a/Week4/src/oo15loipe/LoipePlaatje.java
+++ /dev/null
@@ -1,191 +0,0 @@
-package oo15loipe;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.net.URL;
-import javax.swing.ImageIcon;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-
-/**
- *
- * @author Pieter Koopman
- */
-public class LoipePlaatje extends JFrame implements TekenLoipe
-{
- /** Used for painting the tiles.
- * We assume that all tiles have same width and height.
- */
- private final int UNIT;
-
- /** Color for painting the background. */
- private static final Color SNOW = new Color(0xF0,0xF0,0xFF);
-
- /**
- * The icons for drawing
- */
- private final ImageIcon nz, ow, no, nw, zo, zw, nzow;
-
- private JPanel panel;
-
- /**
- * the loipe to be painted and a boolean indicating whether it is okay
- */
- private InfoLoipe loipe;
- private boolean loipeOK = true;
- /**
- * previous position for walking the loipe
- */
- private Punt previousPos = null;
-
- /**
- * Constructor. Fill all icons.
- */
- public LoipePlaatje(InfoLoipe s) {
- super("Loipe");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- nz = plaatje("nz");
- ow = plaatje("ow");
- no = plaatje("no");
- nw = plaatje("nw");
- zo = plaatje("zo");
- zw = plaatje("zw");
- nzow = plaatje("nzow");
- UNIT = nz.getIconWidth();
- setLoipe(s);
- if (loipeOK) {
- panel = new JPanel();
- add(panel);
- }
- }
-
- /**
- * Creates a LoipePlaatje object based on the track information in Loipe
.
- * @param s this Loipe contains the 2D track information
- */
- public void setLoipe (InfoLoipe s) {
- loipe = s;
- checkLoipe();
- setBackground(SNOW);
- }
-
- /**
- * Checks validity of the input track description. Terminates normally
- * when the track is valid, prints a message otherwise.
- */
- private void checkLoipe() {
- if (loipe == null)
- {
- System.err.println("Illegale loipe: null pointer");
- loipeOK = false;
- }
- else if (loipe.getHeight() == 0)
- {
- System.err.println("Illegale loipe: height should be at least 1");
- loipeOK = false;
- }
- else if (loipe.getWidth() == 0)
- {
- System.err.println("Illegale loipe: width should be at least 1");
- loipeOK = false;
- }
- }
- /**
- * Gets the preferred size of this component.
- *
- * @return a dimension object indicating this component's preferred size.
- */
- @Override
- public Dimension getPreferredSize() {
- return new Dimension(loipe.getWidth() * UNIT, loipe.getHeight() * UNIT);
- }
-
- /**
- * try to read a picture with the given name
- * @param naam "name.png" is filename of picture
- * @return the picture
- * @throws IllegalArgumentexception if file is not found
- */
- private ImageIcon plaatje (String name) {
- name += ".png";
- URL resource = getClass().getClassLoader().getResource(name);
- if (resource != null) {
- return new ImageIcon (resource);
- } else {
- System.err.printf ("ERROR: Resource \"%s\" not found... aborting...\n", name);
- System.err.println("For NetBeans the file should be placed in the src folder.");
- throw new IllegalArgumentException ("Image " + name + " not found!");
- }
- }
-
- /**
- * Update graphics according to stored track.
- * @param g the graphics context to use for painting.
- */
- @Override
- public void paint(Graphics g) {
- super.paint(g);
- g = panel.getGraphics();
- for (int i = 0; i < loipe.getWidth(); i += 1) {
- for (int j = 0; j < loipe.getHeight(); j += 1) {
- tekenFragment(g, i, j);
- }
- }
- if (previousPos != null) {
- g.setColor(Color.RED);
- g.fillOval(previousPos.getX() * UNIT + UNIT / 4, previousPos.getY() * UNIT + UNIT / 4, UNIT / 2, UNIT / 2);
- }
- }
-
- /**
- * Draw the fragment from the loipe at the given position
- * @param g
- * @param x
- * @param y
- */
- private void tekenFragment(Graphics g, int x, int y) {
- Fragment f = loipe.getFragment(x, y);
- ImageIcon plaatje;
- if (f != null) {
- switch (f) {
- case NZ: plaatje = nz; break;
- case OW: plaatje = ow; break;
- case NO: plaatje = no; break;
- case NW: plaatje = nw; break;
- case ZO: plaatje = zo; break;
- case ZW: plaatje = zw; break;
- default: plaatje = nzow;
- }
- if (plaatje != null) {
- plaatje.paintIcon(this, g, x * UNIT, y * UNIT);
- }
- }
- }
- /**
- * The method to call in order to draw a window with the given track.
- * You are supposed to use this method once for each object.
- */
- @Override
- public void teken() {
- if (loipeOK) {
- setSize(loipe.getWidth() * UNIT, loipe.getHeight() * UNIT + UNIT / 2);
- setVisible(true); // make frame visible
- }
- else
- System.err.println("LoipePlaatje kan niet tekenen. Loipe is ongeldig of plaatjes niet gevonden");
- }
-
- @Override
- public void setPosition(Punt p) {
- Graphics g = panel.getGraphics();
- if (previousPos != null) {
- g.setColor(SNOW);
- g.fillRect(previousPos.getX() * UNIT, previousPos.getY() * UNIT, UNIT, UNIT);
- tekenFragment(g,previousPos.getX(), previousPos.getY());
- }
- g.setColor(Color.RED);
- g.fillOval(p.getX() * UNIT + UNIT / 4, p.getY() * UNIT + UNIT / 4, UNIT / 2, UNIT / 2);
- previousPos = p;
- }
-}
\ No newline at end of file
diff --git a/Week4/src/oo15loipe/Punt.java b/Week4/src/oo15loipe/Punt.java
deleted file mode 100644
index 2c94f1f..0000000
--- a/Week4/src/oo15loipe/Punt.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package oo15loipe;
-
-/**
- * Een Punt in 2D
- * @author pieter koopman
- */
-
-public class Punt {
- private int x, y;
-
- /**
- * de gewone constructor
- * @param i: x
- * @param j; y
- */
- public Punt(int i, int j) {
- x = i;
- y = j;
- }
-
- /**
- * copy constructor
- * @param p
- */
- public Punt (Punt p) {
- if (p != null) {
- x = p.x;
- y = p.y;
- } else {
- x = y = 0;
- }
- }
-
- /**
- * getter voor x
- * @return x
- */
- public int getX (){
- return x;
- }
-
- /**
- * getter voor y
- * @return y
- */
- public int getY (){
- return y;
- }
-
- /**
- * equals methode vergelijkt x en y
- * @param o
- * @return
- */
- @Override
- public boolean equals(Object o) {
- if (o != null && o instanceof Punt) {
- Punt p = (Punt) o;
- return x == p.x && y == p.y;
- } else {
- return false;
- }
- }
-
- /**
- * Punt naar String conversie
- * @return Strin met waarde van x en y
- */
- @Override
- public String toString () {
- return "(" + x + "," + y + ")";
- }
-}
diff --git a/Week4/src/oo15loipe/TekenLoipe.java b/Week4/src/oo15loipe/TekenLoipe.java
deleted file mode 100644
index 8c9386f..0000000
--- a/Week4/src/oo15loipe/TekenLoipe.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package oo15loipe;
-
-/**
- * Interface for a class that can show a loipe on the screen
- *
- * @author Thijs Heijligenberg s4451414, Camil Staps, s4498062
- */
-public interface TekenLoipe {
- /**
- * Draw the loipe
- */
- public void teken() ; // teken de gegeven loipe
-
- /**
- * Set the current position of the skier
- * @param p
- */
- public void setPosition(Punt p) ; // teken de spor ter op de gegeven po s i t i e
-}
diff --git a/Week4/src/ow.png b/Week4/src/ow.png
deleted file mode 100644
index 8d35019..0000000
Binary files a/Week4/src/ow.png and /dev/null differ
diff --git a/Week4/src/week4/Week4.java b/Week4/src/week4/Week4.java
deleted file mode 100644
index e523a54..0000000
--- a/Week4/src/week4/Week4.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package week4;
-
-import java.util.Scanner;
-import oo15loipe.AsciiArt;
-import oo15loipe.Loipe;
-import oo15loipe.LoipePlaatje;
-
-/**
- * Solutions for assignment 4
- *
- * @author Thijs Heijligenberg, s4451414, Camil Staps, s4498062
- */
-public class Week4 {
-
- /**
- * Create a Loipe, draw it using LoipePlaatje and AsciiArt
- *
- * @param args the command line arguments (are ignored)
- */
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
-
- Loipe l = new Loipe("srssrsslsllsss");
-
- LoipePlaatje lp = new LoipePlaatje(l);
- lp.teken();
-
- AsciiArt aa = new AsciiArt(l);
- do {
- aa.setPosition(l.stap());
- aa.teken();
- } while (sc.nextLine() != null);
-
- }
-
-}
diff --git a/Week4/src/zo.png b/Week4/src/zo.png
deleted file mode 100644
index 1b578c0..0000000
Binary files a/Week4/src/zo.png and /dev/null differ
diff --git a/Week4/src/zw.png b/Week4/src/zw.png
deleted file mode 100644
index 702e57d..0000000
Binary files a/Week4/src/zw.png and /dev/null differ
diff --git a/Week4/week4-retake.tar.gz b/Week4/week4-retake.tar.gz
deleted file mode 100644
index 265e68a..0000000
Binary files a/Week4/week4-retake.tar.gz and /dev/null differ
diff --git a/Week4/week4.tar.gz b/Week4/week4.tar.gz
deleted file mode 100644
index 1afbf84..0000000
Binary files a/Week4/week4.tar.gz and /dev/null differ
diff --git a/Week5 Quiz/.gitignore b/Week5 Quiz/.gitignore
new file mode 100644
index 0000000..4523fc2
--- /dev/null
+++ b/Week5 Quiz/.gitignore
@@ -0,0 +1,3 @@
+nbproject/private/
+build/
+dist/
diff --git a/Week5 Quiz/Assignment (in Dutch).pdf b/Week5 Quiz/Assignment (in Dutch).pdf
new file mode 100644
index 0000000..4f6bdb6
Binary files /dev/null and b/Week5 Quiz/Assignment (in Dutch).pdf differ
diff --git a/Week5 Quiz/build.xml b/Week5 Quiz/build.xml
new file mode 100644
index 0000000..9bff533
--- /dev/null
+++ b/Week5 Quiz/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Week5 Quiz.
+
+
+
diff --git a/Week5 Quiz/manifest.mf b/Week5 Quiz/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Week5 Quiz/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Week5 Quiz/nbproject/build-impl.xml b/Week5 Quiz/nbproject/build-impl.xml
new file mode 100644
index 0000000..53f5488
--- /dev/null
+++ b/Week5 Quiz/nbproject/build-impl.xml
@@ -0,0 +1,1413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week5 Quiz/nbproject/genfiles.properties b/Week5 Quiz/nbproject/genfiles.properties
new file mode 100644
index 0000000..11660ae
--- /dev/null
+++ b/Week5 Quiz/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=923bb433
+build.xml.script.CRC32=a5811974
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=923bb433
+nbproject/build-impl.xml.script.CRC32=fe4be7f8
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week5 Quiz/nbproject/project.properties b/Week5 Quiz/nbproject/project.properties
new file mode 100644
index 0000000..5fccc18
--- /dev/null
+++ b/Week5 Quiz/nbproject/project.properties
@@ -0,0 +1,75 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=Week5 Quiz
+application.vendor=camilstaps
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Week5_Quiz.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.7
+javac.target=1.7
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=week5.Week5
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Week5 Quiz/nbproject/project.xml b/Week5 Quiz/nbproject/project.xml
new file mode 100644
index 0000000..d85592c
--- /dev/null
+++ b/Week5 Quiz/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Week5 Quiz
+
+
+
+
+
+
+
+
+
diff --git a/Week5 Quiz/src/week5/MCQuestion.java b/Week5 Quiz/src/week5/MCQuestion.java
new file mode 100644
index 0000000..86869c5
--- /dev/null
+++ b/Week5 Quiz/src/week5/MCQuestion.java
@@ -0,0 +1,81 @@
+package week5;
+
+import java.util.Random;
+
+/**
+ * Class for multiple choice questions
+ *
+ * Note: for 2-choice questions the TCQuestion class should be used.
+ *
+ * @author Camil Staps, s4498062
+ */
+public class MCQuestion extends Question {
+
+ protected final String[] answers;
+ protected final int correctAnswer;
+
+ /**
+ * Construct a new instance
+ *
+ * @param question the question
+ * @param answers array of the answer
+ * @param correctAnswer index for answers pointing to the correct answer
+ * @param weight weight of the question
+ */
+ public MCQuestion (String question, String[] answers, int correctAnswer, int weight) {
+ this.question = question;
+ this.answers = answers;
+ this.correctAnswer = correctAnswer;
+ setWeight(weight);
+ }
+
+ /** See the javadoc on the constructor above */
+ public MCQuestion (String question, String[] answers, int correctAnswer) {
+ this.question = question;
+ this.answers = answers;
+ this.correctAnswer = correctAnswer;
+ }
+
+ @Override
+ public boolean isCorrect(String answer) {
+ return correctAnswer == (answer.charAt(0) - 'A');
+ }
+
+ @Override
+ public String juisteAntwoord() {
+ return answers[correctAnswer];
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString());
+ sb.append("\n");
+ int i = 0;
+ for (String a : answers) {
+ sb.append((char) ('A' + i++)).append(": ").append(a).append("\n");
+ }
+ sb.deleteCharAt(sb.length() - 1);
+ return sb.toString();
+ }
+
+ /**
+ * For this type of questions, duplicating randomizes the order of the answers.
+ *
+ * @return A new instance of the MCQuestion class with the same parameters, just another order of the answers.
+ */
+ @Override
+ public Question duplicate() {
+ Random r = new Random();
+ int shift = r.nextInt(answers.length - 1) + 1;
+
+ String[] new_answers = new String[answers.length];
+ for (String a : answers) {
+ new_answers[shift++ % answers.length] = a;
+ }
+
+ int new_correctAnswer = (correctAnswer + shift) % answers.length;
+
+ return new MCQuestion(question, new_answers, new_correctAnswer, weight);
+ }
+
+}
diff --git a/Week5 Quiz/src/week5/OpenQuestion.java b/Week5 Quiz/src/week5/OpenQuestion.java
new file mode 100644
index 0000000..4f154ea
--- /dev/null
+++ b/Week5 Quiz/src/week5/OpenQuestion.java
@@ -0,0 +1,32 @@
+package week5;
+
+/**
+ * Class for open questions
+ *
+ * @author Camil Staps, s4498062
+ */
+public class OpenQuestion extends Question {
+
+ private final String answer;
+
+ public OpenQuestion(String question, String answer, int weight) {
+ this.question = question;
+ this.answer = answer;
+ setWeight(weight);
+ }
+
+ public OpenQuestion(String question, String answer) {
+ this.question = question;
+ this.answer = answer;
+ }
+
+ @Override
+ public boolean isCorrect(String answer) {
+ return answer.equalsIgnoreCase(this.answer);
+ }
+
+ @Override
+ public String juisteAntwoord() {
+ return answer;
+ }
+}
diff --git a/Week5 Quiz/src/week5/Question.java b/Week5 Quiz/src/week5/Question.java
new file mode 100644
index 0000000..3b05414
--- /dev/null
+++ b/Week5 Quiz/src/week5/Question.java
@@ -0,0 +1,56 @@
+package week5;
+
+/**
+ * Abstract class for quiz questions
+ *
+ * @author Camil Staps, s4498062
+ */
+public abstract class Question {
+
+ protected String question = "";
+ protected int weight = 3;
+
+ @Override
+ public String toString() {
+ return question + " (pt: " + weight + ")";
+ }
+
+ /**
+ * Checks if a given answer is correct
+ *
+ * @param answer the answer to check
+ * @return true iff the answer is correct
+ */
+ public abstract boolean isCorrect(String answer);
+
+ /**
+ * Returns the correct answer
+ *
+ * @return the correct answer
+ */
+ public abstract String juisteAntwoord();
+
+ /**
+ * Set the weight of this question (succeeds only if 0 < weight < 6)
+ *
+ * @param weight the new weight
+ */
+ protected void setWeight(int weight) {
+ if (weight > 0 && weight < 6) {
+ this.weight = weight;
+ }
+ }
+
+ public int getWeight() {
+ return weight;
+ }
+
+ /**
+ * Create a new instance with the same parameters
+ *
+ * @return the new question
+ */
+ public Question duplicate() {
+ return this;
+ }
+}
diff --git a/Week5 Quiz/src/week5/TCQuestion.java b/Week5 Quiz/src/week5/TCQuestion.java
new file mode 100644
index 0000000..f89240c
--- /dev/null
+++ b/Week5 Quiz/src/week5/TCQuestion.java
@@ -0,0 +1,40 @@
+package week5;
+
+/**
+ * Class for 2-choice questions
+ *
+ * Note: for 3+-choice questions one can use MCQuestion.
+ *
+ * @author Camil Staps, s4498062
+ */
+public class TCQuestion extends MCQuestion {
+
+ /**
+ * Construct a new TCQuestion instance
+ *
+ * @param question the question
+ * @param answer1 the first answer
+ * @param answer2 the second answer
+ * @param correctAnswer 0 if answer1 is correct, 1 if answer2 is correct
+ * @param weight the weight for this question
+ */
+ public TCQuestion (String question, String answer1, String answer2, int correctAnswer, int weight) {
+ super(question, new String[] {answer1, answer2}, correctAnswer, weight);
+ }
+
+ /** See the javadoc on the constructor above */
+ public TCQuestion (String question, String answer1, String answer2, int correctAnswer) {
+ super(question, new String[] {answer1, answer2}, correctAnswer);
+ }
+
+ /**
+ * For TCQuestions we don't need to randomize the answers.
+ *
+ * @return the new question
+ */
+ @Override
+ public Question duplicate() {
+ return this;
+ }
+
+}
diff --git a/Week5 Quiz/src/week5/Week5.java b/Week5 Quiz/src/week5/Week5.java
new file mode 100644
index 0000000..24f91b2
--- /dev/null
+++ b/Week5 Quiz/src/week5/Week5.java
@@ -0,0 +1,106 @@
+package week5;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * Uitwerking voor week 5
+ *
+ * @author Camil Staps, s4498062
+ */
+public class Week5 {
+
+ private final List questions = new LinkedList();
+ private final List questions_2 = new LinkedList();
+
+ private int score_round1 = 0;
+ private int score_round2 = 0;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ Week5 w5 = new Week5();
+ w5.play();
+ }
+
+ /**
+ * Add default questions
+ */
+ public Week5() {
+ questions.add(new OpenQuestion("Wat is de complexiteit van binair zoeken?", "O(log N)"));
+ questions.add(new OpenQuestion("Hoe lees je in Java een integer i uit een scanner s?", "i = s.nextInt();", 2));
+ questions.add(new OpenQuestion("Is er verschil tussen een interface en een abstracte klasse?", "Ja", 5));
+ questions.add(new OpenQuestion("Hoeveel constructoren je minstens maken bij een klasse in Java?", "0", 2));
+ questions.add(new OpenQuestion("Is er een maximum aantal constructoren van een klasse in Java?", "Nee"));
+
+ questions.add(new MCQuestion("Wat is de complexiteit van slim in situ sorteren?", new String [] {
+ "O(N^2)",
+ "O(N log N)",
+ "O(N)",
+ "O(log N)"}, 1, 4));
+ questions.add(new MCQuestion("Hoe print je \"Hello world\" op een regel in Java?", new String [] {
+ "System.out.print(\"Hello world\");",
+ "System.out.println(\"Hello world\");",
+ "cout << \"Hello world\";"}, 1));
+ questions.add(new MCQuestion("Hoe lees je in Java een niet leeg woord uit scanner s?", new String []{
+ "s.nextline()",
+ "s.next(\"\\S+\")",
+ "s.next(\"\\a*\")",
+ "s.next(\"\\S*\")",
+ "s.next(\"\\\\s+\")",
+ "s.next(\"\\s+\")",
+ "s.nextString(\"\\s*\")",
+ "s.next(\"\\\\S+\")",
+ "s.nextString()"}, 7, 1));
+
+ questions.add(new TCQuestion("Deze opgave is eigenlijk niet zo moeilijk.", "Juist", "Onjuist", 0, 5));
+ }
+
+ private void play() {
+ round1();
+ System.out.println();
+ round2();
+ System.out.println();
+
+ System.out.println("Score ronde 1: " + score_round1);
+ System.out.println("Score ronde 2: " + score_round2);
+ }
+
+ private void round1() {
+ Scanner sc = new Scanner(System.in);
+
+ for (Question q : questions) {
+ System.out.println(q);
+ if (q.isCorrect(sc.nextLine())) {
+ System.out.println("Goed zo!\n");
+ score_round1 += q.getWeight();
+ } else {
+ System.out.println("Helaas...\n");
+ questions_2.add(q.duplicate());
+ }
+ }
+ }
+
+ private void round2() {
+ Scanner sc = new Scanner(System.in);
+
+ if (!questions_2.isEmpty()) {
+ System.out.println("Je krijgt een herkansing voor de " + questions_2.size() + " vragen die je zojuist fout had.\n");
+
+ for (Question q : questions_2) {
+ System.out.println(q);
+ if (q.isCorrect(sc.nextLine())) {
+ System.out.println("Goed zo!\n");
+ score_round2 += q.getWeight();
+ } else {
+ System.out.println("Helaas... het juiste antwoord was: " + q.juisteAntwoord() + "\n");
+ }
+ }
+ } else {
+ System.out.println("Alle vragen goed!");
+ }
+ }
+
+}
diff --git a/Week5 Quiz/week5.tar.gz b/Week5 Quiz/week5.tar.gz
new file mode 100644
index 0000000..7e6c609
Binary files /dev/null and b/Week5 Quiz/week5.tar.gz differ
diff --git a/Week5/Assignment (in Dutch).pdf b/Week5/Assignment (in Dutch).pdf
deleted file mode 100644
index 4f6bdb6..0000000
Binary files a/Week5/Assignment (in Dutch).pdf and /dev/null differ
diff --git a/Week5/build.xml b/Week5/build.xml
deleted file mode 100644
index 9a71604..0000000
--- a/Week5/build.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Week5.
-
-
-
diff --git a/Week5/manifest.mf b/Week5/manifest.mf
deleted file mode 100644
index 328e8e5..0000000
--- a/Week5/manifest.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-X-COMMENT: Main-Class will be added automatically by build
-
diff --git a/Week5/nbproject/build-impl.xml b/Week5/nbproject/build-impl.xml
deleted file mode 100644
index 201fa28..0000000
--- a/Week5/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1413 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Week5/nbproject/genfiles.properties b/Week5/nbproject/genfiles.properties
deleted file mode 100644
index 67ffa3c..0000000
--- a/Week5/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=a4e487f2
-build.xml.script.CRC32=1be3e29b
-build.xml.stylesheet.CRC32=8064a381@1.75.2.48
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=a4e487f2
-nbproject/build-impl.xml.script.CRC32=fa7c912f
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week5/nbproject/project.properties b/Week5/nbproject/project.properties
deleted file mode 100644
index 717c087..0000000
--- a/Week5/nbproject/project.properties
+++ /dev/null
@@ -1,75 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=Week5
-application.vendor=camilstaps
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# Files in build.classes.dir which should be excluded from distribution jar
-dist.archive.excludes=
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Week5.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.7
-javac.target=1.7
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=week5.Week5
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project.
-# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
-# To set system properties for unit tests define test-sys-prop.name=value:
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/Week5/nbproject/project.xml b/Week5/nbproject/project.xml
deleted file mode 100644
index f655a5a..0000000
--- a/Week5/nbproject/project.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Week5
-
-
-
-
-
-
-
-
-
diff --git a/Week5/src/week5/MCQuestion.java b/Week5/src/week5/MCQuestion.java
deleted file mode 100644
index 86869c5..0000000
--- a/Week5/src/week5/MCQuestion.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package week5;
-
-import java.util.Random;
-
-/**
- * Class for multiple choice questions
- *
- * Note: for 2-choice questions the TCQuestion class should be used.
- *
- * @author Camil Staps, s4498062
- */
-public class MCQuestion extends Question {
-
- protected final String[] answers;
- protected final int correctAnswer;
-
- /**
- * Construct a new instance
- *
- * @param question the question
- * @param answers array of the answer
- * @param correctAnswer index for answers pointing to the correct answer
- * @param weight weight of the question
- */
- public MCQuestion (String question, String[] answers, int correctAnswer, int weight) {
- this.question = question;
- this.answers = answers;
- this.correctAnswer = correctAnswer;
- setWeight(weight);
- }
-
- /** See the javadoc on the constructor above */
- public MCQuestion (String question, String[] answers, int correctAnswer) {
- this.question = question;
- this.answers = answers;
- this.correctAnswer = correctAnswer;
- }
-
- @Override
- public boolean isCorrect(String answer) {
- return correctAnswer == (answer.charAt(0) - 'A');
- }
-
- @Override
- public String juisteAntwoord() {
- return answers[correctAnswer];
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(super.toString());
- sb.append("\n");
- int i = 0;
- for (String a : answers) {
- sb.append((char) ('A' + i++)).append(": ").append(a).append("\n");
- }
- sb.deleteCharAt(sb.length() - 1);
- return sb.toString();
- }
-
- /**
- * For this type of questions, duplicating randomizes the order of the answers.
- *
- * @return A new instance of the MCQuestion class with the same parameters, just another order of the answers.
- */
- @Override
- public Question duplicate() {
- Random r = new Random();
- int shift = r.nextInt(answers.length - 1) + 1;
-
- String[] new_answers = new String[answers.length];
- for (String a : answers) {
- new_answers[shift++ % answers.length] = a;
- }
-
- int new_correctAnswer = (correctAnswer + shift) % answers.length;
-
- return new MCQuestion(question, new_answers, new_correctAnswer, weight);
- }
-
-}
diff --git a/Week5/src/week5/OpenQuestion.java b/Week5/src/week5/OpenQuestion.java
deleted file mode 100644
index 4f154ea..0000000
--- a/Week5/src/week5/OpenQuestion.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package week5;
-
-/**
- * Class for open questions
- *
- * @author Camil Staps, s4498062
- */
-public class OpenQuestion extends Question {
-
- private final String answer;
-
- public OpenQuestion(String question, String answer, int weight) {
- this.question = question;
- this.answer = answer;
- setWeight(weight);
- }
-
- public OpenQuestion(String question, String answer) {
- this.question = question;
- this.answer = answer;
- }
-
- @Override
- public boolean isCorrect(String answer) {
- return answer.equalsIgnoreCase(this.answer);
- }
-
- @Override
- public String juisteAntwoord() {
- return answer;
- }
-}
diff --git a/Week5/src/week5/Question.java b/Week5/src/week5/Question.java
deleted file mode 100644
index 3b05414..0000000
--- a/Week5/src/week5/Question.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package week5;
-
-/**
- * Abstract class for quiz questions
- *
- * @author Camil Staps, s4498062
- */
-public abstract class Question {
-
- protected String question = "";
- protected int weight = 3;
-
- @Override
- public String toString() {
- return question + " (pt: " + weight + ")";
- }
-
- /**
- * Checks if a given answer is correct
- *
- * @param answer the answer to check
- * @return true iff the answer is correct
- */
- public abstract boolean isCorrect(String answer);
-
- /**
- * Returns the correct answer
- *
- * @return the correct answer
- */
- public abstract String juisteAntwoord();
-
- /**
- * Set the weight of this question (succeeds only if 0 < weight < 6)
- *
- * @param weight the new weight
- */
- protected void setWeight(int weight) {
- if (weight > 0 && weight < 6) {
- this.weight = weight;
- }
- }
-
- public int getWeight() {
- return weight;
- }
-
- /**
- * Create a new instance with the same parameters
- *
- * @return the new question
- */
- public Question duplicate() {
- return this;
- }
-}
diff --git a/Week5/src/week5/TCQuestion.java b/Week5/src/week5/TCQuestion.java
deleted file mode 100644
index f89240c..0000000
--- a/Week5/src/week5/TCQuestion.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package week5;
-
-/**
- * Class for 2-choice questions
- *
- * Note: for 3+-choice questions one can use MCQuestion.
- *
- * @author Camil Staps, s4498062
- */
-public class TCQuestion extends MCQuestion {
-
- /**
- * Construct a new TCQuestion instance
- *
- * @param question the question
- * @param answer1 the first answer
- * @param answer2 the second answer
- * @param correctAnswer 0 if answer1 is correct, 1 if answer2 is correct
- * @param weight the weight for this question
- */
- public TCQuestion (String question, String answer1, String answer2, int correctAnswer, int weight) {
- super(question, new String[] {answer1, answer2}, correctAnswer, weight);
- }
-
- /** See the javadoc on the constructor above */
- public TCQuestion (String question, String answer1, String answer2, int correctAnswer) {
- super(question, new String[] {answer1, answer2}, correctAnswer);
- }
-
- /**
- * For TCQuestions we don't need to randomize the answers.
- *
- * @return the new question
- */
- @Override
- public Question duplicate() {
- return this;
- }
-
-}
diff --git a/Week5/src/week5/Week5.java b/Week5/src/week5/Week5.java
deleted file mode 100644
index 24f91b2..0000000
--- a/Week5/src/week5/Week5.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package week5;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Scanner;
-
-/**
- * Uitwerking voor week 5
- *
- * @author Camil Staps, s4498062
- */
-public class Week5 {
-
- private final List questions = new LinkedList();
- private final List questions_2 = new LinkedList();
-
- private int score_round1 = 0;
- private int score_round2 = 0;
-
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Week5 w5 = new Week5();
- w5.play();
- }
-
- /**
- * Add default questions
- */
- public Week5() {
- questions.add(new OpenQuestion("Wat is de complexiteit van binair zoeken?", "O(log N)"));
- questions.add(new OpenQuestion("Hoe lees je in Java een integer i uit een scanner s?", "i = s.nextInt();", 2));
- questions.add(new OpenQuestion("Is er verschil tussen een interface en een abstracte klasse?", "Ja", 5));
- questions.add(new OpenQuestion("Hoeveel constructoren je minstens maken bij een klasse in Java?", "0", 2));
- questions.add(new OpenQuestion("Is er een maximum aantal constructoren van een klasse in Java?", "Nee"));
-
- questions.add(new MCQuestion("Wat is de complexiteit van slim in situ sorteren?", new String [] {
- "O(N^2)",
- "O(N log N)",
- "O(N)",
- "O(log N)"}, 1, 4));
- questions.add(new MCQuestion("Hoe print je \"Hello world\" op een regel in Java?", new String [] {
- "System.out.print(\"Hello world\");",
- "System.out.println(\"Hello world\");",
- "cout << \"Hello world\";"}, 1));
- questions.add(new MCQuestion("Hoe lees je in Java een niet leeg woord uit scanner s?", new String []{
- "s.nextline()",
- "s.next(\"\\S+\")",
- "s.next(\"\\a*\")",
- "s.next(\"\\S*\")",
- "s.next(\"\\\\s+\")",
- "s.next(\"\\s+\")",
- "s.nextString(\"\\s*\")",
- "s.next(\"\\\\S+\")",
- "s.nextString()"}, 7, 1));
-
- questions.add(new TCQuestion("Deze opgave is eigenlijk niet zo moeilijk.", "Juist", "Onjuist", 0, 5));
- }
-
- private void play() {
- round1();
- System.out.println();
- round2();
- System.out.println();
-
- System.out.println("Score ronde 1: " + score_round1);
- System.out.println("Score ronde 2: " + score_round2);
- }
-
- private void round1() {
- Scanner sc = new Scanner(System.in);
-
- for (Question q : questions) {
- System.out.println(q);
- if (q.isCorrect(sc.nextLine())) {
- System.out.println("Goed zo!\n");
- score_round1 += q.getWeight();
- } else {
- System.out.println("Helaas...\n");
- questions_2.add(q.duplicate());
- }
- }
- }
-
- private void round2() {
- Scanner sc = new Scanner(System.in);
-
- if (!questions_2.isEmpty()) {
- System.out.println("Je krijgt een herkansing voor de " + questions_2.size() + " vragen die je zojuist fout had.\n");
-
- for (Question q : questions_2) {
- System.out.println(q);
- if (q.isCorrect(sc.nextLine())) {
- System.out.println("Goed zo!\n");
- score_round2 += q.getWeight();
- } else {
- System.out.println("Helaas... het juiste antwoord was: " + q.juisteAntwoord() + "\n");
- }
- }
- } else {
- System.out.println("Alle vragen goed!");
- }
- }
-
-}
diff --git a/Week5/week5.tar.gz b/Week5/week5.tar.gz
deleted file mode 100644
index 7e6c609..0000000
Binary files a/Week5/week5.tar.gz and /dev/null differ
diff --git a/Week6 Sliding game solver/.gitignore b/Week6 Sliding game solver/.gitignore
new file mode 100644
index 0000000..4523fc2
--- /dev/null
+++ b/Week6 Sliding game solver/.gitignore
@@ -0,0 +1,3 @@
+nbproject/private/
+build/
+dist/
diff --git a/Week6 Sliding game solver/Assignment (in Dutch).pdf b/Week6 Sliding game solver/Assignment (in Dutch).pdf
new file mode 100644
index 0000000..dbf029b
Binary files /dev/null and b/Week6 Sliding game solver/Assignment (in Dutch).pdf differ
diff --git a/Week6 Sliding game solver/build.xml b/Week6 Sliding game solver/build.xml
new file mode 100644
index 0000000..d221676
--- /dev/null
+++ b/Week6 Sliding game solver/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Week6 Sliding game solver.
+
+
+
diff --git a/Week6 Sliding game solver/manifest.mf b/Week6 Sliding game solver/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Week6 Sliding game solver/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Week6 Sliding game solver/nbproject/build-impl.xml b/Week6 Sliding game solver/nbproject/build-impl.xml
new file mode 100644
index 0000000..7738925
--- /dev/null
+++ b/Week6 Sliding game solver/nbproject/build-impl.xml
@@ -0,0 +1,1413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week6 Sliding game solver/nbproject/genfiles.properties b/Week6 Sliding game solver/nbproject/genfiles.properties
new file mode 100644
index 0000000..cb500dc
--- /dev/null
+++ b/Week6 Sliding game solver/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=af7e9351
+build.xml.script.CRC32=13880061
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=af7e9351
+nbproject/build-impl.xml.script.CRC32=d44e7934
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week6 Sliding game solver/nbproject/project.properties b/Week6 Sliding game solver/nbproject/project.properties
new file mode 100644
index 0000000..7e69501
--- /dev/null
+++ b/Week6 Sliding game solver/nbproject/project.properties
@@ -0,0 +1,75 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=Week6 Sliding game solver
+application.vendor=camilstaps
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Week6_Sliding_game_solver.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.7
+javac.target=1.7
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=Main
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=-ea
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Week6 Sliding game solver/nbproject/project.xml b/Week6 Sliding game solver/nbproject/project.xml
new file mode 100644
index 0000000..b58c22b
--- /dev/null
+++ b/Week6 Sliding game solver/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Week6 Sliding game solver
+
+
+
+
+
+
+
+
+
diff --git a/Week6 Sliding game solver/src/Configuration.java b/Week6 Sliding game solver/src/Configuration.java
new file mode 100644
index 0000000..7264c5f
--- /dev/null
+++ b/Week6 Sliding game solver/src/Configuration.java
@@ -0,0 +1,21 @@
+import java.util.Collection;
+
+
+/**
+ * An interface for representing nodes in a state space.
+ *
+ * @author Sjaak Smetsers
+ * @version 1.2
+ * @date 28-02-2015
+ */
+public interface Configuration extends Comparable {
+ /*
+ * To obtain the successors for a specific configuration
+ * @return a collection of configurations containing the successors
+ */
+ public Collection successors ();
+ /*
+ * For marking final / solution configurations.
+ */
+ public boolean isSolution ();
+}
diff --git a/Week6 Sliding game solver/src/Direction.java b/Week6 Sliding game solver/src/Direction.java
new file mode 100644
index 0000000..d4837b9
--- /dev/null
+++ b/Week6 Sliding game solver/src/Direction.java
@@ -0,0 +1,26 @@
+/**
+ * @author Sjaak Smetsers
+ * @version 1.2
+ * @date 28-02-2015
+ * An enumeration type for the 4 points of the compass
+ * Each constant has 2 (final) int attributes indicating
+ * the displacement of each direction on a 2-dimensional grid
+ * of which the origin is located in the upper left corner
+ */
+public enum Direction {
+ NORTH (0,-1), EAST (1,0), SOUTH(0,1), WEST(-1,0);
+
+ private final int dx, dy;
+ private Direction (int dx, int dy) {
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ public int GetDX () {
+ return dx;
+ }
+
+ public int GetDY () {
+ return dy;
+ }
+}
diff --git a/Week6 Sliding game solver/src/Main.java b/Week6 Sliding game solver/src/Main.java
new file mode 100644
index 0000000..4225013
--- /dev/null
+++ b/Week6 Sliding game solver/src/Main.java
@@ -0,0 +1,35 @@
+/**
+ * Solutions for the assignments of week 6.
+ * @author Camil Staps, s4498062
+ */
+public class Main
+{
+
+ /**
+ * Create a new sliding game, attempt to solve it and if it succeeds show a solution.
+ * @param args command-line arguments are ignored.
+ */
+ public static void main(String[] args) {
+ // Some examples:
+ // N = 5
+ //int[] x = {7,17,9,4,5,1,12,15,6,10,3,23,25,14,8,22,2,18,19,24,16,21,11,13,20}; // May take some time (that is, it did not find a solution after some hours here, I didn't check if there is one)
+ //int[] x = {2,4,6,8,10,1,3,5,7,9,12,14,16,18,20,11,13,15,17,19,21,22,23,24,25}; // Solution in 90
+ // N = 4
+ //int[] x = {2,3,10,11,14,1,13,15,5,4,8,7,6,12,9,16}; // Solution in 112
+ //int[] x = {10,8,16,7,6,13,15,3,14,1,4,2,5,9,12,11}; // Solution in 144
+ //int[] x = {9,12,5,4,2,16,7,11,3,6,10,13,14,1,8,15}; // Solution in 140
+ // N = 3
+ //int[] x = {8,7,6,5,4,3,1,2,9}; // No solution (evaluates 292102 different boards before failing)
+ int[] x = {5,9,3,4,6,2,8,7,1}; // Solution in 35
+
+ SlidingGame sg = new SlidingGame(x);
+ System.out.println("Solving:\n" + sg);
+ Solver s = new Solver(sg);
+ if (s.solve()) {
+ System.out.println("Success!");
+ System.out.println(s.getWinner());
+ } else {
+ System.out.println("Failure...");
+ }
+ }
+}
diff --git a/Week6 Sliding game solver/src/Node.java b/Week6 Sliding game solver/src/Node.java
new file mode 100644
index 0000000..cb5c900
--- /dev/null
+++ b/Week6 Sliding game solver/src/Node.java
@@ -0,0 +1,92 @@
+import java.util.ArrayList;
+
+/**
+ * For maintaining lists of T-elements enabling
+ * a structure suited for backwards traversal
+ *
+ * @author Pieter Koopman, Sjaak Smetsers
+ * @author Camil Staps, s4498062
+ *
+ * @param The element this node is based on
+ */
+@SuppressWarnings("Convert2Diamond") // We disable these warnings for Java <=1.7 compatibility.
+public class Node implements Comparable>
+{
+ // the data field
+ private final T item;
+ // a reference to the predecessor
+ private final Node previous;
+
+ /* A constructor that initializes each node
+ * with the specified values
+ * @param from the node preceding the current node
+ * @param item the initial data item
+ */
+ public Node (Node from, T item) {
+ this.previous = from;
+ this.item = item;
+ }
+
+ /* a getter for the item
+ * @return item
+ */
+ public T getItem() {
+ return item;
+ }
+
+ /*
+ * a getter for the predecessor
+ * @return previous
+ */
+ public Node getPrevious() {
+ return previous;
+ }
+
+ /*
+ * determines the length of the current list
+ * @return the length as an integer
+ */
+ public int length () {
+ int length = 1;
+ Node prev = previous;
+ while ( prev != null ) {
+ prev = prev.previous;
+ length++;
+ }
+ return length;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+
+ ArrayList> path;
+ path = new ArrayList>();
+ Node prev = this;
+ while ( prev != null ) {
+ path.add(prev);
+ prev = prev.previous;
+ }
+
+ for (int i = path.size() - 1; i >= 0; i--)
+ result.append(path.size() - i - 1).append(":\n").append(path.get(i).getItem().toString());
+
+ return result.toString();
+ }
+
+ /**
+ * Just comparing the items isn't very clever. The Manhattan distance is a fairly small number.
+ * With large queues, many nodes will then have the same priority. It's much better to select
+ * on both Manhattan distance and path length. That way, we will find shorter paths.
+ * Note though that since we're prioritizing on Manhattan distance primarily, this does not
+ * mean that we necessarily find the shortest path.
+ * @param t
+ * @return
+ */
+ @Override
+ public int compareTo(Node t) {
+ if (this.item.compareTo(t.item) == 0)
+ return Integer.compare(length(), t.length());
+ return this.item.compareTo(t.item);
+ }
+}
diff --git a/Week6 Sliding game solver/src/SlidingGame.java b/Week6 Sliding game solver/src/SlidingGame.java
new file mode 100644
index 0000000..0e80797
--- /dev/null
+++ b/Week6 Sliding game solver/src/SlidingGame.java
@@ -0,0 +1,205 @@
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Pieter Koopman, Sjaak Smetsers
+ * @author Camil Staps, s4498062
+ *
+ * A template implementation of a sliding game also
+ * implementing the Graph interface
+ */
+@SuppressWarnings("Convert2Diamond") // We disable these warnings for Java <=1.7 compatibility.
+public class SlidingGame implements Configuration
+{
+ public static final int N = 3, SIZE = N * N, HOLE = SIZE;
+
+ /*
+ * The board is represented by a 2-dimensional array;
+ * The position of the hole is kept in 2 variables holeX and holeY
+ * We store the summed manhattan of all tiles and the hole in manhattan
+ */
+ private final int [][] board;
+ private int holeX, holeY;
+ private final int manhattan;
+
+ /*
+ * A constructor that initializes the board with the specified array
+ * @param start: a one dimensional array containing the initial board.
+ * The elements of start are stored row-wise.
+ */
+ public SlidingGame (int [] start) {
+ board = new int[N][N];
+
+ assert start.length == SIZE: "Length of specified board incorrect";
+
+ for( int p = 0; p < start.length; p++) {
+ board[p % N][p / N] = start[p];
+ if ( start[p] == HOLE ) {
+ holeX = p % N;
+ holeY = p / N;
+ }
+ }
+
+ manhattan = calculateManhattan();
+ }
+
+ /**
+ * A constructor that initialises the board with a specified 2D array
+ * @param board a 2D array containing the initial board
+ */
+ public SlidingGame (int[][] board) {
+ this.board = new int[N][N];
+
+ assert board.length == N: "Length of specified board incorrect";
+
+ for (int a = 0; a < N; a++) {
+ assert board[a].length == N: "Length of specified board incorrect";
+ for (int b = 0; b < N; b++) {
+ this.board[a][b] = board[a][b];
+ if (board[a][b] == HOLE) {
+ holeX = a;
+ holeY = b;
+ }
+ }
+ }
+
+ manhattan = calculateManhattan();
+ }
+
+ /**
+ * Calculate the summed Manhattan distance for all tiles and the hole
+ * @return the Manhattan distance
+ */
+ private int calculateManhattan() {
+ int result = 0;
+ for (int x = 0; x < N; x++) {
+ for (int y = 0; y < N; y++) {
+ int this_x = (board[x][y] - 1) % N;
+ int this_y = (board[x][y] - 1) / N;
+ result += Math.abs(this_x - x) + Math.abs(this_y - y);
+ }
+ }
+ return result;
+ }
+
+ public int getManhattan() {
+ return manhattan;
+ }
+
+ /**
+ * Attempt to move the hole in a specified direction
+ * @param d the direction in which to move
+ * @return A new instance of this class where the hole has moved
+ * @throws ArrayIndexOutOfBoundsException If the hole cannot be moved
+ */
+ private SlidingGame move(Direction d) throws ArrayIndexOutOfBoundsException {
+ int[][] newboard = new int[N][N];
+ for (int a = 0; a < N; a++)
+ System.arraycopy(board[a], 0, newboard[a], 0, N);
+
+ newboard[holeX][holeY] = newboard[holeX + d.GetDX()][holeY + d.GetDY()];
+ newboard[holeX + d.GetDX()][holeY + d.GetDY()] = HOLE;
+ return new SlidingGame(newboard);
+ }
+
+ /*
+ * Converts a board into a printable representation.
+ * The hole is displayed as a space.
+ * @return the string representation
+ */
+ @Override
+ public String toString() {
+ StringBuilder buf = new StringBuilder();
+ for (int row = 0; row < N; row++) {
+ for (int col = 0; col < N; col++) {
+ int puzzel = board[col][row];
+ // Using String.format to pad left as in http://stackoverflow.com/a/391978/1544337; provides better formatting for puzzles with N > 3
+ buf.append(String.format("%1$" + ((int) Math.log10(SIZE - 1) + 2) + "s", puzzel == HOLE ? " " : puzzel + " "));
+ }
+ buf.append("\n");
+ }
+ return buf.toString();
+ }
+
+ /*
+ * A standard implementation of equals checking whether 2 boards are filled
+ * in exactly the same way.
+ * @return true iff this object and o are equal
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || o.getClass() != getClass()) {
+ return false;
+ } else {
+ SlidingGame other_puzzle = (SlidingGame) o;
+ for (int row = 0; row < N; row++) {
+ for (int col = 0; col < N; col++) {
+ if (board[col][row] != other_puzzle.board[col][row]) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ }
+
+ @Override
+ public boolean isSolution () {
+ for( int p = 0; p < SIZE; p++) {
+ if (board[p % N][p / N] != p + 1) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public Collection successors () {
+ Collection successors = new ArrayList();
+ try {
+ successors.add(move(Direction.EAST));
+ } catch (ArrayIndexOutOfBoundsException e) {}
+ try {
+ successors.add(move(Direction.SOUTH));
+ } catch (ArrayIndexOutOfBoundsException e) {}
+ try {
+ successors.add(move(Direction.WEST));
+ } catch (ArrayIndexOutOfBoundsException e) {}
+ try {
+ successors.add(move(Direction.NORTH));
+ } catch (ArrayIndexOutOfBoundsException e) {}
+ return successors;
+ }
+
+ /**
+ * According to the assignment we should use:
+ * result += board[x][y] * Math.pow(31, x + N*y);
+ * However, this results for even small boards in INT_MAX, so this is not very useful.
+ *
+ * Giving every board a unique hash would be:
+ * result += board[x][y] * Math.pow(SIZE, x + N*y);
+ * However, already with N=4 that results in INT_MAX as well.
+ *
+ * The current implementation uses SIZE as base and subtracts n(n-1) from the exponent.
+ * This results in values well below INT_MAX for N up to 5 (and possibly higher).
+ * Of course, it also means that different puzzles may have the same value.
+ * For N>3 this is unavoidable since 16! > INT_MAX. For N <= 3 we are not too concerned
+ * since the program is fast enough for small programs for us to accept this imperfectness.
+ */
+ @Override
+ public int hashCode() {
+ int result = 0;
+ for (int x = 0; x < N; x++)
+ for (int y = 0; y < N; y++)
+ result += board[x][y] * Math.pow(SIZE, x + N*y - (N-1)*N);
+
+ return result;
+ }
+
+ @Override
+ public int compareTo(Configuration t) {
+ SlidingGame tsg = (SlidingGame) t;
+ return manhattan - tsg.getManhattan();
+ }
+
+}
diff --git a/Week6 Sliding game solver/src/Solver.java b/Week6 Sliding game solver/src/Solver.java
new file mode 100644
index 0000000..9b78f27
--- /dev/null
+++ b/Week6 Sliding game solver/src/Solver.java
@@ -0,0 +1,55 @@
+import java.util.HashSet;
+import java.util.PriorityQueue;
+import java.util.Queue;
+
+/**
+ * A class that implements a breadth-first search algorithm
+ * for finding the Configurations for which the isSolution predicate holds
+ *
+ * @author Pieter Koopman, Sjaak Smetsers
+ * @author Camil Staps, s4498062
+ */
+@SuppressWarnings("Convert2Diamond") // We disable these warnings for Java <=1.7 compatibility.
+public class Solver
+{
+ // A queue for maintaining graphs that are not visited yet.
+ private final Queue> toExamine = new PriorityQueue>();
+ private final HashSet examined = new HashSet();
+
+ private Node winner = null;
+
+ public Solver(Configuration g) {
+ toExamine.add(new Node(null, g));
+ }
+
+ /* A skeleton implementation of the solver
+ * @return a string representation of the solution
+ */
+ public boolean solve () {
+ while (!toExamine.isEmpty()) {
+ Node next = toExamine.remove();
+ Configuration nextConfiguration = (Configuration) next.getItem();
+ examined.add(nextConfiguration);
+ if (nextConfiguration.isSolution()) {
+ winner = next;
+ return true;
+ } else {
+ for (Configuration succ: nextConfiguration.successors()) {
+ if (!examined.contains(succ)) {
+ toExamine.add(new Node(next, succ));
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return the winning Node (from which the path can be reconstructed)
+ * @return the node in which we found a solution
+ */
+ public Node getWinner() {
+ return winner;
+ }
+
+}
diff --git a/Week6 Sliding game solver/week6.tar.gz b/Week6 Sliding game solver/week6.tar.gz
new file mode 100644
index 0000000..b5bca35
Binary files /dev/null and b/Week6 Sliding game solver/week6.tar.gz differ
diff --git a/Week6/Assignment (in Dutch).pdf b/Week6/Assignment (in Dutch).pdf
deleted file mode 100644
index dbf029b..0000000
Binary files a/Week6/Assignment (in Dutch).pdf and /dev/null differ
diff --git a/Week6/build.xml b/Week6/build.xml
deleted file mode 100644
index 2b74971..0000000
--- a/Week6/build.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Week6.
-
-
-
diff --git a/Week6/manifest.mf b/Week6/manifest.mf
deleted file mode 100644
index 328e8e5..0000000
--- a/Week6/manifest.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-X-COMMENT: Main-Class will be added automatically by build
-
diff --git a/Week6/nbproject/build-impl.xml b/Week6/nbproject/build-impl.xml
deleted file mode 100644
index ba6b406..0000000
--- a/Week6/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1413 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Week6/nbproject/genfiles.properties b/Week6/nbproject/genfiles.properties
deleted file mode 100644
index 92d1292..0000000
--- a/Week6/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=bcd01398
-build.xml.script.CRC32=6a261b85
-build.xml.stylesheet.CRC32=8064a381@1.75.2.48
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=bcd01398
-nbproject/build-impl.xml.script.CRC32=e0655e71
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week6/nbproject/project.properties b/Week6/nbproject/project.properties
deleted file mode 100644
index f4df81f..0000000
--- a/Week6/nbproject/project.properties
+++ /dev/null
@@ -1,75 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=Week6
-application.vendor=camilstaps
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# Files in build.classes.dir which should be excluded from distribution jar
-dist.archive.excludes=
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Week6.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.7
-javac.target=1.7
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=Main
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project.
-# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
-# To set system properties for unit tests define test-sys-prop.name=value:
-run.jvmargs=-ea
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/Week6/nbproject/project.xml b/Week6/nbproject/project.xml
deleted file mode 100644
index 1042c24..0000000
--- a/Week6/nbproject/project.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Week6
-
-
-
-
-
-
-
-
-
diff --git a/Week6/src/Configuration.java b/Week6/src/Configuration.java
deleted file mode 100644
index 7264c5f..0000000
--- a/Week6/src/Configuration.java
+++ /dev/null
@@ -1,21 +0,0 @@
-import java.util.Collection;
-
-
-/**
- * An interface for representing nodes in a state space.
- *
- * @author Sjaak Smetsers
- * @version 1.2
- * @date 28-02-2015
- */
-public interface Configuration extends Comparable {
- /*
- * To obtain the successors for a specific configuration
- * @return a collection of configurations containing the successors
- */
- public Collection successors ();
- /*
- * For marking final / solution configurations.
- */
- public boolean isSolution ();
-}
diff --git a/Week6/src/Direction.java b/Week6/src/Direction.java
deleted file mode 100644
index d4837b9..0000000
--- a/Week6/src/Direction.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * @author Sjaak Smetsers
- * @version 1.2
- * @date 28-02-2015
- * An enumeration type for the 4 points of the compass
- * Each constant has 2 (final) int attributes indicating
- * the displacement of each direction on a 2-dimensional grid
- * of which the origin is located in the upper left corner
- */
-public enum Direction {
- NORTH (0,-1), EAST (1,0), SOUTH(0,1), WEST(-1,0);
-
- private final int dx, dy;
- private Direction (int dx, int dy) {
- this.dx = dx;
- this.dy = dy;
- }
-
- public int GetDX () {
- return dx;
- }
-
- public int GetDY () {
- return dy;
- }
-}
diff --git a/Week6/src/Main.java b/Week6/src/Main.java
deleted file mode 100644
index 4225013..0000000
--- a/Week6/src/Main.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Solutions for the assignments of week 6.
- * @author Camil Staps, s4498062
- */
-public class Main
-{
-
- /**
- * Create a new sliding game, attempt to solve it and if it succeeds show a solution.
- * @param args command-line arguments are ignored.
- */
- public static void main(String[] args) {
- // Some examples:
- // N = 5
- //int[] x = {7,17,9,4,5,1,12,15,6,10,3,23,25,14,8,22,2,18,19,24,16,21,11,13,20}; // May take some time (that is, it did not find a solution after some hours here, I didn't check if there is one)
- //int[] x = {2,4,6,8,10,1,3,5,7,9,12,14,16,18,20,11,13,15,17,19,21,22,23,24,25}; // Solution in 90
- // N = 4
- //int[] x = {2,3,10,11,14,1,13,15,5,4,8,7,6,12,9,16}; // Solution in 112
- //int[] x = {10,8,16,7,6,13,15,3,14,1,4,2,5,9,12,11}; // Solution in 144
- //int[] x = {9,12,5,4,2,16,7,11,3,6,10,13,14,1,8,15}; // Solution in 140
- // N = 3
- //int[] x = {8,7,6,5,4,3,1,2,9}; // No solution (evaluates 292102 different boards before failing)
- int[] x = {5,9,3,4,6,2,8,7,1}; // Solution in 35
-
- SlidingGame sg = new SlidingGame(x);
- System.out.println("Solving:\n" + sg);
- Solver s = new Solver(sg);
- if (s.solve()) {
- System.out.println("Success!");
- System.out.println(s.getWinner());
- } else {
- System.out.println("Failure...");
- }
- }
-}
diff --git a/Week6/src/Node.java b/Week6/src/Node.java
deleted file mode 100644
index cb5c900..0000000
--- a/Week6/src/Node.java
+++ /dev/null
@@ -1,92 +0,0 @@
-import java.util.ArrayList;
-
-/**
- * For maintaining lists of T-elements enabling
- * a structure suited for backwards traversal
- *
- * @author Pieter Koopman, Sjaak Smetsers
- * @author Camil Staps, s4498062
- *
- * @param The element this node is based on
- */
-@SuppressWarnings("Convert2Diamond") // We disable these warnings for Java <=1.7 compatibility.
-public class Node implements Comparable>
-{
- // the data field
- private final T item;
- // a reference to the predecessor
- private final Node previous;
-
- /* A constructor that initializes each node
- * with the specified values
- * @param from the node preceding the current node
- * @param item the initial data item
- */
- public Node (Node from, T item) {
- this.previous = from;
- this.item = item;
- }
-
- /* a getter for the item
- * @return item
- */
- public T getItem() {
- return item;
- }
-
- /*
- * a getter for the predecessor
- * @return previous
- */
- public Node getPrevious() {
- return previous;
- }
-
- /*
- * determines the length of the current list
- * @return the length as an integer
- */
- public int length () {
- int length = 1;
- Node prev = previous;
- while ( prev != null ) {
- prev = prev.previous;
- length++;
- }
- return length;
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
-
- ArrayList> path;
- path = new ArrayList>();
- Node prev = this;
- while ( prev != null ) {
- path.add(prev);
- prev = prev.previous;
- }
-
- for (int i = path.size() - 1; i >= 0; i--)
- result.append(path.size() - i - 1).append(":\n").append(path.get(i).getItem().toString());
-
- return result.toString();
- }
-
- /**
- * Just comparing the items isn't very clever. The Manhattan distance is a fairly small number.
- * With large queues, many nodes will then have the same priority. It's much better to select
- * on both Manhattan distance and path length. That way, we will find shorter paths.
- * Note though that since we're prioritizing on Manhattan distance primarily, this does not
- * mean that we necessarily find the shortest path.
- * @param t
- * @return
- */
- @Override
- public int compareTo(Node t) {
- if (this.item.compareTo(t.item) == 0)
- return Integer.compare(length(), t.length());
- return this.item.compareTo(t.item);
- }
-}
diff --git a/Week6/src/SlidingGame.java b/Week6/src/SlidingGame.java
deleted file mode 100644
index 0e80797..0000000
--- a/Week6/src/SlidingGame.java
+++ /dev/null
@@ -1,205 +0,0 @@
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author Pieter Koopman, Sjaak Smetsers
- * @author Camil Staps, s4498062
- *
- * A template implementation of a sliding game also
- * implementing the Graph interface
- */
-@SuppressWarnings("Convert2Diamond") // We disable these warnings for Java <=1.7 compatibility.
-public class SlidingGame implements Configuration
-{
- public static final int N = 3, SIZE = N * N, HOLE = SIZE;
-
- /*
- * The board is represented by a 2-dimensional array;
- * The position of the hole is kept in 2 variables holeX and holeY
- * We store the summed manhattan of all tiles and the hole in manhattan
- */
- private final int [][] board;
- private int holeX, holeY;
- private final int manhattan;
-
- /*
- * A constructor that initializes the board with the specified array
- * @param start: a one dimensional array containing the initial board.
- * The elements of start are stored row-wise.
- */
- public SlidingGame (int [] start) {
- board = new int[N][N];
-
- assert start.length == SIZE: "Length of specified board incorrect";
-
- for( int p = 0; p < start.length; p++) {
- board[p % N][p / N] = start[p];
- if ( start[p] == HOLE ) {
- holeX = p % N;
- holeY = p / N;
- }
- }
-
- manhattan = calculateManhattan();
- }
-
- /**
- * A constructor that initialises the board with a specified 2D array
- * @param board a 2D array containing the initial board
- */
- public SlidingGame (int[][] board) {
- this.board = new int[N][N];
-
- assert board.length == N: "Length of specified board incorrect";
-
- for (int a = 0; a < N; a++) {
- assert board[a].length == N: "Length of specified board incorrect";
- for (int b = 0; b < N; b++) {
- this.board[a][b] = board[a][b];
- if (board[a][b] == HOLE) {
- holeX = a;
- holeY = b;
- }
- }
- }
-
- manhattan = calculateManhattan();
- }
-
- /**
- * Calculate the summed Manhattan distance for all tiles and the hole
- * @return the Manhattan distance
- */
- private int calculateManhattan() {
- int result = 0;
- for (int x = 0; x < N; x++) {
- for (int y = 0; y < N; y++) {
- int this_x = (board[x][y] - 1) % N;
- int this_y = (board[x][y] - 1) / N;
- result += Math.abs(this_x - x) + Math.abs(this_y - y);
- }
- }
- return result;
- }
-
- public int getManhattan() {
- return manhattan;
- }
-
- /**
- * Attempt to move the hole in a specified direction
- * @param d the direction in which to move
- * @return A new instance of this class where the hole has moved
- * @throws ArrayIndexOutOfBoundsException If the hole cannot be moved
- */
- private SlidingGame move(Direction d) throws ArrayIndexOutOfBoundsException {
- int[][] newboard = new int[N][N];
- for (int a = 0; a < N; a++)
- System.arraycopy(board[a], 0, newboard[a], 0, N);
-
- newboard[holeX][holeY] = newboard[holeX + d.GetDX()][holeY + d.GetDY()];
- newboard[holeX + d.GetDX()][holeY + d.GetDY()] = HOLE;
- return new SlidingGame(newboard);
- }
-
- /*
- * Converts a board into a printable representation.
- * The hole is displayed as a space.
- * @return the string representation
- */
- @Override
- public String toString() {
- StringBuilder buf = new StringBuilder();
- for (int row = 0; row < N; row++) {
- for (int col = 0; col < N; col++) {
- int puzzel = board[col][row];
- // Using String.format to pad left as in http://stackoverflow.com/a/391978/1544337; provides better formatting for puzzles with N > 3
- buf.append(String.format("%1$" + ((int) Math.log10(SIZE - 1) + 2) + "s", puzzel == HOLE ? " " : puzzel + " "));
- }
- buf.append("\n");
- }
- return buf.toString();
- }
-
- /*
- * A standard implementation of equals checking whether 2 boards are filled
- * in exactly the same way.
- * @return true iff this object and o are equal
- */
- @Override
- public boolean equals(Object o) {
- if (o == null || o.getClass() != getClass()) {
- return false;
- } else {
- SlidingGame other_puzzle = (SlidingGame) o;
- for (int row = 0; row < N; row++) {
- for (int col = 0; col < N; col++) {
- if (board[col][row] != other_puzzle.board[col][row]) {
- return false;
- }
- }
- }
- return true;
- }
- }
-
- @Override
- public boolean isSolution () {
- for( int p = 0; p < SIZE; p++) {
- if (board[p % N][p / N] != p + 1) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public Collection successors () {
- Collection successors = new ArrayList();
- try {
- successors.add(move(Direction.EAST));
- } catch (ArrayIndexOutOfBoundsException e) {}
- try {
- successors.add(move(Direction.SOUTH));
- } catch (ArrayIndexOutOfBoundsException e) {}
- try {
- successors.add(move(Direction.WEST));
- } catch (ArrayIndexOutOfBoundsException e) {}
- try {
- successors.add(move(Direction.NORTH));
- } catch (ArrayIndexOutOfBoundsException e) {}
- return successors;
- }
-
- /**
- * According to the assignment we should use:
- * result += board[x][y] * Math.pow(31, x + N*y);
- * However, this results for even small boards in INT_MAX, so this is not very useful.
- *
- * Giving every board a unique hash would be:
- * result += board[x][y] * Math.pow(SIZE, x + N*y);
- * However, already with N=4 that results in INT_MAX as well.
- *
- * The current implementation uses SIZE as base and subtracts n(n-1) from the exponent.
- * This results in values well below INT_MAX for N up to 5 (and possibly higher).
- * Of course, it also means that different puzzles may have the same value.
- * For N>3 this is unavoidable since 16! > INT_MAX. For N <= 3 we are not too concerned
- * since the program is fast enough for small programs for us to accept this imperfectness.
- */
- @Override
- public int hashCode() {
- int result = 0;
- for (int x = 0; x < N; x++)
- for (int y = 0; y < N; y++)
- result += board[x][y] * Math.pow(SIZE, x + N*y - (N-1)*N);
-
- return result;
- }
-
- @Override
- public int compareTo(Configuration t) {
- SlidingGame tsg = (SlidingGame) t;
- return manhattan - tsg.getManhattan();
- }
-
-}
diff --git a/Week6/src/Solver.java b/Week6/src/Solver.java
deleted file mode 100644
index 9b78f27..0000000
--- a/Week6/src/Solver.java
+++ /dev/null
@@ -1,55 +0,0 @@
-import java.util.HashSet;
-import java.util.PriorityQueue;
-import java.util.Queue;
-
-/**
- * A class that implements a breadth-first search algorithm
- * for finding the Configurations for which the isSolution predicate holds
- *
- * @author Pieter Koopman, Sjaak Smetsers
- * @author Camil Staps, s4498062
- */
-@SuppressWarnings("Convert2Diamond") // We disable these warnings for Java <=1.7 compatibility.
-public class Solver
-{
- // A queue for maintaining graphs that are not visited yet.
- private final Queue> toExamine = new PriorityQueue>();
- private final HashSet examined = new HashSet();
-
- private Node winner = null;
-
- public Solver(Configuration g) {
- toExamine.add(new Node(null, g));
- }
-
- /* A skeleton implementation of the solver
- * @return a string representation of the solution
- */
- public boolean solve () {
- while (!toExamine.isEmpty()) {
- Node next = toExamine.remove();
- Configuration nextConfiguration = (Configuration) next.getItem();
- examined.add(nextConfiguration);
- if (nextConfiguration.isSolution()) {
- winner = next;
- return true;
- } else {
- for (Configuration succ: nextConfiguration.successors()) {
- if (!examined.contains(succ)) {
- toExamine.add(new Node(next, succ));
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Return the winning Node (from which the path can be reconstructed)
- * @return the node in which we found a solution
- */
- public Node getWinner() {
- return winner;
- }
-
-}
diff --git a/Week6/week6.tar.gz b/Week6/week6.tar.gz
deleted file mode 100644
index b5bca35..0000000
Binary files a/Week6/week6.tar.gz and /dev/null differ
diff --git a/Week7 Polynomials/.gitignore b/Week7 Polynomials/.gitignore
new file mode 100644
index 0000000..4523fc2
--- /dev/null
+++ b/Week7 Polynomials/.gitignore
@@ -0,0 +1,3 @@
+nbproject/private/
+build/
+dist/
diff --git a/Week7 Polynomials/Assignment (in Dutch).pdf b/Week7 Polynomials/Assignment (in Dutch).pdf
new file mode 100644
index 0000000..5c9bd0c
Binary files /dev/null and b/Week7 Polynomials/Assignment (in Dutch).pdf differ
diff --git a/Week7 Polynomials/Week7.tar.gz b/Week7 Polynomials/Week7.tar.gz
new file mode 100644
index 0000000..eaa77df
Binary files /dev/null and b/Week7 Polynomials/Week7.tar.gz differ
diff --git a/Week7 Polynomials/build.xml b/Week7 Polynomials/build.xml
new file mode 100644
index 0000000..a54a461
--- /dev/null
+++ b/Week7 Polynomials/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Week7 Polynomials.
+
+
+
diff --git a/Week7 Polynomials/nbproject/build-impl.xml b/Week7 Polynomials/nbproject/build-impl.xml
new file mode 100644
index 0000000..28a95e1
--- /dev/null
+++ b/Week7 Polynomials/nbproject/build-impl.xml
@@ -0,0 +1,1413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week7 Polynomials/nbproject/genfiles.properties b/Week7 Polynomials/nbproject/genfiles.properties
new file mode 100644
index 0000000..54a54b5
--- /dev/null
+++ b/Week7 Polynomials/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=e009bca9
+build.xml.script.CRC32=6ab8560a
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=e009bca9
+nbproject/build-impl.xml.script.CRC32=918db01b
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week7 Polynomials/nbproject/project.properties b/Week7 Polynomials/nbproject/project.properties
new file mode 100644
index 0000000..bbf02d2
--- /dev/null
+++ b/Week7 Polynomials/nbproject/project.properties
@@ -0,0 +1,73 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Week7_Polynomials.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.7
+javac.target=1.7
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}:\
+ ${libs.junit_4.classpath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=main.Main
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=true
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Week7 Polynomials/nbproject/project.xml b/Week7 Polynomials/nbproject/project.xml
new file mode 100644
index 0000000..18f6583
--- /dev/null
+++ b/Week7 Polynomials/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Week7 Polynomials
+
+
+
+
+
+
+
+
+
diff --git a/Week7 Polynomials/src/main/Main.java b/Week7 Polynomials/src/main/Main.java
new file mode 100644
index 0000000..725b8f3
--- /dev/null
+++ b/Week7 Polynomials/src/main/Main.java
@@ -0,0 +1,23 @@
+package main;
+
+import polynomial.Polynomial;
+
+/**
+ *
+ * @author Sjaak Smetsers
+ */
+public class Main {
+
+ public static void main(String[] args) {
+ Polynomial p1 = new Polynomial( "3.0 1 2 3" );
+ Polynomial p2 = new Polynomial( "4 0 5 3" );
+ Polynomial p3 = new Polynomial( "4 0 -5 3" );
+ Polynomial p4 = new Polynomial( "6 1" );
+
+ System.out.println( p1 );
+ System.out.println( p2 );
+ System.out.println( p3 );
+ System.out.println( p4 );
+ }
+
+}
diff --git a/Week7 Polynomials/src/polynomial/Polynomial.java b/Week7 Polynomials/src/polynomial/Polynomial.java
new file mode 100644
index 0000000..c87b96a
--- /dev/null
+++ b/Week7 Polynomials/src/polynomial/Polynomial.java
@@ -0,0 +1,189 @@
+package polynomial;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * A class for representing Polynomials
+ *
+ * @author Sjaak Smetsers
+ * @date 10-03-2015
+ *
+ * @author Camil Staps, s4498062
+ * @date 17-03-2015
+ */
+public class Polynomial {
+
+ /**
+ * A polynomial is a sequence of terms here kept in an List.
+ * The assignment tells us 'it's handy' when terms are ordered by exponent.
+ * We don't seem to need that though, so there's no need to implement it.
+ */
+ List terms;
+
+ /**
+ * A constructor for creating the zero Polynomial zero is presented as an
+ * empty list of terms and not as a single term with 0 as a coefficient
+ */
+ public Polynomial() {
+ terms = new ArrayList<>();
+ }
+
+ /**
+ * A Constructor creating a polynomial from the argument string.
+ *
+ * This implementation, in contrast to the given implementation, allows for
+ * entering polynomials with two or more terms with the same exponent. Even
+ * though this is strictly not necessary and these inputs aren't legit, this
+ * behaviour is always better than the behaviour of the given implementation
+ * which would happily add two terms with the same exponent to our list.
+ *
+ * This implementation also directly checks that the coefficient unequals 0,
+ * which is also not need-to-have, but still nice-to-have.
+ *
+ * Both changes to the given implementation do not change the behaviour on
+ * legit input but do allow a user to mess up in some cases.
+ *
+ * @param s a String representing a list of terms which is converted to a
+ * scanner and passed to scanTerm for reading each individual term
+ */
+ public Polynomial( String s ) {
+ terms = new ArrayList<>();
+ Scanner scan = new Scanner(s);
+
+ for (Term t = Term.scanTerm(scan); t != null; t = Term.scanTerm(scan))
+ if (t.getCoef() != 0)
+ plus(t);
+ }
+
+ /**
+ * The copy constructor for making a deep copy
+ *
+ * @param p the copied polynomial
+ */
+ public Polynomial( Polynomial p ) {
+ terms = new ArrayList<>(p.terms.size());
+ for (Term t : p.terms) {
+ terms.add(new Term(t));
+ }
+ }
+
+ /**
+ * A straightforward conversion of a Polynomial into a string based on the
+ * toString for terms
+ *
+ * @return a readable string representation of this
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ boolean not_first = false;
+ for (Term t : terms) {
+ if (not_first && t.getCoef() >= 0)
+ sb.append("+");
+ sb.append(t);
+ not_first = true;
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Add a polynomial to this polynomial
+ * @param b the polynomial to add
+ */
+ public void plus(Polynomial b) {
+ for (Term t : b.terms)
+ plus(t);
+ }
+
+ /**
+ * Add a term
+ * @param t the term to add
+ */
+ private void plus(Term t) {
+ if (t.getCoef() == 0)
+ return;
+
+ Iterator iter = terms.iterator();
+ while (iter.hasNext()) {
+ Term this_t = iter.next();
+ if (this_t.getExp() == t.getExp()) {
+ this_t.plus(t);
+ if (this_t.getCoef() == 0)
+ iter.remove();
+ return;
+ }
+ }
+ terms.add(new Term(t));
+ }
+
+ /**
+ * Subtract a polynomial from this polynomial
+ * @param p the polynomial to subtract
+ */
+ public void minus(Polynomial p) {
+ Polynomial temp = new Polynomial(p);
+ temp.times(new Polynomial("-1 0"));
+ plus(temp);
+ }
+
+ /**
+ * Multiply a polynomial with this polynomial
+ * @param p the polynomial to multiply with
+ */
+ public void times(Polynomial p) {
+ Polynomial result = new Polynomial();
+ for (Term that_t : p.terms)
+ for (Term this_t : terms)
+ result.plus(new Term(that_t.getCoef() * this_t.getCoef(), that_t.getExp() + this_t.getExp()));
+ terms = result.terms;
+ }
+
+ public void divide(Polynomial b) {
+ }
+
+ /**
+ * Check equality
+ * @param other_poly the object to check with
+ * @return true iff other_poly represents the same polynomial as this instance
+ */
+ @Override
+ public boolean equals(Object other_poly) {
+ if (other_poly == null || other_poly.getClass() != getClass())
+ return false;
+
+ Polynomial that = new Polynomial((Polynomial) other_poly); // We need to copy because later we'll remove elements
+ if (terms.size() != that.terms.size())
+ return false;
+ for (Term this_t : terms) {
+ Iterator that_iter = that.terms.iterator();
+ boolean found = false;
+ while (that_iter.hasNext()) {
+ if (this_t.equals(that_iter.next())) {
+ found = true;
+ that_iter.remove();
+ break;
+ }
+ }
+ if (!found) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Apply the polynomial to a concrete variable
+ * @param x the variable
+ * @return the result of the polynomial applied on x
+ */
+ public double apply(double x) {
+ double result = 0;
+ for (Term t : terms)
+ result += t.apply(x);
+ return result;
+ }
+
+}
diff --git a/Week7 Polynomials/src/polynomial/Term.java b/Week7 Polynomials/src/polynomial/Term.java
new file mode 100644
index 0000000..60c6381
--- /dev/null
+++ b/Week7 Polynomials/src/polynomial/Term.java
@@ -0,0 +1,145 @@
+package polynomial;
+
+import java.util.Scanner;
+
+/**
+ * For representing terms in a polynomial.
+ *
+ * @author Sjaak Smetsers
+ * @version 1.0
+ * @date 15-02-2012
+ *
+ * @author Camil Staps, s4498062
+ * @date 17-03-2015
+ */
+public class Term {
+
+ /**
+ * Each term consists of a coefficient and an exponent
+ */
+ private double coefficient;
+ private int exponent;
+
+ /**
+ * a get-method for the exponent
+ *
+ * @return exponent
+ */
+ public int getExp() {
+ return exponent;
+ }
+
+ /**
+ * a get-method for the coefficient
+ *
+ * @return coefficient
+ */
+ public double getCoef() {
+ return coefficient;
+ }
+
+ /**
+ * A two-argument constructor
+ *
+ * @param c the value for the coefficient
+ * @param e the value for the exponent
+ */
+ public Term(double c, int e) {
+ coefficient = c;
+ exponent = e;
+ }
+
+ /**
+ * A copy-constructor
+ *
+ * @param t the term to be copied
+ */
+ public Term(Term t) {
+ this(t.coefficient, t.exponent);
+ }
+
+ /**
+ * For adding two terms with equal exponents
+ *
+ * @param t the term added to this
+ * @require exponent == t.exponent
+ */
+ public void plus(Term t) {
+ coefficient += t.coefficient;
+ }
+
+ /**
+ * For multiplying two terms
+ *
+ * @param t the multiplier
+ */
+ public void times(Term t) {
+ exponent += t.exponent;
+ coefficient *= t.coefficient;
+ }
+
+ /**
+ * Converts a term into a readable representation the standard format is
+ * %fx^%d
+ * I changed the implementation to remove trailing zeroes from the coefficient.
+ *
+ * @return the string representing the term
+ */
+ @Override
+ public String toString() {
+ String nice_coefficient = Double.toString(coefficient);
+ if (Math.round(coefficient) == coefficient)
+ nice_coefficient = Integer.toString((int) coefficient);
+ if (exponent == 0) {
+ return String.format("%s", nice_coefficient, exponent);
+ } else if (exponent == 1) {
+ return String.format("%sx", nice_coefficient, exponent);
+ } else {
+ return String.format("%sx^%d", nice_coefficient, exponent);
+ }
+ }
+
+ /**
+ * Standard implementation of equality
+ * @param may_be_term the object to check equality with
+ * @return true iff may_be_term represents the same term as this term
+ */
+ @Override
+ public boolean equals(Object may_be_term) {
+ if (may_be_term == null || getClass() != may_be_term.getClass()) {
+ return false;
+ } else {
+ Term term = (Term) may_be_term;
+ return exponent == term.exponent
+ && coefficient == term.coefficient;
+ }
+ }
+
+ /**
+ * Apply a term to a concrete variable
+ * @param x the variable to apply the term to
+ * @return the result of the application of the term to x
+ */
+ public double apply(double x) {
+ return coefficient * Math.pow(x, exponent);
+ }
+
+ /**
+ * A static method for converting scanner input into a term. The expected
+ * format is two numbers (coef, exp) separated by whitespaces. The coef
+ * should be either an integer or a decimal number. The exp is an integer.
+ *
+ * @param s the scanner providing the input
+ * @return null if no term could be found, the found term otherwise
+ */
+ public static Term scanTerm(Scanner s) {
+ String coef_patt = "\\-?\\d+(\\.\\d+)?";
+ if (s.hasNext(coef_patt)) {
+ String coef = s.next(coef_patt);
+ int exp = s.nextInt();
+ return new Term(Double.parseDouble(coef), exp);
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/Week7 Polynomials/test/polynomial/PolynomialTest.java b/Week7 Polynomials/test/polynomial/PolynomialTest.java
new file mode 100644
index 0000000..c00f165
--- /dev/null
+++ b/Week7 Polynomials/test/polynomial/PolynomialTest.java
@@ -0,0 +1,226 @@
+package polynomial;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * A test class for the polynomial.Polynomial class
+ * @author Camil Staps, s4498062
+ */
+public class PolynomialTest {
+
+ public PolynomialTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of toString method, of class Polynomial.
+ */
+ @Test
+ public void testToString() {
+ System.out.println("toString");
+ // Test exp=0, exp=1, exp>1, positive & negative integer & floating point coefficients all at once
+ assertEquals("3x^5-4x+2.5-3.4x^-7", new Polynomial("3 5 -4 1 2.5 0 -3.4 -7").toString());
+ // Test zero polynomial
+ assertEquals("", new Polynomial().toString());
+ }
+
+ /**
+ * Test of minus method, of class Polynomial.
+ */
+ @Test
+ public void testMinus() {
+ System.out.println("minus");
+ // Test cancelling out and exponents that don't exist in either of the two polynomials all at once
+ Polynomial instance = new Polynomial("7 4 -4 2 3 1 5 0"); // 7x^4 - 4x^2 + 3x + 5
+ instance.minus(new Polynomial("5 3 4 2 3 1 10 0")); // 5x^3 + 4x^2 + 3x + 10
+ assertEquals(new Polynomial("7 4 -5 3 -8 2 -5 0"), instance); // 7x^4 - 5x^3 - 8x^2 - 5
+
+ // Test minus = plus (times -1) on many small 2-term polynomials
+ for (float c1 = -10; c1 < 10; c1 += 2.3)
+ for (int exp1 = 5; exp1 < 10; exp1++)
+ for (float c2 = -10; c2 < 10; c2 += 2.3)
+ for (int exp2 = 5; exp2 < 10; exp2++) {
+ Polynomial fst = new Polynomial(c1 + " " + exp1 + " " + c2 + " " + exp2);
+ Polynomial snd = new Polynomial(c1 + " " + exp2 + " " + c2 + " " + exp1);
+ Polynomial fst_2 = new Polynomial(fst);
+ Polynomial snd_2 = new Polynomial(snd);
+ fst.minus(snd);
+ snd_2.times(new Polynomial("-1 0"));
+ fst_2.plus(snd_2);
+ assertEquals(true, fst.equals(fst_2));
+ }
+
+ // Test associativity for some random polynomials
+ Polynomial a = new Polynomial("5 4 2 5 20 8 4 0");
+ Polynomial b = new Polynomial("9 2 48 2 10 8 28 2");
+ Polynomial c = new Polynomial("3 8 4 20 8 2 4 5 0 0");
+ Polynomial a_bc = new Polynomial(a);
+ a_bc.minus(b);
+ a_bc.minus(c);
+ Polynomial a_cb = new Polynomial(a);
+ a_cb.minus(c);
+ a_cb.minus(b);
+ assertEquals(true, a_bc.equals(a_cb));
+ }
+
+ /**
+ * Test of times method, of class Polynomial.
+ */
+ @Test
+ public void testTimes() {
+ System.out.println("times");
+
+ // Simple case
+ Polynomial instance = new Polynomial("7 1 6 3");
+ instance.times(new Polynomial("5 3 4 2"));
+ assertEquals(new Polynomial("30 6 24 5 35 4 28 3"), instance);
+
+ // Simple case with zero polynomial
+ instance = new Polynomial("5 3");
+ instance.times(new Polynomial());
+ assertEquals(new Polynomial(), instance);
+
+ // Advanced case with coefficient 0 in the result
+ instance = new Polynomial("4 4 2 3"); // 4x^4 + 2x^3
+ instance.times(new Polynomial("2 2 -4 3")); // 2x^2 - 4x^3
+ assertEquals(new Polynomial("4 5 -16 7"), instance); // 4x^5 - 16x^7 (exponent 6 cancels out)
+
+ // Test associativity for some random polynomials
+ Polynomial a = new Polynomial("5 4 2 5 20 8 4 0");
+ Polynomial b = new Polynomial("9 2 48 2 10 8 28 2");
+ Polynomial c = new Polynomial("3 8 4 20 8 2 4 5 0 0");
+ Polynomial a_bc = new Polynomial(a);
+ a_bc.times(b);
+ a_bc.times(c);
+ Polynomial a_cb = new Polynomial(a);
+ a_cb.times(c);
+ a_cb.times(b);
+ assertEquals(true, a_bc.equals(a_cb));
+
+ // Test commutativity
+ Polynomial a_b = new Polynomial(a);
+ a_b.times(b);
+ Polynomial b_a = new Polynomial(b);
+ b_a.times(a);
+ assertEquals(true, a_b.equals(b_a));
+
+ // Test left distributivity
+ Polynomial b_plus_c = new Polynomial(b);
+ b_plus_c.plus(c);
+ Polynomial a_times_b_plus_c = new Polynomial(a);
+ a_times_b_plus_c.times(b_plus_c);
+ Polynomial a_times_c = new Polynomial(a);
+ a_times_c.times(c);
+ Polynomial a_times_b_plus_a_times_c = new Polynomial(a);
+ a_times_b_plus_a_times_c.times(b);
+ a_times_b_plus_a_times_c.plus(a_times_c);
+ assertEquals(true, a_times_b_plus_c.equals(a_times_b_plus_a_times_c));
+
+ // Test right distributivity
+ Polynomial b_plus_c_times_a = new Polynomial(b);
+ b_plus_c_times_a.plus(c);
+ b_plus_c_times_a.times(a);
+ Polynomial c_times_a = new Polynomial(c);
+ c_times_a.times(a);
+ Polynomial b_times_a_plus_c_times_a = new Polynomial(b);
+ b_times_a_plus_c_times_a.times(a);
+ b_times_a_plus_c_times_a.plus(c_times_a);
+ assertEquals(true, b_plus_c_times_a.equals(b_times_a_plus_c_times_a));
+ }
+
+ /**
+ * Test of divide method, of class Polynomial.
+ */
+ @Test
+ public void testDivide() {
+ System.out.println("divide");
+ Polynomial b = null;
+ Polynomial instance = new Polynomial();
+ instance.divide(b);
+ // TODO review the generated test code and remove the default call to fail.
+ fail("The test case is a prototype.");
+ }
+
+ /**
+ * Test of equals method, of class Polynomial.
+ */
+ @Test
+ public void testEquals() {
+ System.out.println("equals");
+ // Order of terms irrelevant
+ assertEquals(true, new Polynomial("4 2 3 5").equals(new Polynomial("3 5 4 2")));
+ // Terms with same exponent are added
+ assertEquals(true, new Polynomial("5 5 10 5").equals(new Polynomial("15 5")));
+ // Simple coefficient 0 removed
+ assertEquals(true, new Polynomial("0 7").equals(new Polynomial()));
+ // Advanced coefficient 0 removed
+ assertEquals(true, new Polynomial("5 10 -5 10").equals(new Polynomial()));
+ // Difference in exponent matters
+ assertEquals(false, new Polynomial("10 0").equals(new Polynomial("10 1")));
+ // Difference in coefficient matters
+ assertEquals(false, new Polynomial("10 0").equals(new Polynomial("5 0")));
+ }
+
+ /**
+ * Test of plus method, of class Polynomial.
+ */
+ @Test
+ public void testPlus_Polynomial() {
+ System.out.println("plus");
+ // Test cancelling out and exponents that don't exist in either of the two polynomials all at once
+ Polynomial instance = new Polynomial("7 4 -4 2 7 1 5 0"); // 7x^4 - 4x^2 + 7x + 5
+ instance.plus(new Polynomial("5 3 4 2 3 1 10 0")); // 5x^3 + 4x^2 + 3x + 10
+ assertEquals(new Polynomial("7 4 5 3 10 1 15 0"), instance); // 7x^4 + 5x^3 + 10x + 15
+
+ // Test associativity for some random polynomials
+ Polynomial a = new Polynomial("5 4 2 5 20 8 4 0");
+ Polynomial b = new Polynomial("9 2 7 5 10 8 28 2");
+ Polynomial c = new Polynomial("3 8 4 20 8 2 4 5 0 0");
+ Polynomial a_bc = new Polynomial(a);
+ a_bc.plus(b);
+ a_bc.plus(c);
+ Polynomial a_cb = new Polynomial(a);
+ a_cb.plus(c);
+ a_cb.plus(b);
+ assertEquals(true, a_bc.equals(a_cb));
+
+ // Test commutativity
+ Polynomial a_b = new Polynomial(a);
+ a_b.plus(b);
+ Polynomial b_a = new Polynomial(b);
+ b_a.plus(a);
+ assertEquals(true, a_b.equals(b_a));
+ }
+
+ /**
+ * Test of apply method, of class Polynomial.
+ */
+ @Test
+ public void testApply() {
+ System.out.println("apply");
+ // Test zero coefficient, floating point coefficient and negative coefficient all at once
+ Polynomial instance = new Polynomial("0 7 5 4 0.5 3 9 2 -8 0");
+ assertEquals(422654.5, instance.apply(17.0), 0.0);
+ }
+
+}
diff --git a/Week7/Assignment (in Dutch).pdf b/Week7/Assignment (in Dutch).pdf
deleted file mode 100644
index 5c9bd0c..0000000
Binary files a/Week7/Assignment (in Dutch).pdf and /dev/null differ
diff --git a/Week7/Week7.tar.gz b/Week7/Week7.tar.gz
deleted file mode 100644
index eaa77df..0000000
Binary files a/Week7/Week7.tar.gz and /dev/null differ
diff --git a/Week7/build.xml b/Week7/build.xml
deleted file mode 100644
index 58539ec..0000000
--- a/Week7/build.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Week7.
-
-
-
diff --git a/Week7/nbproject/build-impl.xml b/Week7/nbproject/build-impl.xml
deleted file mode 100644
index 881af77..0000000
--- a/Week7/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1413 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Week7/nbproject/genfiles.properties b/Week7/nbproject/genfiles.properties
deleted file mode 100644
index 80429a6..0000000
--- a/Week7/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=b4c39fbe
-build.xml.script.CRC32=45654c8f
-build.xml.stylesheet.CRC32=8064a381@1.75.2.48
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=b4c39fbe
-nbproject/build-impl.xml.script.CRC32=5f42e684
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week7/nbproject/private/private.properties b/Week7/nbproject/private/private.properties
deleted file mode 100644
index fca3b8a..0000000
--- a/Week7/nbproject/private/private.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-compile.on.save=true
-user.properties.file=/home/camilstaps/.netbeans/8.0.2/build.properties
diff --git a/Week7/nbproject/private/private.xml b/Week7/nbproject/private/private.xml
deleted file mode 100644
index 6807a2b..0000000
--- a/Week7/nbproject/private/private.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/Week7/nbproject/project.properties b/Week7/nbproject/project.properties
deleted file mode 100644
index 2a8bf83..0000000
--- a/Week7/nbproject/project.properties
+++ /dev/null
@@ -1,72 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processor.options=
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# Files in build.classes.dir which should be excluded from distribution jar
-dist.archive.excludes=
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Week7.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.7
-javac.target=1.7
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${libs.junit_4.classpath}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=true
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project.
-# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
-# To set system properties for unit tests define test-sys-prop.name=value:
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/Week7/nbproject/project.xml b/Week7/nbproject/project.xml
deleted file mode 100644
index 60d2200..0000000
--- a/Week7/nbproject/project.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Week7
-
-
-
-
-
-
-
-
-
diff --git a/Week7/src/main/Main.java b/Week7/src/main/Main.java
deleted file mode 100644
index 725b8f3..0000000
--- a/Week7/src/main/Main.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package main;
-
-import polynomial.Polynomial;
-
-/**
- *
- * @author Sjaak Smetsers
- */
-public class Main {
-
- public static void main(String[] args) {
- Polynomial p1 = new Polynomial( "3.0 1 2 3" );
- Polynomial p2 = new Polynomial( "4 0 5 3" );
- Polynomial p3 = new Polynomial( "4 0 -5 3" );
- Polynomial p4 = new Polynomial( "6 1" );
-
- System.out.println( p1 );
- System.out.println( p2 );
- System.out.println( p3 );
- System.out.println( p4 );
- }
-
-}
diff --git a/Week7/src/polynomial/Polynomial.java b/Week7/src/polynomial/Polynomial.java
deleted file mode 100644
index c87b96a..0000000
--- a/Week7/src/polynomial/Polynomial.java
+++ /dev/null
@@ -1,189 +0,0 @@
-package polynomial;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Scanner;
-
-/**
- * A class for representing Polynomials
- *
- * @author Sjaak Smetsers
- * @date 10-03-2015
- *
- * @author Camil Staps, s4498062
- * @date 17-03-2015
- */
-public class Polynomial {
-
- /**
- * A polynomial is a sequence of terms here kept in an List.
- * The assignment tells us 'it's handy' when terms are ordered by exponent.
- * We don't seem to need that though, so there's no need to implement it.
- */
- List terms;
-
- /**
- * A constructor for creating the zero Polynomial zero is presented as an
- * empty list of terms and not as a single term with 0 as a coefficient
- */
- public Polynomial() {
- terms = new ArrayList<>();
- }
-
- /**
- * A Constructor creating a polynomial from the argument string.
- *
- * This implementation, in contrast to the given implementation, allows for
- * entering polynomials with two or more terms with the same exponent. Even
- * though this is strictly not necessary and these inputs aren't legit, this
- * behaviour is always better than the behaviour of the given implementation
- * which would happily add two terms with the same exponent to our list.
- *
- * This implementation also directly checks that the coefficient unequals 0,
- * which is also not need-to-have, but still nice-to-have.
- *
- * Both changes to the given implementation do not change the behaviour on
- * legit input but do allow a user to mess up in some cases.
- *
- * @param s a String representing a list of terms which is converted to a
- * scanner and passed to scanTerm for reading each individual term
- */
- public Polynomial( String s ) {
- terms = new ArrayList<>();
- Scanner scan = new Scanner(s);
-
- for (Term t = Term.scanTerm(scan); t != null; t = Term.scanTerm(scan))
- if (t.getCoef() != 0)
- plus(t);
- }
-
- /**
- * The copy constructor for making a deep copy
- *
- * @param p the copied polynomial
- */
- public Polynomial( Polynomial p ) {
- terms = new ArrayList<>(p.terms.size());
- for (Term t : p.terms) {
- terms.add(new Term(t));
- }
- }
-
- /**
- * A straightforward conversion of a Polynomial into a string based on the
- * toString for terms
- *
- * @return a readable string representation of this
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- boolean not_first = false;
- for (Term t : terms) {
- if (not_first && t.getCoef() >= 0)
- sb.append("+");
- sb.append(t);
- not_first = true;
- }
- return sb.toString();
- }
-
- /**
- * Add a polynomial to this polynomial
- * @param b the polynomial to add
- */
- public void plus(Polynomial b) {
- for (Term t : b.terms)
- plus(t);
- }
-
- /**
- * Add a term
- * @param t the term to add
- */
- private void plus(Term t) {
- if (t.getCoef() == 0)
- return;
-
- Iterator iter = terms.iterator();
- while (iter.hasNext()) {
- Term this_t = iter.next();
- if (this_t.getExp() == t.getExp()) {
- this_t.plus(t);
- if (this_t.getCoef() == 0)
- iter.remove();
- return;
- }
- }
- terms.add(new Term(t));
- }
-
- /**
- * Subtract a polynomial from this polynomial
- * @param p the polynomial to subtract
- */
- public void minus(Polynomial p) {
- Polynomial temp = new Polynomial(p);
- temp.times(new Polynomial("-1 0"));
- plus(temp);
- }
-
- /**
- * Multiply a polynomial with this polynomial
- * @param p the polynomial to multiply with
- */
- public void times(Polynomial p) {
- Polynomial result = new Polynomial();
- for (Term that_t : p.terms)
- for (Term this_t : terms)
- result.plus(new Term(that_t.getCoef() * this_t.getCoef(), that_t.getExp() + this_t.getExp()));
- terms = result.terms;
- }
-
- public void divide(Polynomial b) {
- }
-
- /**
- * Check equality
- * @param other_poly the object to check with
- * @return true iff other_poly represents the same polynomial as this instance
- */
- @Override
- public boolean equals(Object other_poly) {
- if (other_poly == null || other_poly.getClass() != getClass())
- return false;
-
- Polynomial that = new Polynomial((Polynomial) other_poly); // We need to copy because later we'll remove elements
- if (terms.size() != that.terms.size())
- return false;
- for (Term this_t : terms) {
- Iterator that_iter = that.terms.iterator();
- boolean found = false;
- while (that_iter.hasNext()) {
- if (this_t.equals(that_iter.next())) {
- found = true;
- that_iter.remove();
- break;
- }
- }
- if (!found) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Apply the polynomial to a concrete variable
- * @param x the variable
- * @return the result of the polynomial applied on x
- */
- public double apply(double x) {
- double result = 0;
- for (Term t : terms)
- result += t.apply(x);
- return result;
- }
-
-}
diff --git a/Week7/src/polynomial/Term.java b/Week7/src/polynomial/Term.java
deleted file mode 100644
index 60c6381..0000000
--- a/Week7/src/polynomial/Term.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package polynomial;
-
-import java.util.Scanner;
-
-/**
- * For representing terms in a polynomial.
- *
- * @author Sjaak Smetsers
- * @version 1.0
- * @date 15-02-2012
- *
- * @author Camil Staps, s4498062
- * @date 17-03-2015
- */
-public class Term {
-
- /**
- * Each term consists of a coefficient and an exponent
- */
- private double coefficient;
- private int exponent;
-
- /**
- * a get-method for the exponent
- *
- * @return exponent
- */
- public int getExp() {
- return exponent;
- }
-
- /**
- * a get-method for the coefficient
- *
- * @return coefficient
- */
- public double getCoef() {
- return coefficient;
- }
-
- /**
- * A two-argument constructor
- *
- * @param c the value for the coefficient
- * @param e the value for the exponent
- */
- public Term(double c, int e) {
- coefficient = c;
- exponent = e;
- }
-
- /**
- * A copy-constructor
- *
- * @param t the term to be copied
- */
- public Term(Term t) {
- this(t.coefficient, t.exponent);
- }
-
- /**
- * For adding two terms with equal exponents
- *
- * @param t the term added to this
- * @require exponent == t.exponent
- */
- public void plus(Term t) {
- coefficient += t.coefficient;
- }
-
- /**
- * For multiplying two terms
- *
- * @param t the multiplier
- */
- public void times(Term t) {
- exponent += t.exponent;
- coefficient *= t.coefficient;
- }
-
- /**
- * Converts a term into a readable representation the standard format is
- * %fx^%d
- * I changed the implementation to remove trailing zeroes from the coefficient.
- *
- * @return the string representing the term
- */
- @Override
- public String toString() {
- String nice_coefficient = Double.toString(coefficient);
- if (Math.round(coefficient) == coefficient)
- nice_coefficient = Integer.toString((int) coefficient);
- if (exponent == 0) {
- return String.format("%s", nice_coefficient, exponent);
- } else if (exponent == 1) {
- return String.format("%sx", nice_coefficient, exponent);
- } else {
- return String.format("%sx^%d", nice_coefficient, exponent);
- }
- }
-
- /**
- * Standard implementation of equality
- * @param may_be_term the object to check equality with
- * @return true iff may_be_term represents the same term as this term
- */
- @Override
- public boolean equals(Object may_be_term) {
- if (may_be_term == null || getClass() != may_be_term.getClass()) {
- return false;
- } else {
- Term term = (Term) may_be_term;
- return exponent == term.exponent
- && coefficient == term.coefficient;
- }
- }
-
- /**
- * Apply a term to a concrete variable
- * @param x the variable to apply the term to
- * @return the result of the application of the term to x
- */
- public double apply(double x) {
- return coefficient * Math.pow(x, exponent);
- }
-
- /**
- * A static method for converting scanner input into a term. The expected
- * format is two numbers (coef, exp) separated by whitespaces. The coef
- * should be either an integer or a decimal number. The exp is an integer.
- *
- * @param s the scanner providing the input
- * @return null if no term could be found, the found term otherwise
- */
- public static Term scanTerm(Scanner s) {
- String coef_patt = "\\-?\\d+(\\.\\d+)?";
- if (s.hasNext(coef_patt)) {
- String coef = s.next(coef_patt);
- int exp = s.nextInt();
- return new Term(Double.parseDouble(coef), exp);
- } else {
- return null;
- }
- }
-}
diff --git a/Week7/test/polynomial/PolynomialTest.java b/Week7/test/polynomial/PolynomialTest.java
deleted file mode 100644
index c00f165..0000000
--- a/Week7/test/polynomial/PolynomialTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-package polynomial;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- * A test class for the polynomial.Polynomial class
- * @author Camil Staps, s4498062
- */
-public class PolynomialTest {
-
- public PolynomialTest() {
- }
-
- @BeforeClass
- public static void setUpClass() {
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test of toString method, of class Polynomial.
- */
- @Test
- public void testToString() {
- System.out.println("toString");
- // Test exp=0, exp=1, exp>1, positive & negative integer & floating point coefficients all at once
- assertEquals("3x^5-4x+2.5-3.4x^-7", new Polynomial("3 5 -4 1 2.5 0 -3.4 -7").toString());
- // Test zero polynomial
- assertEquals("", new Polynomial().toString());
- }
-
- /**
- * Test of minus method, of class Polynomial.
- */
- @Test
- public void testMinus() {
- System.out.println("minus");
- // Test cancelling out and exponents that don't exist in either of the two polynomials all at once
- Polynomial instance = new Polynomial("7 4 -4 2 3 1 5 0"); // 7x^4 - 4x^2 + 3x + 5
- instance.minus(new Polynomial("5 3 4 2 3 1 10 0")); // 5x^3 + 4x^2 + 3x + 10
- assertEquals(new Polynomial("7 4 -5 3 -8 2 -5 0"), instance); // 7x^4 - 5x^3 - 8x^2 - 5
-
- // Test minus = plus (times -1) on many small 2-term polynomials
- for (float c1 = -10; c1 < 10; c1 += 2.3)
- for (int exp1 = 5; exp1 < 10; exp1++)
- for (float c2 = -10; c2 < 10; c2 += 2.3)
- for (int exp2 = 5; exp2 < 10; exp2++) {
- Polynomial fst = new Polynomial(c1 + " " + exp1 + " " + c2 + " " + exp2);
- Polynomial snd = new Polynomial(c1 + " " + exp2 + " " + c2 + " " + exp1);
- Polynomial fst_2 = new Polynomial(fst);
- Polynomial snd_2 = new Polynomial(snd);
- fst.minus(snd);
- snd_2.times(new Polynomial("-1 0"));
- fst_2.plus(snd_2);
- assertEquals(true, fst.equals(fst_2));
- }
-
- // Test associativity for some random polynomials
- Polynomial a = new Polynomial("5 4 2 5 20 8 4 0");
- Polynomial b = new Polynomial("9 2 48 2 10 8 28 2");
- Polynomial c = new Polynomial("3 8 4 20 8 2 4 5 0 0");
- Polynomial a_bc = new Polynomial(a);
- a_bc.minus(b);
- a_bc.minus(c);
- Polynomial a_cb = new Polynomial(a);
- a_cb.minus(c);
- a_cb.minus(b);
- assertEquals(true, a_bc.equals(a_cb));
- }
-
- /**
- * Test of times method, of class Polynomial.
- */
- @Test
- public void testTimes() {
- System.out.println("times");
-
- // Simple case
- Polynomial instance = new Polynomial("7 1 6 3");
- instance.times(new Polynomial("5 3 4 2"));
- assertEquals(new Polynomial("30 6 24 5 35 4 28 3"), instance);
-
- // Simple case with zero polynomial
- instance = new Polynomial("5 3");
- instance.times(new Polynomial());
- assertEquals(new Polynomial(), instance);
-
- // Advanced case with coefficient 0 in the result
- instance = new Polynomial("4 4 2 3"); // 4x^4 + 2x^3
- instance.times(new Polynomial("2 2 -4 3")); // 2x^2 - 4x^3
- assertEquals(new Polynomial("4 5 -16 7"), instance); // 4x^5 - 16x^7 (exponent 6 cancels out)
-
- // Test associativity for some random polynomials
- Polynomial a = new Polynomial("5 4 2 5 20 8 4 0");
- Polynomial b = new Polynomial("9 2 48 2 10 8 28 2");
- Polynomial c = new Polynomial("3 8 4 20 8 2 4 5 0 0");
- Polynomial a_bc = new Polynomial(a);
- a_bc.times(b);
- a_bc.times(c);
- Polynomial a_cb = new Polynomial(a);
- a_cb.times(c);
- a_cb.times(b);
- assertEquals(true, a_bc.equals(a_cb));
-
- // Test commutativity
- Polynomial a_b = new Polynomial(a);
- a_b.times(b);
- Polynomial b_a = new Polynomial(b);
- b_a.times(a);
- assertEquals(true, a_b.equals(b_a));
-
- // Test left distributivity
- Polynomial b_plus_c = new Polynomial(b);
- b_plus_c.plus(c);
- Polynomial a_times_b_plus_c = new Polynomial(a);
- a_times_b_plus_c.times(b_plus_c);
- Polynomial a_times_c = new Polynomial(a);
- a_times_c.times(c);
- Polynomial a_times_b_plus_a_times_c = new Polynomial(a);
- a_times_b_plus_a_times_c.times(b);
- a_times_b_plus_a_times_c.plus(a_times_c);
- assertEquals(true, a_times_b_plus_c.equals(a_times_b_plus_a_times_c));
-
- // Test right distributivity
- Polynomial b_plus_c_times_a = new Polynomial(b);
- b_plus_c_times_a.plus(c);
- b_plus_c_times_a.times(a);
- Polynomial c_times_a = new Polynomial(c);
- c_times_a.times(a);
- Polynomial b_times_a_plus_c_times_a = new Polynomial(b);
- b_times_a_plus_c_times_a.times(a);
- b_times_a_plus_c_times_a.plus(c_times_a);
- assertEquals(true, b_plus_c_times_a.equals(b_times_a_plus_c_times_a));
- }
-
- /**
- * Test of divide method, of class Polynomial.
- */
- @Test
- public void testDivide() {
- System.out.println("divide");
- Polynomial b = null;
- Polynomial instance = new Polynomial();
- instance.divide(b);
- // TODO review the generated test code and remove the default call to fail.
- fail("The test case is a prototype.");
- }
-
- /**
- * Test of equals method, of class Polynomial.
- */
- @Test
- public void testEquals() {
- System.out.println("equals");
- // Order of terms irrelevant
- assertEquals(true, new Polynomial("4 2 3 5").equals(new Polynomial("3 5 4 2")));
- // Terms with same exponent are added
- assertEquals(true, new Polynomial("5 5 10 5").equals(new Polynomial("15 5")));
- // Simple coefficient 0 removed
- assertEquals(true, new Polynomial("0 7").equals(new Polynomial()));
- // Advanced coefficient 0 removed
- assertEquals(true, new Polynomial("5 10 -5 10").equals(new Polynomial()));
- // Difference in exponent matters
- assertEquals(false, new Polynomial("10 0").equals(new Polynomial("10 1")));
- // Difference in coefficient matters
- assertEquals(false, new Polynomial("10 0").equals(new Polynomial("5 0")));
- }
-
- /**
- * Test of plus method, of class Polynomial.
- */
- @Test
- public void testPlus_Polynomial() {
- System.out.println("plus");
- // Test cancelling out and exponents that don't exist in either of the two polynomials all at once
- Polynomial instance = new Polynomial("7 4 -4 2 7 1 5 0"); // 7x^4 - 4x^2 + 7x + 5
- instance.plus(new Polynomial("5 3 4 2 3 1 10 0")); // 5x^3 + 4x^2 + 3x + 10
- assertEquals(new Polynomial("7 4 5 3 10 1 15 0"), instance); // 7x^4 + 5x^3 + 10x + 15
-
- // Test associativity for some random polynomials
- Polynomial a = new Polynomial("5 4 2 5 20 8 4 0");
- Polynomial b = new Polynomial("9 2 7 5 10 8 28 2");
- Polynomial c = new Polynomial("3 8 4 20 8 2 4 5 0 0");
- Polynomial a_bc = new Polynomial(a);
- a_bc.plus(b);
- a_bc.plus(c);
- Polynomial a_cb = new Polynomial(a);
- a_cb.plus(c);
- a_cb.plus(b);
- assertEquals(true, a_bc.equals(a_cb));
-
- // Test commutativity
- Polynomial a_b = new Polynomial(a);
- a_b.plus(b);
- Polynomial b_a = new Polynomial(b);
- b_a.plus(a);
- assertEquals(true, a_b.equals(b_a));
- }
-
- /**
- * Test of apply method, of class Polynomial.
- */
- @Test
- public void testApply() {
- System.out.println("apply");
- // Test zero coefficient, floating point coefficient and negative coefficient all at once
- Polynomial instance = new Polynomial("0 7 5 4 0.5 3 9 2 -8 0");
- assertEquals(422654.5, instance.apply(17.0), 0.0);
- }
-
-}
diff --git a/Week8 Quadtrees/.gitignore b/Week8 Quadtrees/.gitignore
new file mode 100644
index 0000000..4523fc2
--- /dev/null
+++ b/Week8 Quadtrees/.gitignore
@@ -0,0 +1,3 @@
+nbproject/private/
+build/
+dist/
diff --git a/Week8 Quadtrees/Assignment (in Dutch).pdf b/Week8 Quadtrees/Assignment (in Dutch).pdf
new file mode 100644
index 0000000..48752d1
Binary files /dev/null and b/Week8 Quadtrees/Assignment (in Dutch).pdf differ
diff --git a/Week8 Quadtrees/Week8.tar.gz b/Week8 Quadtrees/Week8.tar.gz
new file mode 100644
index 0000000..7ca3d94
Binary files /dev/null and b/Week8 Quadtrees/Week8.tar.gz differ
diff --git a/Week8 Quadtrees/build.xml b/Week8 Quadtrees/build.xml
new file mode 100644
index 0000000..096f28f
--- /dev/null
+++ b/Week8 Quadtrees/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Week8 Quadtrees.
+
+
+
diff --git a/Week8 Quadtrees/build/classes/.netbeans_automatic_build b/Week8 Quadtrees/build/classes/.netbeans_automatic_build
new file mode 100644
index 0000000..e69de29
diff --git a/Week8 Quadtrees/build/classes/.netbeans_update_resources b/Week8 Quadtrees/build/classes/.netbeans_update_resources
new file mode 100644
index 0000000..e69de29
diff --git a/Week8 Quadtrees/build/classes/qtrees/Bitmap.class b/Week8 Quadtrees/build/classes/qtrees/Bitmap.class
new file mode 100644
index 0000000..d552ee0
Binary files /dev/null and b/Week8 Quadtrees/build/classes/qtrees/Bitmap.class differ
diff --git a/Week8 Quadtrees/build/classes/qtrees/BlackLeaf.class b/Week8 Quadtrees/build/classes/qtrees/BlackLeaf.class
new file mode 100644
index 0000000..996431c
Binary files /dev/null and b/Week8 Quadtrees/build/classes/qtrees/BlackLeaf.class differ
diff --git a/Week8 Quadtrees/build/classes/qtrees/GreyNode.class b/Week8 Quadtrees/build/classes/qtrees/GreyNode.class
new file mode 100644
index 0000000..fe9a698
Binary files /dev/null and b/Week8 Quadtrees/build/classes/qtrees/GreyNode.class differ
diff --git a/Week8 Quadtrees/build/classes/qtrees/QTNode.class b/Week8 Quadtrees/build/classes/qtrees/QTNode.class
new file mode 100644
index 0000000..13506c9
Binary files /dev/null and b/Week8 Quadtrees/build/classes/qtrees/QTNode.class differ
diff --git a/Week8 Quadtrees/build/classes/qtrees/QTree.class b/Week8 Quadtrees/build/classes/qtrees/QTree.class
new file mode 100644
index 0000000..ff1efb7
Binary files /dev/null and b/Week8 Quadtrees/build/classes/qtrees/QTree.class differ
diff --git a/Week8 Quadtrees/build/classes/qtrees/Qtrees.class b/Week8 Quadtrees/build/classes/qtrees/Qtrees.class
new file mode 100644
index 0000000..744fac8
Binary files /dev/null and b/Week8 Quadtrees/build/classes/qtrees/Qtrees.class differ
diff --git a/Week8 Quadtrees/build/classes/qtrees/WhiteLeaf.class b/Week8 Quadtrees/build/classes/qtrees/WhiteLeaf.class
new file mode 100644
index 0000000..7ee4cd3
Binary files /dev/null and b/Week8 Quadtrees/build/classes/qtrees/WhiteLeaf.class differ
diff --git a/Week8 Quadtrees/nbproject/build-impl.xml b/Week8 Quadtrees/nbproject/build-impl.xml
new file mode 100644
index 0000000..c242c6b
--- /dev/null
+++ b/Week8 Quadtrees/nbproject/build-impl.xml
@@ -0,0 +1,1413 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week8 Quadtrees/nbproject/genfiles.properties b/Week8 Quadtrees/nbproject/genfiles.properties
new file mode 100644
index 0000000..c132556
--- /dev/null
+++ b/Week8 Quadtrees/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=d07c7d97
+build.xml.script.CRC32=544d099d
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=d07c7d97
+nbproject/build-impl.xml.script.CRC32=1870b0c1
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week8 Quadtrees/nbproject/private/private.properties b/Week8 Quadtrees/nbproject/private/private.properties
new file mode 100644
index 0000000..fca3b8a
--- /dev/null
+++ b/Week8 Quadtrees/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=/home/camilstaps/.netbeans/8.0.2/build.properties
diff --git a/Week8 Quadtrees/nbproject/private/private.xml b/Week8 Quadtrees/nbproject/private/private.xml
new file mode 100644
index 0000000..6807a2b
--- /dev/null
+++ b/Week8 Quadtrees/nbproject/private/private.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Week8 Quadtrees/nbproject/project.properties b/Week8 Quadtrees/nbproject/project.properties
new file mode 100644
index 0000000..371311f
--- /dev/null
+++ b/Week8 Quadtrees/nbproject/project.properties
@@ -0,0 +1,72 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Week8_Quadtrees.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.7
+javac.target=1.7
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=qtrees.Qtrees
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=true
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/Week8 Quadtrees/nbproject/project.xml b/Week8 Quadtrees/nbproject/project.xml
new file mode 100644
index 0000000..f2206da
--- /dev/null
+++ b/Week8 Quadtrees/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Week8 Quadtrees
+
+
+
+
+
+
+
+
+
diff --git a/Week8 Quadtrees/src/qtrees/Bitmap.java b/Week8 Quadtrees/src/qtrees/Bitmap.java
new file mode 100644
index 0000000..551c4c4
--- /dev/null
+++ b/Week8 Quadtrees/src/qtrees/Bitmap.java
@@ -0,0 +1,73 @@
+package qtrees;
+
+/**
+ * Bitmap: A class for representing bitmap;
+ * @author Sjaak Smetsers
+ * @version 18-03-2015
+ */
+public class Bitmap {
+ // each bit is stored into an two dimensional array
+ private final boolean[][] raster;
+ private final int bmWidth, bmHeight;
+
+ /**
+ * Creates an empty bitmap of size width * height
+ * @param width
+ * @param height
+ */
+ public Bitmap( int width, int height ) {
+ raster = new boolean[width][height];
+ bmWidth = width;
+ bmHeight = height;
+ }
+
+ /**
+ * Gets a bit at the specified position
+ * @param x: x coordinate
+ * @param y: y coordinate
+ */
+ public boolean getBit( int x, int y ) {
+ return raster[x][y];
+ }
+
+ /**
+ * Sets a bit at the specified position
+ * @param x: x coordinate
+ * @param y: y coordinate
+ * @param val: the bit value
+ */
+ public void setBit( int x, int y, boolean val ){
+ raster[x][y] = val;
+ }
+
+ /**
+ * Converts a bitmap into a string
+ * 1 is represented by '*'; 0 by 'O'
+ * @return the string representation
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for (int y = 0; y < bmHeight; y++) {
+ for (int x = 0; x < bmWidth; x++) {
+ sb.append( raster[x][y] ? '*' : 'O' );
+ }
+ sb.append( '\n' );
+ }
+ return sb.toString();
+ }
+
+ /**
+ * @return the width of the bitmap
+ */
+ public int getWidth() {
+ return bmWidth;
+ }
+
+ /**
+ * @return the height of the bitmap
+ */
+ public int getHeight() {
+ return bmHeight;
+ }
+}
diff --git a/Week8 Quadtrees/src/qtrees/BlackLeaf.java b/Week8 Quadtrees/src/qtrees/BlackLeaf.java
new file mode 100644
index 0000000..0f7e71e
--- /dev/null
+++ b/Week8 Quadtrees/src/qtrees/BlackLeaf.java
@@ -0,0 +1,13 @@
+package qtrees;
+
+/**
+ * @author Camil Staps, s4498062
+ */
+public class BlackLeaf extends QTNode {
+
+ public BlackLeaf () {
+ boolean_value = false;
+ string_value = "0";
+ }
+
+}
diff --git a/Week8 Quadtrees/src/qtrees/GreyNode.java b/Week8 Quadtrees/src/qtrees/GreyNode.java
new file mode 100644
index 0000000..326b0af
--- /dev/null
+++ b/Week8 Quadtrees/src/qtrees/GreyNode.java
@@ -0,0 +1,59 @@
+package qtrees;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A "grey" node (contains both black and white leaves)
+ *
+ * @author Camil Staps, s4498062
+ */
+public class GreyNode extends QTNode {
+
+ /** The four children, starting at North West, counting clockwise */
+ private final QTNode children[];
+
+ public GreyNode() {
+ children = new QTNode[4];
+ }
+
+ @Override
+ public void fillBitmap(int x, int y, int width, Bitmap bitmap) {
+ children[0].fillBitmap(x, y, width / 2, bitmap);
+ children[1].fillBitmap(x + width / 2, y, width / 2, bitmap);
+ children[2].fillBitmap(x + width / 2, y + width / 2, width / 2, bitmap);
+ children[3].fillBitmap(x, y + width / 2, width / 2, bitmap);
+ }
+
+ @Override
+ public void writeNode(Writer out) throws IOException {
+ out.write("1");
+ for (QTNode child : children)
+ child.writeNode(out);
+ }
+
+ /**
+ * Set one of the children nodes
+ * @param index the position of the child: 0 = NW; 1 = NE; 2 = SE; 3 = SW
+ * @param child the child node
+ */
+ public void setChild(int index, QTNode child) {
+ assert (index >= 0 && index <= 3);
+
+ children[index] = child;
+ }
+
+ /**
+ * Compress the current node
+ * @return a BlackLeaf if all the children are black, a WhiteLeaf if all the
+ * children are white, or itself otherwise.
+ */
+ QTNode compress() {
+ if (children[0].getClass() == children[1].getClass()
+ && children[1].getClass() == children[2].getClass()
+ && children[2].getClass() == children[3].getClass())
+ return children[0];
+ return this;
+ }
+
+}
diff --git a/Week8 Quadtrees/src/qtrees/QTNode.java b/Week8 Quadtrees/src/qtrees/QTNode.java
new file mode 100644
index 0000000..e2ad7e5
--- /dev/null
+++ b/Week8 Quadtrees/src/qtrees/QTNode.java
@@ -0,0 +1,63 @@
+package qtrees;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * Representation of a node in a QTree
+ * @author Sjaak Smetsers
+ * @author Camil Staps, s4498062
+ *
+ * Note: the version by Sjaak Smetsers contained a sameLeaf method. This seems to be redundant though, so I removed it.
+ */
+public abstract class QTNode {
+ protected boolean boolean_value;
+ protected String string_value;
+
+ /**
+ * Fill a (part of a) bitmap with this node
+ * In the template this was an abstract method. However, then we would use
+ * essentially the same code in BlackLeaf and WhiteLeaf. Using a concrete
+ * function here that depends on static properties is much more flexible. In
+ * GreyNode we still override this function.
+ * @param x the x coordinate of the top left corner
+ * @param y the y coordinate of the top left corner
+ * @param width the width of the part of the bitmap to fill
+ * @param bitmap the bitmap to fill
+ */
+ public void fillBitmap( int x, int y, int width, Bitmap bitmap ) {
+ int old_x = x, old_y = y;
+ for (; x < old_x + width; x++)
+ for (y = old_y; y < old_y + width; y++)
+ bitmap.setBit(x, y, boolean_value);
+ }
+
+ /**
+ * Write a node as bitstream
+ * In the template this was an abstract method. However, then we would use
+ * essentially the same code in BlackLeaf and WhiteLeaf. Using a concrete
+ * function here that depends on static properties is much more flexible. In
+ * GreyNode we still override this function.
+ * @param out Writer to write to
+ * @throws IOException is passed on from Writer
+ */
+ public void writeNode( Writer out ) throws IOException {
+ out.write("0" + string_value);
+ }
+
+ /**
+ * Fill a complete area of a bitmap with a particular value
+ * @param x the x coordinate of the top left corner
+ * @param y the y coordinate of the top left corner
+ * @param width the width (and height) of the area to fill
+ * @param bitmap the bitmap to fill
+ * @param val the value to fill the area with
+ */
+ public static void fillArea( int x, int y, int width, Bitmap bitmap, boolean val ){
+ for (int i = 0; i < width; i++) {
+ for (int j = 0; j < width; j++) {
+ bitmap.setBit(x+i, y+j, val);
+ }
+ }
+ }
+}
diff --git a/Week8 Quadtrees/src/qtrees/QTree.java b/Week8 Quadtrees/src/qtrees/QTree.java
new file mode 100644
index 0000000..24fa5e0
--- /dev/null
+++ b/Week8 Quadtrees/src/qtrees/QTree.java
@@ -0,0 +1,102 @@
+package qtrees;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Representation of a Quad-tree
+ * @author Camil Staps, s4498062
+ */
+public class QTree {
+ /** the root of the tree */
+ QTNode root;
+
+ /**
+ * Construct the tree based on an ASCII representation of a bitstream on a reader
+ * @param input the reader
+ */
+ public QTree( Reader input ) {
+ root = readQTree( input );
+ }
+
+ /**
+ * Construct the tree based on a bitmap
+ * @param bitmap the bitmap
+ */
+ public QTree( Bitmap bitmap ) {
+ root = bitmap2QTree( 0, 0, bitmap.getWidth(), bitmap );
+ }
+
+ /**
+ * Fill a bitmap based on this tree
+ * @param bitmap the bitmap
+ */
+ public void fillBitmap ( Bitmap bitmap ) {
+ root.fillBitmap(0, 0, bitmap.getWidth(), bitmap);
+ }
+
+ /**
+ * Write the quad-tree as compressed bitstream
+ * @param sb the Writer to write to
+ * @throws IOException is passed on from Writer
+ */
+ public void writeQTree( Writer sb ) throws IOException {
+ root.writeNode( sb );
+ }
+
+ /**
+ * Read a Quad-tree node based on an ASCII representation of a bitstream on a Reader
+ * @param input the Reader
+ * @return the node
+ */
+ private static QTNode readQTree( Reader input ) {
+ try {
+ int read = input.read();
+ if (read == '1') {
+ GreyNode node = new GreyNode();
+ for (int i = 0; i < 4; i++)
+ node.setChild(i, readQTree(input));
+ return node;
+ } else {
+ read = input.read();
+ if (read == '1') {
+ return new WhiteLeaf();
+ } else {
+ return new BlackLeaf();
+ }
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(QTree.class.getName()).log(Level.SEVERE, null, ex);
+ return null;
+ }
+ }
+
+ /**
+ * Get a (compressed) node from a (part of a) bitmap
+ * @param x the x coordinate of the top left corner
+ * @param y the y coordinate of the top left corner
+ * @param width the width of the part to read
+ * @param bitmap the bitmap
+ * @return the (compressed) node
+ */
+ public static QTNode bitmap2QTree( int x, int y, int width, Bitmap bitmap ) {
+ if (width == 1) {
+ if (bitmap.getBit(x,y)) {
+ return new WhiteLeaf();
+ } else {
+ return new BlackLeaf();
+ }
+ } else {
+ GreyNode node = new GreyNode();
+ node.setChild(0, bitmap2QTree(x, y, width / 2, bitmap));
+ node.setChild(1, bitmap2QTree(x + width / 2, y, width / 2, bitmap));
+ node.setChild(2, bitmap2QTree(x + width / 2, y + width / 2, width / 2, bitmap));
+ node.setChild(3, bitmap2QTree(x, y + width / 2, width / 2, bitmap));
+ return node.compress();
+ }
+ }
+
+}
diff --git a/Week8 Quadtrees/src/qtrees/Qtrees.java b/Week8 Quadtrees/src/qtrees/Qtrees.java
new file mode 100644
index 0000000..91783f7
--- /dev/null
+++ b/Week8 Quadtrees/src/qtrees/Qtrees.java
@@ -0,0 +1,54 @@
+package qtrees;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.io.Writer;
+
+/**
+ * Demonstration class for Quad-trees
+ * @author Sjaak
+ * @author Camil Staps, s4498062
+ */
+public class Qtrees {
+
+ /**
+ * Example features of the QTree:
+ * Constucts and outputs the same tree in all possible ways. The output should
+ * therefore repeat itself.
+ *
+ * @param args the command line arguments
+ * @throws java.io.IOException shouldn't happen with System.out anyway
+ */
+ public static void main(String[] args) throws IOException {
+ // Example: reading in a bitstream
+ String test_tekst = "10011010001010010001010101100011000101000000";
+ StringReader input = new StringReader(test_tekst);
+ QTree qt = new QTree( input );
+
+ // Example: filling a bitmap
+ Bitmap bitmap = new Bitmap(8, 8);
+ qt.fillBitmap( bitmap );
+ System.out.println(bitmap);
+
+ // Example: writing a bitstream
+ Writer out = new OutputStreamWriter(System.out);
+ qt.writeQTree(out);
+ out.write("\n");
+ out.flush( );
+
+ // Example: reading a bitmap
+ QTree qt2 = new QTree(bitmap);
+
+ // Example: filling a bitmap
+ Bitmap bm2 = new Bitmap(8,8);
+ qt2.fillBitmap(bm2);
+ System.out.println(bm2);
+
+ // Example: writing a bitstream
+ qt2.writeQTree(out);
+ out.write("\n");
+ out.flush( );
+ }
+
+}
diff --git a/Week8 Quadtrees/src/qtrees/WhiteLeaf.java b/Week8 Quadtrees/src/qtrees/WhiteLeaf.java
new file mode 100644
index 0000000..57cb591
--- /dev/null
+++ b/Week8 Quadtrees/src/qtrees/WhiteLeaf.java
@@ -0,0 +1,13 @@
+package qtrees;
+
+/**
+ * @author Camil Staps, s4498062
+ */
+public class WhiteLeaf extends QTNode {
+
+ public WhiteLeaf() {
+ boolean_value = true;
+ string_value = "1";
+ }
+
+}
diff --git a/Week8/Assignment (in Dutch).pdf b/Week8/Assignment (in Dutch).pdf
deleted file mode 100644
index 48752d1..0000000
Binary files a/Week8/Assignment (in Dutch).pdf and /dev/null differ
diff --git a/Week8/Week8.tar.gz b/Week8/Week8.tar.gz
deleted file mode 100644
index 7ca3d94..0000000
Binary files a/Week8/Week8.tar.gz and /dev/null differ
diff --git a/Week8/build.xml b/Week8/build.xml
deleted file mode 100644
index 201f305..0000000
--- a/Week8/build.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Week8.
-
-
-
diff --git a/Week8/nbproject/build-impl.xml b/Week8/nbproject/build-impl.xml
deleted file mode 100644
index 4f2d68b..0000000
--- a/Week8/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1413 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Week8/nbproject/genfiles.properties b/Week8/nbproject/genfiles.properties
deleted file mode 100644
index 6c1d314..0000000
--- a/Week8/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=cc255a7c
-build.xml.script.CRC32=28c657a8
-build.xml.stylesheet.CRC32=8064a381@1.75.2.48
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=cc255a7c
-nbproject/build-impl.xml.script.CRC32=2d3c14a2
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week8/nbproject/project.properties b/Week8/nbproject/project.properties
deleted file mode 100644
index 778b03f..0000000
--- a/Week8/nbproject/project.properties
+++ /dev/null
@@ -1,72 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processor.options=
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# Files in build.classes.dir which should be excluded from distribution jar
-dist.archive.excludes=
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Week8.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.7
-javac.target=1.7
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=qtrees.Qtrees
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=true
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project.
-# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
-# To set system properties for unit tests define test-sys-prop.name=value:
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/Week8/nbproject/project.xml b/Week8/nbproject/project.xml
deleted file mode 100644
index 75d13e1..0000000
--- a/Week8/nbproject/project.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Week8
-
-
-
-
-
-
-
-
-
diff --git a/Week8/src/qtrees/Bitmap.java b/Week8/src/qtrees/Bitmap.java
deleted file mode 100644
index 551c4c4..0000000
--- a/Week8/src/qtrees/Bitmap.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package qtrees;
-
-/**
- * Bitmap: A class for representing bitmap;
- * @author Sjaak Smetsers
- * @version 18-03-2015
- */
-public class Bitmap {
- // each bit is stored into an two dimensional array
- private final boolean[][] raster;
- private final int bmWidth, bmHeight;
-
- /**
- * Creates an empty bitmap of size width * height
- * @param width
- * @param height
- */
- public Bitmap( int width, int height ) {
- raster = new boolean[width][height];
- bmWidth = width;
- bmHeight = height;
- }
-
- /**
- * Gets a bit at the specified position
- * @param x: x coordinate
- * @param y: y coordinate
- */
- public boolean getBit( int x, int y ) {
- return raster[x][y];
- }
-
- /**
- * Sets a bit at the specified position
- * @param x: x coordinate
- * @param y: y coordinate
- * @param val: the bit value
- */
- public void setBit( int x, int y, boolean val ){
- raster[x][y] = val;
- }
-
- /**
- * Converts a bitmap into a string
- * 1 is represented by '*'; 0 by 'O'
- * @return the string representation
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- for (int y = 0; y < bmHeight; y++) {
- for (int x = 0; x < bmWidth; x++) {
- sb.append( raster[x][y] ? '*' : 'O' );
- }
- sb.append( '\n' );
- }
- return sb.toString();
- }
-
- /**
- * @return the width of the bitmap
- */
- public int getWidth() {
- return bmWidth;
- }
-
- /**
- * @return the height of the bitmap
- */
- public int getHeight() {
- return bmHeight;
- }
-}
diff --git a/Week8/src/qtrees/BlackLeaf.java b/Week8/src/qtrees/BlackLeaf.java
deleted file mode 100644
index 0f7e71e..0000000
--- a/Week8/src/qtrees/BlackLeaf.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package qtrees;
-
-/**
- * @author Camil Staps, s4498062
- */
-public class BlackLeaf extends QTNode {
-
- public BlackLeaf () {
- boolean_value = false;
- string_value = "0";
- }
-
-}
diff --git a/Week8/src/qtrees/GreyNode.java b/Week8/src/qtrees/GreyNode.java
deleted file mode 100644
index 326b0af..0000000
--- a/Week8/src/qtrees/GreyNode.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package qtrees;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * A "grey" node (contains both black and white leaves)
- *
- * @author Camil Staps, s4498062
- */
-public class GreyNode extends QTNode {
-
- /** The four children, starting at North West, counting clockwise */
- private final QTNode children[];
-
- public GreyNode() {
- children = new QTNode[4];
- }
-
- @Override
- public void fillBitmap(int x, int y, int width, Bitmap bitmap) {
- children[0].fillBitmap(x, y, width / 2, bitmap);
- children[1].fillBitmap(x + width / 2, y, width / 2, bitmap);
- children[2].fillBitmap(x + width / 2, y + width / 2, width / 2, bitmap);
- children[3].fillBitmap(x, y + width / 2, width / 2, bitmap);
- }
-
- @Override
- public void writeNode(Writer out) throws IOException {
- out.write("1");
- for (QTNode child : children)
- child.writeNode(out);
- }
-
- /**
- * Set one of the children nodes
- * @param index the position of the child: 0 = NW; 1 = NE; 2 = SE; 3 = SW
- * @param child the child node
- */
- public void setChild(int index, QTNode child) {
- assert (index >= 0 && index <= 3);
-
- children[index] = child;
- }
-
- /**
- * Compress the current node
- * @return a BlackLeaf if all the children are black, a WhiteLeaf if all the
- * children are white, or itself otherwise.
- */
- QTNode compress() {
- if (children[0].getClass() == children[1].getClass()
- && children[1].getClass() == children[2].getClass()
- && children[2].getClass() == children[3].getClass())
- return children[0];
- return this;
- }
-
-}
diff --git a/Week8/src/qtrees/QTNode.java b/Week8/src/qtrees/QTNode.java
deleted file mode 100644
index e2ad7e5..0000000
--- a/Week8/src/qtrees/QTNode.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package qtrees;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * Representation of a node in a QTree
- * @author Sjaak Smetsers
- * @author Camil Staps, s4498062
- *
- * Note: the version by Sjaak Smetsers contained a sameLeaf method. This seems to be redundant though, so I removed it.
- */
-public abstract class QTNode {
- protected boolean boolean_value;
- protected String string_value;
-
- /**
- * Fill a (part of a) bitmap with this node
- * In the template this was an abstract method. However, then we would use
- * essentially the same code in BlackLeaf and WhiteLeaf. Using a concrete
- * function here that depends on static properties is much more flexible. In
- * GreyNode we still override this function.
- * @param x the x coordinate of the top left corner
- * @param y the y coordinate of the top left corner
- * @param width the width of the part of the bitmap to fill
- * @param bitmap the bitmap to fill
- */
- public void fillBitmap( int x, int y, int width, Bitmap bitmap ) {
- int old_x = x, old_y = y;
- for (; x < old_x + width; x++)
- for (y = old_y; y < old_y + width; y++)
- bitmap.setBit(x, y, boolean_value);
- }
-
- /**
- * Write a node as bitstream
- * In the template this was an abstract method. However, then we would use
- * essentially the same code in BlackLeaf and WhiteLeaf. Using a concrete
- * function here that depends on static properties is much more flexible. In
- * GreyNode we still override this function.
- * @param out Writer to write to
- * @throws IOException is passed on from Writer
- */
- public void writeNode( Writer out ) throws IOException {
- out.write("0" + string_value);
- }
-
- /**
- * Fill a complete area of a bitmap with a particular value
- * @param x the x coordinate of the top left corner
- * @param y the y coordinate of the top left corner
- * @param width the width (and height) of the area to fill
- * @param bitmap the bitmap to fill
- * @param val the value to fill the area with
- */
- public static void fillArea( int x, int y, int width, Bitmap bitmap, boolean val ){
- for (int i = 0; i < width; i++) {
- for (int j = 0; j < width; j++) {
- bitmap.setBit(x+i, y+j, val);
- }
- }
- }
-}
diff --git a/Week8/src/qtrees/QTree.java b/Week8/src/qtrees/QTree.java
deleted file mode 100644
index 24fa5e0..0000000
--- a/Week8/src/qtrees/QTree.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package qtrees;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Representation of a Quad-tree
- * @author Camil Staps, s4498062
- */
-public class QTree {
- /** the root of the tree */
- QTNode root;
-
- /**
- * Construct the tree based on an ASCII representation of a bitstream on a reader
- * @param input the reader
- */
- public QTree( Reader input ) {
- root = readQTree( input );
- }
-
- /**
- * Construct the tree based on a bitmap
- * @param bitmap the bitmap
- */
- public QTree( Bitmap bitmap ) {
- root = bitmap2QTree( 0, 0, bitmap.getWidth(), bitmap );
- }
-
- /**
- * Fill a bitmap based on this tree
- * @param bitmap the bitmap
- */
- public void fillBitmap ( Bitmap bitmap ) {
- root.fillBitmap(0, 0, bitmap.getWidth(), bitmap);
- }
-
- /**
- * Write the quad-tree as compressed bitstream
- * @param sb the Writer to write to
- * @throws IOException is passed on from Writer
- */
- public void writeQTree( Writer sb ) throws IOException {
- root.writeNode( sb );
- }
-
- /**
- * Read a Quad-tree node based on an ASCII representation of a bitstream on a Reader
- * @param input the Reader
- * @return the node
- */
- private static QTNode readQTree( Reader input ) {
- try {
- int read = input.read();
- if (read == '1') {
- GreyNode node = new GreyNode();
- for (int i = 0; i < 4; i++)
- node.setChild(i, readQTree(input));
- return node;
- } else {
- read = input.read();
- if (read == '1') {
- return new WhiteLeaf();
- } else {
- return new BlackLeaf();
- }
- }
- } catch (IOException ex) {
- Logger.getLogger(QTree.class.getName()).log(Level.SEVERE, null, ex);
- return null;
- }
- }
-
- /**
- * Get a (compressed) node from a (part of a) bitmap
- * @param x the x coordinate of the top left corner
- * @param y the y coordinate of the top left corner
- * @param width the width of the part to read
- * @param bitmap the bitmap
- * @return the (compressed) node
- */
- public static QTNode bitmap2QTree( int x, int y, int width, Bitmap bitmap ) {
- if (width == 1) {
- if (bitmap.getBit(x,y)) {
- return new WhiteLeaf();
- } else {
- return new BlackLeaf();
- }
- } else {
- GreyNode node = new GreyNode();
- node.setChild(0, bitmap2QTree(x, y, width / 2, bitmap));
- node.setChild(1, bitmap2QTree(x + width / 2, y, width / 2, bitmap));
- node.setChild(2, bitmap2QTree(x + width / 2, y + width / 2, width / 2, bitmap));
- node.setChild(3, bitmap2QTree(x, y + width / 2, width / 2, bitmap));
- return node.compress();
- }
- }
-
-}
diff --git a/Week8/src/qtrees/Qtrees.java b/Week8/src/qtrees/Qtrees.java
deleted file mode 100644
index 91783f7..0000000
--- a/Week8/src/qtrees/Qtrees.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package qtrees;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.StringReader;
-import java.io.Writer;
-
-/**
- * Demonstration class for Quad-trees
- * @author Sjaak
- * @author Camil Staps, s4498062
- */
-public class Qtrees {
-
- /**
- * Example features of the QTree:
- * Constucts and outputs the same tree in all possible ways. The output should
- * therefore repeat itself.
- *
- * @param args the command line arguments
- * @throws java.io.IOException shouldn't happen with System.out anyway
- */
- public static void main(String[] args) throws IOException {
- // Example: reading in a bitstream
- String test_tekst = "10011010001010010001010101100011000101000000";
- StringReader input = new StringReader(test_tekst);
- QTree qt = new QTree( input );
-
- // Example: filling a bitmap
- Bitmap bitmap = new Bitmap(8, 8);
- qt.fillBitmap( bitmap );
- System.out.println(bitmap);
-
- // Example: writing a bitstream
- Writer out = new OutputStreamWriter(System.out);
- qt.writeQTree(out);
- out.write("\n");
- out.flush( );
-
- // Example: reading a bitmap
- QTree qt2 = new QTree(bitmap);
-
- // Example: filling a bitmap
- Bitmap bm2 = new Bitmap(8,8);
- qt2.fillBitmap(bm2);
- System.out.println(bm2);
-
- // Example: writing a bitstream
- qt2.writeQTree(out);
- out.write("\n");
- out.flush( );
- }
-
-}
diff --git a/Week8/src/qtrees/WhiteLeaf.java b/Week8/src/qtrees/WhiteLeaf.java
deleted file mode 100644
index 57cb591..0000000
--- a/Week8/src/qtrees/WhiteLeaf.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package qtrees;
-
-/**
- * @author Camil Staps, s4498062
- */
-public class WhiteLeaf extends QTNode {
-
- public WhiteLeaf() {
- boolean_value = true;
- string_value = "1";
- }
-
-}
diff --git a/Week9 Webshop/.gitignore b/Week9 Webshop/.gitignore
new file mode 100644
index 0000000..52083c3
--- /dev/null
+++ b/Week9 Webshop/.gitignore
@@ -0,0 +1,9 @@
+solution.aux
+solution.idx
+solution.log
+solution.out
+solution.pdf
+db
+
+*.vpp.working
+*.vpp~*
diff --git a/Week9 Webshop/Assignment (in Dutch).pdf b/Week9 Webshop/Assignment (in Dutch).pdf
new file mode 100644
index 0000000..087342f
Binary files /dev/null and b/Week9 Webshop/Assignment (in Dutch).pdf differ
diff --git a/Week9 Webshop/Assignment appendix (in Dutch).pdf b/Week9 Webshop/Assignment appendix (in Dutch).pdf
new file mode 100644
index 0000000..9d24ec8
Binary files /dev/null and b/Week9 Webshop/Assignment appendix (in Dutch).pdf differ
diff --git a/Week9 Webshop/build.xml b/Week9 Webshop/build.xml
new file mode 100644
index 0000000..cee5c20
--- /dev/null
+++ b/Week9 Webshop/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project Week9 Webshop.
+
+
+
diff --git a/Week9 Webshop/build/classes/.netbeans_automatic_build b/Week9 Webshop/build/classes/.netbeans_automatic_build
new file mode 100644
index 0000000..e69de29
diff --git a/Week9 Webshop/build/classes/.netbeans_update_resources b/Week9 Webshop/build/classes/.netbeans_update_resources
new file mode 100644
index 0000000..e69de29
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Article.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Article.class
new file mode 100644
index 0000000..675f853
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Article.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/CLIInteraction.class b/Week9 Webshop/build/classes/com/camilstaps/shop/CLIInteraction.class
new file mode 100644
index 0000000..190a346
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/CLIInteraction.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Cart.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Cart.class
new file mode 100644
index 0000000..579ff82
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Cart.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Category.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Category.class
new file mode 100644
index 0000000..3d56b8a
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Category.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Command.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Command.class
new file mode 100644
index 0000000..7c8cbd2
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Command.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Database.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Database.class
new file mode 100644
index 0000000..93c0842
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Database.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/DatabaseItem.class b/Week9 Webshop/build/classes/com/camilstaps/shop/DatabaseItem.class
new file mode 100644
index 0000000..3c558ea
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/DatabaseItem.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/DuplicateEntryException.class b/Week9 Webshop/build/classes/com/camilstaps/shop/DuplicateEntryException.class
new file mode 100644
index 0000000..8576f34
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/DuplicateEntryException.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/InputRequiredException.class b/Week9 Webshop/build/classes/com/camilstaps/shop/InputRequiredException.class
new file mode 100644
index 0000000..0c3fa57
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/InputRequiredException.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/ItemNotFoundException.class b/Week9 Webshop/build/classes/com/camilstaps/shop/ItemNotFoundException.class
new file mode 100644
index 0000000..709beb7
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/ItemNotFoundException.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Order.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Order.class
new file mode 100644
index 0000000..439633f
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Order.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$1.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$1.class
new file mode 100644
index 0000000..40be108
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$1.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$2.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$2.class
new file mode 100644
index 0000000..79a6e4b
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$2.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$AdminRequiredException.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$AdminRequiredException.class
new file mode 100644
index 0000000..621fccb
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$AdminRequiredException.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$LoginRequiredException.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$LoginRequiredException.class
new file mode 100644
index 0000000..aed9755
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell$LoginRequiredException.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Shell.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell.class
new file mode 100644
index 0000000..3713907
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Shell.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/Shop.class b/Week9 Webshop/build/classes/com/camilstaps/shop/Shop.class
new file mode 100644
index 0000000..eaa980e
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/Shop.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/User.class b/Week9 Webshop/build/classes/com/camilstaps/shop/User.class
new file mode 100644
index 0000000..7267903
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/User.class differ
diff --git a/Week9 Webshop/build/classes/com/camilstaps/shop/UserInteraction.class b/Week9 Webshop/build/classes/com/camilstaps/shop/UserInteraction.class
new file mode 100644
index 0000000..055214a
Binary files /dev/null and b/Week9 Webshop/build/classes/com/camilstaps/shop/UserInteraction.class differ
diff --git a/Week9 Webshop/docs/Makefile b/Week9 Webshop/docs/Makefile
new file mode 100644
index 0000000..bd1f10f
--- /dev/null
+++ b/Week9 Webshop/docs/Makefile
@@ -0,0 +1,7 @@
+all: tex view
+
+tex:
+ pdflatex solution.tex
+
+view:
+ gnome-open solution.pdf
\ No newline at end of file
diff --git a/Week9 Webshop/docs/png/Activity_diagram_adding_article_to_cart.png b/Week9 Webshop/docs/png/Activity_diagram_adding_article_to_cart.png
new file mode 100644
index 0000000..7e212f7
Binary files /dev/null and b/Week9 Webshop/docs/png/Activity_diagram_adding_article_to_cart.png differ
diff --git a/Week9 Webshop/docs/png/Sequence_diagram_adding_article_to_cart.png b/Week9 Webshop/docs/png/Sequence_diagram_adding_article_to_cart.png
new file mode 100644
index 0000000..db2e3a1
Binary files /dev/null and b/Week9 Webshop/docs/png/Sequence_diagram_adding_article_to_cart.png differ
diff --git a/Week9 Webshop/docs/png/com.camilstaps.shop.png b/Week9 Webshop/docs/png/com.camilstaps.shop.png
new file mode 100644
index 0000000..4b89905
Binary files /dev/null and b/Week9 Webshop/docs/png/com.camilstaps.shop.png differ
diff --git a/Week9 Webshop/docs/solution.tex b/Week9 Webshop/docs/solution.tex
new file mode 100644
index 0000000..6102aa1
--- /dev/null
+++ b/Week9 Webshop/docs/solution.tex
@@ -0,0 +1,126 @@
+% Copyright (c) 2015 Camil Staps
+% See the LICENSE file for copying permission.
+
+\documentclass[a4paper,11pt]{article}
+
+\usepackage[margin=2cm,bottom=2.5cm]{geometry}
+\usepackage[hidelinks]{hyperref}
+\usepackage[dutch]{babel}
+\usepackage[utf8]{inputenc}
+\usepackage{graphicx}
+\usepackage{fourier}
+\usepackage{pdflscape}
+\usepackage{textcomp}
+\usepackage{fancyhdr}
+\renewcommand{\headrulewidth}{0pt}
+\fancypagestyle{plain}{%
+ \fancyhead[L,C,R]{}%
+ \fancyfoot[C]{Copyright {\textcopyright} 2015 Camil Staps}%
+ \fancyfoot[R]{\thepage}%
+}
+\pagestyle{plain}
+
+\author{Camil Staps}
+\title{De RU-webwinkel}
+
+\begin{document}
+
+\maketitle
+
+\emph{Allereerst worden de vereenvoudigingen t.o.v. de originele opdracht besproken. Vervolgens zal een beknopte documentatie van de beschikbare commando's volgen. Ten slotten zal een klasse-, sequentie- en activiteitsdiagram worden gegeven.}
+
+\section*{Vereenvoudigingen}
+
+\subsection*{Geen webinterface}
+In plaats van een webinterface schrijven we een Java-applicatie waarbij alle interactie op de command line plaatsvindt.
+We gebruiken geen database backend maar een aantal bestanden die lokaal opgeslagen worden.
+
+\subsection*{Per onderdeel}
+
+\begin{description}
+\item[Registreren] Een gebruiker registreert zich vanaf de command line. Het wachtwoord wat gegenereerd wordt, wordt niet naar het emailadres van de gebruiker verstuurd, maar naar \texttt{stdout} geschreven. Het wachtwoord zal niet beveiligd worden opgeslagen.
+\item[Aanbieden van een product] Het zal niet mogelijk zijn voor een gebruiker om multimedia te \emph{uploaden}. Het zal wel mogelijk zijn om multimedia toe te voegen aan een product: hierbij geeft de gebruiker het pad naar het multimediabestand op. Producten zullen niet automatisch na 30 dagen verdwijnen.
+\item[Zoeken van een product] Een gevolg van het werken op de command line is dat we geen multimedia grafisch kunnen weergeven. In plaats daarvan zullen we, als er multimedia aan een product is gekoppeld, het pad naar het bestand weergeven. Het zal slechts mogelijk zijn te zoeken op naam en beschrijving. Het zal niet mogelijk zijn deze zoekopdracht verder te verfijnen.
+\item[Kopen van een product] We voeren geen vereenvoudigingen door op dit onderdeel.
+\item[Afhandeling van de koop] Betalingen worden niet in het systeem verwerkt. In plaats daarvan gaat de gebruiker akkoord met het betalen, waarna hij verwacht wordt langs te komen om te betalen. Hierna zal de beheerder in het systeem kunnen aangeven dat een order is betaald. Er zullen geen extra kosten (als bezorgings- of administratiekosten) in rekening worden gebracht. De klant geeft verder geen afleveradres op. Hij wordt geacht langs te komen om het artikel op te halen.
+\item[Controle op naleving van de regels] We zullen geen reglement gebruiken. De gebruiker hoeft bij registratie nergens mee in te stemmen, en er wordt dus ook niets vastgelegd. De beheerder zal nog wel gebruikers kunnen blokkeren. Hij wordt hierbij niet gebonden door een reglement, en mag dus iedereen naar believen blokkeren.
+\item[Loggen] Er zullen geen transacties worden gelogd. Op het moment dat een gebruiker uitcheckt, en dus akkoord gaat met de betaling van de artikelen in de winkelwagen, wordt er wel een bestelling aan de database toegevoegd.
+\item[Beheer] Het zal niet mogelijk zijn bestaande artikelen aan te passen. In plaats daarvan zal de beheerder ófwel de lokale bestanden die als database fungeren handmatig moeten aanpassen, of het artikel moeten verwijderen en een nieuw artikel in de plaats zetten. Het zal niet mogelijk zijn personen voor bepaalde tijd te blokkeren, waarbij ze automatisch worden gedeblokkeerd. Het zal wel mogelijk zijn personen handmatig te (de)blokkeren. De beheerder zal geen gebruikers kunnen toevoegen. Gebruikers worden geacht zich zelf te registreren.
+\end{description}
+
+\section*{Interface}
+Bij het opstarten van het programma wordt een Shell-achtige interface getoond. Een overzicht van de beschikbare commando's:
+
+\subsection*{Sessiebeheer}
+\begin{description}
+\item[login] Inloggen als gebruiker.
+\item[logout] Uitloggen (inloggen vereist).
+\item[exit] De Shell verlaten en de Database opslaan.
+\end{description}
+
+\subsection*{Artikelen}
+\begin{description}
+\item[addArticle] Artikel toevoegen (inloggen vereist).
+\item[setArticleDescription] De beschrijving van een artikel veranderen, dan wel toevoegen (inloggen vereist).
+\item[setArticleMultimedia] Het multimedia bestand gelinkt aan een artikel veranderen, dan wel een multimedia bestand linken (inloggen vereist).
+\item[removeArticle] Artikel verwijderen (inloggen vereist).
+\item[listArticles] Overzicht van de artikelen in de database weergeven.
+\item[searchArticle] Zoek een artikel met een regular expression op de naam en beschrijving.
+\item[showArticle] Toon gedetailleerde informatie over een artikel.
+\end{description}
+
+\subsection*{Categorieën}
+\begin{description}
+\item[addCategory] Categorie toevoegen (inloggen als administrator vereist).
+\item[listCategories] Overzicht van de categorieën weergeven.
+\end{description}
+
+\subsection*{Winkelwagen}
+\begin{description}
+\item[addToCart] Voeg een artikel toe aan de winkelwagen (inloggen vereist).
+\item[listCart] Toon een overzicht van de winkelwagen (inloggen vereist).
+\item[removeFromCart] Verwijder een artikel uit de winkelwagen (inloggen vereist).
+\item[clearCart] Verwijder alle artikelen uit de winkelwagen (inloggen vereist).
+\item[checkout] Ga door naar de kassa.
+\end{description}
+
+\subsection*{Bestellingen}
+\begin{description}
+\item[listOrders] Toon een overzicht van de bestellingen (inloggen vereist).
+\item[showOrder] Toon gedetailleerde informatie over een bestelling (inloggen vereist).
+\item[setOrderPaid] Geef aan dat een bestelling betaald is (inloggen als administrator vereist).
+\end{description}
+
+\subsection*{Gebruikers (zie ook Sessiebeheer bovenaan)}
+\begin{description}
+\item[register] Registreer een nieuwe gebruiker. De eerste gebruiker toegevoegd is altijd administrator.
+\item[listUsers] Overzicht van de gebruikers weergeven. Administrators krijgen een geavanceerd overzicht, waarbij emailadressen worden weergegeven, `\texttt{++}' administrators aanduidt, en `\texttt{-!-}' geblokkeerde gebruikers aanduidt.
+\item[blockUser] Blokkeer een gebruiker (inloggen als administrator vereist).
+\item[unblockUser] Deblokkeer een gebruiker (inloggen als administrator vereist).
+\end{description}
+
+\newgeometry{margin=1cm,bottom=2.2cm}
+\begin{landscape}
+
+\begin{figure}[h]
+\centering
+\includegraphics[height=0.8\textheight,width=\textwidth,keepaspectratio]{{png/com.camilstaps.shop}.png}
+\caption{Klassediagram -- getters, setters en triviale constructoren zijn weggelaten om het schema enigszins compact te houden. Tenzij anders aangegeven is het return-type \texttt{void}.}
+\end{figure}
+
+\begin{figure}[h]
+\centering
+\includegraphics[height=0.95\textheight,width=\textwidth,keepaspectratio]{{png/Sequence_diagram_adding_article_to_cart}.png}
+\caption{Sequentiediagram voor het toevoegen van een artikel aan de winkelwagen van een gebruiker die nog niet is ingelogd.}
+\end{figure}
+
+\end{landscape}
+\restoregeometry
+
+\begin{figure}[h]
+\centering
+\includegraphics{{png/Activity_diagram_adding_article_to_cart}.png}
+\caption{Activiteitsdiagram voor het toevoegen van een artikel aan de winkelwagen van een gebruiker die nog niet is ingelogd.}
+\end{figure}
+
+\end{document}
\ No newline at end of file
diff --git a/Week9 Webshop/manifest.mf b/Week9 Webshop/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/Week9 Webshop/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/Week9 Webshop/nbproject/build-impl.xml b/Week9 Webshop/nbproject/build-impl.xml
new file mode 100644
index 0000000..e316645
--- /dev/null
+++ b/Week9 Webshop/nbproject/build-impl.xml
@@ -0,0 +1,1396 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Week9 Webshop/nbproject/genfiles.properties b/Week9 Webshop/nbproject/genfiles.properties
new file mode 100644
index 0000000..39baa44
--- /dev/null
+++ b/Week9 Webshop/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=e7ef24c6
+build.xml.script.CRC32=57c150b3
+build.xml.stylesheet.CRC32=8064a381@1.75.2.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=e7ef24c6
+nbproject/build-impl.xml.script.CRC32=eb494d24
+nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week9 Webshop/nbproject/private/private.properties b/Week9 Webshop/nbproject/private/private.properties
new file mode 100644
index 0000000..fca3b8a
--- /dev/null
+++ b/Week9 Webshop/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=/home/camilstaps/.netbeans/8.0.2/build.properties
diff --git a/Week9 Webshop/nbproject/private/private.xml b/Week9 Webshop/nbproject/private/private.xml
new file mode 100644
index 0000000..6807a2b
--- /dev/null
+++ b/Week9 Webshop/nbproject/private/private.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Week9 Webshop/nbproject/project.properties b/Week9 Webshop/nbproject/project.properties
new file mode 100644
index 0000000..5757cc4
--- /dev/null
+++ b/Week9 Webshop/nbproject/project.properties
@@ -0,0 +1,73 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.test.classpath=\
+ ${run.test.classpath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Week9_Webshop.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+excludes=
+file.reference.Week9-src=src
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=1.7
+javac.target=1.7
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+main.class=com.camilstaps.shop.Shop
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=${file.reference.Week9-src}
diff --git a/Week9 Webshop/nbproject/project.xml b/Week9 Webshop/nbproject/project.xml
new file mode 100644
index 0000000..dac0b61
--- /dev/null
+++ b/Week9 Webshop/nbproject/project.xml
@@ -0,0 +1,13 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ Week9 Webshop
+
+
+
+
+
+
+
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Article.java b/Week9 Webshop/src/com/camilstaps/shop/Article.java
new file mode 100644
index 0000000..d22a323
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Article.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.io.File;
+
+/**
+ * An Article in the webshop
+ * @author Camil Staps, s4498062
+ */
+public class Article extends DatabaseItem {
+
+ /**
+ * Basic data about the article
+ */
+ private final String name;
+ private String description;
+ private final Category category;
+ private File multimedia;
+ private final float price;
+
+ /**
+ * The owner who added the article
+ */
+ private final User owner;
+
+ /**
+ * Straightforwardly creating a new article
+ * @param user
+ * @param name
+ * @param category
+ * @param price
+ */
+ public Article(User user, String name, Category category, float price) {
+ this.owner = user;
+ this.name = name;
+ this.category = category;
+ this.price = price;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public File getMultimedia() {
+ return multimedia;
+ }
+
+ public float getPrice() {
+ return price;
+ }
+
+ /**
+ * Set a new description
+ * @param description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Set multimedia
+ * @param multimedia
+ */
+ public void setMultimedia(File multimedia) {
+ this.multimedia = multimedia;
+ }
+
+ @Override
+ public String toString() {
+ return name + " (" + category.getName() + "): " + Float.toString(price);
+ }
+
+}
\ No newline at end of file
diff --git a/Week9 Webshop/src/com/camilstaps/shop/CLIInteraction.java b/Week9 Webshop/src/com/camilstaps/shop/CLIInteraction.java
new file mode 100644
index 0000000..cbf59ab
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/CLIInteraction.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.InputMismatchException;
+import java.util.Scanner;
+
+/**
+ * Command Line Interface Interaction
+ * @author Camil Staps, s4498062
+ */
+public class CLIInteraction extends UserInteraction {
+
+ private final Scanner in;
+ private final PrintStream out;
+
+ /**
+ * Default is stdin and stdout
+ */
+ public CLIInteraction() {
+ this(System.in, System.out);
+ }
+
+ /**
+ * CLI interaction with custom input and outputstream
+ * @param is
+ * @param ps
+ */
+ public CLIInteraction(InputStream is, PrintStream ps) {
+ in = new Scanner(is);
+ out = ps;
+ }
+
+ @Override
+ String getString() {
+ return in.nextLine();
+ }
+
+ @Override
+ public int getChoice(String question, String[] options) {
+ out.println(question);
+ int i = 1;
+ for (String option : options) {
+ out.println(" " + (i++) + " : " + option);
+ }
+ int selection = 0;
+ boolean read = false;
+ do {
+ if (read) {
+ out.println("Invalid option. Try again:");
+ }
+ try {
+ selection = in.nextInt();
+ } catch (InputMismatchException ex) {
+ }
+ in.nextLine();
+ read = true;
+ } while (selection < 1 || selection > options.length);
+ return selection - 1;
+ }
+
+ @Override
+ void putString(String string) {
+ out.print(string);
+ }
+
+ @Override
+ Command getCommand() {
+ putString("► ");
+ return new Command(getString());
+ }
+
+ @Override
+ float getFloat() {
+ float result = in.nextFloat();
+ in.nextLine();
+ return result;
+ }
+
+ @Override
+ boolean getBoolean() {
+ putString(" (yes/no) ");
+ String result;
+ do {
+ result = in.nextLine();
+ } while (!result.equalsIgnoreCase("yes") && !result.equalsIgnoreCase("no"));
+ return result.equalsIgnoreCase("yes");
+ }
+}
\ No newline at end of file
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Cart.java b/Week9 Webshop/src/com/camilstaps/shop/Cart.java
new file mode 100644
index 0000000..74f6ccd
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Cart.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A Cart holds the articles a User is planning to buy.
+ * @author Camil Staps, s4498062
+ */
+public class Cart implements Serializable {
+
+ private final Set articles = new HashSet<>();
+
+ public Set getArticles() {
+ return articles;
+ }
+
+ /**
+ * Get the total price of all articles
+ * @return
+ */
+ public float getTotalAmount() {
+ float result = 0;
+ for (Article a : articles) {
+ result += a.getPrice();
+ }
+ return result;
+ }
+
+ /**
+ * Add a new article
+ * @param article
+ */
+ public void add(Article article) {
+ Database.getInstance().removeItem(article);
+ articles.add(article);
+ }
+
+ /**
+ * Remove an article (and put it back in the database)
+ * @param article
+ */
+ public void remove(Article article) {
+ articles.remove(article);
+ try {
+ Database.getInstance().addItem(article);
+ } catch (DuplicateEntryException ex) {
+ }
+ }
+
+ /**
+ * Remove all articles in the manner of remove()
+ * @see self#remove
+ */
+ public void reset() {
+ for (Article a : articles) {
+ remove(a);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Category.java b/Week9 Webshop/src/com/camilstaps/shop/Category.java
new file mode 100644
index 0000000..05c247c
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Category.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+/**
+ * A Category for Articles
+ * @author Camil Staps, s4498062
+ */
+public class Category extends DatabaseItem {
+
+ private final String name;
+
+ /**
+ * Create a new Category
+ * @param name
+ */
+ public Category(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
\ No newline at end of file
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Command.java b/Week9 Webshop/src/com/camilstaps/shop/Command.java
new file mode 100644
index 0000000..b4694c0
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Command.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+/**
+ * A Command is something that can be executed by a normal visitor, a User or an Administrator.
+ * The current version only holds one string as command, but later versions could include arguments.
+ * @author Camil Staps, s4498062
+ */
+public class Command {
+
+ private final String command;
+
+ public Command(String command) {
+ this.command = command;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+}
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Database.java b/Week9 Webshop/src/com/camilstaps/shop/Database.java
new file mode 100644
index 0000000..8344bca
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Database.java
@@ -0,0 +1,393 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * The Shop database
+ * @author Camil Staps, s4498062
+ */
+public class Database {
+
+ /**
+ * This is a singleton
+ */
+ private static Database instance;
+
+ /**
+ * Keep the database in working memory during runtime
+ */
+ private Set users;
+ private Set articles;
+ private Set categories;
+ private Set orders;
+
+ /**
+ * Files to store the database
+ * Considering backups, it's nicer to have different objects stored in
+ * different files, so that if the Orders file breaks, we still have the
+ * Users, etc.
+ */
+ private final File FILE_DB = new File("./db");
+ private final File FILE_USERS = new File("./db/users.db");
+ private final File FILE_ARTICLES = new File("./db/articles.db");
+ private final File FILE_CATEGORIES = new File("./db/categories.db");
+ private final File FILE_ORDERS = new File("./db/orders.db");
+
+ /**
+ * Don't use this constructor. This is a singleton: use getInstance() instead.
+ * @see self#getInstance()
+ */
+ public Database() {
+ if (!FILE_DB.exists())
+ FILE_DB.mkdir();
+
+ readUsers();
+ readArticles();
+ readCategories();
+ readOrders();
+ }
+
+ /**
+ * Get an instance of the database. This is a singleton.
+ * @return the database
+ */
+ public static Database getInstance() {
+ if (instance == null) {
+ instance = new Database();
+ }
+ return instance;
+ }
+
+ /**
+ * Add an item to the database
+ * @param item the item
+ * @throws com.camilstaps.shop.DuplicateEntryException
+ * @throws ClassCastException if the item to remove is not a DatabaseItem
+ */
+ public void addItem(DatabaseItem item) throws DuplicateEntryException {
+ if (item instanceof User) {
+ if (isUserExists(((User) item).getNr())) {
+ throw new DuplicateEntryException();
+ }
+ users.add((User) item);
+ } else if (item instanceof Article) {
+ if (isArticleExists(((Article) item).getName())) {
+ throw new DuplicateEntryException();
+ }
+ articles.add((Article) item);
+ } else if (item instanceof Category) {
+ if (isCategoryExists(((Category) item).getName())) {
+ throw new DuplicateEntryException();
+ }
+ categories.add((Category) item);
+ } else if (item instanceof Order) {
+ orders.add((Order) item);
+ } else {
+ throw new ClassCastException();
+ }
+ }
+
+ /**
+ * Remove an item from the database
+ * @param item the item to remove
+ * @throws ClassCastException if the item to remove is not a DatabaseItem
+ */
+ public void removeItem(DatabaseItem item) {
+ if (item instanceof User) {
+ users.remove((User) item);
+ } else if (item instanceof Article) {
+ articles.remove((Article) item);
+ } else if (item instanceof Category) {
+ categories.remove((Category) item);
+ } else if (item instanceof Order) {
+ orders.remove((Order) item);
+ } else {
+ throw new ClassCastException();
+ }
+ }
+
+ /**
+ * Save the database to the filesystem.
+ * @return true on success, false on failure
+ */
+ public boolean write() {
+ return writeUsers() && writeArticles() && writeCategories() && writeOrders();
+ }
+
+ /**
+ * Check if there exists a user with a certain U/S-number
+ * @param nr
+ * @return
+ */
+ public boolean isUserExists(String nr) {
+ for (User user : users) {
+ if (user.getNr().equals(nr)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if an article with a name exists
+ * @param name
+ * @return
+ */
+ public boolean isArticleExists(String name) {
+ for (Article article : articles) {
+ if (article.getName().equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if a category with a name exists
+ * @param name
+ * @return
+ */
+ public boolean isCategoryExists(String name) {
+ for (Category category : categories) {
+ if (category.getName().equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the set of users
+ * @return
+ */
+ public Set getUsers() {
+ return users;
+ }
+
+ /**
+ * Get the set of articles
+ * @return
+ */
+ public Set getArticles() {
+ return articles;
+ }
+
+ /**
+ * Get the set of categories
+ * @return
+ */
+ public Set getCategories() {
+ return categories;
+ }
+
+ /**
+ * Get an array of the names of the categories
+ * @return
+ */
+ public String[] getCategoryNames() {
+ String[] categoryNames = new String[categories.size()];
+ int i = 0;
+ for (Category c : categories) {
+ categoryNames[i++] = c.getName();
+ }
+ return categoryNames;
+ }
+
+ /**
+ * Get the set of orders
+ * @return
+ */
+ public Set getOrders() {
+ return orders;
+ }
+
+ /**
+ * Get the set of articles of which the name or description matches a regular expression
+ * @param p the regular expression
+ * @return
+ */
+ public Set searchArticle(Pattern p) {
+ Set result = new HashSet<>();
+ for (Article a : articles) {
+ if (p.matcher(a.getName()).find() || p.matcher(a.getDescription()).find()) {
+ result.add(a);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get a user by his number
+ * @param number
+ * @return
+ * @throws com.camilstaps.shop.ItemNotFoundException
+ */
+ public User getUser(String number) throws ItemNotFoundException {
+ for (User u : users) {
+ if (u.getNr().equals(number)) {
+ return u;
+ }
+ }
+ throw new ItemNotFoundException();
+ }
+
+ /**
+ * Get an article by its name
+ * @param name
+ * @return
+ * @throws ItemNotFoundException
+ */
+ public Article getArticle(String name) throws ItemNotFoundException {
+ for (Article a : articles) {
+ if (a.getName().equals(name)) {
+ return a;
+ }
+ }
+ throw new ItemNotFoundException();
+ }
+
+ /**
+ * Get a category by a name
+ * @param name
+ * @return
+ */
+ public Category getCategory(String name) throws ItemNotFoundException {
+ for (Category c : categories) {
+ if (c.getName().equals(name)) {
+ return c;
+ }
+ }
+ throw new ItemNotFoundException();
+ }
+
+ /**
+ * Read the users from the database into RAM
+ */
+ private void readUsers() {
+ users = new HashSet<>();
+ try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_USERS))) {
+ users = (Set) in.readObject();
+ in.close();
+ } catch (FileNotFoundException ex) {
+ } catch (IOException | ClassNotFoundException ex) {
+ }
+ }
+
+ /**
+ * Read the articles from the database into RAM
+ */
+ private void readArticles() {
+ articles = new HashSet<>();
+ try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_ARTICLES))) {
+ articles = (Set) in.readObject();
+ in.close();
+ } catch (FileNotFoundException ex) {
+ } catch (IOException | ClassNotFoundException ex) {
+ }
+ }
+
+ /**
+ * Read the categories from the database into RAM
+ */
+ private void readCategories() {
+ categories = new HashSet<>();
+ try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_CATEGORIES))) {
+ categories = (Set) in.readObject();
+ in.close();
+ } catch (FileNotFoundException ex) {
+ } catch (IOException | ClassNotFoundException ex) {
+ }
+ }
+
+ /**
+ * Read the orders from the database into RAM
+ */
+ private void readOrders() {
+ orders = new HashSet<>();
+ try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_ORDERS))) {
+ orders = (Set) in.readObject();
+ in.close();
+ } catch (FileNotFoundException ex) {
+ } catch (IOException | ClassNotFoundException ex) {
+ }
+ }
+
+ /**
+ * Write the users from RAM to the database
+ */
+ private boolean writeUsers() {
+ System.err.println("Saving users...");
+
+ try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_USERS))) {
+ out.writeObject(users);
+ out.close();
+ return true;
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Write the articles from RAM to the database
+ */
+ private boolean writeArticles() {
+ System.err.println("Saving articles...");
+
+ try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_ARTICLES))) {
+ out.writeObject(articles);
+ out.close();
+ return true;
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Write the categories from RAM to the database
+ */
+ private boolean writeCategories() {
+ System.err.println("Saving categories...");
+
+ try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_CATEGORIES))) {
+ out.writeObject(categories);
+ out.close();
+ return true;
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * Write the orders from RAM to the database
+ */
+ private boolean writeOrders() {
+ System.err.println("Saving orders...");
+
+ try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_ORDERS))) {
+ out.writeObject(orders);
+ out.close();
+ return true;
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/Week9 Webshop/src/com/camilstaps/shop/DatabaseItem.java b/Week9 Webshop/src/com/camilstaps/shop/DatabaseItem.java
new file mode 100644
index 0000000..0cbe661
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/DatabaseItem.java
@@ -0,0 +1,15 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.io.Serializable;
+
+/**
+ * DatabaseItem is a general class for anything that is stored in the Database
+ * @author Camil Staps, s4498062
+ */
+public class DatabaseItem implements Serializable {
+}
\ No newline at end of file
diff --git a/Week9 Webshop/src/com/camilstaps/shop/DuplicateEntryException.java b/Week9 Webshop/src/com/camilstaps/shop/DuplicateEntryException.java
new file mode 100644
index 0000000..a91d7c7
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/DuplicateEntryException.java
@@ -0,0 +1,18 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+/**
+ * This Exception is thrown when an attempt is made to add a DatabaseItem to the
+ * Database which gives a uniqueness conflict, such as:
+ * * An article with the same name exists
+ * * A category with the same name exists
+ * * A user with the same number exists
+ *
+ * @author Camil Staps, s4498062
+ */
+public class DuplicateEntryException extends Exception {
+}
diff --git a/Week9 Webshop/src/com/camilstaps/shop/InputRequiredException.java b/Week9 Webshop/src/com/camilstaps/shop/InputRequiredException.java
new file mode 100644
index 0000000..ca0110d
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/InputRequiredException.java
@@ -0,0 +1,13 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+/**
+ * This Exception is thrown when required input was omitted by the user.
+ * @author Camil Staps, s4498062
+ */
+public class InputRequiredException extends Exception {
+}
diff --git a/Week9 Webshop/src/com/camilstaps/shop/ItemNotFoundException.java b/Week9 Webshop/src/com/camilstaps/shop/ItemNotFoundException.java
new file mode 100644
index 0000000..5122d79
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/ItemNotFoundException.java
@@ -0,0 +1,14 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+/**
+ * This error is thrown when an attempt is made to instantiate an object with a
+ * non-existing name, number, etc.
+ * @author Camil Staps, s4498062
+ */
+public class ItemNotFoundException extends Exception {
+}
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Order.java b/Week9 Webshop/src/com/camilstaps/shop/Order.java
new file mode 100644
index 0000000..2b0c5a7
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Order.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An order is a set of articles, purchased by a user
+ * @author Camil Staps, s4498062
+ */
+public class Order extends DatabaseItem {
+
+ private final Set articles;
+ private final User user;
+ private boolean paid = false;
+
+ /**
+ * This constructor takes the articles from the Cart of the User, and clears
+ * that Cart afterwards.
+ * @param user
+ */
+ public Order(User user) {
+ this.user = user;
+ articles = new HashSet<>();
+ for (Article a : user.getCart().getArticles()) {
+ articles.add(a);
+ }
+ user.getCart().getArticles().clear();
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public Set getArticles() {
+ return articles;
+ }
+
+ public void setPaid(boolean set) {
+ paid = set;
+ }
+
+ /**
+ * See whether payment has been received for this article already
+ * @return
+ */
+ public boolean isPaid() {
+ return paid;
+ }
+
+ /**
+ * Get the total price of all articles
+ * @return
+ */
+ public float getTotalAmount() {
+ float result = 0;
+ for (Article a : articles) {
+ result += a.getPrice();
+ }
+ return result;
+ }
+
+}
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Shell.java b/Week9 Webshop/src/com/camilstaps/shop/Shell.java
new file mode 100644
index 0000000..7939963
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Shell.java
@@ -0,0 +1,476 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * Executing commands and providing output, using a UserInteraction and acting
+ * on a Database.
+ * @author Camil Staps, s4498062
+ */
+public class Shell {
+
+ /**
+ * The Database to work with
+ */
+ private final Database database;
+ /**
+ * The UserInteraction to use
+ */
+ private final UserInteraction ui;
+
+ /**
+ * The current User, if logged in
+ */
+ private User user;
+
+ public Shell(UserInteraction userInteraction) {
+ this.database = Database.getInstance();
+ this.ui = userInteraction;
+ }
+
+ /**
+ * Request commands, execute them, and show the results
+ */
+ public void run() {
+ while (true) {
+ Command command = ui.getCommand();
+ try {
+ Method method = getClass().getMethod("exec" + command.getCommand().substring(0,1).toUpperCase() + command.getCommand().substring(1));
+ method.invoke(this);
+
+ if (command.getCommand().equalsIgnoreCase("exit")) {
+ return;
+ }
+ } catch (NoSuchMethodException ex) {
+ ui.putStringln("Failure: no such command");
+ } catch (InvocationTargetException ex) {
+ ui.putStringln("Failure: " + ex.getCause().toString());
+ } catch (SecurityException | IllegalAccessException | IllegalArgumentException ex) {
+ ui.putStringln("Failure: unknown error");
+ }
+ }
+ }
+
+ /**
+ * Require that the visitor logs in
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException if the visitor fails to login
+ * @throws ItemNotFoundException if the visitor tries to login with a non-existing User number
+ */
+ public void requireLogin() throws LoginRequiredException, ItemNotFoundException {
+ if (user == null) {
+ ui.putStringln("You must login first.");
+
+ try {
+ execLogin();
+ } catch (InputRequiredException ex) {
+ }
+
+ if (user == null) {
+ throw new LoginRequiredException();
+ }
+ }
+ }
+
+ /**
+ * Require that an administrator is logged in
+ * @throws com.camilstaps.shop.Shell.AdminRequiredException if the visitor fails to login, or is not an administrator
+ * @throws ItemNotFoundException if the visitor tries to login with a non-existing User number
+ */
+ public void requireAdmin() throws AdminRequiredException, ItemNotFoundException {
+ if (user == null || !user.isAdmin()) {
+ ui.putStringln("You must login as an administrator first.");
+
+ try {
+ execLogin();
+ } catch (InputRequiredException ex) {
+ }
+
+ if (user == null || !user.isAdmin()) {
+ throw new AdminRequiredException();
+ }
+ }
+ }
+
+ /**
+ * Command: add an article
+ * @throws DuplicateEntryException
+ * @throws InputRequiredException
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ */
+ public void execAddArticle() throws DuplicateEntryException, InputRequiredException, LoginRequiredException, ItemNotFoundException {
+ requireLogin();
+
+ String name = ui.getRequiredString("Name: ");
+ Category category = ui.getCategory();
+ float price = ui.getFloat("Price: ");
+
+ Article a = new Article(user, name, category, price);
+ database.addItem(a);
+ }
+
+ /**
+ * Command: set the article description
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ * @throws InputRequiredException
+ */
+ public void execSetArticleDescription() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
+ requireLogin();
+
+ Article a;
+ if (user.isAdmin()) {
+ a = ui.getArticle();
+ } else {
+ a = ui.getArticle(user);
+ }
+
+ a.setDescription(ui.getRequiredString("Description: "));
+ }
+
+ /**
+ * Command: set the multimedia linked to an article
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ * @throws InputRequiredException
+ */
+ public void execSetArticleMultimedia() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
+ requireLogin();
+
+ Article a;
+ if (user.isAdmin()) {
+ a = ui.getArticle();
+ } else {
+ a = ui.getArticle(user);
+ }
+
+ a.setMultimedia(new File(ui.getRequiredString("Multimedia: ")));
+ }
+
+ /**
+ * Command: remove an article
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ * @throws InputRequiredException
+ */
+ public void execRemoveArticle() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
+ requireLogin();
+
+ Article a;
+ if (user.isAdmin()) {
+ a = ui.getArticle();
+ } else {
+ a = ui.getArticle(user);
+ }
+
+ database.removeItem(a);
+ }
+
+ /**
+ * Command: show a list of articles
+ */
+ public void execListArticles() {
+ for (Article a : database.getArticles()) {
+ ui.putStringln(a.toString());
+ }
+ }
+
+ /**
+ * Command: search for an article
+ */
+ public void execSearchArticle() {
+ String regex = ui.getString("Keywords: ");
+ for (Article a : database.searchArticle(Pattern.compile(regex))) {
+ ui.putStringln(a.toString());
+ }
+ }
+
+ /**
+ * Command: show detailed data about an article
+ * @throws InputRequiredException
+ * @throws ItemNotFoundException
+ */
+ public void execShowArticle() throws InputRequiredException, ItemNotFoundException {
+ Article a = ui.getArticle();
+ ui.putStringln(a.toString());
+ if (a.getDescription() != null) {
+ ui.putStringln(a.getDescription());
+ }
+ File multimedia = a.getMultimedia();
+ if (multimedia != null) {
+ ui.putStringln("Multimedia: " + multimedia.getPath());
+ }
+ if (user != null && user.isAdmin()) {
+ ui.putStringln("User: " + a.getOwner().toString(true));
+ }
+ }
+
+ /**
+ * Command: add a category
+ * @throws DuplicateEntryException
+ * @throws InputRequiredException
+ * @throws com.camilstaps.shop.Shell.AdminRequiredException
+ * @throws ItemNotFoundException
+ */
+ public void execAddCategory() throws DuplicateEntryException, InputRequiredException, AdminRequiredException, ItemNotFoundException {
+ requireAdmin();
+
+ String name = ui.getRequiredString("Name: ");
+ database.addItem(new Category(name));
+ }
+
+ /**
+ * Command: list categories
+ */
+ public void execListCategories() {
+ for (String c : database.getCategoryNames()) {
+ ui.putStringln(c);
+ }
+ }
+
+ /**
+ * Command: list users
+ * Administrators see a more detailed list
+ */
+ public void execListUsers() {
+ for (User u : database.getUsers()) {
+ ui.putStringln(u.toString(user != null && user.isAdmin()));
+ }
+ }
+
+ /**
+ * Command: register a new user
+ * @throws DuplicateEntryException
+ * @throws InputRequiredException
+ */
+ public void execRegister() throws DuplicateEntryException, InputRequiredException {
+ boolean addAsAdmin = false;
+
+ if (database.getUsers().isEmpty()) {
+ addAsAdmin = true;
+ ui.putStringln("This is the first user and will therefore be added as administrator.");
+ } else if (user != null && user.isAdmin()) {
+ addAsAdmin = ui.getBoolean("Add user as administrator");
+ }
+
+ String nr = ui.getRequiredString("Number: ");
+ String email = ui.getRequiredString("Email: ");
+
+ User u = new User(nr, email, addAsAdmin);
+
+ String password = u.setRandomPassword();
+ ui.putStringln("Password: " + password);
+
+ database.addItem(u);
+ }
+
+ /**
+ * Command: login
+ * @throws InputRequiredException
+ * @throws ItemNotFoundException
+ */
+ public void execLogin() throws InputRequiredException, ItemNotFoundException {
+ if (user != null) {
+ ui.putStringln("You are already logged in.");
+ return;
+ }
+
+ User u = ui.getUser();
+ String pw = ui.getRequiredString("Password: ");
+
+ if (!u.verify(pw)) {
+ ui.putStringln("Failed to login.");
+ return;
+ }
+
+ if (u.isBlocked()) {
+ ui.putStringln("You are blocked.");
+ return;
+ }
+
+ user = u;
+ }
+
+ /**
+ * Command: logout
+ */
+ public void execLogout() {
+ user = null;
+ }
+
+ /**
+ * Command: add an article to the cart
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ * @throws InputRequiredException
+ */
+ public void execAddToCart() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
+ requireLogin();
+
+ user.getCart().add(ui.getArticle());
+ }
+
+ /**
+ * Command: remove an article from the cart
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ */
+ public void execRemoveFromCart() throws LoginRequiredException, ItemNotFoundException {
+ requireLogin();
+
+ user.getCart().remove(ui.getArticle(user.getCart().getArticles()));
+ }
+
+ /**
+ * Command: list articles in the cart
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ */
+ public void execListCart() throws LoginRequiredException, ItemNotFoundException {
+ requireLogin();
+
+ for (Article a : user.getCart().getArticles()) {
+ ui.putStringln(a.toString());
+ }
+
+ ui.putStringln("Total value: " + user.getCart().getTotalAmount());
+ }
+
+ /**
+ * Command: remove all articles from the cart
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ */
+ public void execClearCart() throws LoginRequiredException, ItemNotFoundException {
+ requireLogin();
+
+ if (ui.getBoolean("Are you sure?")) user.getCart().reset();
+ }
+
+ /**
+ * Command: checkout (create an Order using the current Cart)
+ * @throws ItemNotFoundException
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws DuplicateEntryException
+ */
+ public void execCheckout() throws ItemNotFoundException, LoginRequiredException, DuplicateEntryException {
+ requireLogin();
+
+ if (user.getCart().getArticles().isEmpty()) {
+ throw new ItemNotFoundException();
+ }
+
+ ui.putStringln("By checking out, you agree to pay the total amount.");
+ if (!ui.getBoolean("Do you agree?"))
+ return;
+
+ Order order = new Order(user);
+ database.addItem(order);
+
+ ui.putStringln("Your order has been added as " + order.toString());
+ }
+
+ /**
+ * Command: list orders
+ * @throws ItemNotFoundException
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ */
+ public void execListOrders() throws ItemNotFoundException, LoginRequiredException {
+ requireLogin();
+
+ Set orders;
+ if (user.isAdmin()) {
+ orders = database.getOrders();
+ } else {
+ orders = user.getOrders();
+ }
+ for (Order o : orders) {
+ ui.putStringln(o.toString());
+ }
+ }
+
+ /**
+ * Command: show detailed information about an order
+ * @throws com.camilstaps.shop.Shell.LoginRequiredException
+ * @throws ItemNotFoundException
+ * @throws InputRequiredException
+ */
+ public void execShowOrder() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
+ requireLogin();
+
+ Order o;
+ if (user.isAdmin()) {
+ o = ui.getOrder();
+ } else {
+ o = ui.getOrder(user);
+ }
+ ui.putStringln(o.toString());
+ for (Article a : o.getArticles()) {
+ ui.putStringln(" " + a.toString());
+ }
+ ui.putStringln("Total amount: " + o.getTotalAmount());
+ ui.putStringln("Paid: " + (o.isPaid() ? "yes" : "no"));
+ }
+
+ /**
+ * Command: set the paid status of an Order to true
+ * @throws com.camilstaps.shop.Shell.AdminRequiredException
+ * @throws ItemNotFoundException
+ * @throws InputRequiredException
+ */
+ public void execSetOrderPaid() throws AdminRequiredException, ItemNotFoundException, InputRequiredException {
+ requireAdmin();
+ ui.getOrder().setPaid(true);
+ }
+
+ /**
+ * Command: block a user
+ * @throws InputRequiredException
+ * @throws ItemNotFoundException
+ * @throws com.camilstaps.shop.Shell.AdminRequiredException
+ */
+ public void execBlockUser() throws InputRequiredException, ItemNotFoundException, AdminRequiredException {
+ requireAdmin();
+ ui.getUser().setBlocked(true);
+ }
+
+ /**
+ * Command: unblock a user
+ * @throws InputRequiredException
+ * @throws ItemNotFoundException
+ * @throws com.camilstaps.shop.Shell.AdminRequiredException
+ */
+ public void execUnblockUser() throws InputRequiredException, ItemNotFoundException, AdminRequiredException {
+ requireAdmin();
+ ui.getUser().setBlocked(false);
+ }
+
+ /**
+ * Command: save the database
+ */
+ public void execExit() {
+ database.write();
+ }
+
+ /**
+ * This Exception is thrown when the visitor is required to login, but fails
+ */
+ private class LoginRequiredException extends Exception {
+ }
+
+ /**
+ * This Exception is thrown when the visitor is required to login as an administrator, but fails
+ */
+ private class AdminRequiredException extends Exception {
+ }
+
+}
diff --git a/Week9 Webshop/src/com/camilstaps/shop/Shop.java b/Week9 Webshop/src/com/camilstaps/shop/Shop.java
new file mode 100644
index 0000000..cab828a
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/Shop.java
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+/**
+ * The webshop
+ * @author Camil Staps, s4498062
+ */
+public class Shop {
+
+ /**
+ * Create a shell and run
+ * @param args
+ */
+ public static void main(String[] args) {
+ Shell sh = new Shell(new CLIInteraction());
+ sh.run();
+ }
+
+}
diff --git a/Week9 Webshop/src/com/camilstaps/shop/User.java b/Week9 Webshop/src/com/camilstaps/shop/User.java
new file mode 100644
index 0000000..12cfd4d
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/User.java
@@ -0,0 +1,143 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+
+/**
+ * A User is a person with a U/S-number, email and password.
+ * He may be blocked / be an admin, and has a Cart.
+ * @author Camil Staps, s4498062
+ */
+public class User extends DatabaseItem {
+
+ private final String nr;
+ private final String email;
+ private String hash;
+ private final boolean isAdmin;
+ private final Cart cart = new Cart();
+ private boolean isBlocked = false;
+
+ public User (String nr, String email) {
+ this.nr = nr;
+ this.email = email;
+ this.isAdmin = false;
+ }
+
+ public User (String nr, String email, boolean isAdmin) {
+ this.nr = nr;
+ this.email = email;
+ this.isAdmin = isAdmin;
+ }
+
+ public String getNr() {
+ return nr;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public boolean isAdmin() {
+ return isAdmin;
+ }
+
+ public Cart getCart() {
+ return cart;
+ }
+
+ public void setBlocked(boolean set) {
+ isBlocked = set;
+ }
+
+ public boolean isBlocked() {
+ return isBlocked;
+ }
+
+ public Set getArticles() {
+ Set articles = Database.getInstance().getArticles();
+ Set result = new HashSet<>();
+ for (Article a : articles) {
+ if (a.getOwner().getNr().equals(nr)) {
+ result.add(a);
+ }
+ }
+ return result;
+ }
+
+ public Set getOrders() {
+ Set orders = Database.getInstance().getOrders();
+ Set result = new HashSet<>();
+ for (Order o : orders) {
+ if (o.getUser().getNr().equals(nr)) {
+ result.add(o);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Set a random new password for the user
+ * @return the new password
+ */
+ public String setRandomPassword() {
+ String pw = generatePassword();
+ hash = hash(pw);
+ return pw;
+ }
+
+ /**
+ * Hash a password. Currently, this is just the identity function.
+ * @param password
+ * @return
+ */
+ public static String hash(String password) {
+ return password;
+ }
+
+ /**
+ * Generate a random password
+ * @return
+ */
+ private static String generatePassword() {
+ // Only characters that cannot easily be confused
+ final String drawFrom = "123456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
+ final Random r = new Random();
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < 12; i++) {
+ sb.append(drawFrom.charAt(r.nextInt(drawFrom.length())));
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Verify if a password matches the user's password
+ * @param password the password to check
+ * @return
+ */
+ public boolean verify(String password) {
+ return hash(password).equals(hash);
+ }
+
+ @Override
+ public String toString() {
+ return (isAdmin ? "++ " : "") + nr + " (" + email + ")" + (isBlocked ? " -!-" : "");
+ }
+
+ /**
+ * This User as a String, with a detailed and a quick view
+ * @param showSensitive whether to show sensitive data (email, isAdmin, isBlocked) or not
+ * @return
+ */
+ public String toString(boolean showSensitive) {
+ return showSensitive ? toString() : nr;
+ }
+
+}
\ No newline at end of file
diff --git a/Week9 Webshop/src/com/camilstaps/shop/UserInteraction.java b/Week9 Webshop/src/com/camilstaps/shop/UserInteraction.java
new file mode 100644
index 0000000..1140089
--- /dev/null
+++ b/Week9 Webshop/src/com/camilstaps/shop/UserInteraction.java
@@ -0,0 +1,198 @@
+/**
+ * Copyright (c) 2015 Camil Staps
+ * See the LICENSE file for copying permission.
+ */
+
+package com.camilstaps.shop;
+
+import java.util.Set;
+
+/**
+ * Interact with the user: provide and request information.
+ * @author Camil Staps, s4498062
+ */
+public abstract class UserInteraction {
+
+ /**
+ * Show a String
+ * @param string
+ */
+ abstract void putString(String string);
+
+ /**
+ * Show a String with a linefeed
+ * @param string
+ */
+ void putStringln(String string) {
+ putString(string + System.lineSeparator());
+ }
+
+ /**
+ * Get a String as input
+ * @return
+ */
+ abstract String getString();
+
+ /**
+ * Get a String as input, after outputting a question
+ * @param question
+ * @return
+ */
+ String getString(String question) {
+ putString(question);
+ return getString();
+ }
+
+ /**
+ * Get a String as input, and throw an Exception when it's empty
+ * @return
+ * @throws InputRequiredException
+ */
+ String getRequiredString() throws InputRequiredException {
+ String result = getString();
+ if (result.isEmpty()) throw new InputRequiredException();
+ return result;
+ }
+
+ /**
+ * Get a String as input, after outputting a question, and throw an
+ * Exception when the input is empty
+ * @param question
+ * @return
+ * @throws InputRequiredException
+ */
+ String getRequiredString(String question) throws InputRequiredException {
+ putString(question);
+ return getRequiredString();
+ }
+
+ /**
+ * Get a float as input
+ * @return
+ */
+ abstract float getFloat();
+
+ /**
+ * Get a float as input, after outputting a question
+ * @param question
+ * @return
+ */
+ float getFloat(String question) {
+ putString(question);
+ return getFloat();
+ }
+
+ /**
+ * Get a boolean as input
+ * @return
+ */
+ abstract boolean getBoolean();
+
+ /**
+ * Get a boolean as input, after outputting a question
+ * @param question
+ * @return
+ */
+ boolean getBoolean(String question) {
+ putString(question);
+ return getBoolean();
+ }
+
+ /**
+ * Get a Command as input
+ * @return
+ */
+ abstract Command getCommand();
+
+ /**
+ * Let the user choose from an array of options, after outputting a question
+ * @param question
+ * @param options
+ * @return the index of the choice in the options array
+ */
+ abstract int getChoice(String question, String[] options);
+
+ /**
+ * Let the user choose from a Set of Articles
+ * @param set
+ * @return
+ */
+ Article getArticle(Set set) {
+ String[] articleNames = new String[set.size()];
+ Article[] articles = new Article[set.size()];
+ int i = 0;
+ for (Article a : set) {
+ articleNames[i] = a.toString();
+ articles[i++] = a;
+ }
+ return articles[getChoice("Article: ", articleNames)];
+ }
+
+ /**
+ * Let the user choose an Article
+ * @return
+ * @throws InputRequiredException
+ * @throws ItemNotFoundException
+ */
+ Article getArticle() throws InputRequiredException, ItemNotFoundException {
+ String name = getRequiredString("Name article: ");
+ return Database.getInstance().getArticle(name);
+ }
+
+ /**
+ * Let the user choose an Article from the Articles of a specific User
+ * @param user
+ * @return
+ */
+ Article getArticle(User user) {
+ return getArticle(user.getArticles());
+ }
+
+ /**
+ * Let the user choose a category
+ * @return
+ * @throws ItemNotFoundException
+ */
+ Category getCategory() throws ItemNotFoundException {
+ String[] categories = Database.getInstance().getCategoryNames();
+ return Database.getInstance().getCategory(categories[getChoice("Category: ", categories)]);
+ }
+
+ /**
+ * Let the user choose a User
+ * @return
+ * @throws InputRequiredException
+ * @throws ItemNotFoundException
+ */
+ User getUser() throws InputRequiredException, ItemNotFoundException {
+ return Database.getInstance().getUser(getRequiredString("Number user: "));
+ }
+
+ /**
+ * Let the user choose an order
+ * @return
+ * @throws InputRequiredException
+ * @throws ItemNotFoundException
+ */
+ Order getOrder() throws InputRequiredException, ItemNotFoundException {
+ return getOrder(getUser());
+ }
+
+ /**
+ * Let the user choose an order, from the orders of a specific User
+ * @param user
+ * @return
+ */
+ Order getOrder(User user) {
+ Set orders = user.getOrders();
+ String[] orderStrings = new String[orders.size()];
+ Order[] orderObjects = new Order[orders.size()];
+ int i = 0;
+ for (Order o : orders) {
+ orderStrings[i] = o.toString();
+ orderObjects[i++] = o;
+ }
+ return orderObjects[getChoice("Order: ", orderStrings)];
+ }
+
+}
\ No newline at end of file
diff --git a/Week9 Webshop/uml-project.vpp b/Week9 Webshop/uml-project.vpp
new file mode 100644
index 0000000..52763eb
Binary files /dev/null and b/Week9 Webshop/uml-project.vpp differ
diff --git a/Week9/.gitignore b/Week9/.gitignore
deleted file mode 100644
index 52083c3..0000000
--- a/Week9/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-solution.aux
-solution.idx
-solution.log
-solution.out
-solution.pdf
-db
-
-*.vpp.working
-*.vpp~*
diff --git a/Week9/Assignment (in Dutch).pdf b/Week9/Assignment (in Dutch).pdf
deleted file mode 100644
index 087342f..0000000
Binary files a/Week9/Assignment (in Dutch).pdf and /dev/null differ
diff --git a/Week9/Assignment appendix (in Dutch).pdf b/Week9/Assignment appendix (in Dutch).pdf
deleted file mode 100644
index 9d24ec8..0000000
Binary files a/Week9/Assignment appendix (in Dutch).pdf and /dev/null differ
diff --git a/Week9/build.xml b/Week9/build.xml
deleted file mode 100644
index d3fe323..0000000
--- a/Week9/build.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project Week9.
-
-
-
diff --git a/Week9/docs/Makefile b/Week9/docs/Makefile
deleted file mode 100644
index bd1f10f..0000000
--- a/Week9/docs/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all: tex view
-
-tex:
- pdflatex solution.tex
-
-view:
- gnome-open solution.pdf
\ No newline at end of file
diff --git a/Week9/docs/png/Activity_diagram_adding_article_to_cart.png b/Week9/docs/png/Activity_diagram_adding_article_to_cart.png
deleted file mode 100644
index 7e212f7..0000000
Binary files a/Week9/docs/png/Activity_diagram_adding_article_to_cart.png and /dev/null differ
diff --git a/Week9/docs/png/Sequence_diagram_adding_article_to_cart.png b/Week9/docs/png/Sequence_diagram_adding_article_to_cart.png
deleted file mode 100644
index db2e3a1..0000000
Binary files a/Week9/docs/png/Sequence_diagram_adding_article_to_cart.png and /dev/null differ
diff --git a/Week9/docs/png/com.camilstaps.shop.png b/Week9/docs/png/com.camilstaps.shop.png
deleted file mode 100644
index 4b89905..0000000
Binary files a/Week9/docs/png/com.camilstaps.shop.png and /dev/null differ
diff --git a/Week9/docs/solution.tex b/Week9/docs/solution.tex
deleted file mode 100644
index 6102aa1..0000000
--- a/Week9/docs/solution.tex
+++ /dev/null
@@ -1,126 +0,0 @@
-% Copyright (c) 2015 Camil Staps
-% See the LICENSE file for copying permission.
-
-\documentclass[a4paper,11pt]{article}
-
-\usepackage[margin=2cm,bottom=2.5cm]{geometry}
-\usepackage[hidelinks]{hyperref}
-\usepackage[dutch]{babel}
-\usepackage[utf8]{inputenc}
-\usepackage{graphicx}
-\usepackage{fourier}
-\usepackage{pdflscape}
-\usepackage{textcomp}
-\usepackage{fancyhdr}
-\renewcommand{\headrulewidth}{0pt}
-\fancypagestyle{plain}{%
- \fancyhead[L,C,R]{}%
- \fancyfoot[C]{Copyright {\textcopyright} 2015 Camil Staps}%
- \fancyfoot[R]{\thepage}%
-}
-\pagestyle{plain}
-
-\author{Camil Staps}
-\title{De RU-webwinkel}
-
-\begin{document}
-
-\maketitle
-
-\emph{Allereerst worden de vereenvoudigingen t.o.v. de originele opdracht besproken. Vervolgens zal een beknopte documentatie van de beschikbare commando's volgen. Ten slotten zal een klasse-, sequentie- en activiteitsdiagram worden gegeven.}
-
-\section*{Vereenvoudigingen}
-
-\subsection*{Geen webinterface}
-In plaats van een webinterface schrijven we een Java-applicatie waarbij alle interactie op de command line plaatsvindt.
-We gebruiken geen database backend maar een aantal bestanden die lokaal opgeslagen worden.
-
-\subsection*{Per onderdeel}
-
-\begin{description}
-\item[Registreren] Een gebruiker registreert zich vanaf de command line. Het wachtwoord wat gegenereerd wordt, wordt niet naar het emailadres van de gebruiker verstuurd, maar naar \texttt{stdout} geschreven. Het wachtwoord zal niet beveiligd worden opgeslagen.
-\item[Aanbieden van een product] Het zal niet mogelijk zijn voor een gebruiker om multimedia te \emph{uploaden}. Het zal wel mogelijk zijn om multimedia toe te voegen aan een product: hierbij geeft de gebruiker het pad naar het multimediabestand op. Producten zullen niet automatisch na 30 dagen verdwijnen.
-\item[Zoeken van een product] Een gevolg van het werken op de command line is dat we geen multimedia grafisch kunnen weergeven. In plaats daarvan zullen we, als er multimedia aan een product is gekoppeld, het pad naar het bestand weergeven. Het zal slechts mogelijk zijn te zoeken op naam en beschrijving. Het zal niet mogelijk zijn deze zoekopdracht verder te verfijnen.
-\item[Kopen van een product] We voeren geen vereenvoudigingen door op dit onderdeel.
-\item[Afhandeling van de koop] Betalingen worden niet in het systeem verwerkt. In plaats daarvan gaat de gebruiker akkoord met het betalen, waarna hij verwacht wordt langs te komen om te betalen. Hierna zal de beheerder in het systeem kunnen aangeven dat een order is betaald. Er zullen geen extra kosten (als bezorgings- of administratiekosten) in rekening worden gebracht. De klant geeft verder geen afleveradres op. Hij wordt geacht langs te komen om het artikel op te halen.
-\item[Controle op naleving van de regels] We zullen geen reglement gebruiken. De gebruiker hoeft bij registratie nergens mee in te stemmen, en er wordt dus ook niets vastgelegd. De beheerder zal nog wel gebruikers kunnen blokkeren. Hij wordt hierbij niet gebonden door een reglement, en mag dus iedereen naar believen blokkeren.
-\item[Loggen] Er zullen geen transacties worden gelogd. Op het moment dat een gebruiker uitcheckt, en dus akkoord gaat met de betaling van de artikelen in de winkelwagen, wordt er wel een bestelling aan de database toegevoegd.
-\item[Beheer] Het zal niet mogelijk zijn bestaande artikelen aan te passen. In plaats daarvan zal de beheerder ófwel de lokale bestanden die als database fungeren handmatig moeten aanpassen, of het artikel moeten verwijderen en een nieuw artikel in de plaats zetten. Het zal niet mogelijk zijn personen voor bepaalde tijd te blokkeren, waarbij ze automatisch worden gedeblokkeerd. Het zal wel mogelijk zijn personen handmatig te (de)blokkeren. De beheerder zal geen gebruikers kunnen toevoegen. Gebruikers worden geacht zich zelf te registreren.
-\end{description}
-
-\section*{Interface}
-Bij het opstarten van het programma wordt een Shell-achtige interface getoond. Een overzicht van de beschikbare commando's:
-
-\subsection*{Sessiebeheer}
-\begin{description}
-\item[login] Inloggen als gebruiker.
-\item[logout] Uitloggen (inloggen vereist).
-\item[exit] De Shell verlaten en de Database opslaan.
-\end{description}
-
-\subsection*{Artikelen}
-\begin{description}
-\item[addArticle] Artikel toevoegen (inloggen vereist).
-\item[setArticleDescription] De beschrijving van een artikel veranderen, dan wel toevoegen (inloggen vereist).
-\item[setArticleMultimedia] Het multimedia bestand gelinkt aan een artikel veranderen, dan wel een multimedia bestand linken (inloggen vereist).
-\item[removeArticle] Artikel verwijderen (inloggen vereist).
-\item[listArticles] Overzicht van de artikelen in de database weergeven.
-\item[searchArticle] Zoek een artikel met een regular expression op de naam en beschrijving.
-\item[showArticle] Toon gedetailleerde informatie over een artikel.
-\end{description}
-
-\subsection*{Categorieën}
-\begin{description}
-\item[addCategory] Categorie toevoegen (inloggen als administrator vereist).
-\item[listCategories] Overzicht van de categorieën weergeven.
-\end{description}
-
-\subsection*{Winkelwagen}
-\begin{description}
-\item[addToCart] Voeg een artikel toe aan de winkelwagen (inloggen vereist).
-\item[listCart] Toon een overzicht van de winkelwagen (inloggen vereist).
-\item[removeFromCart] Verwijder een artikel uit de winkelwagen (inloggen vereist).
-\item[clearCart] Verwijder alle artikelen uit de winkelwagen (inloggen vereist).
-\item[checkout] Ga door naar de kassa.
-\end{description}
-
-\subsection*{Bestellingen}
-\begin{description}
-\item[listOrders] Toon een overzicht van de bestellingen (inloggen vereist).
-\item[showOrder] Toon gedetailleerde informatie over een bestelling (inloggen vereist).
-\item[setOrderPaid] Geef aan dat een bestelling betaald is (inloggen als administrator vereist).
-\end{description}
-
-\subsection*{Gebruikers (zie ook Sessiebeheer bovenaan)}
-\begin{description}
-\item[register] Registreer een nieuwe gebruiker. De eerste gebruiker toegevoegd is altijd administrator.
-\item[listUsers] Overzicht van de gebruikers weergeven. Administrators krijgen een geavanceerd overzicht, waarbij emailadressen worden weergegeven, `\texttt{++}' administrators aanduidt, en `\texttt{-!-}' geblokkeerde gebruikers aanduidt.
-\item[blockUser] Blokkeer een gebruiker (inloggen als administrator vereist).
-\item[unblockUser] Deblokkeer een gebruiker (inloggen als administrator vereist).
-\end{description}
-
-\newgeometry{margin=1cm,bottom=2.2cm}
-\begin{landscape}
-
-\begin{figure}[h]
-\centering
-\includegraphics[height=0.8\textheight,width=\textwidth,keepaspectratio]{{png/com.camilstaps.shop}.png}
-\caption{Klassediagram -- getters, setters en triviale constructoren zijn weggelaten om het schema enigszins compact te houden. Tenzij anders aangegeven is het return-type \texttt{void}.}
-\end{figure}
-
-\begin{figure}[h]
-\centering
-\includegraphics[height=0.95\textheight,width=\textwidth,keepaspectratio]{{png/Sequence_diagram_adding_article_to_cart}.png}
-\caption{Sequentiediagram voor het toevoegen van een artikel aan de winkelwagen van een gebruiker die nog niet is ingelogd.}
-\end{figure}
-
-\end{landscape}
-\restoregeometry
-
-\begin{figure}[h]
-\centering
-\includegraphics{{png/Activity_diagram_adding_article_to_cart}.png}
-\caption{Activiteitsdiagram voor het toevoegen van een artikel aan de winkelwagen van een gebruiker die nog niet is ingelogd.}
-\end{figure}
-
-\end{document}
\ No newline at end of file
diff --git a/Week9/manifest.mf b/Week9/manifest.mf
deleted file mode 100644
index 328e8e5..0000000
--- a/Week9/manifest.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-X-COMMENT: Main-Class will be added automatically by build
-
diff --git a/Week9/nbproject/build-impl.xml b/Week9/nbproject/build-impl.xml
deleted file mode 100644
index 6df8cc2..0000000
--- a/Week9/nbproject/build-impl.xml
+++ /dev/null
@@ -1,1396 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Week9/nbproject/genfiles.properties b/Week9/nbproject/genfiles.properties
deleted file mode 100644
index 12dfb41..0000000
--- a/Week9/nbproject/genfiles.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=e81d22ef
-build.xml.script.CRC32=078500a2
-build.xml.stylesheet.CRC32=8064a381@1.75.2.48
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=e81d22ef
-nbproject/build-impl.xml.script.CRC32=8b93a16f
-nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
diff --git a/Week9/nbproject/project.properties b/Week9/nbproject/project.properties
deleted file mode 100644
index b361673..0000000
--- a/Week9/nbproject/project.properties
+++ /dev/null
@@ -1,73 +0,0 @@
-annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.processor.options=
-annotation.processing.processors.list=
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# Files in build.classes.dir which should be excluded from distribution jar
-dist.archive.excludes=
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Week9.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-file.reference.Week9-src=src
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.7
-javac.target=1.7
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-main.class=com.camilstaps.shop.Shop
-manifest.file=manifest.mf
-meta.inf.dir=${src.dir}/META-INF
-mkdist.disabled=false
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project.
-# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
-# To set system properties for unit tests define test-sys-prop.name=value:
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=${file.reference.Week9-src}
diff --git a/Week9/nbproject/project.xml b/Week9/nbproject/project.xml
deleted file mode 100644
index 16c13ca..0000000
--- a/Week9/nbproject/project.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Week9
-
-
-
-
-
-
-
diff --git a/Week9/src/com/camilstaps/shop/Article.java b/Week9/src/com/camilstaps/shop/Article.java
deleted file mode 100644
index d22a323..0000000
--- a/Week9/src/com/camilstaps/shop/Article.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.io.File;
-
-/**
- * An Article in the webshop
- * @author Camil Staps, s4498062
- */
-public class Article extends DatabaseItem {
-
- /**
- * Basic data about the article
- */
- private final String name;
- private String description;
- private final Category category;
- private File multimedia;
- private final float price;
-
- /**
- * The owner who added the article
- */
- private final User owner;
-
- /**
- * Straightforwardly creating a new article
- * @param user
- * @param name
- * @param category
- * @param price
- */
- public Article(User user, String name, Category category, float price) {
- this.owner = user;
- this.name = name;
- this.category = category;
- this.price = price;
- }
-
- public User getOwner() {
- return owner;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public Category getCategory() {
- return category;
- }
-
- public File getMultimedia() {
- return multimedia;
- }
-
- public float getPrice() {
- return price;
- }
-
- /**
- * Set a new description
- * @param description
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * Set multimedia
- * @param multimedia
- */
- public void setMultimedia(File multimedia) {
- this.multimedia = multimedia;
- }
-
- @Override
- public String toString() {
- return name + " (" + category.getName() + "): " + Float.toString(price);
- }
-
-}
\ No newline at end of file
diff --git a/Week9/src/com/camilstaps/shop/CLIInteraction.java b/Week9/src/com/camilstaps/shop/CLIInteraction.java
deleted file mode 100644
index cbf59ab..0000000
--- a/Week9/src/com/camilstaps/shop/CLIInteraction.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.io.InputStream;
-import java.io.PrintStream;
-import java.util.InputMismatchException;
-import java.util.Scanner;
-
-/**
- * Command Line Interface Interaction
- * @author Camil Staps, s4498062
- */
-public class CLIInteraction extends UserInteraction {
-
- private final Scanner in;
- private final PrintStream out;
-
- /**
- * Default is stdin and stdout
- */
- public CLIInteraction() {
- this(System.in, System.out);
- }
-
- /**
- * CLI interaction with custom input and outputstream
- * @param is
- * @param ps
- */
- public CLIInteraction(InputStream is, PrintStream ps) {
- in = new Scanner(is);
- out = ps;
- }
-
- @Override
- String getString() {
- return in.nextLine();
- }
-
- @Override
- public int getChoice(String question, String[] options) {
- out.println(question);
- int i = 1;
- for (String option : options) {
- out.println(" " + (i++) + " : " + option);
- }
- int selection = 0;
- boolean read = false;
- do {
- if (read) {
- out.println("Invalid option. Try again:");
- }
- try {
- selection = in.nextInt();
- } catch (InputMismatchException ex) {
- }
- in.nextLine();
- read = true;
- } while (selection < 1 || selection > options.length);
- return selection - 1;
- }
-
- @Override
- void putString(String string) {
- out.print(string);
- }
-
- @Override
- Command getCommand() {
- putString("► ");
- return new Command(getString());
- }
-
- @Override
- float getFloat() {
- float result = in.nextFloat();
- in.nextLine();
- return result;
- }
-
- @Override
- boolean getBoolean() {
- putString(" (yes/no) ");
- String result;
- do {
- result = in.nextLine();
- } while (!result.equalsIgnoreCase("yes") && !result.equalsIgnoreCase("no"));
- return result.equalsIgnoreCase("yes");
- }
-}
\ No newline at end of file
diff --git a/Week9/src/com/camilstaps/shop/Cart.java b/Week9/src/com/camilstaps/shop/Cart.java
deleted file mode 100644
index 74f6ccd..0000000
--- a/Week9/src/com/camilstaps/shop/Cart.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A Cart holds the articles a User is planning to buy.
- * @author Camil Staps, s4498062
- */
-public class Cart implements Serializable {
-
- private final Set articles = new HashSet<>();
-
- public Set getArticles() {
- return articles;
- }
-
- /**
- * Get the total price of all articles
- * @return
- */
- public float getTotalAmount() {
- float result = 0;
- for (Article a : articles) {
- result += a.getPrice();
- }
- return result;
- }
-
- /**
- * Add a new article
- * @param article
- */
- public void add(Article article) {
- Database.getInstance().removeItem(article);
- articles.add(article);
- }
-
- /**
- * Remove an article (and put it back in the database)
- * @param article
- */
- public void remove(Article article) {
- articles.remove(article);
- try {
- Database.getInstance().addItem(article);
- } catch (DuplicateEntryException ex) {
- }
- }
-
- /**
- * Remove all articles in the manner of remove()
- * @see self#remove
- */
- public void reset() {
- for (Article a : articles) {
- remove(a);
- }
- }
-
-}
\ No newline at end of file
diff --git a/Week9/src/com/camilstaps/shop/Category.java b/Week9/src/com/camilstaps/shop/Category.java
deleted file mode 100644
index 05c247c..0000000
--- a/Week9/src/com/camilstaps/shop/Category.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-/**
- * A Category for Articles
- * @author Camil Staps, s4498062
- */
-public class Category extends DatabaseItem {
-
- private final String name;
-
- /**
- * Create a new Category
- * @param name
- */
- public Category(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
-}
\ No newline at end of file
diff --git a/Week9/src/com/camilstaps/shop/Command.java b/Week9/src/com/camilstaps/shop/Command.java
deleted file mode 100644
index b4694c0..0000000
--- a/Week9/src/com/camilstaps/shop/Command.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-/**
- * A Command is something that can be executed by a normal visitor, a User or an Administrator.
- * The current version only holds one string as command, but later versions could include arguments.
- * @author Camil Staps, s4498062
- */
-public class Command {
-
- private final String command;
-
- public Command(String command) {
- this.command = command;
- }
-
- public String getCommand() {
- return command;
- }
-
-}
diff --git a/Week9/src/com/camilstaps/shop/Database.java b/Week9/src/com/camilstaps/shop/Database.java
deleted file mode 100644
index 8344bca..0000000
--- a/Week9/src/com/camilstaps/shop/Database.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * The Shop database
- * @author Camil Staps, s4498062
- */
-public class Database {
-
- /**
- * This is a singleton
- */
- private static Database instance;
-
- /**
- * Keep the database in working memory during runtime
- */
- private Set users;
- private Set articles;
- private Set categories;
- private Set orders;
-
- /**
- * Files to store the database
- * Considering backups, it's nicer to have different objects stored in
- * different files, so that if the Orders file breaks, we still have the
- * Users, etc.
- */
- private final File FILE_DB = new File("./db");
- private final File FILE_USERS = new File("./db/users.db");
- private final File FILE_ARTICLES = new File("./db/articles.db");
- private final File FILE_CATEGORIES = new File("./db/categories.db");
- private final File FILE_ORDERS = new File("./db/orders.db");
-
- /**
- * Don't use this constructor. This is a singleton: use getInstance() instead.
- * @see self#getInstance()
- */
- public Database() {
- if (!FILE_DB.exists())
- FILE_DB.mkdir();
-
- readUsers();
- readArticles();
- readCategories();
- readOrders();
- }
-
- /**
- * Get an instance of the database. This is a singleton.
- * @return the database
- */
- public static Database getInstance() {
- if (instance == null) {
- instance = new Database();
- }
- return instance;
- }
-
- /**
- * Add an item to the database
- * @param item the item
- * @throws com.camilstaps.shop.DuplicateEntryException
- * @throws ClassCastException if the item to remove is not a DatabaseItem
- */
- public void addItem(DatabaseItem item) throws DuplicateEntryException {
- if (item instanceof User) {
- if (isUserExists(((User) item).getNr())) {
- throw new DuplicateEntryException();
- }
- users.add((User) item);
- } else if (item instanceof Article) {
- if (isArticleExists(((Article) item).getName())) {
- throw new DuplicateEntryException();
- }
- articles.add((Article) item);
- } else if (item instanceof Category) {
- if (isCategoryExists(((Category) item).getName())) {
- throw new DuplicateEntryException();
- }
- categories.add((Category) item);
- } else if (item instanceof Order) {
- orders.add((Order) item);
- } else {
- throw new ClassCastException();
- }
- }
-
- /**
- * Remove an item from the database
- * @param item the item to remove
- * @throws ClassCastException if the item to remove is not a DatabaseItem
- */
- public void removeItem(DatabaseItem item) {
- if (item instanceof User) {
- users.remove((User) item);
- } else if (item instanceof Article) {
- articles.remove((Article) item);
- } else if (item instanceof Category) {
- categories.remove((Category) item);
- } else if (item instanceof Order) {
- orders.remove((Order) item);
- } else {
- throw new ClassCastException();
- }
- }
-
- /**
- * Save the database to the filesystem.
- * @return true on success, false on failure
- */
- public boolean write() {
- return writeUsers() && writeArticles() && writeCategories() && writeOrders();
- }
-
- /**
- * Check if there exists a user with a certain U/S-number
- * @param nr
- * @return
- */
- public boolean isUserExists(String nr) {
- for (User user : users) {
- if (user.getNr().equals(nr)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check if an article with a name exists
- * @param name
- * @return
- */
- public boolean isArticleExists(String name) {
- for (Article article : articles) {
- if (article.getName().equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check if a category with a name exists
- * @param name
- * @return
- */
- public boolean isCategoryExists(String name) {
- for (Category category : categories) {
- if (category.getName().equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Get the set of users
- * @return
- */
- public Set getUsers() {
- return users;
- }
-
- /**
- * Get the set of articles
- * @return
- */
- public Set getArticles() {
- return articles;
- }
-
- /**
- * Get the set of categories
- * @return
- */
- public Set getCategories() {
- return categories;
- }
-
- /**
- * Get an array of the names of the categories
- * @return
- */
- public String[] getCategoryNames() {
- String[] categoryNames = new String[categories.size()];
- int i = 0;
- for (Category c : categories) {
- categoryNames[i++] = c.getName();
- }
- return categoryNames;
- }
-
- /**
- * Get the set of orders
- * @return
- */
- public Set getOrders() {
- return orders;
- }
-
- /**
- * Get the set of articles of which the name or description matches a regular expression
- * @param p the regular expression
- * @return
- */
- public Set searchArticle(Pattern p) {
- Set result = new HashSet<>();
- for (Article a : articles) {
- if (p.matcher(a.getName()).find() || p.matcher(a.getDescription()).find()) {
- result.add(a);
- }
- }
- return result;
- }
-
- /**
- * Get a user by his number
- * @param number
- * @return
- * @throws com.camilstaps.shop.ItemNotFoundException
- */
- public User getUser(String number) throws ItemNotFoundException {
- for (User u : users) {
- if (u.getNr().equals(number)) {
- return u;
- }
- }
- throw new ItemNotFoundException();
- }
-
- /**
- * Get an article by its name
- * @param name
- * @return
- * @throws ItemNotFoundException
- */
- public Article getArticle(String name) throws ItemNotFoundException {
- for (Article a : articles) {
- if (a.getName().equals(name)) {
- return a;
- }
- }
- throw new ItemNotFoundException();
- }
-
- /**
- * Get a category by a name
- * @param name
- * @return
- */
- public Category getCategory(String name) throws ItemNotFoundException {
- for (Category c : categories) {
- if (c.getName().equals(name)) {
- return c;
- }
- }
- throw new ItemNotFoundException();
- }
-
- /**
- * Read the users from the database into RAM
- */
- private void readUsers() {
- users = new HashSet<>();
- try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_USERS))) {
- users = (Set) in.readObject();
- in.close();
- } catch (FileNotFoundException ex) {
- } catch (IOException | ClassNotFoundException ex) {
- }
- }
-
- /**
- * Read the articles from the database into RAM
- */
- private void readArticles() {
- articles = new HashSet<>();
- try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_ARTICLES))) {
- articles = (Set) in.readObject();
- in.close();
- } catch (FileNotFoundException ex) {
- } catch (IOException | ClassNotFoundException ex) {
- }
- }
-
- /**
- * Read the categories from the database into RAM
- */
- private void readCategories() {
- categories = new HashSet<>();
- try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_CATEGORIES))) {
- categories = (Set) in.readObject();
- in.close();
- } catch (FileNotFoundException ex) {
- } catch (IOException | ClassNotFoundException ex) {
- }
- }
-
- /**
- * Read the orders from the database into RAM
- */
- private void readOrders() {
- orders = new HashSet<>();
- try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(FILE_ORDERS))) {
- orders = (Set) in.readObject();
- in.close();
- } catch (FileNotFoundException ex) {
- } catch (IOException | ClassNotFoundException ex) {
- }
- }
-
- /**
- * Write the users from RAM to the database
- */
- private boolean writeUsers() {
- System.err.println("Saving users...");
-
- try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_USERS))) {
- out.writeObject(users);
- out.close();
- return true;
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- return false;
- }
-
- /**
- * Write the articles from RAM to the database
- */
- private boolean writeArticles() {
- System.err.println("Saving articles...");
-
- try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_ARTICLES))) {
- out.writeObject(articles);
- out.close();
- return true;
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- return false;
- }
-
- /**
- * Write the categories from RAM to the database
- */
- private boolean writeCategories() {
- System.err.println("Saving categories...");
-
- try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_CATEGORIES))) {
- out.writeObject(categories);
- out.close();
- return true;
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- return false;
- }
-
- /**
- * Write the orders from RAM to the database
- */
- private boolean writeOrders() {
- System.err.println("Saving orders...");
-
- try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FILE_ORDERS))) {
- out.writeObject(orders);
- out.close();
- return true;
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- return false;
- }
-
-}
\ No newline at end of file
diff --git a/Week9/src/com/camilstaps/shop/DatabaseItem.java b/Week9/src/com/camilstaps/shop/DatabaseItem.java
deleted file mode 100644
index 0cbe661..0000000
--- a/Week9/src/com/camilstaps/shop/DatabaseItem.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.io.Serializable;
-
-/**
- * DatabaseItem is a general class for anything that is stored in the Database
- * @author Camil Staps, s4498062
- */
-public class DatabaseItem implements Serializable {
-}
\ No newline at end of file
diff --git a/Week9/src/com/camilstaps/shop/DuplicateEntryException.java b/Week9/src/com/camilstaps/shop/DuplicateEntryException.java
deleted file mode 100644
index a91d7c7..0000000
--- a/Week9/src/com/camilstaps/shop/DuplicateEntryException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-/**
- * This Exception is thrown when an attempt is made to add a DatabaseItem to the
- * Database which gives a uniqueness conflict, such as:
- * * An article with the same name exists
- * * A category with the same name exists
- * * A user with the same number exists
- *
- * @author Camil Staps, s4498062
- */
-public class DuplicateEntryException extends Exception {
-}
diff --git a/Week9/src/com/camilstaps/shop/InputRequiredException.java b/Week9/src/com/camilstaps/shop/InputRequiredException.java
deleted file mode 100644
index ca0110d..0000000
--- a/Week9/src/com/camilstaps/shop/InputRequiredException.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-/**
- * This Exception is thrown when required input was omitted by the user.
- * @author Camil Staps, s4498062
- */
-public class InputRequiredException extends Exception {
-}
diff --git a/Week9/src/com/camilstaps/shop/ItemNotFoundException.java b/Week9/src/com/camilstaps/shop/ItemNotFoundException.java
deleted file mode 100644
index 5122d79..0000000
--- a/Week9/src/com/camilstaps/shop/ItemNotFoundException.java
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-/**
- * This error is thrown when an attempt is made to instantiate an object with a
- * non-existing name, number, etc.
- * @author Camil Staps, s4498062
- */
-public class ItemNotFoundException extends Exception {
-}
diff --git a/Week9/src/com/camilstaps/shop/Order.java b/Week9/src/com/camilstaps/shop/Order.java
deleted file mode 100644
index 2b0c5a7..0000000
--- a/Week9/src/com/camilstaps/shop/Order.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * An order is a set of articles, purchased by a user
- * @author Camil Staps, s4498062
- */
-public class Order extends DatabaseItem {
-
- private final Set articles;
- private final User user;
- private boolean paid = false;
-
- /**
- * This constructor takes the articles from the Cart of the User, and clears
- * that Cart afterwards.
- * @param user
- */
- public Order(User user) {
- this.user = user;
- articles = new HashSet<>();
- for (Article a : user.getCart().getArticles()) {
- articles.add(a);
- }
- user.getCart().getArticles().clear();
- }
-
- public User getUser() {
- return user;
- }
-
- public Set getArticles() {
- return articles;
- }
-
- public void setPaid(boolean set) {
- paid = set;
- }
-
- /**
- * See whether payment has been received for this article already
- * @return
- */
- public boolean isPaid() {
- return paid;
- }
-
- /**
- * Get the total price of all articles
- * @return
- */
- public float getTotalAmount() {
- float result = 0;
- for (Article a : articles) {
- result += a.getPrice();
- }
- return result;
- }
-
-}
diff --git a/Week9/src/com/camilstaps/shop/Shell.java b/Week9/src/com/camilstaps/shop/Shell.java
deleted file mode 100644
index 7939963..0000000
--- a/Week9/src/com/camilstaps/shop/Shell.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * Executing commands and providing output, using a UserInteraction and acting
- * on a Database.
- * @author Camil Staps, s4498062
- */
-public class Shell {
-
- /**
- * The Database to work with
- */
- private final Database database;
- /**
- * The UserInteraction to use
- */
- private final UserInteraction ui;
-
- /**
- * The current User, if logged in
- */
- private User user;
-
- public Shell(UserInteraction userInteraction) {
- this.database = Database.getInstance();
- this.ui = userInteraction;
- }
-
- /**
- * Request commands, execute them, and show the results
- */
- public void run() {
- while (true) {
- Command command = ui.getCommand();
- try {
- Method method = getClass().getMethod("exec" + command.getCommand().substring(0,1).toUpperCase() + command.getCommand().substring(1));
- method.invoke(this);
-
- if (command.getCommand().equalsIgnoreCase("exit")) {
- return;
- }
- } catch (NoSuchMethodException ex) {
- ui.putStringln("Failure: no such command");
- } catch (InvocationTargetException ex) {
- ui.putStringln("Failure: " + ex.getCause().toString());
- } catch (SecurityException | IllegalAccessException | IllegalArgumentException ex) {
- ui.putStringln("Failure: unknown error");
- }
- }
- }
-
- /**
- * Require that the visitor logs in
- * @throws com.camilstaps.shop.Shell.LoginRequiredException if the visitor fails to login
- * @throws ItemNotFoundException if the visitor tries to login with a non-existing User number
- */
- public void requireLogin() throws LoginRequiredException, ItemNotFoundException {
- if (user == null) {
- ui.putStringln("You must login first.");
-
- try {
- execLogin();
- } catch (InputRequiredException ex) {
- }
-
- if (user == null) {
- throw new LoginRequiredException();
- }
- }
- }
-
- /**
- * Require that an administrator is logged in
- * @throws com.camilstaps.shop.Shell.AdminRequiredException if the visitor fails to login, or is not an administrator
- * @throws ItemNotFoundException if the visitor tries to login with a non-existing User number
- */
- public void requireAdmin() throws AdminRequiredException, ItemNotFoundException {
- if (user == null || !user.isAdmin()) {
- ui.putStringln("You must login as an administrator first.");
-
- try {
- execLogin();
- } catch (InputRequiredException ex) {
- }
-
- if (user == null || !user.isAdmin()) {
- throw new AdminRequiredException();
- }
- }
- }
-
- /**
- * Command: add an article
- * @throws DuplicateEntryException
- * @throws InputRequiredException
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- */
- public void execAddArticle() throws DuplicateEntryException, InputRequiredException, LoginRequiredException, ItemNotFoundException {
- requireLogin();
-
- String name = ui.getRequiredString("Name: ");
- Category category = ui.getCategory();
- float price = ui.getFloat("Price: ");
-
- Article a = new Article(user, name, category, price);
- database.addItem(a);
- }
-
- /**
- * Command: set the article description
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- * @throws InputRequiredException
- */
- public void execSetArticleDescription() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
- requireLogin();
-
- Article a;
- if (user.isAdmin()) {
- a = ui.getArticle();
- } else {
- a = ui.getArticle(user);
- }
-
- a.setDescription(ui.getRequiredString("Description: "));
- }
-
- /**
- * Command: set the multimedia linked to an article
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- * @throws InputRequiredException
- */
- public void execSetArticleMultimedia() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
- requireLogin();
-
- Article a;
- if (user.isAdmin()) {
- a = ui.getArticle();
- } else {
- a = ui.getArticle(user);
- }
-
- a.setMultimedia(new File(ui.getRequiredString("Multimedia: ")));
- }
-
- /**
- * Command: remove an article
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- * @throws InputRequiredException
- */
- public void execRemoveArticle() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
- requireLogin();
-
- Article a;
- if (user.isAdmin()) {
- a = ui.getArticle();
- } else {
- a = ui.getArticle(user);
- }
-
- database.removeItem(a);
- }
-
- /**
- * Command: show a list of articles
- */
- public void execListArticles() {
- for (Article a : database.getArticles()) {
- ui.putStringln(a.toString());
- }
- }
-
- /**
- * Command: search for an article
- */
- public void execSearchArticle() {
- String regex = ui.getString("Keywords: ");
- for (Article a : database.searchArticle(Pattern.compile(regex))) {
- ui.putStringln(a.toString());
- }
- }
-
- /**
- * Command: show detailed data about an article
- * @throws InputRequiredException
- * @throws ItemNotFoundException
- */
- public void execShowArticle() throws InputRequiredException, ItemNotFoundException {
- Article a = ui.getArticle();
- ui.putStringln(a.toString());
- if (a.getDescription() != null) {
- ui.putStringln(a.getDescription());
- }
- File multimedia = a.getMultimedia();
- if (multimedia != null) {
- ui.putStringln("Multimedia: " + multimedia.getPath());
- }
- if (user != null && user.isAdmin()) {
- ui.putStringln("User: " + a.getOwner().toString(true));
- }
- }
-
- /**
- * Command: add a category
- * @throws DuplicateEntryException
- * @throws InputRequiredException
- * @throws com.camilstaps.shop.Shell.AdminRequiredException
- * @throws ItemNotFoundException
- */
- public void execAddCategory() throws DuplicateEntryException, InputRequiredException, AdminRequiredException, ItemNotFoundException {
- requireAdmin();
-
- String name = ui.getRequiredString("Name: ");
- database.addItem(new Category(name));
- }
-
- /**
- * Command: list categories
- */
- public void execListCategories() {
- for (String c : database.getCategoryNames()) {
- ui.putStringln(c);
- }
- }
-
- /**
- * Command: list users
- * Administrators see a more detailed list
- */
- public void execListUsers() {
- for (User u : database.getUsers()) {
- ui.putStringln(u.toString(user != null && user.isAdmin()));
- }
- }
-
- /**
- * Command: register a new user
- * @throws DuplicateEntryException
- * @throws InputRequiredException
- */
- public void execRegister() throws DuplicateEntryException, InputRequiredException {
- boolean addAsAdmin = false;
-
- if (database.getUsers().isEmpty()) {
- addAsAdmin = true;
- ui.putStringln("This is the first user and will therefore be added as administrator.");
- } else if (user != null && user.isAdmin()) {
- addAsAdmin = ui.getBoolean("Add user as administrator");
- }
-
- String nr = ui.getRequiredString("Number: ");
- String email = ui.getRequiredString("Email: ");
-
- User u = new User(nr, email, addAsAdmin);
-
- String password = u.setRandomPassword();
- ui.putStringln("Password: " + password);
-
- database.addItem(u);
- }
-
- /**
- * Command: login
- * @throws InputRequiredException
- * @throws ItemNotFoundException
- */
- public void execLogin() throws InputRequiredException, ItemNotFoundException {
- if (user != null) {
- ui.putStringln("You are already logged in.");
- return;
- }
-
- User u = ui.getUser();
- String pw = ui.getRequiredString("Password: ");
-
- if (!u.verify(pw)) {
- ui.putStringln("Failed to login.");
- return;
- }
-
- if (u.isBlocked()) {
- ui.putStringln("You are blocked.");
- return;
- }
-
- user = u;
- }
-
- /**
- * Command: logout
- */
- public void execLogout() {
- user = null;
- }
-
- /**
- * Command: add an article to the cart
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- * @throws InputRequiredException
- */
- public void execAddToCart() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
- requireLogin();
-
- user.getCart().add(ui.getArticle());
- }
-
- /**
- * Command: remove an article from the cart
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- */
- public void execRemoveFromCart() throws LoginRequiredException, ItemNotFoundException {
- requireLogin();
-
- user.getCart().remove(ui.getArticle(user.getCart().getArticles()));
- }
-
- /**
- * Command: list articles in the cart
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- */
- public void execListCart() throws LoginRequiredException, ItemNotFoundException {
- requireLogin();
-
- for (Article a : user.getCart().getArticles()) {
- ui.putStringln(a.toString());
- }
-
- ui.putStringln("Total value: " + user.getCart().getTotalAmount());
- }
-
- /**
- * Command: remove all articles from the cart
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- */
- public void execClearCart() throws LoginRequiredException, ItemNotFoundException {
- requireLogin();
-
- if (ui.getBoolean("Are you sure?")) user.getCart().reset();
- }
-
- /**
- * Command: checkout (create an Order using the current Cart)
- * @throws ItemNotFoundException
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws DuplicateEntryException
- */
- public void execCheckout() throws ItemNotFoundException, LoginRequiredException, DuplicateEntryException {
- requireLogin();
-
- if (user.getCart().getArticles().isEmpty()) {
- throw new ItemNotFoundException();
- }
-
- ui.putStringln("By checking out, you agree to pay the total amount.");
- if (!ui.getBoolean("Do you agree?"))
- return;
-
- Order order = new Order(user);
- database.addItem(order);
-
- ui.putStringln("Your order has been added as " + order.toString());
- }
-
- /**
- * Command: list orders
- * @throws ItemNotFoundException
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- */
- public void execListOrders() throws ItemNotFoundException, LoginRequiredException {
- requireLogin();
-
- Set orders;
- if (user.isAdmin()) {
- orders = database.getOrders();
- } else {
- orders = user.getOrders();
- }
- for (Order o : orders) {
- ui.putStringln(o.toString());
- }
- }
-
- /**
- * Command: show detailed information about an order
- * @throws com.camilstaps.shop.Shell.LoginRequiredException
- * @throws ItemNotFoundException
- * @throws InputRequiredException
- */
- public void execShowOrder() throws LoginRequiredException, ItemNotFoundException, InputRequiredException {
- requireLogin();
-
- Order o;
- if (user.isAdmin()) {
- o = ui.getOrder();
- } else {
- o = ui.getOrder(user);
- }
- ui.putStringln(o.toString());
- for (Article a : o.getArticles()) {
- ui.putStringln(" " + a.toString());
- }
- ui.putStringln("Total amount: " + o.getTotalAmount());
- ui.putStringln("Paid: " + (o.isPaid() ? "yes" : "no"));
- }
-
- /**
- * Command: set the paid status of an Order to true
- * @throws com.camilstaps.shop.Shell.AdminRequiredException
- * @throws ItemNotFoundException
- * @throws InputRequiredException
- */
- public void execSetOrderPaid() throws AdminRequiredException, ItemNotFoundException, InputRequiredException {
- requireAdmin();
- ui.getOrder().setPaid(true);
- }
-
- /**
- * Command: block a user
- * @throws InputRequiredException
- * @throws ItemNotFoundException
- * @throws com.camilstaps.shop.Shell.AdminRequiredException
- */
- public void execBlockUser() throws InputRequiredException, ItemNotFoundException, AdminRequiredException {
- requireAdmin();
- ui.getUser().setBlocked(true);
- }
-
- /**
- * Command: unblock a user
- * @throws InputRequiredException
- * @throws ItemNotFoundException
- * @throws com.camilstaps.shop.Shell.AdminRequiredException
- */
- public void execUnblockUser() throws InputRequiredException, ItemNotFoundException, AdminRequiredException {
- requireAdmin();
- ui.getUser().setBlocked(false);
- }
-
- /**
- * Command: save the database
- */
- public void execExit() {
- database.write();
- }
-
- /**
- * This Exception is thrown when the visitor is required to login, but fails
- */
- private class LoginRequiredException extends Exception {
- }
-
- /**
- * This Exception is thrown when the visitor is required to login as an administrator, but fails
- */
- private class AdminRequiredException extends Exception {
- }
-
-}
diff --git a/Week9/src/com/camilstaps/shop/Shop.java b/Week9/src/com/camilstaps/shop/Shop.java
deleted file mode 100644
index cab828a..0000000
--- a/Week9/src/com/camilstaps/shop/Shop.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-/**
- * The webshop
- * @author Camil Staps, s4498062
- */
-public class Shop {
-
- /**
- * Create a shell and run
- * @param args
- */
- public static void main(String[] args) {
- Shell sh = new Shell(new CLIInteraction());
- sh.run();
- }
-
-}
diff --git a/Week9/src/com/camilstaps/shop/User.java b/Week9/src/com/camilstaps/shop/User.java
deleted file mode 100644
index 12cfd4d..0000000
--- a/Week9/src/com/camilstaps/shop/User.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.util.HashSet;
-import java.util.Random;
-import java.util.Set;
-
-/**
- * A User is a person with a U/S-number, email and password.
- * He may be blocked / be an admin, and has a Cart.
- * @author Camil Staps, s4498062
- */
-public class User extends DatabaseItem {
-
- private final String nr;
- private final String email;
- private String hash;
- private final boolean isAdmin;
- private final Cart cart = new Cart();
- private boolean isBlocked = false;
-
- public User (String nr, String email) {
- this.nr = nr;
- this.email = email;
- this.isAdmin = false;
- }
-
- public User (String nr, String email, boolean isAdmin) {
- this.nr = nr;
- this.email = email;
- this.isAdmin = isAdmin;
- }
-
- public String getNr() {
- return nr;
- }
-
- public String getEmail() {
- return email;
- }
-
- public boolean isAdmin() {
- return isAdmin;
- }
-
- public Cart getCart() {
- return cart;
- }
-
- public void setBlocked(boolean set) {
- isBlocked = set;
- }
-
- public boolean isBlocked() {
- return isBlocked;
- }
-
- public Set getArticles() {
- Set articles = Database.getInstance().getArticles();
- Set result = new HashSet<>();
- for (Article a : articles) {
- if (a.getOwner().getNr().equals(nr)) {
- result.add(a);
- }
- }
- return result;
- }
-
- public Set getOrders() {
- Set orders = Database.getInstance().getOrders();
- Set result = new HashSet<>();
- for (Order o : orders) {
- if (o.getUser().getNr().equals(nr)) {
- result.add(o);
- }
- }
- return result;
- }
-
- /**
- * Set a random new password for the user
- * @return the new password
- */
- public String setRandomPassword() {
- String pw = generatePassword();
- hash = hash(pw);
- return pw;
- }
-
- /**
- * Hash a password. Currently, this is just the identity function.
- * @param password
- * @return
- */
- public static String hash(String password) {
- return password;
- }
-
- /**
- * Generate a random password
- * @return
- */
- private static String generatePassword() {
- // Only characters that cannot easily be confused
- final String drawFrom = "123456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
- final Random r = new Random();
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < 12; i++) {
- sb.append(drawFrom.charAt(r.nextInt(drawFrom.length())));
- }
-
- return sb.toString();
- }
-
- /**
- * Verify if a password matches the user's password
- * @param password the password to check
- * @return
- */
- public boolean verify(String password) {
- return hash(password).equals(hash);
- }
-
- @Override
- public String toString() {
- return (isAdmin ? "++ " : "") + nr + " (" + email + ")" + (isBlocked ? " -!-" : "");
- }
-
- /**
- * This User as a String, with a detailed and a quick view
- * @param showSensitive whether to show sensitive data (email, isAdmin, isBlocked) or not
- * @return
- */
- public String toString(boolean showSensitive) {
- return showSensitive ? toString() : nr;
- }
-
-}
\ No newline at end of file
diff --git a/Week9/src/com/camilstaps/shop/UserInteraction.java b/Week9/src/com/camilstaps/shop/UserInteraction.java
deleted file mode 100644
index 1140089..0000000
--- a/Week9/src/com/camilstaps/shop/UserInteraction.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * Copyright (c) 2015 Camil Staps
- * See the LICENSE file for copying permission.
- */
-
-package com.camilstaps.shop;
-
-import java.util.Set;
-
-/**
- * Interact with the user: provide and request information.
- * @author Camil Staps, s4498062
- */
-public abstract class UserInteraction {
-
- /**
- * Show a String
- * @param string
- */
- abstract void putString(String string);
-
- /**
- * Show a String with a linefeed
- * @param string
- */
- void putStringln(String string) {
- putString(string + System.lineSeparator());
- }
-
- /**
- * Get a String as input
- * @return
- */
- abstract String getString();
-
- /**
- * Get a String as input, after outputting a question
- * @param question
- * @return
- */
- String getString(String question) {
- putString(question);
- return getString();
- }
-
- /**
- * Get a String as input, and throw an Exception when it's empty
- * @return
- * @throws InputRequiredException
- */
- String getRequiredString() throws InputRequiredException {
- String result = getString();
- if (result.isEmpty()) throw new InputRequiredException();
- return result;
- }
-
- /**
- * Get a String as input, after outputting a question, and throw an
- * Exception when the input is empty
- * @param question
- * @return
- * @throws InputRequiredException
- */
- String getRequiredString(String question) throws InputRequiredException {
- putString(question);
- return getRequiredString();
- }
-
- /**
- * Get a float as input
- * @return
- */
- abstract float getFloat();
-
- /**
- * Get a float as input, after outputting a question
- * @param question
- * @return
- */
- float getFloat(String question) {
- putString(question);
- return getFloat();
- }
-
- /**
- * Get a boolean as input
- * @return
- */
- abstract boolean getBoolean();
-
- /**
- * Get a boolean as input, after outputting a question
- * @param question
- * @return
- */
- boolean getBoolean(String question) {
- putString(question);
- return getBoolean();
- }
-
- /**
- * Get a Command as input
- * @return
- */
- abstract Command getCommand();
-
- /**
- * Let the user choose from an array of options, after outputting a question
- * @param question
- * @param options
- * @return the index of the choice in the options array
- */
- abstract int getChoice(String question, String[] options);
-
- /**
- * Let the user choose from a Set of Articles
- * @param set
- * @return
- */
- Article getArticle(Set set) {
- String[] articleNames = new String[set.size()];
- Article[] articles = new Article[set.size()];
- int i = 0;
- for (Article a : set) {
- articleNames[i] = a.toString();
- articles[i++] = a;
- }
- return articles[getChoice("Article: ", articleNames)];
- }
-
- /**
- * Let the user choose an Article
- * @return
- * @throws InputRequiredException
- * @throws ItemNotFoundException
- */
- Article getArticle() throws InputRequiredException, ItemNotFoundException {
- String name = getRequiredString("Name article: ");
- return Database.getInstance().getArticle(name);
- }
-
- /**
- * Let the user choose an Article from the Articles of a specific User
- * @param user
- * @return
- */
- Article getArticle(User user) {
- return getArticle(user.getArticles());
- }
-
- /**
- * Let the user choose a category
- * @return
- * @throws ItemNotFoundException
- */
- Category getCategory() throws ItemNotFoundException {
- String[] categories = Database.getInstance().getCategoryNames();
- return Database.getInstance().getCategory(categories[getChoice("Category: ", categories)]);
- }
-
- /**
- * Let the user choose a User
- * @return
- * @throws InputRequiredException
- * @throws ItemNotFoundException
- */
- User getUser() throws InputRequiredException, ItemNotFoundException {
- return Database.getInstance().getUser(getRequiredString("Number user: "));
- }
-
- /**
- * Let the user choose an order
- * @return
- * @throws InputRequiredException
- * @throws ItemNotFoundException
- */
- Order getOrder() throws InputRequiredException, ItemNotFoundException {
- return getOrder(getUser());
- }
-
- /**
- * Let the user choose an order, from the orders of a specific User
- * @param user
- * @return
- */
- Order getOrder(User user) {
- Set orders = user.getOrders();
- String[] orderStrings = new String[orders.size()];
- Order[] orderObjects = new Order[orders.size()];
- int i = 0;
- for (Order o : orders) {
- orderStrings[i] = o.toString();
- orderObjects[i++] = o;
- }
- return orderObjects[getChoice("Order: ", orderStrings)];
- }
-
-}
\ No newline at end of file
diff --git a/Week9/uml-project.vpp b/Week9/uml-project.vpp
deleted file mode 100644
index 52763eb..0000000
Binary files a/Week9/uml-project.vpp and /dev/null differ
--
cgit v1.2.3