This commit is contained in:
HORVILLE 2022-05-24 17:28:29 +02:00
parent c0b06ea837
commit 79791b395c
16 changed files with 1084 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,55 @@
package Devinette;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Devinette {
public static void main(String[] args) {
int rand = 0;
try (DataInputStream ois = new DataInputStream(new FileInputStream("/dev/random"))){
try {
rand = ois.readInt() % 100 + 1;
System.out.println(rand);
} catch (IOException e) {
System.err.println(e);
System.exit(1);
}
try {
ois.close();
} catch (IOException e) {
System.err.println(e);
System.exit(1);
}
} catch (IOException e) {
System.err.println(e);
System.exit(1);
}
try (BufferedReader ois = new BufferedReader(new InputStreamReader(System.in))) {
for (int i = 0; i < 5; i++) {
int guess = Integer.parseInt(ois.readLine());
System.out.println(guess + " " + rand);
if (guess == rand) {
System.out.println("Gagné !");
return;
} else if (guess > rand) {
System.out.println("-");
} else if (guess < rand) {
System.out.println("+");
}
}
System.out.println("Perdu !");
} catch (IOException e) {
System.exit(1);
}
}
}

Binary file not shown.

View File

@ -0,0 +1,22 @@
import javax.swing.JPanel;
import java.awt.*;
import java.awt.Image;
public class AwesomeImage extends JPanel {
private Image img;
public AwesomeImage(Image a) {
super();
this.img = a;
}
@Override
protected void paintComponent(Graphics g) {
Graphics newG = g.create();
if (this.isOpaque()) {
newG.setColor(this.getBackground());
newG.fillRect(0, 0, this.getWidth(), this.getHeight());
}
newG.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
}
}

Binary file not shown.

View File

@ -0,0 +1,61 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class Image {
public static void main(String[] args) {
try (BufferedReader r = new BufferedReader(new FileReader("image.xpm"))) {
r.readLine(); r.readLine(); r.readLine(); //On skip les 3 première lignes.
String[] infos = r.readLine().replaceAll("[\" ]", " ").trim().split(" ");
System.out.println(Arrays.toString(infos));
int columns = Integer.parseInt(infos[0]);
int rows = Integer.parseInt(infos[1]);
int colorCount = Integer.parseInt(infos[2]);
int charPerPixel = Integer.parseInt(infos[3]);
char[] paletteId = new char[colorCount];
Color[] palette = new Color[colorCount];
for (int i = 0; i < colorCount; i++) {
String colorInfos = r.readLine().replaceAll("[\"]", "");
paletteId[i] = colorInfos.charAt(0);
System.out.println(colorInfos.substring(4, 11));
palette[i] = Color.decode(colorInfos.substring(4, 11));
}
r.readLine(); //On skip la ligne pixels.
BufferedImage bi = new BufferedImage(columns, rows, BufferedImage.TYPE_3BYTE_BGR);
for (int i = 0; i < rows; i++) {
String row = r.readLine().replaceAll("\"", "");
for (int y = 0; y < columns; y++) {
char a = row.charAt(y);
for (int j = 0; j < paletteId.length; j++) {
if (paletteId[j] == a) {
bi.setRGB(y, i, palette[j].getRGB());
}
}
}
}
JFrame j = new JFrame();
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setSize(500 + 50, 500 + 50);
j.setLayout(null);
AwesomeImage a = new AwesomeImage(bi);
a.setLocation(10, 10);
a.setSize(500, 500);
j.add(a);
j.setVisible(true);
} catch (IOException e) {
}
}
}

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

Binary file not shown.

View File

@ -0,0 +1,53 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Conversion {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new FileReader(args[0]))) {
String fullContent = "";
String htmlContent = "";
{
int i = 0;
boolean canRead = true;
while (canRead) {
String content = br.readLine();
if (content != null) {
if (i == 0) {
fullContent += content;
} else {
fullContent += "<br>" + content;
}
i++;
} else canRead = false;
}
}
System.out.println(fullContent);
br.close();
try (BufferedReader br2 = new BufferedReader(new FileReader("base.html"))) {
htmlContent = br2.readLine();
br2.close();
} catch (Exception e) {
}
htmlContent = htmlContent.replaceAll("TOREPLACE", fullContent);
System.out.println(htmlContent);
try (BufferedWriter bw = new BufferedWriter(new FileWriter(args[0] + ".html"))) {
bw.write(htmlContent);
bw.close();
} catch (IOException e) {
}
} catch (IOException e) {
}
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><html lang="fr"><head><meta charset="utf-8"><title>OwO</title></head><body><p>TOREPLACE</p></body></html>

View File

@ -0,0 +1,9 @@
jiGJIOPAEJIOGOJIEAGJIOAEIO
ZFIAJPIFPJIAZJPF
AQG
AQGAZ
GAZ
GAZAZ
GAZAZ
GAZ

View File

@ -0,0 +1 @@
<!DOCTYPE html><html lang="fr"><head><meta charset="utf-8"><title>OwO</title></head><body><p>jiGJIOPAEJIOGOJIEAGJIOAEIO<br>ZFIAJPIFPJIAZJPF<br><br>AQG<br>AQGAZ<br>GAZ<br>GAZAZ<br>GAZAZ<br>GAZ</p></body></html>

Binary file not shown.

View File

@ -0,0 +1,70 @@
import java.awt.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Random;
import javax.swing.*;
public class Couleurs extends JPanel {
int max;
int index1 = -1;
int index2 = -1;
String[] nameList;
Color[] colorList;
public static void main(String[] args) {
JFrame f = new JFrame("OwO");
f.setSize(300, 300);
f.setLocation(100, 100);
f.setResizable(false);
f.add(new Couleurs());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
public Couleurs() {
super();
try (BufferedReader br = new BufferedReader(new FileReader("rgb.txt"))) {
br.mark(2000000000);
this.max = (int)br.lines().count();
br.reset();
this.nameList = new String[max];
this.colorList = new Color[max];
System.out.println(br.readLine());
for (int i = 0; i < max-1; i++) {
String[] infos = br.readLine().trim().split("[ \t]+");
nameList[i] = infos[3];
colorList[i] = new Color(Integer.parseInt(infos[0]), Integer.parseInt(infos[1]), Integer.parseInt(infos[2]));
}
Random r = new Random();
this.index1 = r.nextInt(max);
this.index2 = r.nextInt(max);
br.close();
} catch (IOException e) {
}
}
@Override
protected void paintComponent(Graphics g) {
Graphics newG = g.create();
if (this.isOpaque()) {
newG.setColor(this.getBackground());
newG.fillRect(0, 0, this.getWidth(), this.getHeight());
}
if (index1 != -1 && index2 != -1) {
newG.setColor(colorList[index1]);
newG.fillPolygon(new int[] {0, 0, this.getWidth()}, new int[] {0, this.getHeight(), this.getHeight()}, 3);
newG.setColor(colorList[index2]);
newG.fillPolygon(new int[] {0, this.getWidth(), this.getWidth()}, new int[] {0, 0, this.getHeight()}, 3);
}
}
}

View File

@ -0,0 +1,3 @@
public class Listener extends MouseListener {
}

File diff suppressed because it is too large Load Diff