From 60c2e5c69b536db175b937b97c84ac852decd5c7 Mon Sep 17 00:00:00 2001 From: iboyeau Date: Thu, 9 Mar 2023 11:04:42 +0100 Subject: [PATCH] UserSelection Round Robin --- .../java/fr/ntr/scheduler/RoundRobin.java | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/main/java/fr/ntr/scheduler/RoundRobin.java b/src/main/java/fr/ntr/scheduler/RoundRobin.java index 1db8218..331661f 100644 --- a/src/main/java/fr/ntr/scheduler/RoundRobin.java +++ b/src/main/java/fr/ntr/scheduler/RoundRobin.java @@ -1,33 +1,39 @@ package fr.ntr.scheduler; import java.util.List; -import java.util.Random; import fr.ntr.User; public class RoundRobin extends Scheduler { - private String name; - private int index; - - public RoundRobin(String name, int index) { - this.name = name; - this.index = index; - } - - @Override - public void scheduling() { - } - - //Ts = Time Slot - //Sp =sous porteuse - private void selectionUtilisateur(int Ts, int Sp, List Users) { - int random = new Random().nextInt(0, Users.size()-1); - - - } + private String name; + private int index; - + public RoundRobin(String name, int index) { + this.name = name; + this.index = index; + } - - + /** + * Entry + * Return + */ + @Override + public void scheduling() { + index = 0; + + } + + /** + * Entry Time slot (int), Sous porteuse(int), and users ( List) + * Return the user in function of TS and SP selected + */ + private User UserSelection(int Ts, int Sp, List Users) { + for (int i = 0; i < Ts; i++) { + for (int j = 0; j < Sp; j++) { + index++; + } + } + return Users.get(index%(Users.size() - 1)); + + } }