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 java.util.Random;
|
||||||
|
import static org.fusesource.jansi.Ansi.*;
|
||||||
|
|
||||||
public class Client extends Thread {
|
public class Client extends Thread {
|
||||||
private int MAX_PORTION = 100;
|
private int MAX_PORTION = 100;
|
||||||
@@ -74,7 +75,8 @@ public class Client extends Thread {
|
|||||||
while(!restaurant.libre()){
|
while(!restaurant.libre()){
|
||||||
restaurant.wait();
|
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();
|
restaurant.ajouterClient();
|
||||||
}catch (InterruptedException e) {
|
}catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -102,7 +104,9 @@ public class Client extends Thread {
|
|||||||
*/
|
*/
|
||||||
public void sort(){
|
public void sort(){
|
||||||
synchronized(restaurant){
|
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.diminuerClient();
|
||||||
restaurant.notify();
|
restaurant.notify();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import static org.fusesource.jansi.Ansi.*;
|
||||||
|
|
||||||
|
|
||||||
public class Cuisinier extends Thread {
|
public class Cuisinier extends Thread {
|
||||||
Stand_de_cuisson stand;
|
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)
|
* une fois fini il indique au stand que la cuisson est fini (qui fait notifyAll aux clients)
|
||||||
*/
|
*/
|
||||||
public void faire_cuire(Client client){
|
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{
|
try{
|
||||||
long temps_cuire =new Random().nextInt(400 - 200) + 200;
|
long temps_cuire =new Random().nextInt(400 - 200) + 200;
|
||||||
Thread.sleep(temps_cuire);
|
Thread.sleep(temps_cuire);
|
||||||
}catch(InterruptedException e){
|
}catch(InterruptedException e){
|
||||||
e.printStackTrace();
|
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();
|
stand.cuissonFini();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import static org.fusesource.jansi.Ansi.*;
|
||||||
|
|
||||||
public class Employe_du_buffet extends Thread{
|
public class Employe_du_buffet extends Thread{
|
||||||
|
|
||||||
public Buffet buffet;
|
public Buffet buffet;
|
||||||
@@ -20,7 +22,8 @@ public class Employe_du_buffet extends Thread{
|
|||||||
try {
|
try {
|
||||||
compartiment.getSemaphore().acquire();
|
compartiment.getSemaphore().acquire();
|
||||||
if(compartiment.getQuantite()<100){
|
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();
|
compartiment.remplir();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user