Ajout des travaux effectuer
This commit is contained in:
BIN
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Devinette.class
Normal file
BIN
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Devinette.class
Normal file
Binary file not shown.
42
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Devinette.java
Normal file
42
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Devinette.java
Normal file
@@ -0,0 +1,42 @@
|
||||
import java.util.Random;
|
||||
import java.io.*;
|
||||
|
||||
public class Devinette
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
Random rand = new Random();
|
||||
int number =(1+rand.nextInt(100));
|
||||
int tentative = 5;
|
||||
while(tentative > 0)
|
||||
{
|
||||
System.out.println("Nombre de tentative : "+tentative);
|
||||
--tentative;
|
||||
try{
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
|
||||
String player_input = input.readLine().trim();
|
||||
int player_try =Integer.parseInt(player_input);
|
||||
if(player_try == number)
|
||||
{
|
||||
System.out.println(player_try+" est le nombre mystere !");
|
||||
return;
|
||||
}
|
||||
else if(player_try < number)
|
||||
{
|
||||
System.out.println("C'est plus !");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("C'est moins !");
|
||||
}
|
||||
}catch(IOException e){
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
}catch(NumberFormatException e){
|
||||
System.out.println("Vous devez choisir un nombre !");
|
||||
}
|
||||
}
|
||||
System.out.println("Perdu ! C'est : "+number);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Conversion
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Couleur extends JComponent
|
||||
{
|
||||
protected void paintComponent(Graphics g)
|
||||
{
|
||||
Graphics secondPinceau = g.create();
|
||||
secondPinceau.setColor(Color.getColor());
|
||||
Polygon poly1 = new Polygon();
|
||||
poly1.addPoint(0,0);
|
||||
poly1.addPoint(this.getWidth(), 0);
|
||||
poly1.addPoint(this.getWidth(), this.getHeight());
|
||||
secondPinceau.fillPolygon(poly1);
|
||||
secondPinceau.setColor(Color.getColor());
|
||||
Polygon poly2 = new Polygon();
|
||||
poly2.addPoint(0, 0);
|
||||
poly2.addPoint(0, this.getHeight());
|
||||
poly2.addPoint(this.getWidth(), this.getHeight());
|
||||
secondPinceau.fillPolygon(poly2);
|
||||
}
|
||||
public String getColor(){
|
||||
try
|
||||
{
|
||||
FileReader fr = new FileReader("rgb.txt");
|
||||
StringReader sr = new StringReader(fr);
|
||||
try
|
||||
{
|
||||
sr.close();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
System.out.println("Erreur de fermeture");
|
||||
}
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
System.out.println("Erreur d'ouverture");
|
||||
}
|
||||
}
|
||||
public Couleur()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class TestCouleur
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(400, 400);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
Couleur coul = new Couleur();
|
||||
fenetre.add(coul);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
MIDNIGHTBLUE
|
||||
BLANCHEDALMOND
|
||||
BIN
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Image.class
Normal file
BIN
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Image.class
Normal file
Binary file not shown.
43
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Image.java
Normal file
43
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Image.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
|
||||
public class Image
|
||||
{
|
||||
public static String remove_quote(String line)
|
||||
{
|
||||
return line.substring(1,line.length()-2);
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
/*if(args.length == 0)
|
||||
{
|
||||
System.err.println("Need image path");
|
||||
System.exit(1);
|
||||
}*/
|
||||
try
|
||||
{
|
||||
BufferedReader img_file = new BufferedReader(new FileReader("./image.xpm"));
|
||||
String line = null;
|
||||
int width, height, number_of_colors, pixel_size;
|
||||
//Read metaData
|
||||
while((line= img_file.readLine())!=null)
|
||||
{
|
||||
if(line.charAt(0) != '"'){
|
||||
continue;
|
||||
}
|
||||
String[] metadatas = remove_quote(line).split(" ");
|
||||
width = Integer.parseInt(metadatas[0]);
|
||||
height = Integer.parseInt(metadatas[1]);
|
||||
number_of_colors = Integer.parseInt(metadatas[2]);
|
||||
pixel_size = Integer.parseInt(metadatas[3]);
|
||||
System.out.println(width+""+height+""+number_of_colors+""+pixel_size);
|
||||
break;
|
||||
}
|
||||
}catch(IOException | NumberFormatException e){
|
||||
System.err.println(e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Questionnaire.java
Normal file
29
23DEV1.1/TPS2/TP01/FluxDeCaracteres/Questionnaire.java
Normal file
@@ -0,0 +1,29 @@
|
||||
import java.io.*;
|
||||
|
||||
public class Questionnaire
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
try{
|
||||
BufferedReader Questionner = new BufferedReader(new InputStreamReader("java.quiz",false));
|
||||
BufferedReader listen = new BufferedReader(new InputStreamReader(System.in));
|
||||
BufferedWriter addrep = new BufferedWriter(new FileWriter("reponses.txt"));
|
||||
BufferedWriter erased = new BufferedWriter (new FileWriter("reponses.txt",false));
|
||||
if(listen.readLine() != null)
|
||||
{
|
||||
erased.write("");
|
||||
erased.close();
|
||||
}
|
||||
while(Questionner.readLine()){
|
||||
System.out.println();
|
||||
addrep.write(listen.readLine().trim());
|
||||
}
|
||||
addrep.write(listen.readLine().trim());
|
||||
addrep.close();
|
||||
}catch(IOException e){
|
||||
System.err.println(e.getMessage());
|
||||
}catch(NumberFormatException e){
|
||||
System.out.println("erreur");
|
||||
}
|
||||
}
|
||||
}
|
||||
56
23DEV1.1/TPS2/TP01/FluxDeCaracteres/image.xpm
Normal file
56
23DEV1.1/TPS2/TP01/FluxDeCaracteres/image.xpm
Normal file
@@ -0,0 +1,56 @@
|
||||
/* XPM */
|
||||
static char *test[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 35 15 1",
|
||||
" c #000000",
|
||||
". c #731810",
|
||||
"X c #A52918",
|
||||
"o c #FF5210",
|
||||
"O c #D64221",
|
||||
"+ c #FF8C10",
|
||||
"@ c #FFBD29",
|
||||
"# c #FFE739",
|
||||
"$ c #FFBD4A",
|
||||
"% c #FFFF63",
|
||||
"& c #9C8C8C",
|
||||
"* c #C6B5B5",
|
||||
"= c #B0D8D0",
|
||||
"- c #EFDEDE",
|
||||
"; c #FFFFFF",
|
||||
/* pixels */
|
||||
"================================",
|
||||
"================================",
|
||||
"=============O====o=============",
|
||||
"==============O==o#o============",
|
||||
"==============oO=o@o============",
|
||||
"==============ooOo+o============",
|
||||
"==========o===o+o=o=============",
|
||||
"=========o@o=Oo++o==============",
|
||||
"=========ooo=o+@+o==============",
|
||||
"==========o=O++@+oO=============",
|
||||
"============o+@#@o+O============",
|
||||
"===========O+@#;#+@+o===========",
|
||||
"===========O+#;;;+#@o===========",
|
||||
"===========o@;;;;@#o============",
|
||||
"=== =======..........======= ===",
|
||||
"== = = ==..XXOOooOOXX..== = = ==",
|
||||
"= = =.XXoOO OOoXX.= = =",
|
||||
"== XXXX % % XXXX ==",
|
||||
"=== oX XXX XXX Xo ===",
|
||||
"=====X o$X -& &- X$o X=====",
|
||||
"=====X o$$o ;;;;;; o$$o X=====",
|
||||
"===== Xoo$$$ -;oo;- $$$ooX =====",
|
||||
"===== OoX$Xoo ;;;; ooX$XoO =====",
|
||||
"===== Xo o O -;;- O o oX =====",
|
||||
"====== O O = -- = O O ======",
|
||||
"======= = *= o o =* = =======",
|
||||
"=========== * oooo * ===========",
|
||||
"=========== oooooo ===========",
|
||||
"========== XooooooX ==========",
|
||||
"========= X XooooooX X =========",
|
||||
"========= OooOOOOOOooO =========",
|
||||
"========== oooooooo ==========",
|
||||
"============ ============",
|
||||
"================================",
|
||||
"================================"
|
||||
};
|
||||
1
23DEV1.1/TPS2/TP01/FluxDeCaracteres/reponses.txt
Normal file
1
23DEV1.1/TPS2/TP01/FluxDeCaracteres/reponses.txt
Normal file
@@ -0,0 +1 @@
|
||||
1,2,3,2,1,2
|
||||
Reference in New Issue
Block a user