This commit is contained in:
Menouer MELIANI 2023-04-04 14:03:16 +02:00
parent 7021891e9c
commit e32d4de827
111 changed files with 1928 additions and 6 deletions

View File

@ -0,0 +1,36 @@
//MELIANI SAMY (TP1)
public class Deduction{
public static void main(String[] args) {
Deduction2 compte = new Deduction2();
compte.voir();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.vider();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
System.out.println(compte.toString());
Deduction3 compte2 = new Deduction3();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
System.out.println(compte2.toString());
}
}

View File

@ -0,0 +1,39 @@
//MELIANI SAMY (TP1)
public class Deduction2{
private int Limite, identifiant, Credit;
private int Accumulation;
public Deduction2(){
Limite = 10;
Accumulation=0;
Credit = 0;
identifiant = 253782;
}
public int voir(){
return Credit;
}
public void crediter(){
if (Credit < 10){
Credit += 1;
Accumulation += 1;
}
else{
Credit = 1;
Accumulation += 1;
}
}
public void vider(){
Credit = 0;
}
public String toString(){
String str = "";
str += "identifiant : " + identifiant + " ";
str += "Crédits restants : " + Credit + " ";
str += "Accumulation : " + Accumulation;
if(Credit == 10){
str+= " PLAT OFFERT ";
}
return str;
}
}

View File

@ -0,0 +1,30 @@
//MELIANI SAMY (TP1)
public class Deduction3{
private int Limite, identifiant, Credit;
private int Accumulation;
public Deduction3(){
Limite = 10;
Accumulation=0;
Credit = 10;
identifiant = 253782;
}
public int voir(){
return Credit;
}
public void crediter(){
Accumulation += 1;
}
public void vider(){
Credit = 10;
}
public String toString(){
String str = "";
str += "YesCard USER ";
str += "identifiant : " + identifiant + " ";
str += "Crédits restants : " + Credit + " ";
str += "Accumulation : " + Accumulation;
str+= " PLAT OFFERT ";
return str;
}
}

Binary file not shown.

View File

@ -0,0 +1,14 @@
import java.awt.*;
//MELIANI SAMY (TP1)
public class Decapite{
public static void main(String[] args) {
boolean ihl1= GraphicsEnvironment.isHeadless();
GraphicsEnvironment ihl2 = new GraphicsEnvironment();
boolean yes = ihl2.isHeadlessInstance();
if(ihl1){
System.out.println("oui");
}
}
}

Binary file not shown.

View File

@ -0,0 +1,29 @@
//MELIANI SAMY (TP1)
import javax.swing.*;
import java.awt.*;
public class Directions {
public static void main(String[] args) {
// un objet pour servir de fenetre
JFrame fenetre = new JFrame();
// on configure la fenetre
fenetre.setSize(800, 800);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout layout = new GridLayout(2, 2);
fenetre.setLayout(layout);
fenetre.add(new Button(""));
fenetre.add(new Button(""));
fenetre.add(new Button(""));
fenetre.add(new Button(""));
layout.setHgap(500);
layout.setVgap(500);
layout.setAlignment(100);
fenetre.setVisible(true);
}
}

View File

@ -0,0 +1,18 @@
//MELIANI SAMY (TP1)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Debut {
public static void main(String[] args) {
JFrame fenetre = new JFrame("");
fenetre.setSize(650,650);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Debut2 appel1 = new Debut2();
Debut3 appel2 = new Debut3(appel1);
fenetre.addMouseListener(appel2);
fenetre.add(appel1);
fenetre.setVisible(true);
}
}

View File

@ -0,0 +1,30 @@
//MELIANI SAMY (TP1)
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
public class Debut2 extends JComponent {
private int rayon;
public Debut2(){
super();
rayon = 60;
}
public void getrayon(int radius){
this.rayon=radius;
this.repaint();
}
@Override
public void paintComponent(Graphics pinceau){
Graphics secondPinceau=pinceau.create();
if(this.isOpaque()){
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
secondPinceau.setColor(new Color(115,194,251));
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
secondPinceau.setColor(Color.YELLOW);
secondPinceau.fillOval((this.getWidth()/2)-(this.rayon/2), (this.getHeight())-(this.rayon/2), this.rayon, this.rayon);
}
}

View File

@ -0,0 +1,23 @@
//MELIANI SAMY (TP1)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Debut3 implements MouseListener{
private int rayon;
private Debut2 ref;
public Debut3(Debut2 appel){
super();
this.rayon=60;
this.ref=appel;
}
public void mouseEntered(MouseEvent evenement){}
public void mousePressed(MouseEvent evenement){}
public void mouseReleased(MouseEvent evenement){}
public void mouseExited(MouseEvent evenement){}
public void mouseClicked(MouseEvent evenement){
this.rayon+=20;
ref.getrayon(this.rayon);
}
}

View File

@ -0,0 +1,36 @@
//MELIANI SAMY (TP1)
public class Deduction{
public static void main(String[] args) {
Deduction2 compte = new Deduction2();
compte.voir();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.vider();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
compte.crediter();
System.out.println(compte.toString());
Deduction3 compte2 = new Deduction3();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
compte2.crediter();
System.out.println(compte2.toString());
}
}

View File

@ -0,0 +1,39 @@
//MELIANI SAMY (TP1)
public class Deduction2{
private int Limite, identifiant, Credit;
private int Accumulation;
public Deduction2(){
Limite = 10;
Accumulation=0;
Credit = 0;
identifiant = 253782;
}
public int voir(){
return Credit;
}
public void crediter(){
if (Credit < 10){
Credit += 1;
Accumulation += 1;
}
else{
Credit = 1;
Accumulation += 1;
}
}
public void vider(){
Credit = 0;
}
public String toString(){
String str = "";
str += "identifiant : " + identifiant + " ";
str += "Crédits restants : " + Credit + " ";
str += "Accumulation : " + Accumulation;
if(Credit == 10){
str+= " PLAT OFFERT ";
}
return str;
}
}

View File

@ -0,0 +1,30 @@
//MELIANI SAMY (TP1)
public class Deduction3{
private int Limite, identifiant, Credit;
private int Accumulation;
public Deduction3(){
Limite = 10;
Accumulation=0;
Credit = 10;
identifiant = 253782;
}
public int voir(){
return Credit;
}
public void crediter(){
Accumulation += 1;
}
public void vider(){
Credit = 10;
}
public String toString(){
String str = "";
str += "YesCard USER ";
str += "identifiant : " + identifiant + " ";
str += "Crédits restants : " + Credit + " ";
str += "Accumulation : " + Accumulation;
str+= " PLAT OFFERT ";
return str;
}
}

View File

@ -0,0 +1,14 @@
import java.awt.*;
//MELIANI SAMY (TP1)
public class Decapite{
public static void main(String[] args) {
boolean ihl1= GraphicsEnvironment.isHeadless();
GraphicsEnvironment ihl2 = new GraphicsEnvironment();
boolean yes = ihl2.isHeadlessInstance();
if(ihl1){
System.out.println("oui");
}
}
}

View File

@ -0,0 +1,51 @@
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Direction extends JFrame{
GridLayout grid = new GridLayout(2, 2);
public Direction(){
grid.setHgap(350);
grid.setVgap(350);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1900,900);
frame.setVisible(true);
JPanel panel = new JPanel();
frame.setContentPane(panel);
panel.setLayout(grid);
JButton btn1 = new JButton("");
btn1.setSize(20,50);
panel.add(btn1);
JButton btn2 = new JButton("");
panel.add(btn2);
JButton btn3 = new JButton("");
panel.add(btn3);
JButton btn4 = new JButton("");
panel.add(btn4);
}
public static void main(String[] args) {
new Direction();
}
}

View File

@ -0,0 +1,29 @@
//MELIANI SAMY (TP1)
import javax.swing.*;
import java.awt.*;
public class Directions {
public static void main(String[] args) {
// un objet pour servir de fenetre
JFrame fenetre = new JFrame();
// on configure la fenetre
fenetre.setSize(800, 800);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout layout = new GridLayout(2, 2);
fenetre.setLayout(layout);
fenetre.add(new Button(""));
fenetre.add(new Button(""));
fenetre.add(new Button(""));
fenetre.add(new Button(""));
layout.setHgap(500);
layout.setVgap(500);
layout.setAlignment(100);
fenetre.setVisible(true);
}
}

View File

@ -0,0 +1,18 @@
//MELIANI SAMY (TP1)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Debut {
public static void main(String[] args) {
JFrame fenetre = new JFrame("");
fenetre.setSize(650,650);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Debut2 appel1 = new Debut2();
Debut3 appel2 = new Debut3(appel1);
fenetre.addMouseListener(appel2);
fenetre.add(appel1);
fenetre.setVisible(true);
}
}

View File

@ -0,0 +1,30 @@
//MELIANI SAMY (TP1)
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JComponent;
public class Debut2 extends JComponent {
private int rayon;
public Debut2(){
super();
rayon = 60;
}
public void getrayon(int radius){
this.rayon=radius;
this.repaint();
}
@Override
public void paintComponent(Graphics pinceau){
Graphics secondPinceau=pinceau.create();
if(this.isOpaque()){
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
secondPinceau.setColor(new Color(115,194,251));
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
secondPinceau.setColor(Color.YELLOW);
secondPinceau.fillOval((this.getWidth()/2)-(this.rayon/2), (this.getHeight())-(this.rayon/2), this.rayon, this.rayon);
}
}

View File

@ -0,0 +1,23 @@
//MELIANI SAMY (TP1)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Debut3 implements MouseListener{
private int rayon;
private Debut2 ref;
public Debut3(Debut2 appel){
super();
this.rayon=60;
this.ref=appel;
}
public void mouseEntered(MouseEvent evenement){}
public void mousePressed(MouseEvent evenement){}
public void mouseReleased(MouseEvent evenement){}
public void mouseExited(MouseEvent evenement){}
public void mouseClicked(MouseEvent evenement){
this.rayon+=20;
ref.getrayon(this.rayon);
}
}

View File

@ -0,0 +1,3 @@
public class Aléatoire{
}

Binary file not shown.

View File

@ -0,0 +1,12 @@
import java.lang.Math;
import java.util.Random;
public class Aléatoire{
public static void main(String[] args) {
double nb1;
nb1 = Math.random();
Random nb2 = new Random();
System.out.println("random propose : "+ nb1);
System.out.println("nextDouble propose : "+ nb2.nextDouble());
}
}

View File

@ -0,0 +1,52 @@
//HORVILLE Ewen Groupe N°4
public class Grille {
private short[][] Cases = new short[7][6];
private int joueurActuel;
public Grille() {
joueurActuel = 0;
}
public void jouer(int colonne) {
if (colonne < 1 && colonne > 7) {
System.out.println("N° de colonne invalide !");
return;
}
boolean placementValide = false;
for (int i = 5; i >= 0; i--) {
if (Cases[colonne-1][i] == 0) {
Cases[colonne-1][i] = (short)(joueurActuel+1);
joueurActuel = (joueurActuel + 1) % 2;
placementValide = true;
break;
}
}
if (!placementValide) {
System.out.println("Colonne n°" + colonne + " pleine !");
}
}
@Override
public String toString() {
String str = "";
for (int x = 0; x < 6; x++) {
for (int y = 0; y < 7; y++) {
str += "";
if (Cases[y][x] == 0) str += " ";
else if (Cases[y][x] == 1) str += "";
else if (Cases[y][x] == 2) str += "";
}
str += "\n";
}
str += "┴─┴─┴─┴─┴─┴─┴─┴";
return str;
}
}

View File

@ -0,0 +1,48 @@
public class MaGrille {
private String[][] Grille;
private int i, j, ligne, colonne, tour = 0;
public MaGrille(int li, int col) {
this.ligne = li;
this.colonne = col;
}
public MaGrille Gvide(int l, int c) {
MaGrille newGrille = new MaGrille(this.ligne, this.colonne);
String[][] grille = new String[newGrille.ligne][newGrille.colonne];
for(i=0;i<grille.length;i++) {
for(j=0;j<grille[i].length;j++) {
grille[i][j] = " ";
}
}
this.Grille = grille;
return null;
}
public String toString() {
String str = "";
for (i=0;i<Grille.length;i++) {
str += "";
for (j=0;j<Grille[i].length;j++) {
str += Grille[i][j] + "";
}
str += "\n";
}
return str + "┴─┴─┴─┴─┴─┴─┴─┴";
}
public void Jouer(int colonne) {
for (i=Grille.length-1;i>0;i--) {
if (Grille[i][colonne-1] == " ") {
if (tour%2 == 0) {
this.Grille[i][colonne-1] = "o";
tour++;
}
else {
this.Grille[i][colonne-1] = "x";
tour++;
}
}
}
}
}

View File

@ -0,0 +1,15 @@
public class Puissance {
public static void main(String[] args) {
MaGrille grille = new MaGrille(6, 7);
grille.Gvide(6, 7);
grille.Jouer(3);
grille.Jouer(4);
grille.Jouer(4);
grille.Jouer(6);
grille.Jouer(4);
grille.Jouer(6);
System.out.println(grille.toString());
}
}

View File

@ -0,0 +1,15 @@
//HORVILLE Ewen Groupe N°4
public class Puissance {
public static void main(String[] args) {
Grille g = new Grille();
g.jouer(3);
g.jouer(4);
g.jouer(4);
g.jouer(6);
g.jouer(4);
g.jouer(6);
System.out.println(g);
}
}

View File

@ -0,0 +1,292 @@
{
"_type": "Project",
"_id": "AAAAAAFF+h6SjaM2Hec=",
"name": "Untitled",
"ownedElements": [
{
"_type": "UMLModel",
"_id": "AAAAAAFF+qBWK6M3Z8Y=",
"_parent": {
"$ref": "AAAAAAFF+h6SjaM2Hec="
},
"name": "Model",
"ownedElements": [
{
"_type": "UMLClassDiagram",
"_id": "AAAAAAFF+qBtyKM79qY=",
"_parent": {
"$ref": "AAAAAAFF+qBWK6M3Z8Y="
},
"name": "Main",
"defaultDiagram": true,
"ownedViews": [
{
"_type": "UMLClassView",
"_id": "AAAAAAGHKCIlSPo2MVY=",
"_parent": {
"$ref": "AAAAAAFF+qBtyKM79qY="
},
"model": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"subViews": [
{
"_type": "UMLNameCompartmentView",
"_id": "AAAAAAGHKCIlSfo3DSc=",
"_parent": {
"$ref": "AAAAAAGHKCIlSPo2MVY="
},
"model": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"subViews": [
{
"_type": "LabelView",
"_id": "AAAAAAGHKCIlSfo48Ks=",
"_parent": {
"$ref": "AAAAAAGHKCIlSfo3DSc="
},
"visible": false,
"font": "Arial;13;0",
"top": -16,
"height": 13
},
{
"_type": "LabelView",
"_id": "AAAAAAGHKCIlSvo5dwo=",
"_parent": {
"$ref": "AAAAAAGHKCIlSfo3DSc="
},
"font": "Arial;13;1",
"left": 437,
"top": 255,
"width": 230,
"height": 13,
"text": "Grille"
},
{
"_type": "LabelView",
"_id": "AAAAAAGHKCIlSvo6CzE=",
"_parent": {
"$ref": "AAAAAAGHKCIlSfo3DSc="
},
"visible": false,
"font": "Arial;13;0",
"top": -16,
"width": 73.67724609375,
"height": 13,
"text": "(from Model)"
},
{
"_type": "LabelView",
"_id": "AAAAAAGHKCIlSvo7yPk=",
"_parent": {
"$ref": "AAAAAAGHKCIlSfo3DSc="
},
"visible": false,
"font": "Arial;13;0",
"top": -16,
"height": 13,
"horizontalAlignment": 1
}
],
"font": "Arial;13;0",
"left": 432,
"top": 248,
"width": 240,
"height": 25,
"stereotypeLabel": {
"$ref": "AAAAAAGHKCIlSfo48Ks="
},
"nameLabel": {
"$ref": "AAAAAAGHKCIlSvo5dwo="
},
"namespaceLabel": {
"$ref": "AAAAAAGHKCIlSvo6CzE="
},
"propertyLabel": {
"$ref": "AAAAAAGHKCIlSvo7yPk="
}
},
{
"_type": "UMLAttributeCompartmentView",
"_id": "AAAAAAGHKCIlSvo8Uko=",
"_parent": {
"$ref": "AAAAAAGHKCIlSPo2MVY="
},
"model": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"subViews": [
{
"_type": "UMLAttributeView",
"_id": "AAAAAAGHKCJMvPpheJY=",
"_parent": {
"$ref": "AAAAAAGHKCIlSvo8Uko="
},
"model": {
"$ref": "AAAAAAGHKCJMuPpekSE="
},
"font": "Arial;13;0",
"left": 437,
"top": 278,
"width": 230,
"height": 13,
"text": "+Attribute1",
"horizontalAlignment": 0
},
{
"_type": "UMLAttributeView",
"_id": "AAAAAAGHKCMAjvpq7Tw=",
"_parent": {
"$ref": "AAAAAAGHKCIlSvo8Uko="
},
"model": {
"$ref": "AAAAAAGHKCMAffpn4Pg="
},
"font": "Arial;13;0",
"left": 437,
"top": 293,
"width": 230,
"height": 13,
"text": "+Attribute2",
"horizontalAlignment": 0
}
],
"font": "Arial;13;0",
"left": 432,
"top": 273,
"width": 240,
"height": 38
},
{
"_type": "UMLOperationCompartmentView",
"_id": "AAAAAAGHKCIlS/o9i6E=",
"_parent": {
"$ref": "AAAAAAGHKCIlSPo2MVY="
},
"model": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"subViews": [
{
"_type": "UMLOperationView",
"_id": "AAAAAAGHKCObzvp6IIc=",
"_parent": {
"$ref": "AAAAAAGHKCIlS/o9i6E="
},
"model": {
"$ref": "AAAAAAGHKCObvPp3kUs="
},
"font": "Arial;13;0",
"left": 437,
"top": 316,
"width": 230,
"height": 13,
"text": "+Operation1()",
"horizontalAlignment": 0
}
],
"font": "Arial;13;0",
"left": 432,
"top": 311,
"width": 240,
"height": 23
},
{
"_type": "UMLReceptionCompartmentView",
"_id": "AAAAAAGHKCIlS/o+pRA=",
"_parent": {
"$ref": "AAAAAAGHKCIlSPo2MVY="
},
"model": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"visible": false,
"font": "Arial;13;0",
"top": -8,
"width": 10,
"height": 10
},
{
"_type": "UMLTemplateParameterCompartmentView",
"_id": "AAAAAAGHKCIlTPo/W/0=",
"_parent": {
"$ref": "AAAAAAGHKCIlSPo2MVY="
},
"model": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"visible": false,
"font": "Arial;13;0",
"top": -8,
"width": 10,
"height": 10
}
],
"font": "Arial;13;0",
"containerChangeable": true,
"left": 432,
"top": 248,
"width": 240,
"height": 216,
"nameCompartment": {
"$ref": "AAAAAAGHKCIlSfo3DSc="
},
"attributeCompartment": {
"$ref": "AAAAAAGHKCIlSvo8Uko="
},
"operationCompartment": {
"$ref": "AAAAAAGHKCIlS/o9i6E="
},
"receptionCompartment": {
"$ref": "AAAAAAGHKCIlS/o+pRA="
},
"templateParameterCompartment": {
"$ref": "AAAAAAGHKCIlTPo/W/0="
}
}
]
},
{
"_type": "UMLClass",
"_id": "AAAAAAGHKCIlRfo0xPg=",
"_parent": {
"$ref": "AAAAAAFF+qBWK6M3Z8Y="
},
"name": "Grille",
"attributes": [
{
"_type": "UMLAttribute",
"_id": "AAAAAAGHKCJMuPpekSE=",
"_parent": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"name": "Attribute1",
"type": ""
},
{
"_type": "UMLAttribute",
"_id": "AAAAAAGHKCMAffpn4Pg=",
"_parent": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"name": "Attribute2",
"type": ""
}
],
"operations": [
{
"_type": "UMLOperation",
"_id": "AAAAAAGHKCObvPp3kUs=",
"_parent": {
"$ref": "AAAAAAGHKCIlRfo0xPg="
},
"name": "Operation1"
}
]
}
]
}
]
}

Binary file not shown.

View File

@ -0,0 +1,43 @@
import javax.swing.*;
import java.awt.*;
public class CrocsCars extends JComponent{
private Image pingouin;
public CrocsCars(){
super();
this.pingouin = Toolkit.getDefaultToolkit().getImage("tuile.png");
}
@Override
protected void paintComponent(Graphics pinceau){
Graphics secondPinceau = pinceau.create();
if (this.isOpaque()){
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
secondPinceau.drawImage(this.pingouin, 0, 0,this);
secondPinceau.drawImage(this.pingouin, 512, 0,this);
secondPinceau.drawImage(this.pingouin, 0, 512,this);
secondPinceau.drawImage(this.pingouin, 512, 512,this);
if(this.getHeight() >= 1024){
secondPinceau.drawImage(this.pingouin, 0, 1024,this);
secondPinceau.drawImage(this.pingouin, 512, 1024,this);
if(this.getWidth() >= 1024){
secondPinceau.drawImage(this.pingouin, 1024, 1024,this);
}
if(this.getWidth() >= 1024){
secondPinceau.drawImage(this.pingouin, 1024, 0,this);
secondPinceau.drawImage(this.pingouin, 1024, 512,this);
if(this.getHeight() >= 1024){
secondPinceau.drawImage(this.pingouin, 1024, 1024,this);
}
}
}
}
}

Binary file not shown.

View File

@ -0,0 +1,14 @@
import javax.swing.*;
import java.awt.*;
public class Tuile{
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(1920,1080);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
CrocsCars cadre = new CrocsCars();
fenetre.add(cadre);
fenetre.setVisible(true);
}
}

View File

@ -0,0 +1,29 @@
import java.awt.;
import javax.swing.;
public class TileBackground extends JComponent {
private Image tile;
private int tileScale;
public TileBackground(int tileScale, String imagePath) {
super();
this.tile = Toolkit.getDefaultToolkit().getImage(imagePath);
this.tileScale = tileScale;
}
@Override
protected void paintComponent(Graphics brush) {
Graphics newBrush = brush.create();
if (this.isOpaque()) {
newBrush.setColor(this.getBackground());
newBrush.fillRect(0, 0, this.getWidth(), this.getHeight());
}
int horizontalReps = this.getWidth() / this.tileScale + 1;
int verticalReps = this.getHeight() / this.tileScale + 1;
for (int x = 0; x < horizontalReps; x++) {
for (int y = 0; y < verticalReps; y++) {
newBrush.drawImage(this.tile, x * tileScale, y * tileScale, tileScale, tileScale, this);
}
}
}
}

View File

@ -0,0 +1,13 @@
import javax.swing.*;
public class Tuile2 {
public static void main(String[] args) {
JFrame f = new JFrame("Tuile");
f.setLocation(150, 150);
f.setSize(500, 500);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
TileBackground tb = new TileBackground(150, "./tuile.jpg");
f.add(tb);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

View File

@ -0,0 +1,21 @@
import java.awt.*;
import javax.swing.*;
public class Fermeture{
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(800, 800);
Oui yeet = new Oui();
while(yeet.checkVrai()!= true){
fenetre.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
fenetre.setVisible(true);
}
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.addWindowListener(yeet);
fenetre.setVisible(true);
}
}

Binary file not shown.

View File

@ -0,0 +1,28 @@
import java.awt.event.*;
import javax.swing.*;
public class Oui implements WindowListener{
private int a;
public Oui(){
super();
this.a=0;
}
public void windowActivated(WindowEvent evenement){} // premier plan
public void windowClosed(WindowEvent evenement){} // après fermeture
public void windowClosing(WindowEvent evenement){} // avant fermeture
public void windowDeactivated(WindowEvent evenement){} // arrière-plan
public void windowDeiconified(WindowEvent evenement){} // restauration
public void windowOpened(WindowEvent evenement){}
public void windowIconified(WindowEvent e){
this.a=1;
}
public boolean checkVrai(){
if (this.a == 1){
return true;
}
else{
return false;
}
}
}

BIN
DEV2.1/TP02/Contin.class Normal file

Binary file not shown.

31
DEV2.1/TP02/Contin.java Normal file
View File

@ -0,0 +1,31 @@
import javax.swing.*;
import java.awt.*;
public class Contin {
public static void main(String[] args) {
// un objet pour servir de fenetre
JFrame fenetre = new JFrame();
// on configure la fenetre
fenetre.setSize(900, 600);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// un composant pour afficher du texte
JTextField etiquette = new JTextField("JE suis un texte oui je suis du texte !");
// on configure l'etiquette
etiquette.setForeground(new Color(0,255,0));
etiquette.setBackground(new Color(211,211,211));
etiquette.setHorizontalAlignment(JTextField.CENTER);
fenetre.add(etiquette, BorderLayout.SOUTH);
JTextArea champ = new JTextArea();
champ.setLineWrap(true);
champ.setBackground(new Color(0,0,0));
champ.setForeground(new Color(0,255,0));
fenetre.add(champ, BorderLayout.CENTER);
JScrollPane barre = new JScrollPane(champ);
barre.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
fenetre.add(barre, BorderLayout.CENTER);
fenetre.setVisible(true);
}
}

BIN
DEV2.1/TP03/Choix.class Normal file

Binary file not shown.

View File

@ -1,8 +1,7 @@
import javax.sql.rowset.serial.SerialArray;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
public class Choix { public class Choix{
public static void main(String[] args) { public static void main(String[] args) {
// un objet pour servir de fenetre // un objet pour servir de fenetre
JFrame fenetre = new JFrame(); JFrame fenetre = new JFrame();
@ -17,20 +16,25 @@ public class Choix {
JRadioButton Serdaigle = new JRadioButton("Serdaigle"); JRadioButton Serdaigle = new JRadioButton("Serdaigle");
Serdaigle.setHorizontalAlignment(JRadioButton.CENTER); Serdaigle.setHorizontalAlignment(JRadioButton.CENTER);
fenetre.add(Serdaigle, BorderLayout.CENTER); fenetre.add(Serdaigle, BorderLayout.EAST);
JRadioButton Serpentard = new JRadioButton("Serpentard"); JRadioButton Serpentard = new JRadioButton("Serpentard");
Serpentard.setHorizontalAlignment(JRadioButton.CENTER); Serpentard.setHorizontalAlignment(JRadioButton.CENTER);
fenetre.add(Serpentard, BorderLayout.SOUTH); fenetre.add(Serpentard, BorderLayout.WEST);
JRadioButton Poufsouffle = new JRadioButton("PoufsouffleEclaté");
Poufsouffle.setHorizontalAlignment(JRadioButton.CENTER);
fenetre.add(Poufsouffle, BorderLayout.SOUTH);
ButtonGroup Groupe = new ButtonGroup(); ButtonGroup Groupe = new ButtonGroup();
Groupe.add(Gryffondor); Groupe.add(Gryffondor);
Groupe.add(Serdaigle); Groupe.add(Serdaigle);
Groupe.add(Serpentard); Groupe.add(Serpentard);
Groupe.add(Poufsouffle);
Dimension size = new Dimension(300,150);
fenetre.setMinimumSize(size);
fenetre.setVisible(true); fenetre.setVisible(true);
} }
} }

BIN
DEV2.1/TP03/Damier.class Normal file

Binary file not shown.

33
DEV2.1/TP03/Damier.java Normal file
View File

@ -0,0 +1,33 @@
import javax.swing.*;
import java.awt.*;
public class Damier{
public static void main(String[] args) {
// un objet pour servir de fenetre
JFrame fenetre = new JFrame("Damier");
// on configure la fenetre
fenetre.setSize(500, 500);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// on fait la grille
int ligne = Integer.parseInt(args[0]);
GridLayout grille = new GridLayout(ligne,ligne);
fenetre.setLayout(grille);
for(int i=0; i <ligne ; i++){
for(int j=0; j<ligne ; j++){
JPanel panneau = new JPanel();
if((j%2) == (i%2)){
panneau.setBackground(Color.CYAN);
fenetre.add(panneau);
}
else{
panneau.setBackground(Color.WHITE);
fenetre.add(panneau);
}
}
}
fenetre.setVisible(true);
}
}

BIN
DEV2.1/TP03/Question.class Normal file

Binary file not shown.

33
DEV2.1/TP03/Question.java Normal file
View File

@ -0,0 +1,33 @@
import javax.swing.*;
import java.awt.*;
public class Question{
public static void main(String[] args) {
// un objet pour servir de fenetre
JFrame fenetre = new JFrame("Question");
// on configure la fenetre
fenetre.setSize(500, 250);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grille = new GridLayout(2,1);
fenetre.setLayout(grille);
JLabel texte = new JLabel("Aimez vous les chiens");
texte.setHorizontalAlignment(JLabel.CENTER);
fenetre.add(texte, BorderLayout.CENTER);
JPanel panneau = new JPanel();
JButton bouton = new JButton("Oui");
JButton bouton2 = new JButton("Non");
JButton bouton3 = new JButton("NSPP");
panneau.add(bouton);
panneau.add(bouton2);
panneau.add(bouton3);
fenetre.add(panneau, BorderLayout.SOUTH);
Dimension size = new Dimension(250,125);
fenetre.setMinimumSize(size);
fenetre.setVisible(true);
}
}

BIN
DEV2.1/TP04/Alligner.class Normal file

Binary file not shown.

65
DEV2.1/TP04/Alligner.java Normal file
View File

@ -0,0 +1,65 @@
public class Alligner{
private int jour;
private int mois;
private int annee;
public Alligner(){
this.jour = 14;
this.mois = 02;
this.annee = 2023;
}
public lendemain(){
if(this.mois != 2){
if (this.jour == 30){
if(this.mois<=7){
if(this.jour%2 == 0){
this.jour = 1;
}
else{
this.jour += 1;
}
}
if(this.mois >= 8){
if(this.jour%2 == 0){
this.jour +=1
}
else{
this.jour = 1;
}
}
}
}
else{
if (this.jour == 28){
this.jour == 1;
}
else{
this.jour +=1;
}
}
if(this.jour == 31){
this.jour == 1;
}
if (this.jour ==1){
if(this.mois !=12){
this.mois+=1;
}
else{
this.mois = 1;
this.annee +=1;
}
}
}
public String toString(){
/*if(this.jour <10){
return Integer.toString(this.annee) +"-" + Integer.toString(this.mois) + "-0" + Integer.toString(this.jour);
}
if(this.mois <10){
return Integer.toString(this.annee) +"-0" + Integer.toString(this.mois) + "-" + Integer.toString(this.jour);
}
if(this.annee < 1000){
return "0" + Integer.toString(this.annee) +"-" + Integer.toString(this.mois) + "-" + Integer.toString(this.jour); */
return Integer.toString(this.annee) +"-" + Integer.toString(this.mois) + "-" + Integer.toString(this.jour);
}
}

BIN
DEV2.1/TP04/Compteur.class Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More