From 9fe033ea88c2f705ec18c232873d056e0c229d72 Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:05:53 +0200 Subject: Initial commit --- sem_5/HLIN505_Java/HLIN505/src/TP1/Adherent.java | 25 +++++++++ sem_5/HLIN505_Java/HLIN505/src/TP1/Creneau.java | 40 ++++++++++++++ sem_5/HLIN505_Java/HLIN505/src/TP1/Heure.java | 59 ++++++++++++++++++++ .../HLIN505_Java/HLIN505/src/TP1/JourSemaine.java | 11 ++++ sem_5/HLIN505_Java/HLIN505/src/TP1/Lieu.java | 29 ++++++++++ .../HLIN505_Java/HLIN505/src/TP1/ListeChainee.java | 64 ++++++++++++++++++++++ sem_5/HLIN505_Java/HLIN505/src/TP1/Main.java | 32 +++++++++++ 7 files changed, 260 insertions(+) create mode 100644 sem_5/HLIN505_Java/HLIN505/src/TP1/Adherent.java create mode 100644 sem_5/HLIN505_Java/HLIN505/src/TP1/Creneau.java create mode 100644 sem_5/HLIN505_Java/HLIN505/src/TP1/Heure.java create mode 100644 sem_5/HLIN505_Java/HLIN505/src/TP1/JourSemaine.java create mode 100644 sem_5/HLIN505_Java/HLIN505/src/TP1/Lieu.java create mode 100644 sem_5/HLIN505_Java/HLIN505/src/TP1/ListeChainee.java create mode 100644 sem_5/HLIN505_Java/HLIN505/src/TP1/Main.java (limited to 'sem_5/HLIN505_Java/HLIN505/src/TP1') 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 horairedispo = new ArrayList(); + 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()); + } + +} -- cgit v1.2.3