/** * 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().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; } }