2018_2019:s2:td:td_final
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
2018_2019:s2:td:td_final [2019/02/16 22:33] – [Votre application : SpyMe (2H20)] blay | 2018_2019:s2:td:td_final [2019/02/28 20:07] – [La classe Journey (30mn)] blay | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== De la modélisation au code : FINALE ====== | ====== De la modélisation au code : FINALE ====== | ||
- | |||
- | FIXME | ||
Dans ce TD nous avons pour objectif de partir de la modélisation et d' | Dans ce TD nous avons pour objectif de partir de la modélisation et d' | ||
- | |||
- | comprendre la relation entre la modélisation et le code, et ceci en utilisant tous les éléments de modélisation. | ||
/* | /* | ||
Line 19: | Line 15: | ||
===== La classe " | ===== La classe " | ||
- | * On définit un '' | + | * On définit un '' |
* Un point a un intitulé (par exemple, "IUT, Fabron" | * Un point a un intitulé (par exemple, "IUT, Fabron" | ||
* Un point peut appartenir à plusieurs Trajets. | * Un point peut appartenir à plusieurs Trajets. | ||
Line 96: | Line 92: | ||
* Avez-vous besoin d' | * Avez-vous besoin d' | ||
* De quelles informations avez-vous besoin pour construire un Parcours? | * De quelles informations avez-vous besoin pour construire un Parcours? | ||
- | * | ||
== Obtenir le moment présent == | == Obtenir le moment présent == | ||
Line 128: | Line 123: | ||
</ | </ | ||
+ | < | ||
+ | <panel title=" | ||
=== Vision Globale | === Vision Globale | ||
Line 133: | Line 130: | ||
<code java> | <code java> | ||
- | public | + | Scanner sc = new Scanner(System.in); |
- | System.out.println(" | + | int interval = 1000; |
- | ... | + | |
- | .... | + | public |
- | PointDate pCourant | + | System.out.println(" |
- | Parcours parcours | + | |
- | boolean | + | Journey path = new Journey(currentPoint); |
- | while (encore){ | + | boolean |
- | pCourant | + | while (again){ |
- | parcours.addPoint(pCourant); | + | currentPoint |
- | System.out.println(" | + | path.addPoint(currentPoint); |
- | System.out.println(" | + | System.out.println(" |
- | .... | + | System.out.println(" |
- | System.out.println(" | + | System.out.println(" |
- | encore | + | again = sc.nextBoolean(); |
- | Thread.sleep(intervalle); //1000 milliseconds is one second. | + | Thread.sleep(interval); //1000 milliseconds is one second. |
} | } | ||
- | return | + | return |
} | } | ||
- | + | ||
- | private | + | private |
- | PointDate pCourant; | + | DatedPoint currentPoint; |
int x; | int x; | ||
int y; | int y; | ||
Line 163: | Line 160: | ||
//obtenir la date courante | //obtenir la date courante | ||
Date date = new Date(); | Date date = new Date(); | ||
- | pCourant | + | currentPoint |
- | return | + | return |
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | Autres exemples | ||
+ | |||
+ | <code java> | ||
+ | //To improve taking into account the displacement | ||
+ | public Date whenWasYouHere(Point point) { | ||
+ | DatedPoint closestPoint = points[0]; | ||
+ | double distanceMin = point.distance(closestPoint); | ||
+ | for (int i =1; i< | ||
+ | double distance = point.distance(points[i]); | ||
+ | if (distance < distanceMin) { | ||
+ | distanceMin = distance; | ||
+ | closestPoint = points[i]; | ||
+ | } | ||
+ | } | ||
+ | return closestPoint.getDate(); | ||
+ | } | ||
+ | |||
+ | |||
+ | //To improve taking into account the displacement | ||
+ | public DatedPoint whereWereYou(Date date) { | ||
+ | long time = date.getTime(); | ||
+ | DatedPoint closestPoint = points[0]; | ||
+ | long durationMin = Math.abs(closestPoint.getDate().getTime()-time); | ||
+ | for (int i =1; i< | ||
+ | long duration = Math.abs(points[i].getDate().getTime()-time); | ||
+ | if (duration < durationMin) { | ||
+ | durationMin = duration; | ||
+ | closestPoint = points[i]; | ||
+ | } | ||
+ | } | ||
+ | return closestPoint; | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Et des exemples de tests ... | ||
+ | |||
+ | <code java> | ||
+ | @Test | ||
+ | void testClosestPoint() throws InterruptedException { | ||
+ | Date currentDate1 = new Date(); | ||
+ | DatedPoint currentPoint1 = new DatedPoint(5, | ||
+ | Thread.sleep(1000); | ||
+ | Date currentDate2 = new Date(); | ||
+ | DatedPoint currentPoint2 = new DatedPoint(7, | ||
+ | Thread.sleep(1000); | ||
+ | DatedPoint currentPoint3 = new DatedPoint(10, | ||
+ | Thread.sleep(1000); | ||
+ | Date currentDate3 = new Date(); | ||
+ | Journey path = new Journey(currentPoint1); | ||
+ | path.addPoint(currentPoint2); | ||
+ | path.addPoint(currentPoint3); | ||
+ | assertEquals(currentPoint1.getDate(), | ||
+ | assertEquals(currentPoint2.getDate(), | ||
+ | assertEquals(currentPoint3.getDate(), | ||
+ | assertEquals(currentPoint3.getDate(), | ||
+ | assertEquals(currentPoint1.getDate(), | ||
+ | assertEquals(currentPoint2.getDate(), | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | @Test | ||
+ | void testWhereWereYou() throws InterruptedException { | ||
+ | Date currentDate1 = new Date(); | ||
+ | DatedPoint currentPoint1 = new DatedPoint(5, | ||
+ | Thread.sleep(1000); | ||
+ | Date currentDate2 = new Date(); | ||
+ | DatedPoint currentPoint2 = new DatedPoint(7, | ||
+ | Thread.sleep(1000); | ||
+ | DatedPoint currentPoint3 = new DatedPoint(10, | ||
+ | Thread.sleep(1000); | ||
+ | Date currentDate3 = new Date(); | ||
+ | Journey path = new Journey(currentPoint1); | ||
+ | path.addPoint(currentPoint2); | ||
+ | path.addPoint(currentPoint3); | ||
+ | assertEquals(currentPoint1, | ||
+ | assertEquals(currentPoint2, | ||
+ | assertEquals(currentPoint3, | ||
+ | assertEquals(currentPoint3, | ||
+ | assertEquals(currentPoint1, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Rendu pour ce devoir ==== | ||
+ | |||
+ | FIXME | ||
+ | |||
+ | - Les rendus se font sous [[http:// | ||
+ | - Le rendu respecte ce qui suit : | ||
+ | - il se fait à 2 maximum | ||
+ | - le titre est composé de FIN< | ||
+ | - Un document qui comprend : | ||
+ | - votre diagramme de cas d' | ||
+ | - votre diagramme de séquence | ||
+ | - votre diagramme de classes cohérent relativement à l' | ||
+ | - les codes sources (là où vous en êtes) | ||
+ | - les tests si vous en avez, sinon le main de test | ||
2018_2019/s2/td/td_final.txt · Last modified: 2019/04/12 14:13 by blay