2019_2020:s2:td:td8
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| 2019_2020:s2:td:td8 [2020/03/01 21:52] – created blay | 2019_2020:s2:td:td8 [2020/03/08 15:58] (current) – [De la modélisation au code : FINALE] blay | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| + | [[2019_2020: | ||
| + | |||
| + | |||
| + | {{: | ||
| ===== 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 34: | Line 38: | ||
| <note tip>Le choix de l' | <note tip>Le choix de l' | ||
| */ | */ | ||
| + | |||
| + | |||
| + | |||
| + | ===== Votre application : SpyMe (2H20) ===== | ||
| + | |||
| + | <note warning> | ||
| + | |||
| + | On décide de produire une nouvelle application telle que : | ||
| + | * Un internaute peut s' | ||
| + | * Un membre peut enregistrer son parcours : | ||
| + | - il déclare sur son téléphone qu'il commence à enregistrer un parcours; | ||
| + | - toutes les 10 secondes, le système crée un nouveau point automatiquement en demandant au GPS du téléphone sa position et l' | ||
| + | - le membre signale la fin du parcours qui est automatiquement enregistré dans sa base de parcours. | ||
| + | * Un membre peut visualiser les parcours passés : par la distance parcourue, la durée, la vitesse moyenne, la date (jour et heure), le type d' | ||
| + | * Un membre peut demander à visualiser un parcours en utilisant googleMAP. | ||
| + | * Un membre peut savoir quand il était le plus proche d'un point donné lors d'un parcours. | ||
| + | * Un membre peut savoir où il était à une date particulière : le système renvoie la position enregistrée à la date la plus proche. | ||
| + | * Un membre peut préciser qu'il veut enregistrer un parcours d' | ||
| + | * Un membre peut créer son propre mode d' | ||
| + | * Un membre qui a précisé son compte twitter, peut demander en début de parcours, que chaque relevé de point soit automatiquement " | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ==== Questions | ||
| + | Evidemment vous commencez par identifier les cas d' | ||
| + | * Définir le diagramme de cas d' | ||
| + | * Définir le diagramme de classes | ||
| + | * Définir le diagramme de séquence correspondant à l' | ||
| + | * Implémenter les scénario de la partie 1 ci-après en vous aidant des codes donnés. En particulier, | ||
| + | * Pouvez-vous étendre votre application pour donner la vitesse moyenne entre deux points donnés d'un parcours? | ||
| + | |||
| + | |||
| + | * **Partie 1** : Voici des exemples très simples de tests de " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - (1) si le point a été enregistré pendant le parcours e.g. ( (7,7) -> '' | ||
| + | - (2) si le point n'a pas été enregistré, | ||
| + | -" | ||
| + | * **Partie 2** : " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | |||
| + | ==== Pour vous aider ==== | ||
| + | |||
| + | === Si vous avez du mal à identifier les " | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | * Avez-vous besoin d' | ||
| + | * De quelles informations avez-vous besoin pour construire un Parcours? | ||
| + | |||
| + | == Obtenir le moment présent == | ||
| + | |||
| + | <code java> | ||
| + | import java.util.Date; | ||
| + | ................ | ||
| + | // | ||
| + | Date date = new Date(); | ||
| + | </ | ||
| + | |||
| + | === Gestion du temps === | ||
| + | |||
| + | Si vous voulez représenter la gestion du temps (mais vous pouvez vous en passer), voici une approche très simple : | ||
| + | <code java> | ||
| + | try { | ||
| + | Thread.sleep(10000);// | ||
| + | } catch (InterruptedException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | === Saisir des entiers ou des boolean au clavier === | ||
| + | <code java> | ||
| + | import java.util.Scanner; | ||
| + | |||
| + | ..................... | ||
| + | Scanner sc = new Scanner(System.in); | ||
| + | int y = sc.nextInt(); | ||
| + | boolean encore = sc.nextBoolean(); | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | <panel title=" | ||
| + | === Vision Globale | ||
| + | |||
| + | Attention, votre code ne correspond probablement pas à cela !! | ||
| + | |||
| + | <code java> | ||
| + | Scanner sc = new Scanner(System.in); | ||
| + | int interval = 1000; | ||
| + | |||
| + | public Journey createJourney(Member m) throws InterruptedException{ | ||
| + | System.out.println(" | ||
| + | DatedPoint currentPoint = enterDatedPoint(); | ||
| + | Journey path = new Journey(currentPoint); | ||
| + | boolean again = true; | ||
| + | while (again){ | ||
| + | currentPoint = enterDatedPoint(); | ||
| + | path.addPoint(currentPoint); | ||
| + | System.out.println(" | ||
| + | System.out.println(" | ||
| + | System.out.println(" | ||
| + | again = sc.nextBoolean(); | ||
| + | Thread.sleep(interval); | ||
| + | } | ||
| + | return path; | ||
| + | } | ||
| + | |||
| + | private DatedPoint enterDatedPoint() { | ||
| + | DatedPoint currentPoint; | ||
| + | int x; | ||
| + | int y; | ||
| + | System.out.println(" | ||
| + | x = sc.nextInt(); | ||
| + | System.out.println(" | ||
| + | y = sc.nextInt(); | ||
| + | //obtenir la date courante | ||
| + | Date date = new Date(); | ||
| + | currentPoint = new DatedPoint(x, | ||
| + | return currentPoint; | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | 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> | ||
| + | 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); | ||
| + | Journey path = new Journey(currentPoint1); | ||
| + | path.addPoint(currentPoint2); | ||
| + | path.addPoint(currentPoint3); | ||
| + | System.out.println(path); | ||
| + | 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, | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | {{: | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
2019_2020/s2/td/td8.1583099524.txt.gz · Last modified: 2020/03/01 21:52 by blay