Select Git revision
saved_model.pb
Forked from
Automatants / Facial expression detection
Source project has a limited visibility.
Customer.java 5.43 KiB
package User;
import java.util.Scanner;
import Cli.Confirm;
import Cards.BasicFidelityCard;
import Cards.FidelityCard;
import Cards.LotteryFidelityCard;
import Cards.PointFidelityCard;
import Cards.VisitableCard;
import Cards.VisiterCard;
import Others.Adress;
import Others.Historique;
import Others.IDCard;
import Order.Order;
import Cli.Input;
import Item.FactoryDish;
import Item.Meal;
import Item.MealFactory;
import Offers.Observer;
public class Customer extends HumanUser implements VisiterCard,Observer {
private boolean spamAgree;
private Historique historique;
private FidelityCard card;
private IDCard idCard;
public Customer(long phoneNumber, String name, String username, String mail, String password,
Adress adress, boolean activated, String birthdayDate, String surname,boolean spamAgree,Historique historique,FidelityCard card ) {
super(phoneNumber, name, username, mail, password, adress, activated, birthdayDate, surname);
this.spamAgree = spamAgree;
this.historique = historique;
this.card = card;
}
public FidelityCard getCard() {
return card;
}
@Override
public String toString() {
return "Customer [spamAgree=" + spamAgree + ", historique=" + historique + ", card=" + card + "]";
}
public void placeOrder(Restaurant restaurant){
Order order = new Order();
System.out.println(restaurant.toString());
do {
if (Confirm.text("Do you want a Meal?")){
System.out.println("listdesMeal"); // faire
String choice = Cli.Input.string("Which meal do you want?");
boolean isIn = false;
for(Meal meal : restaurant.listOfMeal){
if(meal.toString() == choice){
isIn = true;
}
}
if (isIn == false){
System.out.println("This meal isn't propose by this restaurant");
}
else {
if(choice == "FullMeal"){
System.out.println("listedesDish"); // faire
String entry1 = Cli.Input.string("Which entry do you want in your meal?");
String main1 = Cli.Input.string("Which main do you want in your meal?");
String dessert1 = Cli.Input.string("Which dessert do you want in your meal?");
MealFactory factory1 = new MealFactory();
//Meal newmeal = factory1.createMeal("fullmeal", _name, _typeOfFood)
}
if (choice == "HalfMeal"){
System.out.println("listedesDish"); // faire
String typeOfFormule = Cli.Input.string("Which formula do you want? Entry/Main(EM) or Main/Dessert(MD)");
if(typeOfFormule == "EM"){
String entry2 = Cli.Input.string("Which entry do you want in your meal?");
String main2 = Cli.Input.string("Which main do you want in your meal?");
MealFactory factory2 = new MealFactory();
//Meal newmeal = factory2.createMeal("halfmeal"
}
else if(typeOfFormule == "MD"){
String main3 = Cli.Input.string("Which main do you want in your meal?");
String dessert3 = Cli.Input.string("Which dessert do you want in your meal?");
MealFactory factory3 = new MealFactory();
//Meal newmeal = factory3.createMeal("halfmeal"
}
else{
System.out.println("This type of Meal is not available");
}
}
}
}
else if (Confirm.text("Do you want a dish?")){
System.out.println("listOfDish");
String dish = Cli.Input.string("Which dish do you want ?");
FactoryDish factory4 = new FactoryDish();
}
} while (Confirm.text("Do you want something else ?"));
System.out.println("Do you want a Meal? (y)es or (n)o");
Scanner sc = new Scanner(System.in);
String choice = sc.nextLine();
if (Confirm.text("Do you want a Meal?")){
}
}
public void registerFidelityPlan(String newTypeOfFidelityCard){
if(newTypeOfFidelityCard == this.card.returnType()){
System.out.println("You already have this card");}
else if ((newTypeOfFidelityCard != "Basic")&(newTypeOfFidelityCard != "Lottery")&(newTypeOfFidelityCard != "Point")){
System.out.println("You have to choose between Point, Lottery card");
}
else if (newTypeOfFidelityCard == "Basic"){
System.out.println("You have to choose between Point, Lottery card");
}
else {
if (newTypeOfFidelityCard == "Point"){
idCard=IDCard.getInstance();
this.card = new PointFidelityCard(idCard.getNextSerialNumber(),0);
}
if (newTypeOfFidelityCard == "Lottery"){
idCard=IDCard.getInstance();
this.card = new LotteryFidelityCard(idCard.getNextSerialNumber(),10);
}
}
}
public void unregisterFidelityPlan(String newTypeOfFidelityCard){
if(this.card.returnType() == "Basic"){
System.out.println("You already have this card");}
else {
idCard=IDCard.getInstance();
this.card = new BasicFidelityCard(idCard.getNextSerialNumber());
}
}
public Historique getHistorique() {
return historique;
}
public long getPointInTheCard(){
if((this.card.returnType() == "Basic") || (this.card.returnType() == "Lottery")){
System.out.println("You don't have the right type of Card");
return 0;
}
else {
return visit(card);
}
}
@Override
public long visit(VisitableCard card) {
return card.accept();
}
public void acceptSpam (){
if (spamAgree == true){
System.out.println("You've already accept to receive notifications");
}
else {
this.spamAgree = true;
}
}
public void refuseSpam(){
if (spamAgree == false){
System.out.println("You've already refuse to receive notifications");
}
else {
this.spamAgree = false;
}
}
@Override
public void update() {
}
}