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.
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:
Then comes Destination:
Cost (transportation + accommodation)
Since we have multiple entertainment options, we can use a method to pick one depending on our preferences and budget:
And, finally, an Adventure object needs to include some global information:
Destinations to choose from
Then some info specific for the traveller:
Similarly to entertainment options, we'll need to choose a destination from available options, hence we need a method for it:
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):
Tell a story
Let's transform our last diagram and reverse the order of objects:
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
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!