Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean sellItem(int itemId, int customerId) {
- if (customers.contains(customerId) && items.contains(itemId)){
- for (Item i : items) {
- if(i.getItemId() == itemId && i.getStockNum()>0) {
- sales.add(new Sale(LocalDateTime.now(), itemId, customerId, i.getCost()));
- i.sell();
- }
- for (Customer c : customers) {
- if (c.getCustomerId() == customerId) {
- c.charge(i.getCost());
- }
- }
- }
- return true;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment