diff options
| author | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
|---|---|---|
| committer | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
| commit | 9fe033ea88c2f705ec18c232873d056e0c229d72 (patch) | |
| tree | 0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_5/HLIN505_Java/HLIN505 | |
Initial commit
Diffstat (limited to 'sem_5/HLIN505_Java/HLIN505')
45 files changed, 1898 insertions, 0 deletions
diff --git a/sem_5/HLIN505_Java/HLIN505/.classpath b/sem_5/HLIN505_Java/HLIN505/.classpath new file mode 100644 index 0000000..33db24f --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/.classpath @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="lib" path="C:/Users/coule/Downloads/cofoja.asm-1.3-20160207.jar"/>
+ <classpathentry kind="src" path=".apt_generated">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sem_5/HLIN505_Java/HLIN505/.factorypath b/sem_5/HLIN505_Java/HLIN505/.factorypath new file mode 100644 index 0000000..a7dbadb --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/.factorypath @@ -0,0 +1,3 @@ +<factorypath> + <factorypathentry kind="EXTJAR" id="C:\Users\coule\Downloads\cofoja.asm-1.3-20160207.jar" enabled="true" runInBatchMode="false"/> +</factorypath> diff --git a/sem_5/HLIN505_Java/HLIN505/.gitignore b/sem_5/HLIN505_Java/HLIN505/.gitignore new file mode 100644 index 0000000..e66a2ba --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/.apt_generated/ diff --git a/sem_5/HLIN505_Java/HLIN505/.project b/sem_5/HLIN505_Java/HLIN505/.project new file mode 100644 index 0000000..bb13130 --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>HLIN505</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sem_5/HLIN505_Java/HLIN505/.settings/org.eclipse.jdt.apt.core.prefs b/sem_5/HLIN505_Java/HLIN505/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..586ea86 --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=true
+org.eclipse.jdt.apt.genSrcDir=.apt_generated
+org.eclipse.jdt.apt.processorOptions/com.google.java.contract.classoutput=%PROJECT.DIR%/.apt_generated
+org.eclipse.jdt.apt.processorOptions/com.google.java.contract.classpath=%PROJECT.DIR%/lib/cofoja.asm-1.3-20160207.jar
+org.eclipse.jdt.apt.reconcileEnabled=true
diff --git a/sem_5/HLIN505_Java/HLIN505/.settings/org.eclipse.jdt.core.prefs b/sem_5/HLIN505_Java/HLIN505/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..5f0539d --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.processAnnotations=enabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/sem_5/HLIN505_Java/HLIN505/lib/cofoja.asm-1.3-20160207.jar b/sem_5/HLIN505_Java/HLIN505/lib/cofoja.asm-1.3-20160207.jar Binary files differnew file mode 100644 index 0000000..ca1ae87 --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/lib/cofoja.asm-1.3-20160207.jar 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 Binary files differnew file mode 100644 index 0000000..5372441 --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/src/TP6/foobar.tar.gz 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; + } + +} diff --git a/sem_5/HLIN505_Java/HLIN505/zbeb.txt b/sem_5/HLIN505_Java/HLIN505/zbeb.txt new file mode 100644 index 0000000..f48c859 --- /dev/null +++ b/sem_5/HLIN505_Java/HLIN505/zbeb.txt @@ -0,0 +1,690 @@ +MAN(1) Manual pager utils MAN(1) + + + +NAME + man - an interface to the on-line reference manuals + +SYNOPSIS + man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] + [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I] + [--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P pager] + [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification] [-p + string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] + page ...] ... + man -k [apropos options] regexp ... + man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ... + man -f [whatis options] page ... + man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L + locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] + [-T[device]] [-H[browser]] [-X[dpi]] [-Z] file ... + man -w|-W [-C file] [-d] [-D] page ... + man -c [-C file] [-d] [-D] page ... + man [-?V] + +DESCRIPTION + man is the system's manual pager. Each page argument given to man is nor‐ + mally the name of a program, utility or function. The manual page associ‐ + ated with each of these arguments is then found and displayed. A section, + if provided, will direct man to look only in that section of the manual. + The default action is to search in all of the available sections following + a pre-defined order ("1 n l 8 3 2 3posix 3pm 3perl 5 4 9 6 7" by default, + unless overridden by the SECTION directive in /etc/manpath.config), and to + show only the first page found, even if page exists in several sections. + + The table below shows the section numbers of the manual followed by the + types of pages they contain. + + + 1 Executable programs or shell commands + 2 System calls (functions provided by the kernel) + 3 Library calls (functions within program libraries) + 4 Special files (usually found in /dev) + 5 File formats and conventions eg /etc/passwd + 6 Games + 7 Miscellaneous (including macro packages and conventions), e.g. man(7), + groff(7) + 8 System administration commands (usually only for root) + 9 Kernel routines [Non standard] + + A manual page consists of several sections. + + Conventional section names include NAME, SYNOPSIS, CONFIGURATION, DESCRIP‐ + TION, OPTIONS, EXIT STATUS, RETURN VALUE, ERRORS, ENVIRONMENT, FILES, VER‐ + SIONS, CONFORMING TO, NOTES, BUGS, EXAMPLE, AUTHORS, and SEE ALSO. + + The following conventions apply to the SYNOPSIS section and can be used as + a guide in other sections. + + + bold text type exactly as shown. + italic text replace with appropriate argument. + [-abc] any or all arguments within [ ] are optional. + -a|-b options delimited by | cannot be used together. + argument ... argument is repeatable. + [expression] ... entire expression within [ ] is repeatable. + + Exact rendering may vary depending on the output device. For instance, man + will usually not be able to render italics when running in a terminal, and + will typically use underlined or coloured text instead. + + The command or function illustration is a pattern that should match all + possible invocations. In some cases it is advisable to illustrate several + exclusive invocations as is shown in the SYNOPSIS section of this manual + page. + +EXAMPLES + man ls + Display the manual page for the item (program) ls. + + man -a intro + Display, in succession, all of the available intro manual pages con‐ + tained within the manual. It is possible to quit between successive + displays or skip any of them. + + man -t alias | lpr -Pps + Format the manual page referenced by `alias', usually a shell manual + page, into the default troff or groff format and pipe it to the printer + named ps. The default output for groff is usually PostScript. man + --help should advise as to which processor is bound to the -t option. + + man -l -Tdvi ./foo.1x.gz > ./foo.1x.dvi + This command will decompress and format the nroff source manual page + ./foo.1x.gz into a device independent (dvi) file. The redirection is + necessary as the -T flag causes output to be directed to stdout with no + pager. The output could be viewed with a program such as xdvi or fur‐ + ther processed into PostScript using a program such as dvips. + + man -k printf + Search the short descriptions and manual page names for the keyword + printf as regular expression. Print out any matches. Equivalent to + apropos -r printf. + + man -f smail + Lookup the manual pages referenced by smail and print out the short + descriptions of any found. Equivalent to whatis -r smail. + +OVERVIEW + Many options are available to man in order to give as much flexibility as + possible to the user. Changes can be made to the search path, section + order, output processor, and other behaviours and operations detailed + below. + + If set, various environment variables are interrogated to determine the + operation of man. It is possible to set the `catch all' variable $MANOPT + to any string in command line format with the exception that any spaces + used as part of an option's argument must be escaped (preceded by a back‐ + slash). man will parse $MANOPT prior to parsing its own command line. + Those options requiring an argument will be overridden by the same options + found on the command line. To reset all of the options set in $MANOPT, -D + can be specified as the initial command line option. This will allow man + to `forget' about the options specified in $MANOPT although they must still + have been valid. + + The manual pager utilities packaged as man-db make extensive use of index + database caches. These caches contain information such as where each man‐ + ual page can be found on the filesystem and what its whatis (short one line + description of the man page) contains, and allow man to run faster than if + it had to search the filesystem each time to find the appropriate manual + page. If requested using the -u option, man will ensure that the caches + remain consistent, which can obviate the need to manually run software to + update traditional whatis text databases. + + If man cannot find a mandb initiated index database for a particular manual + page hierarchy, it will still search for the requested manual pages, + although file globbing will be necessary to search within that hierarchy. + If whatis or apropos fails to find an index it will try to extract informa‐ + tion from a traditional whatis database instead. + + These utilities support compressed source nroff files having, by default, + the extensions of .Z, .z and .gz. It is possible to deal with any compres‐ + sion extension, but this information must be known at compile time. Also, + by default, any cat pages produced are compressed using gzip. Each + `global' manual page hierarchy such as /usr/share/man or /usr/X11R6/man may + have any directory as its cat page hierarchy. Traditionally the cat pages + are stored under the same hierarchy as the man pages, but for reasons such + as those specified in the File Hierarchy Standard (FHS), it may be better + to store them elsewhere. For details on how to do this, please read man‐ + path(5). For details on why to do this, read the standard. + + International support is available with this package. Native language man‐ + ual pages are accessible (if available on your system) via use of locale + functions. To activate such support, it is necessary to set either + $LC_MESSAGES, $LANG or another system dependent environment variable to + your language locale, usually specified in the POSIX 1003.1 based format: + + <language>[_<territory>[.<character-set>[,<version>]]] + + If the desired page is available in your locale, it will be displayed in + lieu of the standard (usually American English) page. + + Support for international message catalogues is also featured in this pack‐ + age and can be activated in the same way, again if available. If you find + that the manual pages and message catalogues supplied with this package are + not available in your native language and you would like to supply them, + please contact the maintainer who will be coordinating such activity. + + For information regarding other features and extensions available with this + manual pager, please read the documents supplied with the package. + +DEFAULTS + man will search for the desired manual pages within the index database + caches. If the -u option is given, a cache consistency check is performed + to ensure the databases accurately reflect the filesystem. If this option + is always given, it is not generally necessary to run mandb after the + caches are initially created, unless a cache becomes corrupt. However, the + cache consistency check can be slow on systems with many manual pages + installed, so it is not performed by default, and system administrators may + wish to run mandb every week or so to keep the database caches fresh. To + forestall problems caused by outdated caches, man will fall back to file + globbing if a cache lookup fails, just as it would if no cache was present. + + Once a manual page has been located, a check is performed to find out if a + relative preformatted `cat' file already exists and is newer than the nroff + file. If it does and is, this preformatted file is (usually) decompressed + and then displayed, via use of a pager. The pager can be specified in a + number of ways, or else will fall back to a default is used (see option -P + for details). If no cat is found or is older than the nroff file, the + nroff is filtered through various programs and is shown immediately. + + If a cat file can be produced (a relative cat directory exists and has + appropriate permissions), man will compress and store the cat file in the + background. + + The filters are deciphered by a number of means. Firstly, the command line + option -p or the environment variable $MANROFFSEQ is interrogated. If -p + was not used and the environment variable was not set, the initial line of + the nroff file is parsed for a preprocessor string. To contain a valid + preprocessor string, the first line must resemble + + '\" <string> + + where string can be any combination of letters described by option -p + below. + + If none of the above methods provide any filter information, a default set + is used. + + A formatting pipeline is formed from the filters and the primary formatter + (nroff or [tg]roff with -t) and executed. Alternatively, if an executable + program mandb_nfmt (or mandb_tfmt with -t) exists in the man tree root, it + is executed instead. It gets passed the manual source file, the preproces‐ + sor string, and optionally the device specified with -T or -E as arguments. + +OPTIONS + Non argument options that are duplicated either on the command line, in + $MANOPT, or both, are not harmful. For options that require an argument, + each duplication will override the previous argument value. + + General options + -C file, --config-file=file + Use this user configuration file rather than the default of ~/.man‐ + path. + + -d, --debug + Print debugging information. + + -D, --default + This option is normally issued as the very first option and resets + man's behaviour to its default. Its use is to reset those options + that may have been set in $MANOPT. Any options that follow -D will + have their usual effect. + + --warnings[=warnings] + Enable warnings from groff. This may be used to perform sanity + checks on the source text of manual pages. warnings is a comma-sep‐ + arated list of warning names; if it is not supplied, the default is + "mac". See the “Warnings” node in info groff for a list of avail‐ + able warning names. + + Main modes of operation + -f, --whatis + Equivalent to whatis. Display a short description from the manual + page, if available. See whatis(1) for details. + + -k, --apropos + Equivalent to apropos. Search the short manual page descriptions + for keywords and display any matches. See apropos(1) for details. + + -K, --global-apropos + Search for text in all manual pages. This is a brute-force search, + and is likely to take some time; if you can, you should specify a + section to reduce the number of pages that need to be searched. + Search terms may be simple strings (the default), or regular expres‐ + sions if the --regex option is used. + + -l, --local-file + Activate `local' mode. Format and display local manual files + instead of searching through the system's manual collection. Each + manual page argument will be interpreted as an nroff source file in + the correct format. No cat file is produced. If '-' is listed as + one of the arguments, input will be taken from stdin. When this + option is not used, and man fails to find the page required, before + displaying the error message, it attempts to act as if this option + was supplied, using the name as a filename and looking for an exact + match. + + -w, --where, --path, --location + Don't actually display the manual pages, but do print the loca‐ + tion(s) of the source nroff files that would be formatted. + + -W, --where-cat, --location-cat + Don't actually display the manual pages, but do print the loca‐ + tion(s) of the cat files that would be displayed. If -w and -W are + both specified, print both separated by a space. + + -c, --catman + This option is not for general use and should only be used by the + catman program. + + -R encoding, --recode=encoding + Instead of formatting the manual page in the usual way, output its + source converted to the specified encoding. If you already know the + encoding of the source file, you can also use manconv(1) directly. + However, this option allows you to convert several manual pages to a + single encoding without having to explicitly state the encoding of + each, provided that they were already installed in a structure simi‐ + lar to a manual page hierarchy. + + Finding manual pages + -L locale, --locale=locale + man will normally determine your current locale by a call to the C + function setlocale(3) which interrogates various environment vari‐ + ables, possibly including $LC_MESSAGES and $LANG. To temporarily + override the determined value, use this option to supply a locale + string directly to man. Note that it will not take effect until the + search for pages actually begins. Output such as the help message + will always be displayed in the initially determined locale. + + -m system[,...], --systems=system[,...] + If this system has access to other operating system's manual pages, + they can be accessed using this option. To search for a manual page + from NewOS's manual page collection, use the option -m NewOS. + + The system specified can be a combination of comma delimited operat‐ + ing system names. To include a search of the native operating sys‐ + tem's manual pages, include the system name man in the argument + string. This option will override the $SYSTEM environment variable. + + -M path, --manpath=path + Specify an alternate manpath to use. By default, man uses manpath + derived code to determine the path to search. This option overrides + the $MANPATH environment variable and causes option -m to be + ignored. + + A path specified as a manpath must be the root of a manual page + hierarchy structured into sections as described in the man-db manual + (under "The manual page system"). To view manual pages outside such + hierarchies, see the -l option. + + -S list, -s list, --sections=list + List is a colon- or comma-separated list of `order specific' manual + sections to search. This option overrides the $MANSECT environment + variable. (The -s spelling is for compatibility with System V.) + + -e sub-extension, --extension=sub-extension + Some systems incorporate large packages of manual pages, such as + those that accompany the Tcl package, into the main manual page + hierarchy. To get around the problem of having two manual pages + with the same name such as exit(3), the Tcl pages were usually all + assigned to section l. As this is unfortunate, it is now possible + to put the pages in the correct section, and to assign a specific + `extension' to them, in this case, exit(3tcl). Under normal opera‐ + tion, man will display exit(3) in preference to exit(3tcl). To + negotiate this situation and to avoid having to know which section + the page you require resides in, it is now possible to give man a + sub-extension string indicating which package the page must belong + to. Using the above example, supplying the option -e tcl to man + will restrict the search to pages having an extension of *tcl. + + -i, --ignore-case + Ignore case when searching for manual pages. This is the default. + + -I, --match-case + Search for manual pages case-sensitively. + + --regex + Show all pages with any part of either their names or their descrip‐ + tions matching each page argument as a regular expression, as with + apropos(1). Since there is usually no reasonable way to pick a + "best" page when searching for a regular expression, this option + implies -a. + + --wildcard + Show all pages with any part of either their names or their descrip‐ + tions matching each page argument using shell-style wildcards, as + with apropos(1) --wildcard. The page argument must match the entire + name or description, or match on word boundaries in the description. + Since there is usually no reasonable way to pick a "best" page when + searching for a wildcard, this option implies -a. + + --names-only + If the --regex or --wildcard option is used, match only page names, + not page descriptions, as with whatis(1). Otherwise, no effect. + + -a, --all + By default, man will exit after displaying the most suitable manual + page it finds. Using this option forces man to display all the man‐ + ual pages with names that match the search criteria. + + -u, --update + This option causes man to perform an `inode level' consistency check + on its database caches to ensure that they are an accurate represen‐ + tation of the filesystem. It will only have a useful effect if man + is installed with the setuid bit set. + + --no-subpages + By default, man will try to interpret pairs of manual page names + given on the command line as equivalent to a single manual page name + containing a hyphen or an underscore. This supports the common pat‐ + tern of programs that implement a number of subcommands, allowing + them to provide manual pages for each that can be accessed using + similar syntax as would be used to invoke the subcommands them‐ + selves. For example: + + $ man -aw git diff + /usr/share/man/man1/git-diff.1.gz + + To disable this behaviour, use the --no-subpages option. + + $ man -aw --no-subpages git diff + /usr/share/man/man1/git.1.gz + /usr/share/man/man3/Git.3pm.gz + /usr/share/man/man1/diff.1.gz + + Controlling formatted output + -P pager, --pager=pager + Specify which output pager to use. By default, man uses pager -s. + This option overrides the $MANPAGER environment variable, which in + turn overrides the $PAGER environment variable. It is not used in + conjunction with -f or -k. + + The value may be a simple command name or a command with arguments, + and may use shell quoting (backslashes, single quotes, or double + quotes). It may not use pipes to connect multiple commands; if you + need that, use a wrapper script, which may take the file to display + either as an argument or on standard input. + + -r prompt, --prompt=prompt + If a recent version of less is used as the pager, man will attempt + to set its prompt and some sensible options. The default prompt + looks like + + Manual page name(sec) line x + + where name denotes the manual page name, sec denotes the section it + was found under and x the current line number. This is achieved by + using the $LESS environment variable. + + Supplying -r with a string will override this default. The string + may contain the text $MAN_PN which will be expanded to the name of + the current manual page and its section name surrounded by `(' and + `)'. The string used to produce the default could be expressed as + + \ Manual\ page\ \$MAN_PN\ ?ltline\ %lt?L/%L.: + byte\ %bB?s/%s..?\ (END):?pB\ %pB\\%.. + (press h for help or q to quit) + + It is broken into three lines here for the sake of readability only. + For its meaning see the less(1) manual page. The prompt string is + first evaluated by the shell. All double quotes, back-quotes and + backslashes in the prompt must be escaped by a preceding backslash. + The prompt string may end in an escaped $ which may be followed by + further options for less. By default man sets the -ix8 options. + + The $MANLESS environment variable described below may be used to set + a default prompt string if none is supplied on the command line. + + -7, --ascii + When viewing a pure ascii(7) manual page on a 7 bit terminal or ter‐ + minal emulator, some characters may not display correctly when using + the latin1(7) device description with GNU nroff. This option allows + pure ascii manual pages to be displayed in ascii with the latin1 + device. It will not translate any latin1 text. The following table + shows the translations performed: some parts of it may only be dis‐ + played properly when using GNU nroff's latin1(7) device. + + + Description Octal latin1 ascii + ────────────────────────────────────────── + continuation 255 ‐ - + hyphen + bullet (middle 267 · o + dot) + acute accent 264 ´ ' + multiplication 327 × x + sign + + If the latin1 column displays correctly, your terminal may be set up + for latin1 characters and this option is not necessary. If the + latin1 and ascii columns are identical, you are reading this page + using this option or man did not format this page using the latin1 + device description. If the latin1 column is missing or corrupt, you + may need to view manual pages with this option. + + This option is ignored when using options -t, -H, -T, or -Z and may + be useless for nroff other than GNU's. + + -E encoding, --encoding=encoding + Generate output for a character encoding other than the default. + For backward compatibility, encoding may be an nroff device such as + ascii, latin1, or utf8 as well as a true character encoding such as + UTF-8. + + --no-hyphenation, --nh + Normally, nroff will automatically hyphenate text at line breaks + even in words that do not contain hyphens, if it is necessary to do + so to lay out words on a line without excessive spacing. This + option disables automatic hyphenation, so words will only be hyphen‐ + ated if they already contain hyphens. + + If you are writing a manual page and simply want to prevent nroff + from hyphenating a word at an inappropriate point, do not use this + option, but consult the nroff documentation instead; for instance, + you can put "\%" inside a word to indicate that it may be hyphenated + at that point, or put "\%" at the start of a word to prevent it from + being hyphenated. + + --no-justification, --nj + Normally, nroff will automatically justify text to both margins. + This option disables full justification, leaving justified only to + the left margin, sometimes called "ragged-right" text. + + If you are writing a manual page and simply want to prevent nroff + from justifying certain paragraphs, do not use this option, but con‐ + sult the nroff documentation instead; for instance, you can use the + ".na", ".nf", ".fi", and ".ad" requests to temporarily disable + adjusting and filling. + + -p string, --preprocessor=string + Specify the sequence of preprocessors to run before nroff or + troff/groff. Not all installations will have a full set of pre‐ + processors. Some of the preprocessors and the letters used to des‐ + ignate them are: eqn (e), grap (g), pic (p), tbl (t), vgrind (v), + refer (r). This option overrides the $MANROFFSEQ environment vari‐ + able. zsoelim is always run as the very first preprocessor. + + -t, --troff + Use groff -mandoc to format the manual page to stdout. This option + is not required in conjunction with -H, -T, or -Z. + + -T[device], --troff-device[=device] + This option is used to change groff (or possibly troff's) output to + be suitable for a device other than the default. It implies -t. + Examples (provided with Groff-1.17) include dvi, latin1, ps, utf8, + X75 and X100. + + -H[browser], --html[=browser] + This option will cause groff to produce HTML output, and will dis‐ + play that output in a web browser. The choice of browser is deter‐ + mined by the optional browser argument if one is provided, by the + $BROWSER environment variable, or by a compile-time default if that + is unset (usually lynx). This option implies -t, and will only work + with GNU troff. + + -X[dpi], --gxditview[=dpi] + This option displays the output of groff in a graphical window using + the gxditview program. The dpi (dots per inch) may be 75, 75-12, + 100, or 100-12, defaulting to 75; the -12 variants use a 12-point + base font. This option implies -T with the X75, X75-12, X100, or + X100-12 device respectively. + + -Z, --ditroff + groff will run troff and then use an appropriate post-processor to + produce output suitable for the chosen device. If groff -mandoc is + groff, this option is passed to groff and will suppress the use of a + post-processor. It implies -t. + + Getting help + -?, --help + Print a help message and exit. + + --usage + Print a short usage message and exit. + + -V, --version + Display version information. + +EXIT STATUS + 0 Successful program execution. + + 1 Usage, syntax or configuration file error. + + 2 Operational error. + + 3 A child process returned a non-zero exit status. + + 16 At least one of the pages/files/keywords didn't exist or wasn't + matched. + +ENVIRONMENT + MANPATH + If $MANPATH is set, its value is used as the path to search for man‐ + ual pages. + + MANROFFOPT + The contents of $MANROFFOPT are added to the command line every time + man invokes the formatter (nroff, troff, or groff). + + MANROFFSEQ + If $MANROFFSEQ is set, its value is used to determine the set of + preprocessors to pass each manual page through. The default pre‐ + processor list is system dependent. + + MANSECT + If $MANSECT is set, its value is a colon-delimited list of sections + and it is used to determine which manual sections to search and in + what order. The default is "1 n l 8 3 2 3posix 3pm 3perl 5 4 9 6 + 7", unless overridden by the SECTION directive in /etc/manpath.con‐ + fig. + + MANPAGER, PAGER + If $MANPAGER or $PAGER is set ($MANPAGER is used in preference), its + value is used as the name of the program used to display the manual + page. By default, pager -s is used. + + The value may be a simple command name or a command with arguments, + and may use shell quoting (backslashes, single quotes, or double + quotes). It may not use pipes to connect multiple commands; if you + need that, use a wrapper script, which may take the file to display + either as an argument or on standard input. + + MANLESS + If $MANLESS is set, its value will be used as the default prompt + string for the less pager, as if it had been passed using the -r + option (so any occurrences of the text $MAN_PN will be expanded in + the same way). For example, if you want to set the prompt string + unconditionally to “my prompt string”, set $MANLESS to + ‘-Psmy prompt string’. Using the -r option overrides this environ‐ + ment variable. + + BROWSER + If $BROWSER is set, its value is a colon-delimited list of commands, + each of which in turn is used to try to start a web browser for man + --html. In each command, %s is replaced by a filename containing + the HTML output from groff, %% is replaced by a single percent sign + (%), and %c is replaced by a colon (:). + + SYSTEM If $SYSTEM is set, it will have the same effect as if it had been + specified as the argument to the -m option. + + MANOPT If $MANOPT is set, it will be parsed prior to man's command line and + is expected to be in a similar format. As all of the other man spe‐ + cific environment variables can be expressed as command line + options, and are thus candidates for being included in $MANOPT it is + expected that they will become obsolete. N.B. All spaces that + should be interpreted as part of an option's argument must be + escaped. + + MANWIDTH + If $MANWIDTH is set, its value is used as the line length for which + manual pages should be formatted. If it is not set, manual pages + will be formatted with a line length appropriate to the current ter‐ + minal (using an ioctl(2) if available, the value of $COLUMNS, or + falling back to 80 characters if neither is available). Cat pages + will only be saved when the default formatting can be used, that is + when the terminal line length is between 66 and 80 characters. + + MAN_KEEP_FORMATTING + Normally, when output is not being directed to a terminal (such as + to a file or a pipe), formatting characters are discarded to make it + easier to read the result without special tools. However, if + $MAN_KEEP_FORMATTING is set to any non-empty value, these formatting + characters are retained. This may be useful for wrappers around man + that can interpret formatting characters. + + MAN_KEEP_STDERR + Normally, when output is being directed to a terminal (usually to a + pager), any error output from the command used to produce formatted + versions of manual pages is discarded to avoid interfering with the + pager's display. Programs such as groff often produce relatively + minor error messages about typographical problems such as poor + alignment, which are unsightly and generally confusing when dis‐ + played along with the manual page. However, some users want to see + them anyway, so, if $MAN_KEEP_STDERR is set to any non-empty value, + error output will be displayed as usual. + + LANG, LC_MESSAGES + Depending on system and implementation, either or both of $LANG and + $LC_MESSAGES will be interrogated for the current message locale. + man will display its messages in that locale (if available). See + setlocale(3) for precise details. + +FILES + /etc/manpath.config + man-db configuration file. + + /usr/share/man + A global manual page hierarchy. + + /usr/share/man/index.(bt|db|dir|pag) + A traditional global index database cache. + + /var/cache/man/index.(bt|db|dir|pag) + An FHS compliant global index database cache. + +SEE ALSO + apropos(1), groff(1), less(1), manpath(1), nroff(1), troff(1), whatis(1), + zsoelim(1), setlocale(3), manpath(5), ascii(7), latin1(7), man(7), cat‐ + man(8), mandb(8), the man-db package manual, FSSTND + +HISTORY + 1990, 1991 - Originally written by John W. Eaton (jwe@che.utexas.edu). + + Dec 23 1992: Rik Faith (faith@cs.unc.edu) applied bug fixes supplied by + Willem Kasdorp (wkasdo@nikhefk.nikef.nl). + + 30th April 1994 - 23rd February 2000: Wilf. (G.Wilford@ee.surrey.ac.uk) has + been developing and maintaining this package with the help of a few dedi‐ + cated people. + + 30th October 1996 - 30th March 2001: Fabrizio Polacco <fpolacco@debian.org> + maintained and enhanced this package for the Debian project, with the help + of all the community. + + 31st March 2001 - present day: Colin Watson <cjwatson@debian.org> is now + developing and maintaining man-db. + + + +2.6.7.1 2014-04-10 MAN(1) |
