13 Fevrier

This commit is contained in:
Adrian POURCHOT 2023-02-13 11:29:17 +01:00
parent bc03374f78
commit 3e5709c01d
19 changed files with 289 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,19 @@
/**
* Cette classe est une simple coquille pour recevoir la methode principale
*
* @version 1.1 09 March 2014
* @author Luc Hernandez
*/
public class Arguments {
/**
* Affiche «Bonjour !»
*
* @param args la liste des arguments de la ligne de commande (inutilisee ici)
*/
public static void main(String[] args) {
for(int i=0;i<args.length;i++){
System.out.println("Bonjour "+args[i]+" !");
}
}
}

Binary file not shown.

View File

@ -0,0 +1,17 @@
/**
* Cette classe est une simple coquille pour recevoir la methode principale
*
* @version 1.1 09 March 2014
* @author Luc Hernandez
*/
public class Demarrage {
/**
* Affiche &laquo;Bonjour !&raquo;
*
* @param args la liste des arguments de la ligne de commande (inutilisee ici)
*/
public static void main(String[] args) {
System.out.println("Bonjour !");
}
}

Binary file not shown.

View File

@ -0,0 +1,24 @@
public class Grille{
public static void main(String[] args) {
int n = Integer.parseInt(args[0]);
for(int i=0;i<=2*n;i++){
if(i%2==0){
for(int j=0;j<=2*n;j++){
if(j%2==0){
System.out.print("+");
} else {
System.out.print("-");
}
}
} else {
for(int j=0;j<=2*n;j++){
if(j%2==0){
System.out.print("|");
} else {
System.out.print(" ");
}
}
} System.out.println("");
}
}
}

Binary file not shown.

View File

@ -0,0 +1,10 @@
public class Somme{
public static void main(String[] args) {
int resultat=0;
for(int i=0;i<args.length;i++){
int n = Integer.parseInt(args[i]);
resultat=resultat+n;
} System.out.println("Le resultat est:"+" "+resultat);
}
}

Binary file not shown.

View File

@ -0,0 +1,14 @@
import java.util.Arrays;
public class Tri{
public static void main(String[] args) {
int resultat=0;
for(int i=0;i<args.length;i++){
int n = Integer.parseInt(args[i]);
} Arrays.sort(args);
for(int i=0;i<args.length;i++){
System.out.println(args[i]);
}
}
}

Binary file not shown.

View File

@ -0,0 +1,24 @@
import javax.swing.*;
import java.awt.*;
public class Boutons {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
JPanel pan = new JPanel();
fenetre.setSize(400, 200);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton bouton1 = new JButton();
JButton bouton2 = new JButton();
JButton bouton3 = new JButton();
JButton bouton4 = new JButton();
JButton bouton5 = new JButton();
pan.add(bouton1);
pan.add(bouton2);
pan.add(bouton3);
pan.add(bouton4);
pan.add(bouton5);
fenetre.setContentPane(pan);
fenetre.setVisible(true);
}
}

Binary file not shown.

View File

@ -0,0 +1,16 @@
import javax.swing.*;
import java.awt.*;
public class Sirocco {
public static void main(String[] args) {
JFrame fenetre = new JFrame();
fenetre.setSize(500, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel etiquette = new JLabel("Sirocco");
etiquette.setHorizontalAlignment(JLabel.RIGHT);
etiquette.setVerticalAlignment(JLabel.BOTTOM);
fenetre.add(etiquette, BorderLayout.CENTER);
fenetre.setVisible(true);
}
}

Binary file not shown.

View File

@ -0,0 +1,98 @@
public class Date{
public int annee;
public int mois;
public int jour;
public Date() {
this.annee=2023;
this.mois=02;
this.jour=13;
}
public String toString() {
return (String.format("%04d",this.annee)+"/"+String.format("%02d",this.mois)+"/"+String.format("%02d",this.jour));
}
public Date lendemain(){
Date res = new Date();
if(this.mois==1||this.mois==3||this.mois==5||this.mois==7||this.mois==8||this.mois==10||this.mois>=12){
if (this.jour>=31){
res.jour=1;
if (this.mois==12){
res.mois=1;
res.annee=this.annee+1;
}else{
res.mois=this.mois+1;
res.annee=this.annee;
}
}else{
res.jour=this.jour+1;
res.mois=this.mois;
res.annee=this.annee;
}
}else{
if(this.mois==2){
if (this.jour>=28){
res.jour=1;
res.mois=this.mois+1;
res.annee=this.annee;
}else{
res.jour=this.jour+1;
res.mois=this.mois;
res.annee=this.annee;
}
}else{
if (this.jour>=30){
res.jour=1;
res.mois=this.mois+1;
res.annee=this.annee;
}else{
res.jour=this.jour+1;
res.mois=this.mois;
res.annee=this.annee;
}
}
} return res;
}
public int datecmp(Date b){
if (this.annee<b.annee){
return -1;
}else if (this.annee>b.annee){
return 1;
}else{
if (this.mois<b.mois){
return -1;
}else if (this.mois>b.mois){
return 1;
}else{
if (this.jour<b.jour){
return -1;
}else if (this.jour>b.jour){
return 1;
}else{
return 0;
}
}
}
}
public static void main(String[] args) {
Date d = new Date();
Date l = d.lendemain();
d.toString();
l.toString();
System.out.println("La date est:"+" "+d);
System.out.println("Le lendemain de "+d+" est:"+" "+l);
int cmp = d.datecmp(l);
if (cmp==-1){
System.out.println("La date "+d+" est plus petite que la date "+l);
}else if (cmp==1){
System.out.println("La date "+d+" est plus grande que la date "+l);
}else{
System.out.println("La date "+d+" est egale a la date "+l);
}
}
}

View File

@ -0,0 +1,41 @@
public class Periode{
private int nbrjour;
private Date n;
private Date m;
public Periode(Date a, Date b){
this.n=a;
this.m=b;
this.nbrjour=((b.annee-a.annee)*365)+((b.mois-a.mois)*31)+(b.jour-a.jour);
}
public String toString(){
return System.out.println("L'intervalle entre "+this.n.toString+" et "+this.m.toString+" est de "+this.nbrjour+"jour(s)");
}
public void prolongePeriode(){
this.m=this.m.lendemain;
this.nbrjour++;
}
public int intervalle(){
return this.nbrjour;
}
public static void main(String[] args) {
Date d = new Date();
Date l = d.lendemain();
Periode p = new Periode(d,l);
Periode i = new Periode(d,l);
i.prolongePeriode();
i.prolongePeriode();
int n = p.intervalle();
p.toString();
i.toString();
System.out.println(p);
System.out.println(i);
System.out.println(n);
}
}

Binary file not shown.

View File

@ -0,0 +1,26 @@
public class Progression{
// attribut
private int compte;
// methode
public void plusUn() {
this.compte++;
}
// autre methode
public String toString() {
return Integer.toBinaryString(this.compte);
}
public static void main(String[] args) {
Progression n = new Progression();
n.compte = 5;
int s=5;
for(int i = 0;i<5;i++){
n.toString();
System.out.println("L'ecriture binaire de "+s+" est: "+n);
n.plusUn();
s++;
}
}
}