diff options
author | Camil Staps | 2015-04-18 01:04:19 +0200 |
---|---|---|
committer | Camil Staps | 2015-04-18 01:04:19 +0200 |
commit | a62773f7dad7d62208b174b35fcde59c85db3913 (patch) | |
tree | 7359d0e3d60a55d9c053cb88e0e27b34d10ebadc /Week9/src/com/camilstaps/shop/Shell.java | |
parent | Week9 (diff) |
Cleanup, checked UML class diagram, added diagram to TeX
Diffstat (limited to 'Week9/src/com/camilstaps/shop/Shell.java')
-rw-r--r-- | Week9/src/com/camilstaps/shop/Shell.java | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/Week9/src/com/camilstaps/shop/Shell.java b/Week9/src/com/camilstaps/shop/Shell.java index 69d5207..7939963 100644 --- a/Week9/src/com/camilstaps/shop/Shell.java +++ b/Week9/src/com/camilstaps/shop/Shell.java @@ -51,11 +51,11 @@ public class Shell { return; } } catch (NoSuchMethodException ex) { - ui.putStringLn("Failure: no such command"); + ui.putStringln("Failure: no such command"); } catch (InvocationTargetException ex) { - ui.putStringLn("Failure: " + ex.getCause().toString()); + ui.putStringln("Failure: " + ex.getCause().toString()); } catch (SecurityException | IllegalAccessException | IllegalArgumentException ex) { - ui.putStringLn("Failure: unknown error"); + ui.putStringln("Failure: unknown error"); } } } @@ -67,7 +67,7 @@ public class Shell { */ public void requireLogin() throws LoginRequiredException, ItemNotFoundException { if (user == null) { - ui.putStringLn("You must login first."); + ui.putStringln("You must login first."); try { execLogin(); @@ -87,7 +87,7 @@ public class Shell { */ public void requireAdmin() throws AdminRequiredException, ItemNotFoundException { if (user == null || !user.isAdmin()) { - ui.putStringLn("You must login as an administrator first."); + ui.putStringln("You must login as an administrator first."); try { execLogin(); @@ -180,7 +180,7 @@ public class Shell { */ public void execListArticles() { for (Article a : database.getArticles()) { - ui.putStringLn(a.toString()); + ui.putStringln(a.toString()); } } @@ -190,7 +190,7 @@ public class Shell { public void execSearchArticle() { String regex = ui.getString("Keywords: "); for (Article a : database.searchArticle(Pattern.compile(regex))) { - ui.putStringLn(a.toString()); + ui.putStringln(a.toString()); } } @@ -201,16 +201,16 @@ public class Shell { */ public void execShowArticle() throws InputRequiredException, ItemNotFoundException { Article a = ui.getArticle(); - ui.putStringLn(a.toString()); + ui.putStringln(a.toString()); if (a.getDescription() != null) { - ui.putStringLn(a.getDescription()); + ui.putStringln(a.getDescription()); } File multimedia = a.getMultimedia(); if (multimedia != null) { - ui.putStringLn("Multimedia: " + multimedia.getPath()); + ui.putStringln("Multimedia: " + multimedia.getPath()); } if (user != null && user.isAdmin()) { - ui.putStringLn("User: " + a.getUser().toString(true)); + ui.putStringln("User: " + a.getOwner().toString(true)); } } @@ -233,7 +233,7 @@ public class Shell { */ public void execListCategories() { for (String c : database.getCategoryNames()) { - ui.putStringLn(c); + ui.putStringln(c); } } @@ -243,7 +243,7 @@ public class Shell { */ public void execListUsers() { for (User u : database.getUsers()) { - ui.putStringLn(u.toString(user != null && user.isAdmin())); + ui.putStringln(u.toString(user != null && user.isAdmin())); } } @@ -257,7 +257,7 @@ public class Shell { if (database.getUsers().isEmpty()) { addAsAdmin = true; - ui.putStringLn("This is the first user and will therefore be added as administrator."); + 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"); } @@ -268,7 +268,7 @@ public class Shell { User u = new User(nr, email, addAsAdmin); String password = u.setRandomPassword(); - ui.putStringLn("Password: " + password); + ui.putStringln("Password: " + password); database.addItem(u); } @@ -280,7 +280,7 @@ public class Shell { */ public void execLogin() throws InputRequiredException, ItemNotFoundException { if (user != null) { - ui.putStringLn("You are already logged in."); + ui.putStringln("You are already logged in."); return; } @@ -288,12 +288,12 @@ public class Shell { String pw = ui.getRequiredString("Password: "); if (!u.verify(pw)) { - ui.putStringLn("Failed to login."); + ui.putStringln("Failed to login."); return; } if (u.isBlocked()) { - ui.putStringLn("You are blocked."); + ui.putStringln("You are blocked."); return; } @@ -339,10 +339,10 @@ public class Shell { requireLogin(); for (Article a : user.getCart().getArticles()) { - ui.putStringLn(a.toString()); + ui.putStringln(a.toString()); } - ui.putStringLn("Total value: " + user.getCart().getTotalAmount()); + ui.putStringln("Total value: " + user.getCart().getTotalAmount()); } /** @@ -369,14 +369,14 @@ public class Shell { throw new ItemNotFoundException(); } - ui.putStringLn("By checking out, you agree to pay the total amount."); + 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()); + ui.putStringln("Your order has been added as " + order.toString()); } /** @@ -394,7 +394,7 @@ public class Shell { orders = user.getOrders(); } for (Order o : orders) { - ui.putStringLn(o.toString()); + ui.putStringln(o.toString()); } } @@ -413,12 +413,12 @@ public class Shell { } else { o = ui.getOrder(user); } - ui.putStringLn(o.toString()); + ui.putStringln(o.toString()); for (Article a : o.getArticles()) { - ui.putStringLn(" " + a.toString()); + ui.putStringln(" " + a.toString()); } - ui.putStringLn("Total amount: " + o.getTotalAmount()); - ui.putStringLn("Paid: " + (o.isPaid() ? "yes" : "no")); + ui.putStringln("Total amount: " + o.getTotalAmount()); + ui.putStringln("Paid: " + (o.isPaid() ? "yes" : "no")); } /** |