MàJ par récupération sur Clé USB et dans /mnt/hd/Chargement du pc portable
This commit is contained in:
7
G5a/Solutions/2-exoSyntaxeJava/Bonjour.java
Normal file
7
G5a/Solutions/2-exoSyntaxeJava/Bonjour.java
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
class Bonjour { // essai de hello world
|
||||
public static void main (String[] args) {
|
||||
System.out.println ("Bonjour !");
|
||||
|
||||
}
|
||||
}
|
11
G5a/Solutions/2-exoSyntaxeJava/BonjourToi1.java
Normal file
11
G5a/Solutions/2-exoSyntaxeJava/BonjourToi1.java
Normal file
@ -0,0 +1,11 @@
|
||||
import iutsud.Console;
|
||||
class BonjourToi1{ // essai d'entr<74>e-sortie caractere avec le package iutsud
|
||||
public static void main (String[] args) {
|
||||
String nom;int an;
|
||||
System.out.print ("tapez votre nom : ");
|
||||
nom=Console.readLine();
|
||||
System.out.print ("tapez votre annee de naissance : ");
|
||||
an=Console.readInt();
|
||||
System.out.println ("Bonjour "+nom+" ! Vous avez "+(2007-an)+" ans");
|
||||
}
|
||||
}
|
15
G5a/Solutions/2-exoSyntaxeJava/BonjourToi2.java
Normal file
15
G5a/Solutions/2-exoSyntaxeJava/BonjourToi2.java
Normal file
@ -0,0 +1,15 @@
|
||||
import javax.swing.JOptionPane;
|
||||
import java.util.Calendar;
|
||||
class BonjourToi2 { // essai de hello world avec une entree et une sortie Swing
|
||||
public static void main (String[] args) {
|
||||
String nom,ch;
|
||||
int an,anneeCourante;
|
||||
anneeCourante=Calendar.getInstance().get(Calendar.YEAR);
|
||||
nom=JOptionPane.showInputDialog("taper votre nom ");
|
||||
ch=JOptionPane.showInputDialog("taper votre annee de naissance (4chiffres)");
|
||||
System.out.println("nom="+nom+"; naiss="+ch+"; annee courante : "+anneeCourante);
|
||||
an=Integer.parseInt(ch);
|
||||
JOptionPane.showMessageDialog(null,"Bonjour "+nom+"! Vous avez "+(anneeCourante-an)+"ans");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
13
G5a/Solutions/2-exoSyntaxeJava/InverseArgs.java
Normal file
13
G5a/Solutions/2-exoSyntaxeJava/InverseArgs.java
Normal file
@ -0,0 +1,13 @@
|
||||
public class InverseArgs {
|
||||
public static void main (String[] args) {
|
||||
int longr;
|
||||
longr=args.length;
|
||||
if (longr==0)
|
||||
System.out.println ("il n'y a pas d'arguments !");
|
||||
else System.out.println("nb d'args :"+longr);
|
||||
for (int i =longr-1 ; i>=0; i--) {
|
||||
System.out.print(" "+args[i]);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
26
G5a/Solutions/2-exoSyntaxeJava/Premier.java
Normal file
26
G5a/Solutions/2-exoSyntaxeJava/Premier.java
Normal file
@ -0,0 +1,26 @@
|
||||
import javax.swing.JOptionPane;
|
||||
class Premier { // Determine si un nb est premier ou non
|
||||
public static void main (String[] args) {
|
||||
String nb,reponse ;
|
||||
int n;
|
||||
boolean premier;
|
||||
nb=JOptionPane.showInputDialog("tapez votre nombre");
|
||||
n=Integer.parseInt(nb);
|
||||
while (n!=0) {
|
||||
premier = true;
|
||||
if (n==1) {JOptionPane.showMessageDialog(null,"1 n'est pas premier par convention ");
|
||||
premier=false;}
|
||||
for (int i=2;i<n; i++) {
|
||||
System.out.println(n+" "+i+" "+n%i);
|
||||
if (n%i==0) {
|
||||
JOptionPane.showMessageDialog(null,n+" n'est pas premier :multiple de "+ i);
|
||||
premier=false;
|
||||
break;}
|
||||
}
|
||||
if (premier)JOptionPane.showMessageDialog(null,n+" est un nb premier ");
|
||||
nb=JOptionPane.showInputDialog("tapez votre nombre");
|
||||
n=Integer.parseInt(nb);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
25
G5a/Solutions/2-exoSyntaxeJava/Puissance.java
Normal file
25
G5a/Solutions/2-exoSyntaxeJava/Puissance.java
Normal file
@ -0,0 +1,25 @@
|
||||
import iutsud.Console;
|
||||
/** calcul de x puissance y avec un algorithme basique !*/
|
||||
class Puissance{ // calcul de x puissance y avec un algorithme basique
|
||||
public static void main (String[] args) {
|
||||
int x,y,p;
|
||||
System.out.println ("Calcul de x puissance y");
|
||||
System.out.print ("tapez la valeur de x : ");
|
||||
x=Console.readInt();
|
||||
System.out.print ("tapez la valeur de y : ");
|
||||
y=Console.readInt();
|
||||
if (y==0)
|
||||
if (x==0)
|
||||
System.out.println("0 puissance 0 est indefini");
|
||||
else System.out.println(x+ " puissance 0 = 1");
|
||||
|
||||
else {
|
||||
p=1;
|
||||
for (int i=0;i<y;i++) {
|
||||
p=p*x;
|
||||
}
|
||||
System.out.println(x+ " puissance "+y +" ="+ p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
17
G5a/Solutions/2-exoSyntaxeJava/SommeEntiers.java
Normal file
17
G5a/Solutions/2-exoSyntaxeJava/SommeEntiers.java
Normal file
@ -0,0 +1,17 @@
|
||||
public class SommeEntiers {
|
||||
public static void main (String args[]) {
|
||||
int longr=args.length;
|
||||
switch (longr){
|
||||
case 0 : System.out.println("Eh banane, t'as oublie les arguments !!!");
|
||||
break;
|
||||
case 1 : System.out.println("Quoi, seulement un arg ? "+args[0]);
|
||||
default :
|
||||
int somme=0;
|
||||
for (int i=0 ; i<args.length ; i++) {
|
||||
int j=Integer.parseInt(args[i]);
|
||||
somme+=j;
|
||||
}
|
||||
System.out.println("somme : "+somme);
|
||||
}
|
||||
}
|
||||
}
|
262
G5a/Solutions/3-exosClasses-1/1-Adherent/Adherent.java
Normal file
262
G5a/Solutions/3-exosClasses-1/1-Adherent/Adherent.java
Normal file
@ -0,0 +1,262 @@
|
||||
|
||||
/** Java class "Adherent.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package adherents;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
public class Adherent {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int numeroAdherent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String nom;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String ville;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int anneeNaissance;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant de la cotisation (commun à tous les adherents)
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private static int c_montantCotisation=45;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant actuellement verse par l'adherent
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private int cotisationVersee;
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String getNom() {
|
||||
// your code here
|
||||
return this.nom;
|
||||
} // end getNom
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getNumeroAdh() {
|
||||
return this.numeroAdherent;
|
||||
} // end getNumeroAdh
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a int with ...
|
||||
* </p>
|
||||
*/
|
||||
public int getAge() {
|
||||
// your code here
|
||||
return 2005-anneeNaissance;
|
||||
} // end getAge
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getCotisationVersee() {
|
||||
return cotisationVersee;
|
||||
} // end getCotisationVersee
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean : l'adherent est ou non à jour de cotisation
|
||||
* </p>
|
||||
*/
|
||||
public boolean aJour() {
|
||||
// your code here
|
||||
if (cotisationVersee>=c_montantCotisation)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
} // end aJour
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Ajoute la somme passee en param au montant de la cotisation versee
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean qui dit si l'adherent est a jour apres ce versement
|
||||
* </p>
|
||||
* <p>
|
||||
* @param versement montant de la somme versee
|
||||
* </p>
|
||||
*/
|
||||
public boolean cotiser(int versement) {
|
||||
// your code here
|
||||
cotisationVersee+=versement;
|
||||
return aJour();
|
||||
} // end cotiser
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a String : "A jour" ou " PAS A JOUR !!!"
|
||||
* </p>
|
||||
*/
|
||||
public String etat() {
|
||||
// your code here
|
||||
String etat;
|
||||
if (this.aJour()) etat = "a jour"; else etat = "PAS A JOUR !!!";
|
||||
return etat;
|
||||
} // end etat
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String toString() {
|
||||
// your code here
|
||||
return (getNumeroAdh()+" "+getNom()+" "+getVille()+" "+getAge()+" ans : a cotise : "+getCotisationVersee()+" "+etat());
|
||||
} // end toString
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// your code here
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
} // end main
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructeur d'Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
* @param num ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nom ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param vil ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nss ...
|
||||
* </p>
|
||||
*/
|
||||
public Adherent(int num, String nom, String vil, int nss) {
|
||||
// your code here
|
||||
this.numeroAdherent=num;
|
||||
this.nom=nom;
|
||||
this.ville=vil;
|
||||
this.anneeNaissance=nss;
|
||||
} // end Adherent
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public String getVille() {
|
||||
return ville;
|
||||
} // end getVille
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public void setVille(String _ville) {
|
||||
ville = _ville;
|
||||
} // end setVille
|
||||
|
||||
} // end Adherent
|
||||
|
||||
|
||||
|
66
G5a/Solutions/3-exosClasses-1/1-Adherent/Gerant.java
Normal file
66
G5a/Solutions/3-exosClasses-1/1-Adherent/Gerant.java
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
/** Java class "Gerant.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package adherents;
|
||||
|
||||
import adherents.Adherent;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
class Gerant {
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
// your code here
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
} // end main
|
||||
|
||||
} // end Gerant
|
||||
|
||||
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
@ -0,0 +1,263 @@
|
||||
|
||||
/** Java class "Adherent.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package Pack_adherents;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
public class Adherent {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int numeroAdherent;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String nom;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private String ville;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
private int anneeNaissance;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant de la cotisation (commun à tous les adherents)
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private static int c_montantCotisation=45;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represente le montant actuellement verse par l'adherent
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
private int cotisationVersee;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String getNom() {
|
||||
// your code here
|
||||
return this.nom;
|
||||
} // end getNom
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getNumeroAdh() {
|
||||
return this.numeroAdherent;
|
||||
} // end getNumeroAdh
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a int with ...
|
||||
* </p>
|
||||
*/
|
||||
public int getAge() {
|
||||
// your code here
|
||||
return 2005-anneeNaissance;
|
||||
} // end getAge
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public int getCotisationVersee() {
|
||||
return cotisationVersee;
|
||||
} // end getCotisationVersee
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean : l'adherent est ou non à jour de cotisation
|
||||
* </p>
|
||||
*/
|
||||
public boolean aJour() {
|
||||
// your code here
|
||||
if (cotisationVersee>=c_montantCotisation)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
} // end aJour
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Ajoute la somme passee en param au montant de la cotisation versee
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a boolean qui dit si l'adherent est a jour apres ce versement
|
||||
* </p>
|
||||
* <p>
|
||||
* @param versement montant de la somme versee
|
||||
* </p>
|
||||
*/
|
||||
public boolean cotiser(int versement) {
|
||||
// your code here
|
||||
cotisationVersee+=versement;
|
||||
return aJour();
|
||||
} // end cotiser
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* @return a String : "A jour" ou " PAS A JOUR !!!"
|
||||
* </p>
|
||||
*/
|
||||
public String etat() {
|
||||
// your code here
|
||||
String etat;
|
||||
if (this.aJour()) etat = "a jour"; else etat = "PAS A JOUR !!!";
|
||||
return etat;
|
||||
} // end etat
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a String with ...
|
||||
* </p>
|
||||
*/
|
||||
public String toString() {
|
||||
// your code here
|
||||
return (getNumeroAdh()+" "+getNom()+" "+getVille()+" "+getAge()+" ans : a cotise : "+getCotisationVersee()+" "+etat());
|
||||
} // end toString
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// your code here
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
System.out.println (a1);
|
||||
System.out.println (a2);
|
||||
System.out.println (a3);
|
||||
} // end main
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructeur d'Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
*
|
||||
* @return a Adherent
|
||||
* </p>
|
||||
* <p>
|
||||
* @param num ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nom ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param vil ...
|
||||
* </p>
|
||||
* <p>
|
||||
* @param nss ...
|
||||
* </p>
|
||||
*/
|
||||
public Adherent(int num, String nom, String vil, int nss) {
|
||||
// your code here
|
||||
this.numeroAdherent=num;
|
||||
this.nom=nom;
|
||||
this.ville=vil;
|
||||
this.anneeNaissance=nss;
|
||||
} // end Adherent
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public String getVille() {
|
||||
return ville;
|
||||
} // end getVille
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Represents ...
|
||||
* </p>
|
||||
*/
|
||||
public void setVille(String _ville) {
|
||||
ville = _ville;
|
||||
} // end setVille
|
||||
|
||||
} // end Adherent
|
||||
|
||||
|
||||
|
@ -0,0 +1,134 @@
|
||||
|
||||
/** Java class "Gerant.java" generated from Poseidon for UML.
|
||||
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
|
||||
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
|
||||
*/
|
||||
package Pack_adherents;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
class Gerant {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*/
|
||||
public static Collection adherent = new Vector();
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param args ...
|
||||
* </p>
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
|
||||
|
||||
Adherent a1=new Adherent(1,"Dupont","Paris",1980);
|
||||
addAdherent(a1);
|
||||
Adherent a2=new Adherent(2,"Meyer","Strasbourg",1955);
|
||||
addAdherent(a2);
|
||||
Adherent a3=new Adherent(3,"Legwenn","Brest",1960);
|
||||
addAdherent(a3);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a1.cotiser(45);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a2.cotiser(30);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a3.cotiser(40);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
System.out.println ();
|
||||
a2.cotiser(15);
|
||||
for (int i=0;i<adherent.size();i++){
|
||||
Vector v=(Vector)getAdherents();
|
||||
Adherent a=(Adherent)v.elementAt(i);
|
||||
System.out.println (a);
|
||||
}
|
||||
} // end main
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* @return a Collection with ...
|
||||
* </p>
|
||||
*/
|
||||
public static Collection getAdherents() {
|
||||
return adherent;
|
||||
} // end getAdherents
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param adherent ...
|
||||
* </p>
|
||||
*/
|
||||
public static void addAdherent(Adherent adherent) {
|
||||
if (! Gerant.adherent.contains(adherent)) Gerant.adherent.add(adherent);
|
||||
} // end addAdherent
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Does ...
|
||||
* </p><p>
|
||||
*
|
||||
* </p><p>
|
||||
*
|
||||
* @param adherent ...
|
||||
* </p>
|
||||
*/
|
||||
public static void removeAdherent(Adherent adherent) {
|
||||
Gerant.adherent.remove(adherent);
|
||||
} // end removeAdherent
|
||||
|
||||
} // end Gerant
|
||||
|
||||
|
||||
|
21
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Femme.java
Normal file
21
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Femme.java
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
public class Femme extends Personne {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
private String nomjf;
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
public Femme(String nom,int an, String njf) {
|
||||
super(nom,an);
|
||||
this.nomjf = njf;
|
||||
} // end constructeur
|
||||
public String toString(){
|
||||
return super.toString()+" nee "+nomjf;
|
||||
}
|
||||
} // end Femme
|
||||
|
||||
|
||||
|
54
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Personne.java
Normal file
54
G5a/Solutions/3-exosClasses-1/3-PersonneFemme/Personne.java
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
/** Java class "Personne.java"
|
||||
Repr<EFBFBD>sente une personne quelconque
|
||||
*/
|
||||
import java.util.*;
|
||||
public class Personne {
|
||||
|
||||
///////////////////////////////////////
|
||||
// attributes
|
||||
|
||||
private String nom;
|
||||
private int anneeNaiss;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// operations
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
public void setNom(String _nom) {
|
||||
nom = _nom;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructeur de Personne
|
||||
* </p><p>
|
||||
*
|
||||
* @return a Personne * </p><p>
|
||||
* @param i identifiant
|
||||
* </p> <p>
|
||||
* @param n nom
|
||||
* </p>
|
||||
*/
|
||||
public Personne(String n,int an) {
|
||||
this.nom=n;
|
||||
this.anneeNaiss=an;
|
||||
}
|
||||
public String toString() {
|
||||
return nom+" "+anneeNaiss;
|
||||
}
|
||||
public static void main (String args[]) {
|
||||
Personne p1 = new Personne("Dupont", 1964);
|
||||
Personne p2 = new Personne("Dulac", 1983);
|
||||
Personne p3 = new Femme("Mme Dupont", 1972,"Durand");
|
||||
System.out.println (p1);
|
||||
System.out.println (p2);
|
||||
System.out.println (p3);
|
||||
}
|
||||
} // end Personne
|
||||
|
||||
|
||||
|
79
G5a/Solutions/3-exosClasses-1/4-Confiture/Confiture.java
Normal file
79
G5a/Solutions/3-exosClasses-1/4-Confiture/Confiture.java
Normal file
@ -0,0 +1,79 @@
|
||||
public class Confiture {
|
||||
|
||||
// Attributs
|
||||
private String cuisinier, parfum;
|
||||
private int annee;
|
||||
private int id;
|
||||
private static int c_nextId=1;
|
||||
|
||||
|
||||
// Constructeur
|
||||
public Confiture ( String parfum, String cuisinier,int an ) {
|
||||
this.parfum = parfum;
|
||||
this.cuisinier = cuisinier;
|
||||
this.annee = an;
|
||||
this.id=c_nextId++;
|
||||
|
||||
}
|
||||
|
||||
// Accesseurs
|
||||
public String getCuisinier() {
|
||||
return this.cuisinier;
|
||||
}
|
||||
|
||||
public String getParfum() {
|
||||
return this.parfum;
|
||||
}
|
||||
|
||||
public int getAnnee() {
|
||||
return this.annee;
|
||||
}
|
||||
|
||||
// Modificateurs
|
||||
public void setAnnee( int annee ) {
|
||||
if ( annee >= 0 )
|
||||
this.annee = annee;
|
||||
else
|
||||
System.err.println( "Attention ! l'ann<6E>e entr<74>e n'est pas valide" );
|
||||
}
|
||||
|
||||
public void setCuisinier( String cuisinier ) {
|
||||
this.cuisinier = cuisinier;
|
||||
}
|
||||
|
||||
public void setParfum( String parfum ) {
|
||||
this.parfum = parfum;
|
||||
}
|
||||
|
||||
|
||||
// M<>thode d'affichage
|
||||
public String toString() {
|
||||
StringBuffer infos = new StringBuffer(" ");
|
||||
infos.append(this.id);
|
||||
infos.append(" : Confiture de ").append(this.parfum);
|
||||
infos.append(" par ").append(this.cuisinier);
|
||||
infos.append(" (").append(this.annee).append(")");
|
||||
String res=new String(infos);
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void main( String args[] ) {
|
||||
|
||||
// Creation des deux confitures
|
||||
Confiture conf1 = new Confiture("fraise","Maman",2007 );
|
||||
Confiture conf2 = new Confiture("framboise","Moi",2006 );
|
||||
Confiture conf3 = new Confiture("cassis","Meme",2003 );
|
||||
|
||||
// Modification d'une ann<6E>e
|
||||
conf2.setAnnee( 2005 );
|
||||
|
||||
// Affichage des cuisiniers
|
||||
System.out.println( "Cuisinier confiture 1 : " + conf1.getCuisinier() );
|
||||
System.out.println( "Cuisinier confiture 2 : " + conf2.getCuisinier() );
|
||||
|
||||
// Affichage des informations sur la confiture par la m<>thode println
|
||||
System.out.println( conf1 );
|
||||
System.out.println( conf2 );
|
||||
System.out.println( conf3 );
|
||||
}
|
||||
}
|
BIN
G5a/Solutions/3-exosClasses-1/4-Confiture/confiture.jpg
Normal file
BIN
G5a/Solutions/3-exosClasses-1/4-Confiture/confiture.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
G5a/Solutions/GStock_DCA.jpg
Normal file
BIN
G5a/Solutions/GStock_DCA.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
BIN
G5a/Solutions/Robot/RoboC.jpg
Normal file
BIN
G5a/Solutions/Robot/RoboC.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
BIN
G5a/Solutions/Robot/roboA.jpg
Normal file
BIN
G5a/Solutions/Robot/roboA.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
BIN
G5a/Solutions/Robot/roboC_autre.jpg
Normal file
BIN
G5a/Solutions/Robot/roboC_autre.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
249
G5a/Solutions/Robot/robo_corrige.htm
Normal file
249
G5a/Solutions/Robot/robo_corrige.htm
Normal file
@ -0,0 +1,249 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Language" content="fr">
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<title>ROBOT-2</title>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<span style="font-family: Arial;">
|
||||
<h1>La guerre des robots<br>
|
||||
|
||||
</h1>
|
||||
|
||||
<h2>Solution : </h2>
|
||||
|
||||
<h3>Diagramme de classes d'analyse</h3>
|
||||
|
||||
<p><img style="border: 0px solid ;" alt="DCA Robot" src="RoboA.jpg"></p>
|
||||
|
||||
Quelques remarques :
|
||||
<br>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>On pourrait
|
||||
regrouper en une
|
||||
seule classe Equipe et Base puisqu'elles sont en relation 1--1 ; les
|
||||
concepts étant différents, j'ai toutefois choisi
|
||||
de les
|
||||
séparer, cela permettrait une réutilisation plus
|
||||
rapide
|
||||
si on décidait qu'une équipe peut avoir plusieurs
|
||||
bases</li>
|
||||
|
||||
<li><font face="Arial">La couleur est maintenant
|
||||
un attribut de
|
||||
l'équipe (cf énoncé)<br>
|
||||
|
||||
</font></li>
|
||||
|
||||
<li><font face="Arial">get_distancePerception est
|
||||
abstraite dans
|
||||
Robot et redéfinie dans les sous-classes car la distance de
|
||||
perception n'est connue que ds ces sous-classes ; au contraire,
|
||||
"percevoir" est concrète dans Robot car on peut y produire
|
||||
tout
|
||||
l'algorithme en faisant appel à getDistancePerception, elle
|
||||
retourne un Vector d'Objets des objets perçus (Obstacles,
|
||||
robots, bases)</font></li>
|
||||
|
||||
<li><font face="Arial">getCouleur est
|
||||
concrète dans
|
||||
"Robot" puisque son algorithme ne dépend pas des
|
||||
sous-classes,
|
||||
il ne dépend que de l'équipe ( =
|
||||
getEquipe().getCouleur() ) ; en revanche, elle est abstraite
|
||||
dans
|
||||
Objet à cause de Obstacle<br>
|
||||
|
||||
</font></li>
|
||||
|
||||
<li><font face="Arial">Comme d'habitude, les
|
||||
attributs communs
|
||||
à toutes les instances d'une classe sont
|
||||
préfixés c_ et static
|
||||
(souligné) </font></li>
|
||||
|
||||
<li><font face="Arial">La classe Simulation est un
|
||||
singleton car elle
|
||||
n'a qu'une instance (le jeu en cours) et toutes ses
|
||||
opérations
|
||||
sont collectives<br>
|
||||
|
||||
</font></li>
|
||||
|
||||
<li><font face="Arial">recevoirTir est une
|
||||
opération abstraite
|
||||
de Objet qui est redéfinie dans tous les types d'objets
|
||||
susceptibles de recevoir des tirs de foreuses ; son algorithme devra
|
||||
détailler ce qui se passe alors (p.ex.
|
||||
décrémenter
|
||||
la solidité d'une valeur proportionnelle à la
|
||||
puissance
|
||||
du tir, mais on pourrait aussi complexifier le jeu en tirant
|
||||
aléatoirement une avarie comme par ex. diminuer la distance
|
||||
de
|
||||
perception ou la charge max ). RQ : L'énoncé ne
|
||||
dit rien
|
||||
du tir sur une base : on pourrait la redéfinir en une
|
||||
opération vide.</font></li>
|
||||
|
||||
<li><font face="Arial">"ajouter un nouveau robot"
|
||||
donne naissance
|
||||
à 2 méthodes différentes selon qu'il
|
||||
s'agit d'une
|
||||
foreuse ou d'un porteur (les paramètres sont
|
||||
différents
|
||||
aussi)</font></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<h3>Conception :</h3>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Faites le diagramme de conception, ajoutez une classe "IHM"
|
||||
qui
|
||||
servira d'interface entre l'utilisateur et le système</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><font face="Arial">
|
||||
Quelques remarques : </font></p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><font face="Arial">Rappel : Dans un DCC les
|
||||
relations sans
|
||||
flèches sont des relations bi-orientées</font></li>
|
||||
|
||||
<li><font face="Arial">Alors qu'un diagramme
|
||||
d'analyse
|
||||
présente peu de variations possibles, il y a
|
||||
souvent, au contraire, de nombreux choix de conception
|
||||
possibles
|
||||
avec des avantages et des inconvénients : Ici par exemple,
|
||||
on
|
||||
pourrait choisir de mettre un gestionnaire d'instances sur chaque type
|
||||
d'objet : obstacle, équipe, chaque équipe
|
||||
gérant
|
||||
les instances de ses robots, ("Base" étant liée
|
||||
à
|
||||
"Équipe" en 1..1 elle n'a pas absolument besoin d'une
|
||||
gestion
|
||||
propre), ceci conduit à orienter les relations des
|
||||
gestionnaires
|
||||
vers leurs objets.</font></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><img src="roboC_autre.jpg" border="0" height="437" width="915"></p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><font face="Arial">Je n'ai pas retenu cette
|
||||
solution, j'ai choisi
|
||||
de faire de "Simulation" un super-gestionnaire d'instances de tous les
|
||||
objets car c'est lui de toutes façons qui devra "donner vie"
|
||||
à chaque objet en fonction de son type et qui devra
|
||||
décider du type d'objet qui se trouve en (x,y) lors de la
|
||||
perception par exemple (d'où le "getType" abstrait de
|
||||
"Objet") <br>
|
||||
|
||||
</font></li>
|
||||
|
||||
<li><font face="Arial">Les relations sont
|
||||
orientées dans le
|
||||
sens strictement nécessaire pour une bonne
|
||||
réutilisation
|
||||
p.ex : orienter de Base vers Equipe et non l'inverse permet
|
||||
d'évoluer facilement vers une solution "plusieurs bases par
|
||||
équipe"<br>
|
||||
|
||||
</font></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><img src="RoboC.jpg" border="0" height="735" width="915"></p>
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Faites un diagramme de séquences (cf chapitre 4)
|
||||
pour
|
||||
chacune des requêtes suivantes :
|
||||
<ul>
|
||||
|
||||
<li>Recharger d'une quantité e les batteries du
|
||||
robot
|
||||
N°7 de l'équipe "rouge" </li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p>NB : Les 3 paramètres de la requête
|
||||
sont :
|
||||
numéro et couleur du robot considéré
|
||||
et
|
||||
énergie à recharger mais sur le diagramme de
|
||||
séquence, tous les paramètres apparaissent
|
||||
toujours comme
|
||||
"x" </p>
|
||||
|
||||
<p><img src="DSeq1.jpg" border="0" height="714" width="749"></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Quel est le type (foreuse ou porteur),
|
||||
l'équipe et le
|
||||
niveau d'énergie du robot situé en x,y ? (on
|
||||
supposera
|
||||
qu'il n'y en a qu'un)</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><img src="DSeq2.jpg" border="0" height="794" width="707"></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Ajouter un nouveau robot à la
|
||||
simulation (avec
|
||||
ses paramètres de construction), on supposera qu'il s'agit
|
||||
d'un
|
||||
porteur</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><img src="DSeq3.jpg" border="0" height="674" width="1082"></p>
|
||||
|
||||
</li>
|
||||
|
||||
<li>Afficher l'équipe gagnante : son nom, sa
|
||||
couleur, sa
|
||||
quantité de minerai et le nombre de foreuses qui y sont
|
||||
rattachées</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p><img src="DSeq4.jpg" border="0" height="794" width="790"></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
</span>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user