Ajout
This commit is contained in:
Binary file not shown.
@@ -16,11 +16,6 @@ public class Decapite{
|
||||
String isHeadlessString = this.isHeadless ? "oui" : "non";
|
||||
String isHeadlessInstanceString = this.isHeadlessInstance ? "oui" : "non";
|
||||
|
||||
return "isHeadless dit : " + isHeadlessString + "\nisHeadlessInstance dit :" + isHeadlessInstanceString;
|
||||
return "isHeadless dit : " + isHeadlessString + "\nisHeadlessInstance dit : " + isHeadlessInstanceString;
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
Decapite test = new Decapite();
|
||||
test.toString();
|
||||
}
|
||||
}
|
6
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO1/Test.java
Normal file
6
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO1/Test.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Test{
|
||||
public static void main(String[] args){
|
||||
Decapite test = new Decapite();
|
||||
System.out.println(test.toString());
|
||||
}
|
||||
}
|
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO2/Deduction.class
Normal file
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO2/Deduction.class
Normal file
Binary file not shown.
46
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO2/Deduction.java
Normal file
46
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO2/Deduction.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/* Écrivez une classe pour représenter une carte. Vous y définirez au moins :
|
||||
|
||||
- un constructeur qui permet de préciser le numéro imprimé sur la carte,
|
||||
- une redéfinition de la méthode toString qui produit un
|
||||
texte contenant le numéro, le nombre actuel de crédits et le nombre total de crédits obtenus depuis le départ.
|
||||
- une méthode voir qui renvoie le nombre actuel de crédits.
|
||||
- une méthode crediter qui ajoute un crédit à la carte (si possible).
|
||||
- une méthode vider qui remet le compte à zéro lorsque le client bénéficie d'une gratuité.
|
||||
L'un des développeurs du logiciel, glouton et peu scrupuleux, décide de se créer une yes card, c'est à dire une carte qui dit toujours qu'il a le droit à une ristourne (les crédits restent bloqués à 10). Écrivez une nouvelle classe qui
|
||||
représente une telle carte, avec les mêmes méthodes que la classe précédente. */
|
||||
|
||||
public class Deduction{
|
||||
private int numeroCarte;
|
||||
private int nombreCreditActuel;
|
||||
private int nombreCreditTotal;
|
||||
|
||||
public Deduction(int numero){
|
||||
this.numeroCarte = numero;
|
||||
this.nombreCreditActuel = 0;
|
||||
this.nombreCreditTotal = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Numéro de carte : " + this.numeroCarte + "\nNombre de crédit actuelle : " + this.nombreCreditActuel + "\nNombre de crédit total : " + this.nombreCreditTotal;
|
||||
}
|
||||
|
||||
public int voir(){
|
||||
return this.nombreCreditActuel;
|
||||
}
|
||||
|
||||
public int crediter(){
|
||||
if(this.nombreCreditActuel < 10){
|
||||
this.nombreCreditActuel++;
|
||||
this.nombreCreditTotal++;
|
||||
}
|
||||
if (this.nombreCreditActuel == 10) {
|
||||
vider();
|
||||
}
|
||||
return this.nombreCreditActuel;
|
||||
}
|
||||
|
||||
public void vider(){
|
||||
this.nombreCreditActuel = 0;
|
||||
}
|
||||
}
|
13
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO2/Yescard.java
Normal file
13
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO2/Yescard.java
Normal file
@@ -0,0 +1,13 @@
|
||||
public class YesCard extends Deduction {
|
||||
public YesCard(int numero) {
|
||||
super(numero);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int crediter() {
|
||||
if (this.voir() < 10) {
|
||||
super.crediter();
|
||||
}
|
||||
return this.voir();
|
||||
}
|
||||
}
|
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO3/Direction.class
Normal file
BIN
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO3/Direction.class
Normal file
Binary file not shown.
55
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO3/Direction.java
Normal file
55
BUT1/CONTROLE/DEV2.1/Entrainement/SUJETB/EXO3/Direction.java
Normal file
@@ -0,0 +1,55 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Direction {
|
||||
|
||||
public Direction() {
|
||||
JFrame fenetre = new JFrame("Boutons aux Coins");
|
||||
fenetre.setSize(400, 400);
|
||||
fenetre.setMinimumSize(new Dimension(150,150));
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JPanel panneau = new JPanel(new BorderLayout());
|
||||
|
||||
JButton hautGauche = new JButton("◤");
|
||||
JButton hautDroit = new JButton("◥");
|
||||
JButton basGauche = new JButton("◣");
|
||||
JButton basDroit = new JButton("◢");
|
||||
|
||||
hautGauche.setPreferredSize(new Dimension(50, 50));
|
||||
hautDroit.setPreferredSize(new Dimension(50, 50));
|
||||
basGauche.setPreferredSize(new Dimension(50, 50));
|
||||
basDroit.setPreferredSize(new Dimension(50, 50));
|
||||
|
||||
JPanel panneauHautGauche = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
panneauHautGauche.add(hautGauche);
|
||||
|
||||
JPanel panneauHautDroit = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
panneauHautDroit.add(hautDroit);
|
||||
|
||||
JPanel panneauHaut = new JPanel(new BorderLayout());
|
||||
panneauHaut.add(panneauHautGauche, BorderLayout.WEST);
|
||||
panneauHaut.add(panneauHautDroit, BorderLayout.EAST);
|
||||
|
||||
JPanel panneauBasGauche = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
panneauBasGauche.add(basGauche);
|
||||
|
||||
JPanel panneauBasDroit = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||
panneauBasDroit.add(basDroit);
|
||||
|
||||
JPanel panneauBas = new JPanel(new BorderLayout());
|
||||
panneauBas.add(panneauBasGauche, BorderLayout.WEST);
|
||||
panneauBas.add(panneauBasDroit, BorderLayout.EAST);
|
||||
|
||||
panneau.add(panneauHaut, BorderLayout.NORTH);
|
||||
panneau.add(panneauBas, BorderLayout.SOUTH);
|
||||
|
||||
fenetre.add(panneau);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Direction test = new Direction();
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user