From b028a0f1ab5d8830a65e864a68f926e8ac470242 Mon Sep 17 00:00:00 2001
From: Gabrielle van de Vijver <gabrielle.van-de-vijver@etu.utc.fr>
Date: Thu, 5 Oct 2023 16:41:18 +0200
Subject: [PATCH] SCFFactory sans gestion d'erreur

---
 comsoc/TieBreak.go | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/comsoc/TieBreak.go b/comsoc/TieBreak.go
index 6e1d47d..872f249 100644
--- a/comsoc/TieBreak.go
+++ b/comsoc/TieBreak.go
@@ -75,4 +75,31 @@ func Test_sWFFactory(){
 	sorted_alts,_ := mu(profil)
 	fmt.Println("Alternatives strictement ordonnées selon la méthode de Borda :", sorted_alts)
 }
-//func SCFFactory(func scf(p Profile) ([]Alternative, error), func ([]Alternative) (Alternative, error)) (func(Profile) (Alternative, error))
+
+func SCFFactory(scf func (p Profile) ([]Alternative, error),tb func ([]Alternative) (Alternative, error)) (func(Profile) (Alternative, error)){
+	return func(p Profile) (Alternative, error){
+			//récupération des meilleures alternatives
+			bestAlts,_ := scf(p)
+			//récupération de la meilleure alternative
+			bestAlt,_ := tb(bestAlts)
+			return bestAlt,nil
+	}
+}
+func Test_sCFFactory(){
+	//Définition de l'Ordre strict
+	orderedAlts := []Alternative{8,9,6,1,3,2}
+	fmt.Println("Ordre strict :", orderedAlts)
+
+	//Construction d'un profil avec alternatives ex aequo
+	profil := make([][]Alternative, 2)
+	profil[0] = []Alternative{1, 2, 3,4,5,6}
+	profil[1] = []Alternative{3, 2, 1,4,5,6}
+	fmt.Println("Profil :", profil)
+
+	//Construction de la fonction Tie Break
+	lambda:=TieBreakFactory(orderedAlts)
+	mu := SCFFactory(BordaSCF,lambda)
+	//Construction d'une fonction 
+	best_Alt,_ := mu(profil)
+	fmt.Println("Meilleure alternative selon la méthode de Borda :", best_Alt)
+}
\ No newline at end of file
-- 
GitLab