Package ejava.examples.blpurchase.blimpl
Class PurchasingImpl
- java.lang.Object
-
- ejava.examples.blpurchase.blimpl.PurchasingImpl
-
- All Implemented Interfaces:
Purchasing
public class PurchasingImpl extends Object implements Purchasing
This class implements basic logic used to implement the purchasing aspects of the application.
-
-
Field Summary
Fields Modifier and Type Field Description private EntityManager
em
private static org.slf4j.Logger
logger
private Random
random
-
Constructor Summary
Constructors Constructor Description PurchasingImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
checkout(String email, String password)
Completes the purchase of the items in the user's shopping cart, empties the cart, and returns the total cost paid.Account
createAccount(String email, String firstName, String lastName)
Creates an account for the user to use in purchasing products.private String
generatePassword()
void
setEntityManager(EntityManager em)
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
em
private EntityManager em
-
random
private Random random
-
-
Method Detail
-
setEntityManager
public void setEntityManager(EntityManager em)
-
createAccount
public Account createAccount(String email, String firstName, String lastName)
Description copied from interface:Purchasing
Creates an account for the user to use in purchasing products.- Specified by:
createAccount
in interfacePurchasing
- Returns:
- the Account created with primary key assigned
-
checkout
public double checkout(String email, String password)
Description copied from interface:Purchasing
Completes the purchase of the items in the user's shopping cart, empties the cart, and returns the total cost paid. Note that this capability is not yet fully defined.- Specified by:
checkout
in interfacePurchasing
- Returns:
- amount charged as part of this checkout
-
generatePassword
private String generatePassword()
-
-