<commit_before>package fact;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Classe permettant de créer un serveur pour le calcul de factorielle
 * 
 * @author <NAME>, <NAME>
 *
 */
public class FactServer {

	// Client part

	public class ClientThread extends Thread {

		Socket socket;
		InputStream sInput;
		OutputStream sOutput;
		String name;

		public ClientThread(Socket socket, String name) {
			try {
				this.socket = socket;
				sOutput = socket.getOutputStream();
				sInput  = socket.getInputStream();
				this.name = name;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		@SuppressWarnings("resource")
		public void run() {
			Scanner sc = new Scanner(sInput);
			while (true) {
				if (sc.hasNext()) {
					String msg = sc.nextLine();
					System.out.println(name + ": " + msg);
					broadcast(name + ": " + msg);
				}				
			}
		}
	}

	// Server part

	ArrayList<ClientThread> socks = new ArrayList<ClientThread>();
	int port;
	int num = 0;

	public FactServer(int port) {
		this.port = port;
	}

	public synchronized void broadcast(String msg) {
		for (ClientThread e : socks) {
			PrintStream output = new PrintStream(e.sOutput);
			output.println(msg);
		}
	}

	@SuppressWarnings("resource")
	public void run() {
		try {
			ServerSocket sServer = new ServerSocket(port);
			while (true) {
				Socket s = sServer.accept();
				ClientThread c = new ClientThread(s, "Thread " + num);;
				System.out.println("Connection of client " + num);
				num++;
				socks.add(c);
				c.start();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String [] argv) {
		FactServer c = new FactServer (50000);
		c.run();
	}
}


<commit_msg>Implémentation de la fonction de calcul de factorielle<commit_after>package fact;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Classe permettant de créer un serveur pour le calcul de factorielle
 * 
 * @author <NAME>, <NAME>
 *
 */
public class FactServer {

	// Client part

	public class ClientThread extends Thread {

		private Socket socket;
		private InputStream sInput;
		private OutputStream sOutput;
		private String name;

		public ClientThread(Socket socket, String name) {
			try {
				this.socket = socket;
				this.sOutput = this.socket.getOutputStream();
				this.sInput  = this.socket.getInputStream();
				this.name = name;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		@SuppressWarnings("resource")
		public void run() {
			Scanner sc = new Scanner(this.sInput);
			while (true) {
				if (sc.hasNext()) {
					String msg = sc.nextLine();
					System.out.println(this.name + ": " + msg);
					broadcast(this.name + ": " + msg);
				}				
			}
		}
	}

	// Server part

	private ArrayList<ClientThread> socks = new ArrayList<ClientThread>();
	private int port;
	private int num = 0;

	public FactServer(int port) {
		this.port = port;
	}

	public synchronized void broadcast(String msg) {
		for (ClientThread e : this.socks) {
			PrintStream output = new PrintStream(e.sOutput);
			output.println(msg);
		}
	}

	@SuppressWarnings("resource")
	public void run() {
		try {
			ServerSocket sServer = new ServerSocket(this.port);
			while (true) {
				Socket socket = sServer.accept();
				ClientThread client = new ClientThread(socket, "Thread " + this.num);;
				System.out.println("Connection of client " + this.num);
				this.num++;
				this.socks.add(client);
				client.start();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Méthode permettant le calcul d'une factorielle.
	 * @param n
	 * 		La valeur n de laquelle on doit calculer la factorielle.
	 * @return La factorielle de n.
	 * @throws Exception 
	 */
	public int fact(int n) throws Exception {
		if (n < 0) {
			throw new Exception("Nombre négatif !");
		}
		else if (n != 0) {
			int fact = 1;
			int i = 1;
			while (i <= n) {
				fact = fact*i;
				i++;
			}
			return fact;
		}
		else {
			return 1;
		}
	}

	public static void main(String [] argv) {
		FactServer client = new FactServer (50000);
		client.run();
	}
}



{'fraction_non_alphanumeric': 0.12091288128154487, 'fraction_numerical': 0.003730524467851657, 'mean_word_length': 2.5861526357199054, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5270894', 'n_tokens_mistral': 1714, 'n_tokens_neox': 1424, 'n_words': 387}