GLO-4002 - Site de cours

Temps estimé: 1h

Implanter un Repository en Java

Vous êtes maintenant l'heureux-euse propriétaire d'un garage automobile. Pour offrir une meilleure qualité de service à vos clients, vous décidez de programmer un logiciel simple qui fait le suivi de chaque service effectué.

Le logiciel permet, entre autre, de traiter les scénarios suivants:

Scenario: The one where I swap wheels of a car
  Given the following car:
  | serial number | mileage | front left wheel | front right wheel | rear left wheel | rear right wheel | last oil change date | last oil change mileage |
  | QC38822R83F   | 41736   | 81248233         | 81248234          | 81248235        | 81248236         | 2020-01-01           | 28756                   |
  When I swap 'front left' and 'rear left' wheels of car 'QC38822R83F'
  Then wheel '81248233' should be at position 'rear left'
   And wheel '81248235' should be at position 'front left'
Scenario: The one where I change engine oil of a car
  Given the following car:
  | serial number | mileage | front left wheel | front right wheel | rear left wheel | rear right wheel | last oil change date | last oil change mileage |
  | QC38822R83F   | 41736   | 81248233         | 81248234          | 81248235        | 81248236         | 2020-01-01           | 28756                   |
   And today is '2020-09-25'
  When I change oil of car 'QC38822R83F'
  Then last oil change date is '2020-09-25'
   And last oil change mileage is '41736'

Pour cet exercice, bien que cela pourrait grandement vous aider à définir le/les bon(s) contrat(s) et à pratiquer vos compétences de conception OO, il n'est pas nécessaire d'implémenter les scénarios. Le but est simplement d'implémenter un ou plusieurs Repository pour satisfaire les cas d'utilisation présentés ci-dessus.

La ou les implémentation(s) de votre/vos Repository doit/doivent se faire en Java et doit/doivent aller chercher des données dans des fichiers JSON. Voici des exemples de fichiers JSON qui contiennent les données qui doivent être abstraites:

[
  {
    "serial_number": "QC38822R83F",
    "brand": "Toyota",
    "model": "Rav4",
    "year": "2019",
    "mileage": 41736,
    "id": 237
  },
  {
    "serial_number": "QC87594A39Y",
    "brand": "Nissan",
    "model": "GT-R Nismo",
    "year": "2014",
    "mileage": 11622,
    "id": 430
  }
]
[
  {
    "serial_number": "81248233",
    "brand": "Toyo Tires",
    "model": "PROXES TM1 Ultra High Performance",
    "size": "195R50-15",
    "position": "FL",
    "mileage_installation": 34250,
    "car_id": 430
  },
  {
    "serial_number": "81248234",
    "brand": "Toyo Tires",
    "model": "PROXES TM1 Ultra High Performance",
    "size": "195R50-15",
    "position": "FR",
    "mileage_installation": 34250,
    "car_id": 430
  },
  {
    "serial_number": "81248235",
    "brand": "Toyo Tires",
    "model": "PROXES TM1 Ultra High Performance",
    "size": "195R50-15",
    "position": "RL",
    "mileage_installation": 34250,
    "car_id": 430
  },
  {
    "serial_number": "81248236",
    "brand": "Toyo Tires",
    "model": "PROXES TM1 Ultra High Performance",
    "size": "195R50-15",
    "position": "RR",
    "mileage_installation": 34250,
    "car_id": 237
  },
  {
    "serial_number": "B1234785",
    "brand": "Bridgestone",
    "model": "Dueler A/T Revo 3",
    "size": "P225/75/16",
    "position": "FL",
    "mileage_installation": 1543,
    "car_id": 237
  },
  {
    "serial_number": "B1234786",
    "brand": "Bridgestone",
    "model": "Dueler A/T Revo 3",
    "size": "P225/75/16",
    "position": "FR",
    "mileage_installation": 1543,
    "car_id": 237
  },
  {
    "serial_number": "B1234787",
    "brand": "Bridgestone",
    "model": "Dueler A/T Revo 3",
    "size": "P225/75/16",
    "position": "RL",
    "mileage_installation": 1543,
    "car_id": 237
  },
  {
    "serial_number": "B1234788",
    "brand": "Bridgestone",
    "model": "Dueler A/T Revo 3",
    "size": "P225/75/16",
    "position": "RR",
    "mileage_installation": 1543,
    "car_id": 237
  }
]
[
  {
    "car_id": 237,
    "changed_at_date": "2019-04-21",
    "changed_at_mileage": 11235
  },
  {
    "car_id": 237,
    "changed_at_date": "2019-12-16",
    "changed_at_mileage": 15280
  },
  {
    "car_id": 237,
    "changed_at_date": "2020-02-06",
    "changed_at_mileage": 18199
  },
  {
    "car_id": 430,
    "changed_at_date": "2020-01-01",
    "changed_at_mileage": 9491
  }
]

Vérifiez votre solution avec un ou une assistant(e) lors du prochain TD 😉

Chargement...

Chargement...