• 20 heures
  • Moyenne

Ce cours est visible gratuitement en ligne.

course.header.alt.is_video

course.header.alt.is_certifying

J'ai tout compris !

Mis à jour le 04/07/2019

Start designing your objects

Connectez-vous ou inscrivez-vous gratuitement pour bénéficier de toutes les fonctionnalités de ce cours !

Now we are comfortable with the concept of objects, it’s time start designing them!

Remember the context of our course?

Defining the journey - NeXTDestination

Our subject is planning for travel! Let's call our project NeXTDestination.

On our adventure, we are going to visit up to 5 destinations.

We must stay on a budget, as we make decisions what to visit and what to do we must account for the return cost. Once our spending gets close to our budget minus the return cost, we must interrupt the trip and return home.

This gives us an idea of what classes we need to design:

  • Adventure - to capture our whole experience.

  • Destination - to describe the places we’ll visit.

  • and Entertainment - to describe what we are going to do at each of the chosen destinations. 

View from a top!
View from the top!

Now let’s look at the essential characteristics each of our objects may need to have:

Let's start with the Entertainment object. It needs some properties:

  • Name

  • Cost 

Then comes Destination:

  • Name

  • Cost (transportation + accommodation)

  • Entertainment options

  • Accomplishments

Since we have multiple entertainment options, we can use a method to pick one depending on our preferences and budget:

  • Pick Entertainment

 And, finally, an Adventure object needs to include some global information:

  • Max destinations

  • Total budget

  • Return cost 

  • Destinations to choose from

Then some info specific for the traveller:

  • Amount spent

  • Amount remaining

  • Places visited

Similarly to entertainment options, we'll need to choose a destination from available options, hence we need a method for it:

  • Pick Destination

And in order to show off, we are going to tell our friends all about our trip, so we’ll have a method to so (let’s use a more humble name):

  • Pick Destination

  • Tell a story

Let's transform our last diagram and reverse the order of objects:

Objects defined.
Objects defined.

And, finally, let's demonstrate a relationship between the objects we defined. We are going to have:

  • one adventure per traveler

  • up to 5 visited destinations per adventure

  • multiple entertainment accomplishments per traveller per destination

Things to keep in mind:

  • a number of destinations will be available for all travelers to choose from

  • a number of entertainment options will be available for all travelers at each destination

Traveller's adventure.
Traveller's adventure.

Sounds interesting in theory! though we haven’t written any code :waw:. That's exactly what we are going to address in the next chapter!

Exemple de certificat de réussite
Exemple de certificat de réussite