ajout de couleur dans la console (oui je m'amuse sur un tp déjà rendu)
This commit is contained in:
BIN
lib/jansi-2.4.0.jar
Normal file
BIN
lib/jansi-2.4.0.jar
Normal file
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
import java.util.Random;
|
||||
import static org.fusesource.jansi.Ansi.*;
|
||||
|
||||
public class Client extends Thread {
|
||||
private int MAX_PORTION = 100;
|
||||
@@ -74,7 +75,8 @@ public class Client extends Thread {
|
||||
while(!restaurant.libre()){
|
||||
restaurant.wait();
|
||||
}
|
||||
System.out.println("+ " + this.getNameClient() + " : est entré dans le restaurant");
|
||||
System.out.println( ansi().fgGreen().a("+ ").reset().a(this.getNameClient() + " : est entré dans le restaurant"));
|
||||
//System.out.println("+ " + this.getNameClient() + " : est entré dans le restaurant");
|
||||
restaurant.ajouterClient();
|
||||
}catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
@@ -102,7 +104,9 @@ public class Client extends Thread {
|
||||
*/
|
||||
public void sort(){
|
||||
synchronized(restaurant){
|
||||
System.out.println("- " + this.getNameClient() + " : sorti");
|
||||
|
||||
System.out.println( ansi().fgRgb(255,0,0).a("- ").reset().a(this.getNameClient() + " : est sorti dans le restaurant"));
|
||||
//System.out.println("- " + this.getNameClient() + " : sorti");
|
||||
restaurant.diminuerClient();
|
||||
restaurant.notify();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import java.util.Random;
|
||||
import static org.fusesource.jansi.Ansi.*;
|
||||
|
||||
|
||||
public class Cuisinier extends Thread {
|
||||
Stand_de_cuisson stand;
|
||||
@@ -35,14 +37,17 @@ public class Cuisinier extends Thread {
|
||||
* une fois fini il indique au stand que la cuisson est fini (qui fait notifyAll aux clients)
|
||||
*/
|
||||
public void faire_cuire(Client client){
|
||||
System.out.println("# Cuisinier : fait cuire le plat de " + client.getNameClient()) ;
|
||||
System.out.println( ansi().fgRed().a("Cuisinier").reset().a(": fait cuire le plat de " + client.getNameClient()));
|
||||
//System.out.println("# Cuisinier : fait cuire le plat de " + client.getNameClient()) ;
|
||||
try{
|
||||
long temps_cuire =new Random().nextInt(400 - 200) + 200;
|
||||
Thread.sleep(temps_cuire);
|
||||
}catch(InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("# Cuisinier : a fini de cuire le plat de " + client.getNameClient()) ;
|
||||
System.out.println( ansi().fgRed().a("Cuisinier").reset().a(": a fini de cuire le plat de " + client.getNameClient()));
|
||||
|
||||
//System.out.println("# Cuisinier : a fini de cuire le plat de " + client.getNameClient()) ;
|
||||
stand.cuissonFini();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import static org.fusesource.jansi.Ansi.*;
|
||||
|
||||
public class Employe_du_buffet extends Thread{
|
||||
|
||||
public Buffet buffet;
|
||||
@@ -20,7 +22,8 @@ public class Employe_du_buffet extends Thread{
|
||||
try {
|
||||
compartiment.getSemaphore().acquire();
|
||||
if(compartiment.getQuantite()<100){
|
||||
System.out.println("Employe Buffer : remplie de stand " + compartiment.getName() + ", il ne restait plus que " + compartiment.getQuantite() +" g");
|
||||
System.out.println( ansi().fgBlue().a("Employe Buffer").reset().a(": remplie de stand " + compartiment.getName() + ", il ne restait plus que " + compartiment.getQuantite() +" g"));
|
||||
//System.out.println("Employe Buffer : remplie de stand " + compartiment.getName() + ", il ne restait plus que " + compartiment.getQuantite() +" g");
|
||||
compartiment.remplir();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user