Skip to content
Snippets Groups Projects
Commit c91cda32 authored by Nicolas Fley's avatar Nicolas Fley
Browse files

at least we are quite close to the end

parent 71d19208
Branches
No related tags found
No related merge requests found
Showing
with 511 additions and 65 deletions
model.rar 0 → 100644
File added
# initial login
login ceo 123456789
###############
# Registering Users
###############
registerManager 698697556 cto cto cto@mail.fr 987654321 0.0,0.0 22/03/1985
registerRestaurant 350697523 AuBonResto resto1 mail@mail.fr resto1pwd 0.02,0.03
registerRestaurant 350697523 LaBonneBouffe resto2 mail@mail.fr resto2pwd -0.50,0.25
registerRestaurant 350697523 AuCarreIrlandais resto3 mail@mail.fr resto3pwd 0.02,-0.3
registerRestaurant 350697523 CafeDeLaPaix resto4 mail@mail.fr resto4pwd 23.2,-0.03
registerRestaurant 350697523 Lolivier resto5 mail@mail.fr resto5pwd 0.02,0.36
registerCourier 649878446 Marc cour_marc marc@mail.fr marc_pwd 0.9,-9.0 22/03/1975
registerCourier 498784515 Henri cour_henri henri@mail.fr henri_pwd -0.9,-9.0 12/09/1989
registerCourier 498484516 Luc cour_luc henri@mail.fr luc_pwd 0.9,19.0 27/12/1995
registerCustomer 943684597 Louise custo_louise louise@mail.fr louise_pwd 5.3,9.1 23/02/1994
registerCustomer 465131879 Jean custo_jean jean@mail.fr jean_pwd 3.3,-9.1 18/11/1985
registerCustomer 648451648 Patrick custo_patrick patrick@mail.fr patrick_pwd 4.3,-3.1 12/02/1998
registerCustomer 198745487 Mathieu custo_mathieu mathieu@mail.fr mathieu_pwd -8.3,-0.1 28/13/1958
registerCustomer 877887446 Etienne custo_etienne etienne@mail.fr etienne_pwd -6.3,-6.1 21/12/1980
registerCustomer 489446548 Jeanne custo_jeanne jeanne@mail.fr jeanne_pwd 7.3,-3.1 03/08/1989
registerCustomer 489546844 Marie custo_marie marie@mail.fr marie_pwd 12.3,1.9 21/01/1997
###############
# Switching to restaurant
###############
logout
login resto1 resto1pwd
###############
# Adding Dishes
###############
addDishRestaurantMenu steackFrites MainDish normal 14.50
addDishRestaurantMenu salad Starter vegetarian 5.80
addDishRestaurantMenu cookie Dessert normal 3.00
addDishRestaurantMenu mushroomPie MainDish vegetarian 12.50
addDishRestaurantMenu tartare Starter glutenFree 8.50
addDishRestaurantMenu brownie Dessert normal 14.50
addDishRestaurantMenu fruits Dessert vegetarian 4.50
###############
# Creating Menus
###############
createMeal menuEnfant FullMeal
createMeal menuBoucher FullMeal
createMeal menuVegetarien FullMeal
createMeal menuDuMidi FullMeal
createMeal menuLeger HalfMeal
###############
# Adding Menus to Meals
###############
addDishToMeal steackFrites menuEnfant
addDishToMeal salad menuEnfant
addDishToMeal cookie menuEnfant
addDishToMeal tartare menuBoucher
addDishToMeal steackFrites menuBoucher
addDishToMeal brownie menuBoucher
addDishToMeal salad menuVegetarien
addDishToMeal mushroomPie menuVegetarien
addDishToMeal fruits menuVegetarien
addDishToMeal salad menuDuMidi
addDishToMeal steackFrites menuDuMidi
addDishToMeal cookie menuDuMidi
addDishToMeal salad menuLeger
addDishToMeal mushroomPie menuLeger
\ No newline at end of file
###############
# showing users
###############
login ceo 123456789
showCustomer
showCourier
showRestaurantTop
###############
# register a few more users
###############
registerRestaurant 123756753 LaSalleHaute resto6 resto6@mail.fr resto6pwd 2.02,-1.03
registerRestaurant 789321345 AuBistrot resto7 resto7@mail.fr resto7pwd -5.50,3.25
registerCourier 123786541 Lucie cour_lucie lucie@mail.fr lucie_pwd 1.5,-2.0 23/03/1998
# registerCourier 789534123 Alexandre cour_alexandre alexandre@mail.fr alexandre_pwd -0.8,2.1 14/05/1982
registerCourier 789534123 Pascal cour_pascal pascal@mail.fr pascal_pwd -0.8,2.1 14/05/1978
registerCustomer 943684597 Jacques custo_jacques jacques@mail.fr jacques_pwd 2.3,-9.8 23/02/1975
registerCustomer 465131879 Gabrielle custo_gabrielle gabrielle@mail.fr gabrielle_pwd -3.3,2.1 18/03/1987
# show restaurants
showRestaurantTop
# show customers
showCustomer
# logout
logout
###############
# login, adding and populate a meal to each restaurant
# 5 uniques Full meals
# 2 uniques Half meals
###############
login resto2 resto2pwd
addDishRestaurantMenu steackFrites MainDish normal 14.80
addDishRestaurantMenu salad Starter vegetarian 5.20
addDishRestaurantMenu cookie Dessert normal 3.00
addDishRestaurantMenu mushroomPie MainDish vegetarian 11.50
addDishRestaurantMenu tartare Starter glutenFree 9.50
addDishRestaurantMenu brownie Dessert normal 12.50
addDishRestaurantMenu fruits Dessert vegetarian 6.50
createMeal menuEnfant FullMeal
addDishToMeal steackFrites menuEnfant
addDishToMeal salad menuEnfant
addDishToMeal cookie menuEnfant
createMeal menuDuMidi FullMeal
addDishToMeal salad menuDuMidi
addDishToMeal steackFrites menuDuMidi
addDishToMeal cookie menuDuMidi
createMeal menuLegerEntreePlat HalfMeal
addDishToMeal salad menuLegerEntreePlat
addDishToMeal mushroomPie menuLegerEntreePlat
# login implies logout of the current logged entity
login resto3 resto3pwd
addDishRestaurantMenu steackFrites MainDish normal 14.80
addDishRestaurantMenu salad Starter vegetarian 5.20
addDishRestaurantMenu cookie Dessert normal 3.00
addDishRestaurantMenu mushroomPie MainDish vegetarian 11.50
addDishRestaurantMenu tartare Starter glutenFree 9.50
addDishRestaurantMenu brownie Dessert normal 12.50
addDishRestaurantMenu fruits Dessert vegetarian 6.50
createMeal menuBoucher FullMeal
addDishToMeal tartare menuBoucher
addDishToMeal steackFrites menuBoucher
addDishToMeal brownie menuBoucher
createMeal menuDuMidi FullMeal
addDishToMeal salad menuDuMidi
addDishToMeal steackFrites menuDuMidi
addDishToMeal cookie menuDuMidi
createMeal menuLegerEntreePlat HalfMeal
addDishToMeal salad menuLegerEntreePlat
addDishToMeal mushroomPie menuLegerEntreePlat
login resto4 resto4pwd
addDishRestaurantMenu steackFrites MainDish normal 14.80
addDishRestaurantMenu salad Starter vegetarian 5.20
addDishRestaurantMenu cookie Dessert normal 3.00
addDishRestaurantMenu mushroomPie MainDish vegetarian 11.50
addDishRestaurantMenu tartare Starter glutenFree 9.50
addDishRestaurantMenu brownie Dessert normal 12.50
addDishRestaurantMenu fruits Dessert vegetarian 6.50
createMeal menuVegetarien FullMeal
addDishToMeal salad menuVegetarien
addDishToMeal mushroomPie menuVegetarien
addDishToMeal fruits menuVegetarien
createMeal menuDuMidi FullMeal
addDishToMeal salad menuDuMidi
addDishToMeal steackFrites menuDuMidi
addDishToMeal cookie menuDuMidi
login resto5 resto5pwd
addDishRestaurantMenu steackFrites MainDish normal 14.50
addDishRestaurantMenu salad Starter vegetarian 5.80
addDishRestaurantMenu cookie Dessert normal 3.00
addDishRestaurantMenu mushroomPie MainDish vegetarian 12.50
addDishRestaurantMenu tartare Starter glutenFree 7.60
addDishRestaurantMenu brownie Dessert normal 12.30
addDishRestaurantMenu fruits Dessert vegetarian 6.50
createMeal menuDuMidi FullMeal
addDishToMeal salad menuDuMidi
addDishToMeal steackFrites menuDuMidi
addDishToMeal cookie menuDuMidi
createMeal menuLegerEntreePlat HalfMeal
addDishToMeal salad menuLegerEntreePlat
addDishToMeal mushroomPie menuLegerEntreePlat
login resto6 resto6pwd
addDishRestaurantMenu steackFrites MainDish normal 14.50
addDishRestaurantMenu salad Starter vegetarian 5.80
addDishRestaurantMenu cookie Dessert normal 3.00
addDishRestaurantMenu mushroomPie MainDish vegetarian 12.50
addDishRestaurantMenu tartare Starter glutenFree 8.50
addDishRestaurantMenu brownie Dessert normal 14.50
addDishRestaurantMenu fruits Dessert vegetarian 4.50
createMeal menuLegerPlatDessert HalfMeal
addDishToMeal mushroomPie menuLegerPlatDessert
addDishToMeal cookie menuLegerPlatDessert
createMeal menuDuMidi FullMeal
addDishToMeal salad menuDuMidi
addDishToMeal steackFrites menuDuMidi
addDishToMeal cookie menuDuMidi
login resto7 resto7pwd
addDishRestaurantMenu steackFrites MainDish normal 14.80
addDishRestaurantMenu salad Starter vegetarian 5.20
addDishRestaurantMenu cookie Dessert normal 3.00
addDishRestaurantMenu mushroomPie MainDish vegetarian 11.50
addDishRestaurantMenu tartare Starter glutenFree 8.50
addDishRestaurantMenu brownie Dessert normal 14.50
addDishRestaurantMenu fruits Dessert vegetarian 4.50
createMeal menuLegerEntreePlat HalfMeal
addDishToMeal salad menuLegerEntreePlat
addDishToMeal mushroomPie menuLegerEntreePlat
###############
# setting meal of the week for some restaurant (2,3,5,6)
###############
# !!!!!
# Offers are stocked for each customer, waiting for connection to spam.
# !!!!!
login resto2 resto2pwd
setSpecialOffer menuEnfant
login resto3 resto3pwd
setSpecialOffer menuDuMidi
login resto5 resto5pwd
setSpecialOffer menuLegerEntreePlat
login resto6 resto6pwd
setSpecialOffer menuLegerPlatDessert
# Show all the restaurant and their menu :
login ceo 123456789
showRestaurantTop
# Before testing command let's add afidelity card :
associateCard custo_gabrielle Point
associateCard custo_louise Lottery
# Login a few customers
login custo_jacques jacques_pwd
# login implies logout of the current logged entity
login custo_gabrielle gabrielle_pwd
login custo_louise louise_pwd
createOrder resto6 maCommande
addItemToOrder maCommande menuDuMidi
addItemToOrder maCommande salad
addItemToOrder maCommande menuLegerPlatDessert
endOrder maCommande
login custo_gabrielle gabrielle_pwd
createOrder resto5 maCommande2
addItemToOrder maCommande2 menuDuMidi
addItemToOrder maCommande2 cookie
addItemToOrder maCommande2 menuLegerEntreePlat
endOrder maCommande2
#########"
# Meal Of the week accuracy
### resto 2 & 3 & 4 have exactly the same prices, menuMidi is meal of the week for resto3
createOrder resto4 maCommande3
createOrder resto3 maCommande4
createOrder resto2 maCommande5
# 5% reduc
addItemToOrder maCommande3 menuDuMidi
# 10% reduc
addItemToOrder maCommande4 menuDuMidi
# full price
addItemToOrder maCommande5 salad
addItemToOrder maCommande5 steackFrites
addItemToOrder maCommande5 cookie
endOrder maCommande5
endOrder maCommande3
endOrder maCommande4
# last order, to test profit calculation
createOrder resto2 maCommande6
addItemToOrder maCommande6 menuDuMidi
addItemToOrder maCommande6 menuLegerEntreePlat
addItemToOrder maCommande6 cookie
# at this point no courier available
endOrderAt maCommande6 05/04/2017
login ceo 123456789
# free a courier
offDuty cour_pascal
login custo_gabrielle gabrielle_pwd
endOrderAt maCommande6 05/04/2017
# login again manager
login ceo 123456789
# initial profit
showTotalProfit
# set a markup profit strategy
setProfitPolicy markup 6.0
showTotalProfit
# set a serviceFee strategy
setProfitPolicy ServiceFee 5.0
showTotalProfit
setProfitPolicy deliveryCost 3.0
showTotalProfit
showProfitBetween 01/05/2017 10/05/2017
showCourier
showCourierOrdered ASC
showCourierOrdered DESC
###########
# other stuff :
###########
# onDuty & offDuty
offDuty cour_marc
showCourier
onDuty cour_marc
showCourier
showCustomer
logout
\ No newline at end of file
......@@ -27,5 +27,4 @@ public abstract class FidelityCard implements VisitableCard {
public abstract String returnType();
}
......@@ -11,12 +11,14 @@ import Commands.AssociateCard;
import Commands.CreateMeal;
import Commands.CreateOrder;
import Commands.EndOrder;
import Commands.EndOrderAt;
import Commands.Help;
import Commands.Logout;
import Commands.OffDuty;
import Commands.OnDuty;
import Commands.RegisterCourier;
import Commands.RegisterCustomer;
import Commands.RegisterManager;
import Commands.RegisterRestaurant;
import Commands.RemoveSpecialOffer;
import Commands.RenameMeal;
......@@ -25,6 +27,7 @@ import Commands.SetDeliveryPolicy;
import Commands.SetProfitPolicy;
import Commands.SetSpecialOffer;
import Commands.ShowCourier;
import Commands.ShowCourierOrdered;
import Commands.ShowCustomer;
import Commands.ShowMeal;
import Commands.ShowMenuItem;
......@@ -37,6 +40,7 @@ import Exception.ExceptionUnknownDishType;
import Exception.ExceptionUnknownMealType;
import Exception.ExceptionUnknownStartegyType;
import Exception.ExceptionUnknownTypeOfUser;
import User.Customer;
public class Clui {
......@@ -57,6 +61,7 @@ public class Clui {
this.listOfCommand.add(new CreateMeal());
this.listOfCommand.add(new CreateOrder());
this.listOfCommand.add(new EndOrder());
this.listOfCommand.add(new EndOrderAt());
this.listOfCommand.add(new Help());
this.listOfCommand.add(new Login());
this.listOfCommand.add(new Logout());
......@@ -64,6 +69,7 @@ public class Clui {
this.listOfCommand.add(new OnDuty());
this.listOfCommand.add(new RegisterCourier());
this.listOfCommand.add(new RegisterCustomer());
this.listOfCommand.add(new RegisterManager());
this.listOfCommand.add(new RegisterRestaurant());
this.listOfCommand.add(new RemoveSpecialOffer());
this.listOfCommand.add(new RenameMeal());
......@@ -72,6 +78,7 @@ public class Clui {
this.listOfCommand.add(new SetProfitPolicy());
this.listOfCommand.add(new SetSpecialOffer());
this.listOfCommand.add(new ShowCourier());
this.listOfCommand.add(new ShowCourierOrdered());
this.listOfCommand.add(new ShowCustomer());
this.listOfCommand.add(new ShowMeal());
this.listOfCommand.add(new ShowMenuItem());
......@@ -88,7 +95,8 @@ public class Clui {
return null;
}
public void executeCommand(String command) throws ExceptionUnknownMealType, NumberFormatException, ExceptionUnknownDishType, ExceptionUnknownStartegyType, ExceptionUnknownTypeOfUser{
public void executeCommand(String command){
if(!(command.equals("") || command.substring(0, 1).equals("#"))){
StringTokenizer st = new StringTokenizer(command);
String commandName = st.nextToken();
ArrayList<String> arguments = new ArrayList<String>();
......@@ -101,7 +109,14 @@ public class Clui {
if(commandAsked != null){
try{
if(commandAsked.isGoodArgument(arguments)){
try {
commandAsked.execute(arguments, foodora, activeUser);
} catch (NumberFormatException | ExceptionUnknownMealType | ExceptionUnknownDishType
| ExceptionUnknownStartegyType | ExceptionUnknownTypeOfUser | java.lang.NullPointerException e) {
// TODO Auto-generated catch block
System.out.println("ERROR with command "+commandName+ " : " + e.getMessage());
//e.printStackTrace();
}
}else{
System.out.println("Error in the arguments.");
}
......@@ -114,9 +129,17 @@ public class Clui {
}else{
System.out.println("Unknown command.");
}
// lifeTimeFunction
if(activeUser.getUser() instanceof Customer){
Customer c = (Customer) activeUser.getUser();
c.checkForPendingOffer();
}
}
}
public void launchClui() throws errorWrongNumberOfParams, errorWrongFormatValue, ExceptionUnknownMealType, NumberFormatException, ExceptionUnknownDishType, ExceptionUnknownStartegyType, ExceptionUnknownTypeOfUser{
public void launchClui(){
System.out.println("Welcome to MyFoodora system, type help <> in order to have all the possible commands");
while(true){
String command = Input.string("===================\n"
......
......@@ -26,12 +26,14 @@ public abstract class Command {
public boolean isGoodArgument(ArrayList<String> arguments) throws errorWrongNumberOfParams,errorWrongFormatValue{
if(arguments.size() != listOfArgs.length){
throw new errorWrongNumberOfParams("Error : "+Integer.toString(arguments.size())+" parameter insteed of "+Integer.toString(listOfArgs.length));
throw new errorWrongNumberOfParams("Error : "+ commandName +" : "+Integer.toString(arguments.size())+" parameter insteed of "+Integer.toString(listOfArgs.length));
}
int i = 0;
for (String arg : arguments) {
listOfArgs[i].isTockenCorrect(arg); // throw une erreur, faut la catch au dessus !
if(listOfArgs[i].isTockenCorrect(arg))
i++;
else
throw new errorWrongFormatValue("Error : "+ commandName +" : " + i + " arg is wrong format");
}
// trow une erreur
return true;
......
......@@ -37,7 +37,7 @@ public class Token {
return true;
break;
case position:
if(_value.matches("-?\\d+(\\.\\d+)\\,\\d+(\\.\\d+)?"))
if(_value.matches("-?\\d+(\\.\\d+)\\,-?\\d+(\\.\\d+)?"))
return true;
break;
case decimal:
......
......@@ -32,7 +32,7 @@ public class AddDishRestaurantMenu extends Command {
if(activeUser.getUser() instanceof Restaurant){
Restaurant r = (Restaurant) activeUser.getUser();
r.addDish(arg.get(1), arg.get(0), arg.get(2), Double.parseDouble(arg.get(3)));
System.out.println("Customer added : " + foodora.getUserByName(arg.get(1), arg.get(2)));
System.out.println("Dish added : " + r.getDishByName(arg.get(0)));
}else{
System.out.println("You need to be a logged Restaurant in order to access this function");
}
......
......@@ -6,11 +6,8 @@ import Cli.Command;
import Cli.Token;
import Core.ActiveUserContext;
import Core.MyFoodora;
import Exception.ExceptionUnknownDishType;
import Exception.ExceptionUnknownMealType;
import Order.Order;
import User.Customer;
import User.Restaurant;
public class AddItemToOrder extends Command {
......@@ -28,6 +25,7 @@ public class AddItemToOrder extends Command {
if(activeUser.getUser() instanceof Customer){
Customer c = (Customer) activeUser.getUser();
Order o = c.getOrderByName(arg.get(0));
//System.out.println(c.getListOrder());
o.addItemByName(arg.get(1));
System.out.println(arg.get(1) + " added in "+arg.get(0)+".");
}else{
......
......@@ -29,6 +29,7 @@ public class AssociateCard extends Command {
if(activeUser.getUser() instanceof Manager){
Manager m = (Manager) activeUser.getUser();
Customer c = (Customer) foodora.getUserByUsername(arg.get(0));
System.out.println("You are choosing a "+arg.get(1)+" card.");
c.registerFidelityPlan(arg.get(1));
}else{
System.out.println("You need to be a logged Manager in order to access this function");
......
......@@ -15,8 +15,7 @@ public class EndOrder extends Command {
public EndOrder() {
super("endOrder",
new Token[]{new Token(Token.TypeToken.str,"orderName"),
new Token(Token.TypeToken.date,"orderDate")}
new Token[]{new Token(Token.TypeToken.str,"orderName")}
);
// TODO Auto-generated constructor stub
}
......@@ -26,8 +25,8 @@ public class EndOrder extends Command {
// TODO Auto-generated method stub
if(activeUser.getUser() instanceof Customer){
Customer c = (Customer) activeUser.getUser();
c.getOrderByName(arg.get(0)).finalize();
System.out.println(arg.get(1) + " finalized the "+arg.get(0)+".");
System.out.println("finalising the command : "+ arg.get(0));
c.placeOrder(c.getOrderByName(arg.get(0)), foodora);
}else{
System.out.println("You need to be a logged Customer in order to access this function");
}
......
package Commands;
import java.util.ArrayList;
import Cli.Command;
import Cli.Token;
import Core.ActiveUserContext;
import Core.MyFoodora;
import Exception.ExceptionUnknownDishType;
import Exception.ExceptionUnknownMealType;
import Exception.ExceptionUnknownStartegyType;
import Exception.ExceptionUnknownTypeOfUser;
import Order.Order;
import Others.Date;
import User.Customer;
public class EndOrderAt extends Command {
public EndOrderAt() {
super("endOrderAt",
new Token[]{new Token(Token.TypeToken.str,"orderName"),
new Token(Token.TypeToken.date,"orderDate")}
);
// TODO Auto-generated constructor stub
}
@Override
public void execute(ArrayList<String> arg, MyFoodora foodora, ActiveUserContext activeUser) throws NumberFormatException {
// TODO Auto-generated method stub
if(activeUser.getUser() instanceof Customer){
Customer c = (Customer) activeUser.getUser();
Order o = (Order) c.getOrderByName(arg.get(0));
String[] parts = arg.get(1).split("/");
int day = Integer.parseInt(parts[0]);
int month = Integer.parseInt(parts[1]);
int year = Integer.parseInt(parts[2]);
System.out.println("finalising the command : "+ arg.get(0) + ", the : "+arg.get(1));
c.placeOrder(o, foodora,new Date(year,month,day));
//System.out.println(foodora.getGlobalHistoric());
}else{
System.out.println("You need to be a logged Customer in order to access this function");
}
}
}
......@@ -27,7 +27,7 @@ public class OffDuty extends Command {
Manager m = (Manager) activeUser.getUser();
Courier d = (Courier) foodora.getUserByUsername(arg.get(0));
d.setAvailable(true);
System.out.println(arg.get(0) + " in now on duty.");
System.out.println(arg.get(0) + " in now available.");
}else{
System.out.println("You need to be a logged Manager in order to access this function");
}
......
......@@ -8,6 +8,7 @@ import Core.ActiveUserContext;
import Core.MyFoodora;
import Exception.ExceptionUnknownTypeOfUser;
import Others.Adress;
import User.Courier;
import User.Manager;
import User.User;
......@@ -33,7 +34,7 @@ public class RegisterCourier extends Command {
Manager m = (Manager) activeUser.getUser();
// registerCourier 0123456789 resto1 resto1 mail password 0.01,0.02 22/03/1995
m.addUser(Long.parseLong(arg.get(0)), arg.get(1), arg.get(2), arg.get(3), arg.get(4), Adress.fromStr(arg.get(5)), true, arg.get(6), "1", foodora, User.COURIER , "Human");
System.out.println("Courier added : " + foodora.getUserByName(arg.get(1), arg.get(2)));
System.out.println("Courier added : " + (Courier) foodora.getUserByUsername(arg.get(2)));
}else{
System.out.println("You need to be a manager in order to access this function");
}
......
......@@ -8,6 +8,7 @@ import Core.ActiveUserContext;
import Core.MyFoodora;
import Exception.ExceptionUnknownTypeOfUser;
import Others.Adress;
import User.Customer;
import User.Manager;
import User.User;
......@@ -33,7 +34,7 @@ public class RegisterCustomer extends Command {
Manager m = (Manager) activeUser.getUser();
// registerRestaurant 0123456789 resto1 resto1 mail password 0.01,0.02 22/03/1995
m.addUser(Long.parseLong(arg.get(0)), arg.get(1), arg.get(2), arg.get(3), arg.get(4), Adress.fromStr(arg.get(5)), true, arg.get(6), "1", foodora, User.CUSTOMER , "Human");
System.out.println("Customer added : " + foodora.getUserByName(arg.get(1), arg.get(2)));
System.out.println("Customer added : " + (Customer) foodora.getUserByUsername( arg.get(2)));
}else{
System.out.println("You need to be a logged Manager in order to access this function");
}
......
package Commands;
import java.util.ArrayList;
import Cli.Command;
import Cli.Token;
import Core.ActiveUserContext;
import Core.MyFoodora;
import Exception.ExceptionUnknownTypeOfUser;
import Others.Adress;
import User.Manager;
import User.User;
public class RegisterManager extends Command {
public RegisterManager() {
super("registerManager",
new Token[]{new Token(Token.TypeToken.integer,"tel")
,new Token(Token.TypeToken.str,"name")
,new Token(Token.TypeToken.str,"username")
,new Token(Token.TypeToken.str,"mail")
,new Token(Token.TypeToken.str,"password")
,new Token(Token.TypeToken.position,"adress")
,new Token(Token.TypeToken.date,"birthday")}
);
// TODO Auto-generated constructor stub
}
@Override
public void execute(ArrayList<String> arg, MyFoodora foodora, ActiveUserContext activeUser) throws NumberFormatException, ExceptionUnknownTypeOfUser {
// TODO Auto-generated method stub
if(activeUser.getUser() instanceof Manager){
Manager m = (Manager) activeUser.getUser();
// registerRestaurant 0123456789 resto1 resto1 mail password 0.01,0.02 22/03/1995
m.addUser(Long.parseLong(arg.get(0)), arg.get(1), arg.get(2), arg.get(3), arg.get(4), Adress.fromStr(arg.get(5)), true, arg.get(6), "1", foodora, User.MANAGER , "Human");
System.out.println("Manager added : " + (Manager) foodora.getUserByUsername(arg.get(2)));
}else{
System.out.println("You need to be a logged Manager in order to access this function");
}
}
}
......@@ -33,7 +33,7 @@ public class RegisterRestaurant extends Command {
Manager m = (Manager) activeUser.getUser();
// registerRestaurant 0123456789 resto1 resto1 mail password 0.01,0.02
m.addUser(Long.parseLong(arg.get(0)), arg.get(1), arg.get(2), arg.get(3), arg.get(4), Adress.fromStr(arg.get(5)), true, "1", "1", foodora, User.RESTAURANT , "Moral");
System.out.println("Restaurant added : " + foodora.getUserByName(arg.get(1), arg.get(2)));
System.out.println("Restaurant added : " + (Restaurant) foodora.getUserByUsername(arg.get(2)));
}else{
System.out.println("You need to be a manager in order to access this function");
}
......
......@@ -14,6 +14,7 @@ import Core.MyFoodora;
import Exception.ExceptionUnknownDishType;
import Exception.ExceptionUnknownMealType;
import Exception.ExceptionUnknownStartegyType;
import Exception.ExceptionUnknownTypeOfUser;
import User.Manager;
public class RunTest extends Command {
......@@ -28,29 +29,16 @@ public class RunTest extends Command {
@Override
public void execute(ArrayList<String> arg, MyFoodora foodora, ActiveUserContext activeUser) {
if(activeUser.getUser() instanceof Manager){
Clui clui = new Clui(foodora, activeUser);
String fileName = arg.get(0);
String fileName = System.getProperty("user.dir") + "/" + arg.get(0);
//read file into stream, try-with-resources
try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
stream.forEach(command -> {
try {
clui.executeCommand(command);
} catch (NumberFormatException | ExceptionUnknownMealType | ExceptionUnknownDishType | ExceptionUnknownStartegyType e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
stream.forEach(command -> clui.executeCommand(command));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
System.out.println("You need to be a manager in order to access this function");
}
}
}
......@@ -15,7 +15,8 @@ public class SetProfitPolicy extends Command {
public SetProfitPolicy() {
super("setProfitPolicy",
new Token[]{new Token(Token.TypeToken.str,"profityPolicyName")}
new Token[]{new Token(Token.TypeToken.str,"profityPolicyName"),
new Token(Token.TypeToken.decimal,"valueTargetted")}
);
// TODO Auto-generated constructor stub
}
......@@ -26,7 +27,8 @@ public class SetProfitPolicy extends Command {
if(activeUser.getUser() instanceof Manager){
Manager m = (Manager) activeUser.getUser();
foodora.getContextTargetProfitStrategy().setStrategy(arg.get(0));
System.out.println(arg.get(0) + " is now the profit policy.");
foodora.getContextTargetProfitStrategy().execute(foodora, Double.parseDouble(arg.get(1)));
System.out.println(arg.get(0) + " is now the profit policy, target is : "+arg.get(1)+".");
}else{
System.out.println("You need to be a logged Manager in order to access this function");
}
......
......@@ -23,7 +23,6 @@ public class SetSpecialOffer extends Command {
if(activeUser.getUser() instanceof Restaurant){
Restaurant r = (Restaurant) activeUser.getUser();
r.addMealOfTheWeek(foodora, arg.get(0));
System.out.println("Meal "+arg.get(0)+" is now the Meal Of The Week.");
}else{
System.out.println("You need to be a logged Restaurant in order to access this function");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment