Guest User

Untitled

a guest
Nov 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. public boolean sellItem(int itemId, int customerId) {
  2. if (customers.contains(customerId) && items.contains(itemId)){
  3. for (Item i : items) {
  4. if(i.getItemId() == itemId && i.getStockNum()>0) {
  5. sales.add(new Sale(LocalDateTime.now(), itemId, customerId, i.getCost()));
  6. i.sell();
  7. }
  8. for (Customer c : customers) {
  9. if (c.getCustomerId() == customerId) {
  10. c.charge(i.getCost());
  11. }
  12. }
  13. }
  14. return true;
  15. }
  16. return false;
  17. }
Add Comment
Please, Sign In to add comment