Visual illustration of the code challenge: POO #2 – Une classe à construire

POO #2 – Une classe à construire

Un schéma UML à suivre pour construire une classe.

Coding in the sandbox You must be logged in to access the sandbox.

Pour ces challenges STARTER POO, l’objectif est de résoudre le challenge en suivant le schéma UML proposé (certains éléments du schéma font référence à PHP mais cette conception vaut pour tous les langages).

Mission

Tu dois construire une classe Touriste qui représente un.e touriste visitant une ville.

Un.e touriste possède ces informations :

  • Un nom
  • Un budget (en euros)
  • Un nombre de visites effectués (initialisé à 0)

Tu as à ta disposition 3 variables :

  • name et budget sont les informations du.de la touriste
  • prices est un tableau contenant les prix (en euros) des visites à effectuer

Pour chaque visite, s’il y a assez d’argent dans le budget :

  • Tu diminues le budget du prix de la visite
  • Tu incrémentes de 1 le nombre de visites effectués

Sinon, tu passes simplement à la visite suivante.

Tu dois parcourir tout le tableau prices et retourner la description du.de la touriste sous la forme :

Nom: NbVisites visites, Budget euros restants

Par exemple : Lea: 6 visites, 5 euros restants

Schéma UML à suivre

Solve the challenge

To code this challenge, several possibilities:
- Want to start coding right away? Use the online Sandbox.
- Want to work in your favorite editor? Organize your code well, test, check out our API documentation.
- You can also copy/paste a dataset below.

challenge code for resolution via API: STARTER_POO_2

Some resources to help you:
Data and algorithmic logic Methodologies Corrections

Support for resolution

Progress through challenges using our resolution aids: tools, techniques and advice to help you overcome the most complex programming challenges with methodology, confidence and creativity.

Dataset and algorithmic logic

Based on the data and the expected response, use the process to determine the logic to implement.

Show data and progress

Methodologies

Develop a structured approach with our solving guides. Work on specific concepts such as object-oriented programming or unit testing to improve your coding style and progress.

No methodology yet for this challenge, but we are working on it! Follow us to be informed of the release!


Corrections

The corrections allow you to discover certain technical concepts but will also give you a solution to the challenge. Code the challenge yourself before consulting the corrections ;)

No answer yet for this challenge, but we&'re working on it! Follow us to be informed of the release!

Programming concept(s) that can be used to solve this challenge: Programmation Orientée Objet

Keep coding

Other challenges to complete

Intermediate
Die Hard

Die Hard

Profite d’un challenge exaltant et rejoins John McClane dans son combat pour sauver le réveillon au Nakatomi Plaza !

Behavioral
Intermediate
WALL-E #4 : un peu de rangement

WALL-E #4 : un peu de rangement

Wall-E s’ennuie un peu et décide de ranger tous les blocs de déchets qu’il a construit.

Behavioral
Beginner
Coupe du monde de rugby #2 Compter les points

Coupe du monde de rugby #2 Compter les points

Tu connais les règles du rubgy ? Tu sais compter les points ? C’est ce qu’on va voir…

Behavioral