From 6a44b074f0169a1b0f9e92347af929c5e471746e Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 18 Apr 2015 13:44:44 +0200 Subject: Reorganised projects --- Week9/src/com/camilstaps/shop/Cart.java | 67 --------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 Week9/src/com/camilstaps/shop/Cart.java (limited to 'Week9/src/com/camilstaps/shop/Cart.java') 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 -- cgit v1.2.3