tp2Imunes - devMadelaine - Q1ControleBlancDev32
This commit is contained in:
parent
24cc7baddc
commit
1fc92e50c3
1
BD/Lekpa/.##connectDB#
Symbolic link
1
BD/Lekpa/.##connectDB#
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
lekpa@morinl.3345:1669890146
|
BIN
BD/Lekpa/PLSQL_cours.pdf
Normal file
BIN
BD/Lekpa/PLSQL_cours.pdf
Normal file
Binary file not shown.
@ -82,6 +82,7 @@ la contrainte de suppression en cascade
|
|||||||
|
|
||||||
exercice 6
|
exercice 6
|
||||||
|
|
||||||
|
// faire manuellement (car la suppression ne marche pas)
|
||||||
drop table Client cascade constraints;
|
drop table Client cascade constraints;
|
||||||
drop table Commande cascade constraints;
|
drop table Commande cascade constraints;
|
||||||
drop table ligne_commande cascade constraints;
|
drop table ligne_commande cascade constraints;
|
||||||
@ -116,3 +117,34 @@ CREATE TABLE ligne_commande (
|
|||||||
|
|
||||||
Exercice 7
|
Exercice 7
|
||||||
|
|
||||||
|
create table CommandeAuditLog(
|
||||||
|
Utilisateur VARCHAR(255),
|
||||||
|
ActionSQL VARCHAR(3) CONSTRAINT type_enumere_requette CHECK (ActionSQL IN ('INS', 'DEL', 'UDP')),
|
||||||
|
DateMAJ DATE,
|
||||||
|
ActCol VARCHAR(255)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE TRIGGER insertionCommandeAuditLog
|
||||||
|
AFTER INSERT OR DELETE OR UPDATE
|
||||||
|
ON Commande
|
||||||
|
FOR EACH ROW
|
||||||
|
DECLARE
|
||||||
|
CURSOR c_attribut IS SELECT column_name FROM user_tab_columns WHERE table_name = 'COMMANDE';
|
||||||
|
nom_colonne VARCHAR(255);
|
||||||
|
BEGIN
|
||||||
|
IF INSERTING THEN
|
||||||
|
INSERT INTO CommandeAuditLog VALUES (USER, 'INS', SYSDATE, null);
|
||||||
|
ELSIF DELETING THEN
|
||||||
|
INSERT INTO CommandeAuditLog VALUES (USER, 'DEL', SYSDATE, null);
|
||||||
|
ELSIF UPDATING THEN
|
||||||
|
OPEN c_attribut;
|
||||||
|
LOOP
|
||||||
|
FETCH c_attribut INTO nom_colonne ;
|
||||||
|
IF UPDATING(nom_colonne) THEN
|
||||||
|
INSERT INTO CommandeAuditLog VALUES (USER, 'UDP', SYSDATE, nom_colonne);
|
||||||
|
END IF;
|
||||||
|
EXIT WHEN c_attribut%NOTFOUND;
|
||||||
|
END LOOP;
|
||||||
|
CLOSE c_attribut;
|
||||||
|
END IF;
|
||||||
|
END combinedTrigger;
|
15
DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Coche.java
Normal file
15
DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Coche.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
|
public class Coche extends JCheckBox{
|
||||||
|
|
||||||
|
private Ingredient valeur;
|
||||||
|
|
||||||
|
public Coche(Ingredient valeur){
|
||||||
|
super(valeur.name());
|
||||||
|
this.valeur = valeur;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ingredient getValeur(){
|
||||||
|
return this.valeur;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class EvenementIngredient implements ItemListener{
|
||||||
|
|
||||||
|
private PileIngredient historiqueChoix;
|
||||||
|
private JButton boutonRetour;
|
||||||
|
|
||||||
|
public EvenementIngredient(PileIngredient historiqueChoix, JButton boutonRetour){
|
||||||
|
this.historiqueChoix = historiqueChoix;
|
||||||
|
this.boutonRetour = boutonRetour;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void itemStateChanged(ItemEvent e){
|
||||||
|
Coche coche = (Coche) e.getSource();
|
||||||
|
this.historiqueChoix.push(coche.getValeur());
|
||||||
|
this.boutonRetour.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class EvenementRetour implements ActionListener{
|
||||||
|
|
||||||
|
private PileIngredient historique;
|
||||||
|
private Coche[] listeCoche;
|
||||||
|
private EvenementIngredient evenementIngredient;
|
||||||
|
|
||||||
|
|
||||||
|
public EvenementRetour(PileIngredient historique, Coche[] listeCoche, EvenementIngredient evenementIngredient){
|
||||||
|
this.historique = historique;
|
||||||
|
this.listeCoche = listeCoche;
|
||||||
|
this.evenementIngredient = evenementIngredient;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e){
|
||||||
|
Ingredient dernierChoisis = this.historique.pop();
|
||||||
|
JButton boutonRetour = (JButton) e.getSource();
|
||||||
|
for (Coche coche : this.listeCoche){
|
||||||
|
if (coche.getValeur() == dernierChoisis){
|
||||||
|
coche.removeItemListener(evenementIngredient);
|
||||||
|
coche.setSelected(!coche.isSelected());
|
||||||
|
coche.addItemListener(evenementIngredient);
|
||||||
|
if (historique.isEmpty()){
|
||||||
|
boutonRetour.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Fenetre.java
Normal file
38
DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Fenetre.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class Fenetre extends JFrame{
|
||||||
|
|
||||||
|
private PileIngredient historique;
|
||||||
|
|
||||||
|
public Fenetre(){
|
||||||
|
super();
|
||||||
|
this.setTitle("Question1");
|
||||||
|
this.setSize(500, 300);
|
||||||
|
this.setLocation(0, 0);
|
||||||
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
this.historique = new PileIngredient();
|
||||||
|
this.addIngredient();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIngredient(){
|
||||||
|
JButton retour = new JButton("RETOUR");
|
||||||
|
EvenementIngredient evenementIngredient = new EvenementIngredient(this.historique, retour);
|
||||||
|
Ingredient[] listeIngredient = Ingredient.values();
|
||||||
|
int nbIngredient = listeIngredient.length;
|
||||||
|
Coche[] listeCoche = new Coche[nbIngredient];
|
||||||
|
int i;
|
||||||
|
this.setLayout(new GridLayout(1,nbIngredient+1));
|
||||||
|
|
||||||
|
for (i=0; i<nbIngredient; i++){
|
||||||
|
listeCoche[i] = new Coche(listeIngredient[i]);
|
||||||
|
listeCoche[i].addItemListener(evenementIngredient);
|
||||||
|
this.add(listeCoche[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
EvenementRetour evenementRetour = new EvenementRetour(this.historique, listeCoche, evenementIngredient);
|
||||||
|
retour.setEnabled(false);
|
||||||
|
retour.addActionListener(evenementRetour);
|
||||||
|
this.add(retour);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
enum Ingredient{
|
||||||
|
SALADE,
|
||||||
|
TOMATES,
|
||||||
|
OIGNONS
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class PileIngredient{
|
||||||
|
|
||||||
|
private Deque<Ingredient> pile;
|
||||||
|
|
||||||
|
public PileIngredient(){
|
||||||
|
this.pile = new ArrayDeque<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void push(Ingredient valeur){
|
||||||
|
this.pile.push(valeur);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ingredient pop(){
|
||||||
|
return this.pile.pop();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty(){
|
||||||
|
return this.pile.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
11
DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Q4Main.java
Normal file
11
DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Q4Main.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
|
||||||
|
public class Q4Main{
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
Fenetre fenetre = new Fenetre();
|
||||||
|
fenetre.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV/DEV_Madelaine/Shadock_couliior/Donjon.class
Normal file
BIN
DEV/DEV_Madelaine/Shadock_couliior/Donjon.class
Normal file
Binary file not shown.
5
DEV/DEV_Madelaine/Shadock_couliior/Donjon.java
Normal file
5
DEV/DEV_Madelaine/Shadock_couliior/Donjon.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
public interface Donjon {
|
||||||
|
public Piece apres();
|
||||||
|
public Piece avant();
|
||||||
|
public Piece ici();
|
||||||
|
}
|
98
DEV/DEV_Madelaine/Shadock_couliior/DonjonBD.java
Normal file
98
DEV/DEV_Madelaine/Shadock_couliior/DonjonBD.java
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
import org.mariadb.jdbc.*;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DonjonBD implements Donjon {
|
||||||
|
|
||||||
|
private int idPiece;
|
||||||
|
private int contenu;
|
||||||
|
private Connection connexion;
|
||||||
|
|
||||||
|
public DonjonBD(){
|
||||||
|
try{
|
||||||
|
this.ouvrirConnexion();
|
||||||
|
PreparedStatement requete = this.connexion.prepareStatement(
|
||||||
|
"SELECT idPiece,contenu FROM Piece");
|
||||||
|
ResultSet resultat = requete.executeQuery();
|
||||||
|
requete.close();
|
||||||
|
if (resultat.next()){
|
||||||
|
this.idPiece = resultat.getInt("idPiece");
|
||||||
|
this.contenu = resultat.getInt("contenu");
|
||||||
|
}
|
||||||
|
resultat.close();
|
||||||
|
}
|
||||||
|
catch(SQLException e){
|
||||||
|
System.out.println(e);
|
||||||
|
this.fermerConnexion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Piece apres(){
|
||||||
|
try{
|
||||||
|
PreparedStatement requete = this.connexion.prepareStatement(
|
||||||
|
"SELECT idPiece,contenu FROM Piece WHERE idPiece=(Select apres FROM Piece WHERE idPiece=?)");
|
||||||
|
requete.setInt(1, this.idPiece);
|
||||||
|
ResultSet resultat = requete.executeQuery();
|
||||||
|
requete.close();
|
||||||
|
if (resultat.next()){
|
||||||
|
this.idPiece = resultat.getInt("idPiece");
|
||||||
|
this.contenu = resultat.getInt("contenu");
|
||||||
|
}
|
||||||
|
resultat.close();
|
||||||
|
return new PieceConcrete(this.contenu);
|
||||||
|
}
|
||||||
|
catch(SQLException e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Piece avant(){
|
||||||
|
try{
|
||||||
|
PreparedStatement requete = this.connexion.prepareStatement(
|
||||||
|
"SELECT idPiece,contenu FROM Piece WHERE apres=?");
|
||||||
|
requete.setInt(1, this.idPiece);
|
||||||
|
ResultSet resultat = requete.executeQuery();
|
||||||
|
requete.close();
|
||||||
|
if (resultat.next()){
|
||||||
|
this.idPiece = resultat.getInt("idPiece");
|
||||||
|
this.contenu = resultat.getInt("contenu");
|
||||||
|
}
|
||||||
|
resultat.close();
|
||||||
|
return new PieceConcrete(this.contenu);
|
||||||
|
}
|
||||||
|
catch(SQLException e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Piece ici() {
|
||||||
|
return new PieceConcrete(this.contenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fermerConnexion(){
|
||||||
|
try {
|
||||||
|
this.connexion.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ouvrirConnexion() throws SQLException {
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
Class.forName("org.mariadb.jdbc.Driver");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException("ClassNotFoundException", e);
|
||||||
|
}
|
||||||
|
this.connexion = DriverManager.getConnection(
|
||||||
|
"jdbc:mariadb://dwarves.iut-fbleau.fr/williatt",
|
||||||
|
"williatt", "OscarSQL92");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new SQLException("Connexion au serveur impossible ! Verifiez votre connexion internet puis reessayez",
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV/DEV_Madelaine/Shadock_couliior/DonjonLocal.class
Normal file
BIN
DEV/DEV_Madelaine/Shadock_couliior/DonjonLocal.class
Normal file
Binary file not shown.
38
DEV/DEV_Madelaine/Shadock_couliior/DonjonLocal.java
Normal file
38
DEV/DEV_Madelaine/Shadock_couliior/DonjonLocal.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class DonjonLocal implements Donjon {
|
||||||
|
|
||||||
|
private List<Piece> couloir;
|
||||||
|
private int position;
|
||||||
|
|
||||||
|
public DonjonLocal() {
|
||||||
|
this.couloir = new ArrayList<>();
|
||||||
|
this.position = 0;
|
||||||
|
this.remplirCouloir(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Piece apres() {
|
||||||
|
this.position = (this.position+1)%this.couloir.size();
|
||||||
|
return this.couloir.get(this.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Piece avant() {
|
||||||
|
this.position = (this.position+(this.couloir.size()-1))%this.couloir.size();
|
||||||
|
return this.couloir.get(this.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Piece ici() {
|
||||||
|
return this.couloir.get(this.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void remplirCouloir(int nbPiece) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < nbPiece; i++) {
|
||||||
|
Piece piece = new PieceConcrete();
|
||||||
|
this.couloir.add(piece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV/DEV_Madelaine/Shadock_couliior/Main.class
Normal file
BIN
DEV/DEV_Madelaine/Shadock_couliior/Main.class
Normal file
Binary file not shown.
28
DEV/DEV_Madelaine/Shadock_couliior/Main.java
Normal file
28
DEV/DEV_Madelaine/Shadock_couliior/Main.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
public class Main{
|
||||||
|
public static void main (String[] args){
|
||||||
|
Donjon sametlenoob = new DonjonLocal();
|
||||||
|
VueShadock oscarDansLeDonjonDeSamet = new VueShadock(sametlenoob, 3);
|
||||||
|
System.out.println(oscarDansLeDonjonDeSamet);
|
||||||
|
|
||||||
|
oscarDansLeDonjonDeSamet.avance();
|
||||||
|
System.out.println(" ===> "+ oscarDansLeDonjonDeSamet);
|
||||||
|
|
||||||
|
oscarDansLeDonjonDeSamet.avance();
|
||||||
|
System.out.println(" ===> "+ oscarDansLeDonjonDeSamet);
|
||||||
|
|
||||||
|
oscarDansLeDonjonDeSamet.recule();
|
||||||
|
System.out.println(" <=== "+ oscarDansLeDonjonDeSamet);
|
||||||
|
|
||||||
|
oscarDansLeDonjonDeSamet.recule();
|
||||||
|
System.out.println(" <=== "+ oscarDansLeDonjonDeSamet);
|
||||||
|
|
||||||
|
oscarDansLeDonjonDeSamet.recule();
|
||||||
|
System.out.println(" <=== "+ oscarDansLeDonjonDeSamet);
|
||||||
|
|
||||||
|
oscarDansLeDonjonDeSamet.avance();
|
||||||
|
System.out.println(" ===> "+ oscarDansLeDonjonDeSamet);
|
||||||
|
|
||||||
|
oscarDansLeDonjonDeSamet.avance();
|
||||||
|
System.out.println(" ===> "+ oscarDansLeDonjonDeSamet);
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV/DEV_Madelaine/Shadock_couliior/Piece.class
Normal file
BIN
DEV/DEV_Madelaine/Shadock_couliior/Piece.class
Normal file
Binary file not shown.
15
DEV/DEV_Madelaine/Shadock_couliior/Piece.java
Normal file
15
DEV/DEV_Madelaine/Shadock_couliior/Piece.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
public abstract class Piece {
|
||||||
|
protected int contenu;
|
||||||
|
|
||||||
|
public Piece(int contenu) {
|
||||||
|
this.contenu = contenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getContenu() {
|
||||||
|
return contenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return ""+this.contenu;
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV/DEV_Madelaine/Shadock_couliior/PieceConcrete.class
Normal file
BIN
DEV/DEV_Madelaine/Shadock_couliior/PieceConcrete.class
Normal file
Binary file not shown.
19
DEV/DEV_Madelaine/Shadock_couliior/PieceConcrete.java
Normal file
19
DEV/DEV_Madelaine/Shadock_couliior/PieceConcrete.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class PieceConcrete extends Piece {
|
||||||
|
|
||||||
|
public PieceConcrete(int n){
|
||||||
|
super(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PieceConcrete(){
|
||||||
|
super(0);
|
||||||
|
Random r = new Random();
|
||||||
|
int n = r.nextInt(10);
|
||||||
|
this.contenu = n;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getContenu(){
|
||||||
|
return super.getContenu();
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV/DEV_Madelaine/Shadock_couliior/VueShadock.class
Normal file
BIN
DEV/DEV_Madelaine/Shadock_couliior/VueShadock.class
Normal file
Binary file not shown.
57
DEV/DEV_Madelaine/Shadock_couliior/VueShadock.java
Normal file
57
DEV/DEV_Madelaine/Shadock_couliior/VueShadock.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
public class VueShadock {
|
||||||
|
|
||||||
|
private Piece[] listePiece;
|
||||||
|
private Donjon donjon;
|
||||||
|
private boolean isAvance; // true si la derniere direction est avance() / false si derniere direction est recule()
|
||||||
|
|
||||||
|
public VueShadock(Donjon donjon, int porteeVision) {
|
||||||
|
this.donjon = donjon;
|
||||||
|
this.listePiece = new PieceConcrete[porteeVision];
|
||||||
|
int i, taille=this.listePiece.length;
|
||||||
|
for (i=0; i<taille; i++){
|
||||||
|
this.listePiece[i] = this.donjon.apres();
|
||||||
|
}
|
||||||
|
this.isAvance = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void avance(){
|
||||||
|
int i, taille=(this.listePiece.length-1);
|
||||||
|
if (this.isAvance){
|
||||||
|
for (i=0; i<taille; i++){
|
||||||
|
this.listePiece[i] = this.listePiece[i+1];
|
||||||
|
}
|
||||||
|
this.listePiece[taille] = this.donjon.apres();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for (i=0; i<=taille; i++){
|
||||||
|
this.listePiece[i] = this.donjon.apres();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.isAvance =true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recule(){
|
||||||
|
int i, taille=(this.listePiece.length-1);
|
||||||
|
if (this.isAvance == false){
|
||||||
|
for (i=taille; i>0; i--){
|
||||||
|
this.listePiece[i] = this.listePiece[i-1];
|
||||||
|
}
|
||||||
|
this.listePiece[0] = this.donjon.avant();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for (i=taille; i>=0; i--){
|
||||||
|
this.listePiece[i] = this.donjon.avant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.isAvance = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String resultat = new String();
|
||||||
|
for (Piece piece : this.listePiece){
|
||||||
|
resultat += piece+" ";
|
||||||
|
}
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
}
|
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Billet.class
Normal file
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Billet.class
Normal file
Binary file not shown.
@ -1,10 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* cette classe represente un billet de banque
|
||||||
|
*/
|
||||||
public class Billet{
|
public class Billet{
|
||||||
|
/**
|
||||||
|
* Valeur du billet
|
||||||
|
*/
|
||||||
private Denomination valeur;
|
private Denomination valeur;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creer un billet
|
||||||
|
* @param valeur valeur du billet
|
||||||
|
*/
|
||||||
public Billet(Denomination valeur){
|
public Billet(Denomination valeur){
|
||||||
this.valeur = valeur;
|
this.valeur = valeur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* donne la valeur du billet
|
||||||
|
* @return montant du billet
|
||||||
|
*/
|
||||||
public int getValeur(){
|
public int getValeur(){
|
||||||
if (valeur == Denomination.UN){
|
if (valeur == Denomination.UN){
|
||||||
return 1;
|
return 1;
|
||||||
@ -35,4 +49,16 @@ public class Billet{
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* compare 2 billets en fonction de leurs valeurs
|
||||||
|
* @param billet billet a comparer
|
||||||
|
* @return true si les 2 billets ont les memes valeurs / false sinon
|
||||||
|
*/
|
||||||
|
public boolean equals(Billet billet){
|
||||||
|
if (this.getValeur() == billet.getValeur()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Denomination.class
Normal file
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Denomination.class
Normal file
Binary file not shown.
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Individu.class
Normal file
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Individu.class
Normal file
Binary file not shown.
@ -1,17 +1,41 @@
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
/**
|
||||||
|
* Cette classe represente un individu (un nom et sa fortune)
|
||||||
|
*/
|
||||||
public class Individu{
|
public class Individu{
|
||||||
private String nom;
|
private String nom;
|
||||||
private List<Billet> fortune;
|
private List<Billet> fortune;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creer un individus et lui donne un nom et une fortune vide
|
||||||
|
* @param nom nom de l'individus
|
||||||
|
*/
|
||||||
public Individu(String nom){
|
public Individu(String nom){
|
||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
this.fortune = new ArrayList<>();
|
this.fortune = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Ajoute un billet a la fortune d'un individus
|
||||||
|
* @param billet billet a ajouter
|
||||||
|
* @return true si l'ajout est reussi / false sinon
|
||||||
|
*/
|
||||||
public boolean add(Billet billet){
|
public boolean add(Billet billet){
|
||||||
return this.fortune.add(billet);
|
return this.fortune.add(billet);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Supprime un billet a la fortune d'un individus
|
||||||
|
* @param billet billet a supprimer (le billet supprimer est un billet de la meme valeur que celui passer en argument)
|
||||||
|
* @return true si la suppression est reussi / false sinon
|
||||||
|
*/
|
||||||
|
public boolean remove(Billet billet){
|
||||||
|
for (Billet b : this.fortune){
|
||||||
|
if (billet.equals(b)){
|
||||||
|
return this.fortune.remove(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void payer(int valeur, Individu vendeur){
|
public void payer(int valeur, Individu vendeur){
|
||||||
// to do (il faut pouvoir trier la liste du plus grand au plus petit)
|
// to do (il faut pouvoir trier la liste du plus grand au plus petit)
|
||||||
@ -20,14 +44,22 @@ public class Individu{
|
|||||||
// cette methode doit etre recursive pour que chaque individus se rembourse plusieurs fois jusqu'a ce qu'il ne puisse plus
|
// cette methode doit etre recursive pour que chaque individus se rembourse plusieurs fois jusqu'a ce qu'il ne puisse plus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Donne le montant de la fortune de l'individus
|
||||||
|
* @return montant de la fortune
|
||||||
|
*/
|
||||||
public int getFortune(){
|
public int getFortune(){
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (Billet billet : fortune){
|
for (Billet billet : this.fortune){
|
||||||
total += billet.getValeur();
|
total += billet.getValeur();
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Donne le nom de l'individus
|
||||||
|
* @return nom
|
||||||
|
*/
|
||||||
public String getNom(){
|
public String getNom(){
|
||||||
return this.nom;
|
return this.nom;
|
||||||
}
|
}
|
||||||
|
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Main.class
Normal file
BIN
DEV/DEV_Madelaine/Wamster_stub/exercice1/Main.class
Normal file
Binary file not shown.
0
SCR/IMUNES/SCR.3.2/TP01/one-gateway.imn
Normal file
0
SCR/IMUNES/SCR.3.2/TP01/one-gateway.imn
Normal file
0
SCR/IMUNES/SCR.3.2/TP01/two-gateway.imn
Normal file
0
SCR/IMUNES/SCR.3.2/TP01/two-gateway.imn
Normal file
534
SCR/IMUNES/SCR.3.2/TP03/tp03_debut.imn
Normal file
534
SCR/IMUNES/SCR.3.2/TP03/tp03_debut.imn
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user