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 EntityManageremprivate static org.slf4j.Loggerloggerprivate Randomrandom
-
Constructor Summary
Constructors Constructor Description PurchasingImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecheckout(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.AccountcreateAccount(String email, String firstName, String lastName)Creates an account for the user to use in purchasing products.private StringgeneratePassword()voidsetEntityManager(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:PurchasingCreates an account for the user to use in purchasing products.- Specified by:
createAccountin interfacePurchasing- Returns:
- the Account created with primary key assigned
-
checkout
public double checkout(String email, String password)
Description copied from interface:PurchasingCompletes 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:
checkoutin interfacePurchasing- Returns:
- amount charged as part of this checkout
-
generatePassword
private String generatePassword()
-
-