summaryrefslogtreecommitdiff
path: root/sem_5/HLIN505_Java/HLIN505/src
diff options
context:
space:
mode:
Diffstat (limited to 'sem_5/HLIN505_Java/HLIN505/src')
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP1/Adherent.java25
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP1/Creneau.java40
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP1/Heure.java59
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP1/JourSemaine.java11
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP1/Lieu.java29
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP1/ListeChainee.java64
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP1/Main.java32
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP2/Constante.java11
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP2/Exp.java5
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP2/ExpComp.java28
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP2/Main.java19
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP3/FicText.java47
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP4/AbstractAudioElement.java31
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP4/IelementAudio.java12
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP4/IncorrectFileNameException.java18
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP4/Iplaylist.java6
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP4/SimplePlayList.java60
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP4/Song.java41
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/TP6/foobar.tar.gzbin0 -> 1234 bytes
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/foobar/FooBarException.java9
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/foobar/SUT.java48
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/foobar/TestFooBar.java64
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java63
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/tp7/Ex1.java59
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/tp7/ManipAnnot.java5
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/tp7/Persobonus.java17
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/tp7/Persoinvisible.java24
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/tp7/Personnage.java35
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/tp7/Todo.java7
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/tp7/fabriquePerso.java38
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Etape.java57
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/visites/toTest/NatureEtape.java8
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Parcours.java65
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestEtqpe.java16
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestParcours.java17
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestTroncon.java16
-rw-r--r--sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Troncon.java69
37 files changed, 1155 insertions, 0 deletions
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP1/Adherent.java b/sem_5/HLIN505_Java/HLIN505/src/TP1/Adherent.java
new file mode 100644
index 0000000..0edcb1c
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP1/Adherent.java
@@ -0,0 +1,25 @@
+package TP1;
+
+import java.util.GregorianCalendar;
+
+public class Adherent {
+ private String nom;
+ private Boolean cotisationajour;
+ private final Integer ID;
+ private static Integer NbAdherents=0;
+ private Integer DerniereAnneeCotis;
+ public Adherent (String n) {
+ nom = n;
+ NbAdherents ++;
+ cotisationajour = true;
+ ID = NbAdherents;
+ DerniereAnneeCotis = new GregorianCalendar().get(GregorianCalendar.YEAR);
+ }
+ public void readhesion() {
+ cotisationajour=true;
+ DerniereAnneeCotis= new GregorianCalendar().get(GregorianCalendar.YEAR);
+ }
+ public void nouvelleAnnee() {
+ cotisationajour = false;
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP1/Creneau.java b/sem_5/HLIN505_Java/HLIN505/src/TP1/Creneau.java
new file mode 100644
index 0000000..2bec420
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP1/Creneau.java
@@ -0,0 +1,40 @@
+package TP1;
+
+public class Creneau {
+ private Heure hdeb;
+ private Heure hfin;
+ private JourSemaine jour;
+
+ protected Heure getHdeb() {
+ return hdeb;
+ }
+ protected void setHdeb(Heure hdeb) {
+ this.hdeb = hdeb;
+ }
+ protected Heure getHfin() {
+ return hfin;
+ }
+ protected void setHfin(Heure hfin) {
+ this.hfin = hfin;
+ }
+ protected JourSemaine getJour() {
+ return jour;
+ }
+ protected void setJour(JourSemaine jour) {
+ this.jour = jour;
+ }
+ public Creneau ( Heure deb, Heure fin, JourSemaine j) {
+ setHdeb(deb);
+ setHfin(fin);
+ setJour(j);
+ }
+ public Boolean chevauche(Creneau c) {
+ return (getHdeb().estAvant(c.getHfin())||c.getHdeb().estAvant(getHfin()));
+ }
+ public Boolean estInclusDans(Creneau c) {
+ return ((c.getHdeb().estAvant(getHdeb()) && (getHfin().estAvant(c.getHfin()))));
+ }
+ public String toString() {
+ return getJour().toString()+" "+ getHdeb().toString()+" - "+ getHfin().toString();
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP1/Heure.java b/sem_5/HLIN505_Java/HLIN505/src/TP1/Heure.java
new file mode 100644
index 0000000..5ea86e8
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP1/Heure.java
@@ -0,0 +1,59 @@
+package TP1;
+
+public class Heure {
+ private Integer hour;
+ private Integer min;
+ private static Integer granularitee= 5;
+ private static Integer hMin = 7;
+ private static Integer hMax = 22;
+
+ public Heure (Integer h, Integer m) {
+ hour = new Integer(h);
+ min=new Integer(m);
+ //setHour(h);
+ //setMin(m);
+ }
+
+ protected Integer getHour() {
+ return hour;
+ }
+
+ protected void setHour(Integer hour) {
+ if ( (hour <= hMin ) && (hour < hMax)) {
+ this.hour = hour;
+ }
+ }
+
+ protected Integer getMin() {
+ return min;
+ }
+
+ protected void setMin(Integer min) {
+ if ((min <=55) && (min % granularitee == 0) && (min >=0)) {
+ this.min = min;
+ }
+ }
+ public String toString () {
+ String htemp;
+ String mtemp;
+ if (getHour().intValue() < 10) {
+ htemp = "0"+getHour().toString();
+ }
+ else htemp = getHour().toString();
+ if (getMin().intValue() < 10) {
+ mtemp = "0"+getMin().toString();
+ }
+ else mtemp = getMin().toString();
+ return htemp+":"+mtemp;
+ }
+ public Boolean estAvant(Heure h) {
+ if (h.getHour() < getHour()) {
+ return false;
+ }
+ else if ( h.getHour() > getHour()) {
+ return true;
+ }
+ else return (h.getMin()>getMin());
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP1/JourSemaine.java b/sem_5/HLIN505_Java/HLIN505/src/TP1/JourSemaine.java
new file mode 100644
index 0000000..35b99a6
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP1/JourSemaine.java
@@ -0,0 +1,11 @@
+package TP1;
+
+public enum JourSemaine {
+Lundi,
+Mardi,
+Mercredi,
+Jeudi,
+Vendredi,
+Samedi,
+Dimanche;
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP1/Lieu.java b/sem_5/HLIN505_Java/HLIN505/src/TP1/Lieu.java
new file mode 100644
index 0000000..567fd3c
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP1/Lieu.java
@@ -0,0 +1,29 @@
+package TP1;
+
+import java.util.*;
+
+public enum Lieu {
+ Stade("Stade de foot"),
+ Gymnase("Gymnase"),
+ Piscine("La piscine");
+ private ArrayList<Creneau> horairedispo = new ArrayList<Creneau>();
+ private String nom = "";
+
+ private Lieu(String nom){
+ this.nom = nom;
+ }
+ public String toString() {
+ String tmp = this.nom+"\n";
+ for (Creneau c:horairedispo)
+ tmp += c.toString()+"\n";
+ return tmp;
+ }
+
+
+ public void ajoutCreneauDisponible(Creneau c) {
+ horairedispo.add(c);
+ }
+ public Boolean estdisponiblePour(Creneau c) {
+ return horairedispo.contains(c);
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP1/ListeChainee.java b/sem_5/HLIN505_Java/HLIN505/src/TP1/ListeChainee.java
new file mode 100644
index 0000000..d4b101a
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP1/ListeChainee.java
@@ -0,0 +1,64 @@
+package TP1;
+
+public class ListeChainee {
+ private Node racine;
+ class Node {
+ private String nom;
+ private Node suivant;
+ public Node (String val) {
+ nom = val;
+ suivant = null;
+ }
+ public Node (String val, Node suiv) {
+ nom = val;
+ suivant = suiv;
+ }
+ }
+ public void push (String val) {
+ int tmp = this.taille();
+ racine= new Node(val,racine);
+ assert(tmp == this.taille()+1);
+ }
+ public int taille() {
+ int cpt=0;
+ Node tmp = racine;
+ if (tmp == null) {
+ return 0;
+ }
+ while (tmp.suivant!=null) {
+ cpt ++;
+ tmp=tmp.suivant;
+ }
+ return cpt;
+ }
+ public void affiche() {
+ Node tmp = racine;
+ while ( tmp != null) {
+ System.out.println(tmp.nom);
+ tmp = tmp.suivant;
+ }
+ }
+ public void renverser() {
+ int tailleAvant = this.taille();
+ ListeChainee elem = new ListeChainee();
+ elem.push(this.racine.nom);
+ Node runner = this.racine.suivant;
+ while(runner != null) {
+ elem.push(runner.nom);
+ runner = runner.suivant;
+ }
+ this.racine = elem.racine;
+ assert (this.taille() == tailleAvant);
+ }
+
+ public static void main (String args []) {
+ ListeChainee li = new ListeChainee();
+ li.push("Zbeb1");
+ li.push("Zbeb2");
+ li.push("Zbeb3");
+ li.affiche();
+ li.renverser();
+ li.affiche();
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP1/Main.java b/sem_5/HLIN505_Java/HLIN505/src/TP1/Main.java
new file mode 100644
index 0000000..a207920
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP1/Main.java
@@ -0,0 +1,32 @@
+package TP1;
+
+public class Main {
+
+ public static void main(String[] args) {
+ Heure h1 = new Heure(8,0);
+ Heure h2 = new Heure(9,30);
+ Heure h3 = new Heure(10,25);
+ Heure h4 = new Heure(12,55);
+ Heure h5 = new Heure(16,15);
+ Heure h6 = new Heure(17,00);
+ Lieu l1 = Lieu.Stade;
+ Lieu l2 = Lieu.Piscine;
+ Lieu l3 = Lieu.Gymnase;
+ JourSemaine j1 = JourSemaine.Lundi;
+ JourSemaine j2 = JourSemaine.Mardi;
+ Creneau c1 = new Creneau(h1,h2,j1);
+ Creneau c2 = new Creneau(h2,h3,j2);
+ Creneau c3 = new Creneau(h1,h2,j1);
+ Creneau c4 = new Creneau(h5,h6,j1);
+ Creneau c5 = new Creneau(h4,h6,j2);
+ l1.ajoutCreneauDisponible(c1);
+ l2.ajoutCreneauDisponible(c2);
+ l3.ajoutCreneauDisponible(c3);
+ l1.ajoutCreneauDisponible(c5);
+ l2.ajoutCreneauDisponible(c4);
+ System.out.println(l1.toString());
+ System.out.println(l2.toString());
+ System.out.println(l3.toString());
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP2/Constante.java b/sem_5/HLIN505_Java/HLIN505/src/TP2/Constante.java
new file mode 100644
index 0000000..5d3cb70
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP2/Constante.java
@@ -0,0 +1,11 @@
+package TP2;
+
+public class Constante extends Exp {
+ float val;
+ public float eval() {
+ return val;
+ }
+ public Constante(float x) {
+ val = x;
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP2/Exp.java b/sem_5/HLIN505_Java/HLIN505/src/TP2/Exp.java
new file mode 100644
index 0000000..b465d4c
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP2/Exp.java
@@ -0,0 +1,5 @@
+package TP2;
+
+public abstract class Exp {
+ public abstract float eval ();
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP2/ExpComp.java b/sem_5/HLIN505_Java/HLIN505/src/TP2/ExpComp.java
new file mode 100644
index 0000000..30cfc2e
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP2/ExpComp.java
@@ -0,0 +1,28 @@
+package TP2;
+
+public class ExpComp extends Exp{
+ private Exp val1;
+ private Exp val2;
+ private String op;
+
+ public ExpComp (Exp v1,String op, Exp v2) {
+ val1= v1;
+ this.op = op;
+ val2=v2;
+ }
+
+ public float eval() {
+ switch (op) {
+ case "*":
+ return val1.eval()*val2.eval();
+ case "/":
+ return val1.eval()/val2.eval();
+ case "+":
+ return val1.eval()+val2.eval();
+ case "-":
+ return val1.eval()-val2.eval();
+ default :
+ return 0;
+ }
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP2/Main.java b/sem_5/HLIN505_Java/HLIN505/src/TP2/Main.java
new file mode 100644
index 0000000..de235ce
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP2/Main.java
@@ -0,0 +1,19 @@
+package TP2;
+
+public class Main {
+
+ public static void main(String[] args) {
+ Constante a = new Constante(5);
+ Constante b = new Constante(2);
+ Constante c = new Constante(3);
+ ExpComp e1 = new ExpComp(a,"+",b);
+ ExpComp e2 = new ExpComp(e1,"*",c);
+ ExpComp e3 = new ExpComp(new Constante(4),"*",e2);
+ System.out.println(a.eval());
+ System.out.println(e1.eval());
+ System.out.println(e2.eval());
+ System.out.println(e3.eval());
+
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP3/FicText.java b/sem_5/HLIN505_Java/HLIN505/src/TP3/FicText.java
new file mode 100644
index 0000000..d50656f
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP3/FicText.java
@@ -0,0 +1,47 @@
+package TP3;
+
+import java.io.*;
+
+public class FicText {
+ public static Boolean existsfile (String nom) throws IOException {
+ Boolean exist= true;
+ try {
+ BufferedReader lectureFichier = new BufferedReader(new FileReader(nom));
+ lectureFichier.close();
+ }
+ catch(FileNotFoundException e) {exist = false;}
+ return exist;
+ }
+
+ public static BufferedReader searchFile () throws IOException{
+ BufferedReader lectureClavier = new BufferedReader(new InputStreamReader (System.in));
+ String aouvrir = lectureClavier.readLine();
+ while (!existsfile(aouvrir)) {
+ System.out.println("Fichier introuvable");
+ aouvrir = lectureClavier.readLine();
+ }
+ BufferedReader lectureFichier = new BufferedReader(new FileReader(aouvrir));
+ return lectureFichier;
+ }
+
+
+ public static void main (String args[]) throws IOException{
+// int nbcharac=0;
+// BufferedReader lectureFichier;
+// try {
+// lectureFichier = searchFile();
+// }
+// catch(FileNotFoundException e) {lectureFichier = searchFile(); };
+// String s = lectureFichier.readLine();
+// while ( s != null) {
+// nbcharac += s.replace(" ","").length();
+// System.out.println(s);
+// s= lectureFichier.readLine();
+//
+// }
+ if (1) {
+ System.out.println("Nombre de characteres autres qu'espace: " + nbcharac);
+ lectureFichier.close();
+
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP4/AbstractAudioElement.java b/sem_5/HLIN505_Java/HLIN505/src/TP4/AbstractAudioElement.java
new file mode 100644
index 0000000..078ece9
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP4/AbstractAudioElement.java
@@ -0,0 +1,31 @@
+package TP4;
+
+import java.io.*;
+
+public abstract class AbstractAudioElement implements IelementAudio{
+ private String Name;
+ private String Path;
+ private File fichier;
+ public String getName() {
+ return Name;
+ }
+ public void setName(String name) {
+ Name = name;
+ }
+ public String getPath() {
+ return Path;
+ }
+ public void setPath(String path) {
+ Path = path;
+ }
+ public File getFichier() {
+ return fichier;
+ }
+ public void setFichier(File fichier) {
+ this.fichier = fichier;
+ }
+ public AbstractAudioElement(String p){
+ setPath(p);
+ fichier= new File(Path);
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP4/IelementAudio.java b/sem_5/HLIN505_Java/HLIN505/src/TP4/IelementAudio.java
new file mode 100644
index 0000000..febe561
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP4/IelementAudio.java
@@ -0,0 +1,12 @@
+package TP4;
+
+public interface IelementAudio {
+ public int getLength();
+ public void setLength(int length);
+ public String getName();
+ public void setName(String name);
+ public String getPath();
+ public void setPath(String path);
+ public int getSize();
+ public void setSize() throws SecurityException;
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP4/IncorrectFileNameException.java b/sem_5/HLIN505_Java/HLIN505/src/TP4/IncorrectFileNameException.java
new file mode 100644
index 0000000..f819343
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP4/IncorrectFileNameException.java
@@ -0,0 +1,18 @@
+package TP4;
+
+public class IncorrectFileNameException extends Exception {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String path;
+ public String getPath() {
+ return path;
+ }
+ public void setPath(String path) {
+ this.path = path;
+ }
+ public IncorrectFileNameException(String path){
+ setPath(path);
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP4/Iplaylist.java b/sem_5/HLIN505_Java/HLIN505/src/TP4/Iplaylist.java
new file mode 100644
index 0000000..58cfaff
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP4/Iplaylist.java
@@ -0,0 +1,6 @@
+package TP4;
+
+public interface Iplaylist extends IelementAudio {
+ public int getnbElements();
+ public void setNbElements();
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP4/SimplePlayList.java b/sem_5/HLIN505_Java/HLIN505/src/TP4/SimplePlayList.java
new file mode 100644
index 0000000..a65fc25
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP4/SimplePlayList.java
@@ -0,0 +1,60 @@
+package TP4;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+
+public class SimplePlayList extends AbstractAudioElement implements Iplaylist{
+ private ArrayList<Song> liste;
+ private int Length;
+ private int Size;
+ private int nbElements;
+ public SimplePlayList (String titre, String Path) throws IOException {
+ super(Path);
+ setName(titre);
+ if (!getFichier().exists()) {
+ getFichier().createNewFile();
+ }
+
+
+ }
+ private void browseFile() throws IOException, NumberFormatException, IncorrectFileNameException {
+ BufferedReader read = new BufferedReader(new FileReader(getPath()));
+ String tmp = read.readLine();
+ while (!tmp.isEmpty()) {
+ liste.add(new Song(Integer.parseInt(tmp.split("\\")[0]),tmp.split("\\")[1],tmp.split("\\")[2],tmp.split("\\")[3]));
+ tmp = read.readLine();
+ }
+ read.close();
+ }
+ public int getLength() {
+ return this.Length;
+ }
+ public void setLength() {
+ Length=0;
+ for ( Song s : liste) {
+ Length+=s.getLength();
+ }
+ }
+ public int getSize() {
+ return this.Size;
+ }
+ public void setSize() throws SecurityException{
+ Size = 0;
+ for(Song s : liste) {
+ Size+=s.getSize();
+ }
+ }
+ public int getnbElements() {
+ return nbElements;
+ }
+ public void setNbElements() {
+ nbElements=liste.size();
+ }
+ @Override
+ public void setLength(int length) {
+ // TODO Auto-generated method stub
+
+ }
+ }
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP4/Song.java b/sem_5/HLIN505_Java/HLIN505/src/TP4/Song.java
new file mode 100644
index 0000000..d82c94f
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP4/Song.java
@@ -0,0 +1,41 @@
+package TP4;
+
+public class Song extends AbstractAudioElement {
+ private String artiste;
+ private int length;
+ private int size;
+
+ public Song (int l, String t,String p, String a) throws IncorrectFileNameException{
+ super(p);
+ setLength(l);
+ setArtiste(a);
+ setName(t);
+ setSize();
+ if (!getFichier().exists()) {
+ throw new IncorrectFileNameException(p);
+ }
+ }
+
+ public String getArtiste() {
+ return artiste;
+ }
+ public void setArtiste(String artiste) {
+ this.artiste = artiste;
+ }
+ public int getLength() {
+ return length;
+ }
+
+ public void setLength(int length) {
+ this.length=length;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize() throws SecurityException {
+ this.size=(int)getFichier().length();
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/TP6/foobar.tar.gz b/sem_5/HLIN505_Java/HLIN505/src/TP6/foobar.tar.gz
new file mode 100644
index 0000000..5372441
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/TP6/foobar.tar.gz
Binary files differ
diff --git a/sem_5/HLIN505_Java/HLIN505/src/foobar/FooBarException.java b/sem_5/HLIN505_Java/HLIN505/src/foobar/FooBarException.java
new file mode 100644
index 0000000..5809650
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/foobar/FooBarException.java
@@ -0,0 +1,9 @@
+package foobar;
+
+public class FooBarException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/foobar/SUT.java b/sem_5/HLIN505_Java/HLIN505/src/foobar/SUT.java
new file mode 100644
index 0000000..7d29953
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/foobar/SUT.java
@@ -0,0 +1,48 @@
+package foobar;
+
+public class SUT {
+ private int x;
+ private int y;
+ private int z;
+
+ public SUT(int x, int y, int z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+ public SUT(){
+ x=1;
+ y=3;
+ z=5;
+ }
+
+ /**
+ * Si t est strictement plus petit que x, on retourne x, sinon si t est strictement plus grand que z, on retourne z, sinon on retourne y.
+ * @param t un entier quelconque
+ * @return x si t<x, z si t>z, y sinon
+ */
+ public int foo(int t){
+ int resultat=0;
+ if (t<x) resultat=x;
+ else if (t>z) resultat=z;
+ else resultat=y;
+ return resultat;
+ }
+
+ /**
+ * décale circulairement les valeurs de x, y et z : x prend la valeur de y, y prend la valeur de z et z prend la valeur de x
+ */
+ public void bar(){
+ int temp=x;
+ x=y;
+ y=z;
+ z=temp;
+ }
+
+ /**
+ *
+ */
+ public void foobar()throws FooBarException{
+ if (x<0) throw new FooBarException();
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/foobar/TestFooBar.java b/sem_5/HLIN505_Java/HLIN505/src/foobar/TestFooBar.java
new file mode 100644
index 0000000..ac8bde0
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/foobar/TestFooBar.java
@@ -0,0 +1,64 @@
+package foobar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class TestFooBar {
+ SUT sut;
+
+ @Before
+ public void setUp() throws Exception {
+ sut=new SUT();
+ }
+
+ @Ignore
+ @Test
+ public void testLouche(){
+ assertEquals(1,2);
+ assertTrue(false);
+ }
+
+ @Test
+ public void testFooInitParDefaut1() {
+ assertTrue(sut.foo(0)==1);
+ assertTrue(sut.foo(2)==3);
+ assertTrue(sut.foo(4)==3);
+ assertTrue(sut.foo(6)==5);
+ }
+
+ @Test
+ public void testFooInitParDefaut3() {
+ assertEquals(1,sut.foo(0));
+ assertEquals(3, sut.foo(2));
+ assertEquals(3, sut.foo(4));
+ assertEquals(5, sut.foo(6));
+ }
+
+
+ @Test
+ public void testFooInitParDefaut2() {
+ assertEquals(sut.foo(0),1);
+ assertEquals(sut.foo(2),3);
+ assertEquals(sut.foo(4),3);
+ assertEquals(sut.foo(6),5);
+ }
+ @Test
+ public void testFooInitParDefaut4() {
+ assertThat(sut.foo(0),is(1));
+ assertThat(sut.foo(2),is(3));
+ assertThat(sut.foo(4),is(3));
+ assertThat(sut.foo(6),is(5));
+ }
+
+ @Test
+ public void testBar(){
+ sut.bar();
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java b/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java
new file mode 100644
index 0000000..9b117d5
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/foobar/TestParametreFoo.java
@@ -0,0 +1,63 @@
+package foobar;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import static org.hamcrest.CoreMatchers.is;
+
+@RunWith(Parameterized.class)
+public class TestParametreFoo {
+
+ private static SUT sut;
+ private int x;
+ private int y;
+ private int z;
+ private int t;
+ private int res;
+
+ @Parameters
+ public static Collection data() {
+ return Arrays.asList(new Object[][]{
+ {-1, 3, 5, 2, 3},
+ {5, 5, 5, 2, 5},
+ {5, 5, 3, 2, 5},
+ {3, 3, 5, 2, 3},
+ {3, 3, 3, 2, 3},
+ {1, 5, 3, 2, 5}
+ });
+ }
+
+
+ public TestParametreFoo(int x, int y, int z, int t, int res) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.res = res;
+ this.t=t;
+ }
+
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void testFoo() {
+ sut=new SUT(x, y, z);
+ assertThat(sut.foo(t), is(res));
+ }
+
+ @Test(expected=FooBarException.class)
+ public void TestFoobarexcept () throws FooBarException {
+ sut=new SUT(-1, 12, 26);
+ sut.foobar();
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/tp7/Ex1.java b/sem_5/HLIN505_Java/HLIN505/src/tp7/Ex1.java
new file mode 100644
index 0000000..1a6116d
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/tp7/Ex1.java
@@ -0,0 +1,59 @@
+package tp7;
+
+import java.util.ArrayList;
+
+import javax.swing.JTextField;
+
+import java.io.File;
+import java.lang.reflect.*;
+
+public class Ex1 {
+ private ArrayList Liste;
+ public Ex1 (ArrayList a) {
+ Liste=a;
+ }
+ public Method[] methodesdei (int i) {
+ Class cl = Liste.get(i).getClass();
+ Method[] m = cl.getMethods();
+ return m;
+ }
+ public Class superclasse() {
+ Class ret;
+ ArrayList<Class> cl= new ArrayList<Class>();
+ for (int i = 0; i < Liste.size(); i++) {
+ cl.add(Liste.get(i).getClass());
+ }
+ ArrayList<Class> cl2 = new ArrayList<Class>();
+ while (cl2.add(cl.get(0).getSuperclass()));
+ Object tmp2=new Object();
+ ret = tmp2.getClass();
+ for (Class tmp : cl2) {
+ Boolean fornow = true;
+ for (int i = 1; i < Liste.size(); i ++) {
+ if (!tmp.isInstance(Liste.get(i))){
+ fornow = false;
+ }
+ }
+ if (fornow) {
+ ret = tmp;
+ break;
+ }
+ }
+ return ret;
+ }
+
+ public <T> void add (T obj) {
+ Liste.add(obj);
+ }
+
+ public static void main (String[] args) {
+ ArrayList<Object> list = new ArrayList<Object>();
+ list.add(new Integer(12));
+ list.add(new String("allo"));
+ list.add(new Double(12.2311));
+ list.add(new File("."));
+ list.add(new JTextField());
+ Ex1 test = new Ex1(list);
+ System.out.println(test.superclasse());
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/tp7/ManipAnnot.java b/sem_5/HLIN505_Java/HLIN505/src/tp7/ManipAnnot.java
new file mode 100644
index 0000000..2b4dcd6
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/tp7/ManipAnnot.java
@@ -0,0 +1,5 @@
+package tp7;
+
+public class ManipAnnot {
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/tp7/Persobonus.java b/sem_5/HLIN505_Java/HLIN505/src/tp7/Persobonus.java
new file mode 100644
index 0000000..9b74195
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/tp7/Persobonus.java
@@ -0,0 +1,17 @@
+package tp7;
+
+public class Persobonus extends Personnage{
+ private int palier;
+ public void setpoint (int point) {
+ super.setpoint(point+super.getpoint());
+ if (getpoint()/palier>0) {
+ setUp(getUp()+getpoint()/palier);
+ super.setpoint(getpoint()%palier);
+ }
+ }
+ public Persobonus(String nom, int point, int Up, int palier) {
+ super(nom,point,Up);
+ this.palier=palier;
+ this.setpoint(0);
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/tp7/Persoinvisible.java b/sem_5/HLIN505_Java/HLIN505/src/tp7/Persoinvisible.java
new file mode 100644
index 0000000..5599ddb
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/tp7/Persoinvisible.java
@@ -0,0 +1,24 @@
+package tp7;
+
+public class Persoinvisible extends Personnage {
+ private Boolean visible;
+ private int invtime;
+ private int cd;
+ public void devenirInvisible() {
+ visible=false;
+ invtime=5;
+ }
+ public void devenirVisible() {
+ visible = true;
+ invtime=0;
+ cd = 5;
+ }
+ @Todo(type="Incroyable", version="0.12", dureeapprox=120)
+
+ public Persoinvisible (String nom, int point, int Up, Boolean visible, int invtime, int cd) {
+ super(nom,point,Up);
+ this.visible=visible;
+ this.invtime=invtime;
+ this.cd=cd;
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/tp7/Personnage.java b/sem_5/HLIN505_Java/HLIN505/src/tp7/Personnage.java
new file mode 100644
index 0000000..2d1a8ff
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/tp7/Personnage.java
@@ -0,0 +1,35 @@
+package tp7;
+
+public abstract class Personnage {
+ private String nom;
+ private int point;
+ private int up;
+ public String getNom() {
+ return nom;
+ }
+ public void setNom(String nom) {
+ this.nom = nom;
+ }
+ public int getpoint() {
+ return point;
+ }
+ public void setpoint(int point) {
+ this.point = point;
+ }
+ public int getUp() {
+ return up;
+ }
+ public void setUp(int up) {
+ this.up = up;
+ }
+ public Personnage (String nom, int point, int Up) {
+ this.nom=nom;
+ this.point=point;
+ this.up=Up;
+ }
+ public Personnage() {
+ nom="defaut";
+ point=0;
+ up=3;
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/tp7/Todo.java b/sem_5/HLIN505_Java/HLIN505/src/tp7/Todo.java
new file mode 100644
index 0000000..2ce9318
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/tp7/Todo.java
@@ -0,0 +1,7 @@
+package tp7;
+
+public @interface Todo {
+ String type();
+ String version();
+ int dureeapprox();
+} \ No newline at end of file
diff --git a/sem_5/HLIN505_Java/HLIN505/src/tp7/fabriquePerso.java b/sem_5/HLIN505_Java/HLIN505/src/tp7/fabriquePerso.java
new file mode 100644
index 0000000..5123c79
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/tp7/fabriquePerso.java
@@ -0,0 +1,38 @@
+package tp7;
+
+import java.lang.reflect.*;
+import java.util.ArrayList;
+
+public class fabriquePerso {
+ public Personnage creer(String name) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+ if (name.equals("Persoinvisible") || name.equals("Persobonus")) {
+ Class t = Class.forName(name);
+ Personnage ret = (Personnage) t.newInstance();
+ return ret;
+ }
+ else {
+ return null;
+ }
+ }
+ public Personnage ficheperso (Personnage pers) {
+ Class c=pers.getClass();
+ Field[] fields = c.getDeclaredFields();
+ ArrayList<Field> AF = tabtoarray(fields);
+ Method[] Methodes = c.getDeclaredMethods();
+ while ((c=c.getSuperclass()) != null) {
+ Field[] tmp = c.getDeclaredFields();
+ for (Field f : tmp) {
+ AF.add(f);
+ }
+
+ }
+ System.out.println("Entrer");
+ }
+ public ArrayList<Field> tabtoarray(Field[] f){
+ ArrayList<Field> ret = new ArrayList<Field>();
+ for (int i =0; i < f.length; i ++) {
+ ret.add(f[i]);
+ }
+ return ret;
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Etape.java b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Etape.java
new file mode 100644
index 0000000..6cc127c
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Etape.java
@@ -0,0 +1,57 @@
+package visites.toTest;
+
+public class Etape {
+ private int dureeVisite;
+ private NatureEtape type;
+ private String nom;
+ private String rue;
+
+ public Etape(String nom, String rue, int dureeVisite, NatureEtape type) {
+ this.nom=nom;
+ this.dureeVisite = dureeVisite;
+ this.type = type;
+ }
+
+ public NatureEtape getType() {
+ return type;
+ }
+
+ public void setType(NatureEtape type) {
+ this.type = type;
+ }
+
+ public String getNom() {
+ return nom;
+ }
+
+ public void setNom(String nom) {
+ this.nom = nom;
+ }
+
+ public int getDureeVisite() {
+ return dureeVisite;
+ }
+
+ public void setDureeVisite(int dureeVisite) {
+ this.dureeVisite = dureeVisite;
+ }
+
+ public String getRue() {
+ return rue;
+ }
+/**
+ * vérifie que l'étape est correcte, c'est à dire que la durée de visite n'est nulle que s'il s'agit d'un lieu d'intérêt sans visite.
+ * @return vrai ssi duree de visite nulle <=> lieu d'intérêt sans visite
+ */
+ public boolean estCorrecte(){
+ if ( dureeVisite == 0 ) {
+ if (type==NatureEtape.lieuInteretSansVisite) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ return type!=NatureEtape.lieuInteretSansVisite;
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/NatureEtape.java b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/NatureEtape.java
new file mode 100644
index 0000000..807dff6
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/NatureEtape.java
@@ -0,0 +1,8 @@
+package visites.toTest;
+
+public enum NatureEtape {
+musee,
+visiteMonument,
+visiteJardin,
+lieuInteretSansVisite;
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Parcours.java b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Parcours.java
new file mode 100644
index 0000000..ccc0db9
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Parcours.java
@@ -0,0 +1,65 @@
+package visites.toTest;
+import java.util.Vector;
+
+
+public class Parcours {
+ private Vector<Troncon> troncons=new Vector<Troncon>();
+
+ public void ajoutTroncon(Troncon t){
+ boolean ajout=true;
+
+ if (!troncons.isEmpty()){
+ Troncon dernierTroncon = troncons.lastElement();
+ if (dernierTroncon.getArrivee()!=t.getDepart()){
+ System.out.println("erreur");
+ ajout=false;
+ }
+ }
+ if (ajout){
+ troncons.add(t);
+ }
+ }
+/***
+ * Calcul de la durée du parcours
+ * @return somme des temps de trajet des tronçons et des visites des étapes
+ */
+ public int calculDuree(){
+ int resultat=0;
+ for (Troncon t:troncons){
+ resultat+=t.getTempsTrajet();
+ resultat+=t.getDepart().getDureeVisite();
+ }
+ return resultat;
+ }
+
+ /**
+ * méthode permettant de déterminer s'il y a des boucles dans le circuit, autre que début/arrivée si le parcours est un circuit.
+ * On considère qu'il y a une boucle dès qu'il y a à l'intérieur du parcours deux passages par la même étape.
+ * @return retourne vrai ssi il y a au moins une boucle dans le parcours, autre que début/arrivée
+ */
+ public boolean existeBoucle(){
+ Vector<Etape> etapes=new Vector<Etape>();
+ for (Troncon t:troncons){
+ etapes.add(t.getDepart());
+ etapes.add(t.getArrivee());
+ }
+ int posEtape=0;
+ for (Etape etape:etapes){
+ for (int i=posEtape+1;i<etapes.size();i++){
+ // on regarde de posEtape+1 à la fin de etapes s'il y a une étape égale à etape
+ if (etapes.get(i).equals(etape)){
+ return false;
+ }
+ }
+ posEtape++;
+ }
+ return true;
+ }
+/**
+ * permet de déterminer si le parcours est un circuit (termine au point de départ)
+ * @return vrai ssi le départ et l'arrivée sont indentiques.
+ */
+ public boolean estUnCircuit(){
+ return troncons.firstElement().getDepart().equals(troncons.lastElement().getArrivee());
+ }
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestEtqpe.java b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestEtqpe.java
new file mode 100644
index 0000000..19820bc
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestEtqpe.java
@@ -0,0 +1,16 @@
+package visites.toTest;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class TestEtqpe {
+ Etape e;
+
+ @Test
+ public void test() {
+ e = new Etape("Mont Saint Michel","Faubourg St Honoré",180,NatureEtape.visiteMonument);
+ assertTrue(e.estCorrecte());
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestParcours.java b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestParcours.java
new file mode 100644
index 0000000..281830d
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestParcours.java
@@ -0,0 +1,17 @@
+package visites.toTest;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+public class TestParcours {
+ Parcours parcours;
+
+ @Test
+ public void test() {
+
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestTroncon.java b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestTroncon.java
new file mode 100644
index 0000000..6fecbd6
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/TestTroncon.java
@@ -0,0 +1,16 @@
+package visites.toTest;
+
+import static org.junit.Assert.*;
+
+import java.util.Vector;
+
+import org.junit.Test;
+
+public class TestTroncon {
+ Troncon t;
+ @Test
+ public void test() {
+ t= new Troncon(Etape depart, Etape arrivee, int tempsTrajet, Vector<String> rues)
+ }
+
+}
diff --git a/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Troncon.java b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Troncon.java
new file mode 100644
index 0000000..460b833
--- /dev/null
+++ b/sem_5/HLIN505_Java/HLIN505/src/visites/toTest/Troncon.java
@@ -0,0 +1,69 @@
+package visites.toTest;
+
+import java.util.Vector;
+
+
+public class Troncon {
+ private Etape depart;
+ private Etape arrivee;
+ private int tempsTrajet;
+ private Vector<String> rues;
+
+ public Troncon(Etape depart, Etape arrivee, int tempsTrajet, Vector<String> rues) {
+ this.depart = depart;
+ this.arrivee = arrivee;
+ this.tempsTrajet = tempsTrajet;
+ this.rues=rues;
+ }
+ public Troncon(Etape depart, Etape arrivee, int tempsTrajet) {
+ this.depart = depart;
+ this.arrivee = arrivee;
+ this.tempsTrajet = tempsTrajet; // rues non initialisé
+ }
+
+ public int getTempsTrajet() {
+ return tempsTrajet;
+ }
+ public void setTempsTrajet(int tempsTrajet) {
+ this.tempsTrajet = tempsTrajet;
+ }
+ public Etape getDepart() {
+ return depart;
+ }
+ public void setDepart(Etape depart) {
+ this.depart = depart;
+ }
+ public Etape getArrivee() {
+ return arrivee;
+ }
+ public void setArrivee(Etape arrivee) {
+ this.arrivee = arrivee;
+ }
+
+ /***
+ * vérifie que la première rue de rues est la rue de départ, et la dernière celle d'arrivée
+ * @return vrai ssi la première rue de rues est la rue de départ, et la dernière celle d'arrivée
+ */
+ public boolean verif(){
+ boolean result;
+ result=depart.getRue()==rues.firstElement();
+ result=result&&arrivee.getRue()==rues.lastElement();
+ return result;
+ }
+
+ /**
+ * vérifie que les noms des rues sont 2 à 2 différentes
+ * @return vrai ssi les noms de rues sont 2 à 2 différentes
+ */
+ public boolean verifListeRues(){
+ for (String r1:rues){
+ for (String r2:rues){
+ if (r1.equals(r2)){
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+}