Ajout des travaux effectuer

This commit is contained in:
2024-12-09 11:53:11 +01:00
parent 05fac8d3ae
commit c4e97e13da
558 changed files with 67900 additions and 0 deletions

Binary file not shown.

View 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);
}
}

View File

@@ -0,0 +1,11 @@
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class Conversion
{
public static void main(String[] args)
{
}
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,2 @@
MIDNIGHTBLUE
BLANCHEDALMOND

Binary file not shown.

View 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);
}
}
}

View 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");
}
}
}

View 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 ==========",
"============ ============",
"================================",
"================================"
};

View File

@@ -0,0 +1 @@
1,2,3,2,1,2