@@ -179,14 +189,14 @@ public class RetailStoreService implements RetailStore, ProductFilter {
if(!addProductToCart(cart,product,connection)){
continue;
}else{
Utility.getLogger().info("\n-----------------------------\nYour product : "+product.getName()+" is added to your cart.\n-----------------------------\n");
log.info("\n-----------------------------\nYour product : "+product.getName()+" is added to your cart.\n-----------------------------\n");
}
booleanmenuFlag=true;
Utility.getLogger().info("\n-----------------------------\nPlease enter 1 - to continue the shopping"+
log.info("\n-----------------------------\nPlease enter 1 - to continue the shopping"+
"\n-----------------------------\nEnter 2 to place the order"+
"\n-----------------------------\nEnter 3 to go back");
while(menuFlag){
intorder=Utility.getInt();
intorder=InputUtil.validateInputNumber();
switch(order){
case1:
categoryBoolean=false;
...
...
@@ -207,7 +217,7 @@ public class RetailStoreService implements RetailStore, ProductFilter {
orderBoolean=false;
break;
default:
Utility.getLogger().info("\n-----------------------------\nPlease enter valid option\n-----------------------------\n");
log.info("\n-----------------------------\nPlease enter valid option\n-----------------------------\n");
createOrder(connection);
}
}
...
...
@@ -220,36 +230,35 @@ public class RetailStoreService implements RetailStore, ProductFilter {
Utility.getLogger().info("\n-----------------------------\nSorry to say this. Currently this product was out of stock.\n-----------------------------\n");
log.info("\n-----------------------------\nSorry to say this. Currently this product was out of stock.\n-----------------------------\n");
Utility.getLogger().warning("\n-----------------------------\nplease enter quantity less or equal to the stock available\n-----------------------------\n");
log.warning("\n-----------------------------\nplease enter quantity less or equal to the stock available\n-----------------------------\n");
returnaddProductToCart(cart,product,connection);
}
}
...
...
@@ -258,24 +267,23 @@ public class RetailStoreService implements RetailStore, ProductFilter {
Utility.getLogger().warning("\n-----------------------------\ngot error while fetching the gender. please try again\n-----------------------------\n");
log.warning(e.getMessage());
log.warning("\n-----------------------------\ngot error while fetching the gender. please try again\n-----------------------------\n");
returngetCategoriesByGender(gender);
}
if(categoryMap.isEmpty()){
Utility.getLogger().info("\n-----------------------------\nCategories not found in "+gender+"\n-----------------------------\n");
log.info("\n-----------------------------\nCategories not found in "+gender+"\n-----------------------------\n");
Utility.getLogger().warning("\n-----------------------------\ngot error while fetching the gender. please try again\n-----------------------------\n");
log.warning(e.getMessage());
log.warning("\n-----------------------------\ngot error while fetching the gender. please try again\n-----------------------------\n");
Utility.getLogger().warning("\n-----------------------------\ngot error while fetching the gender. please try again\n-----------------------------\n");
log.warning(e.getMessage());
log.warning("\n-----------------------------\ngot error while fetching the gender. please try again\n-----------------------------\n");
@@ -339,29 +345,29 @@ public class RetailStoreService implements RetailStore, ProductFilter {
@Override
publicvoidshowOrders(){
booleanorderSelectFlag=true;
Connectionconnection=Database.getConnection();
Connectionconnection=DBUtil.getConnection();
while(orderSelectFlag){
Map<Integer,Order>orders=getOrders(connection);
StringorderMenu=orders.entrySet().stream().map(entry->entry.getKey()+". "+entry.getValue().getOrderId()+"\t"+entry.getValue().getCustomerName()).reduce((allorders,order)->allorders+"\n"+order).orElse("\n----------\nNo orders currently in your orders list");
Utility.getLogger().info(orderMenu);
Utility.getLogger().info("\n-----------------------------\nEnter 0 to go back.\n-----------------------------\n");
Utility.getLogger().info("\n-----------------------------\nSelect order from the above list\n-----------------------------\n");
intorderSelected=Utility.getInt();
log.info(orderMenu);
log.info("\n-----------------------------\nEnter 0 to go back.\n-----------------------------\n");
log.info("\n-----------------------------\nSelect order from the above list\n-----------------------------\n");
intorderSelected=InputUtil.validateInputNumber();
if(orderSelected==0){
orderSelectFlag=false;
break;
}
Orderorder=orders.get(orderSelected);
if(order==null){
Utility.getLogger().info("\n-----------------------------\nPlease select an order available in the list\n-----------------------------\n");
log.info("\n-----------------------------\nPlease select an order available in the list\n-----------------------------\n");
showOrders();
}else{
Utility.getLogger().info(order.showOrder());
Utility.getLogger().info("\n-----------------------------\nenter 1 to view products \n2 to see orders \nenter any keyword to exit");
intchooseProductList=Utility.getInt();
log.info(order.showOrder());
log.info("\n-----------------------------\nenter 1 to view products \n2 to see orders \nenter any keyword to exit");
* Class used to import the values of the option given in the console and print accordingly
* of the required choice chosen
*/
publicclassUtility{
@Log
publicclassInputUtil{
privatestaticfinalScannerSCANNER=null;
privatestaticfinalLoggerLOGGER=null;
/**
* No argument constructor
*/
privateUtility(){
privateInputUtil(){
}
/**
...
...
@@ -38,11 +39,11 @@ public class Utility {
CategorycategoryValue;
StringcategoryOptions=Arrays.stream(Category.values()).filter(category->!category.equals(Category.EXIT)).map(category->"("+category.getOption()+")"+category).reduce((categories,category)->categories+" "+category).get()+"\nPress 0 to go back.";
getLogger().info("\n------------------------\n+Please enter valid category\n------------------------\n"+categoryOptions+"\n------------------------\n");
log.info("\n------------------------\n+Please enter valid category\n------------------------\n"+categoryOptions+"\n------------------------\n");
StringcategoryOptions=Arrays.stream(Size.values()).filter(size->!size.equals(Size.EXIT)).map(size->"("+size.getOption()+")"+size).reduce((sizes,size)->sizes+" "+size).get()+"\nPress 0 to go back.";
getLogger().info("\n------------------------\nPlease enter valid category\n------------------------\n"+categoryOptions+"\n------------------------\n");
log.info("\n------------------------\nPlease enter valid category\n------------------------\n"+categoryOptions+"\n------------------------\n");
returngetSize(false,message);
});
returnsizeValue.equals(Size.EXIT)?null:sizeValue;
...
...
@@ -80,11 +81,11 @@ public class Utility {
GendergenderValue;
StringgenderOptions=Arrays.stream(Gender.values()).filter(gender->!gender.equals(Gender.EXIT)).map(gender->"("+gender.getOption()+")"+gender).reduce((genders,gender)->genders+" "+gender).get()+"\nPress 0 to go back.";
StringcolorOptions=Arrays.stream(Color.values()).filter(color->!color.equals(Color.EXIT)).map(color->"("+color.getOption()+")"+color).reduce((categories,category)->categories+" "+category).get()+"\nPress 0 to go back.";