Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi currently in stuck to create c++ simple puzzle .
can someone give me coding sample to create game in c++?

The Puzzle:
Ships
There are 5 ships in a port:

1. The Greek ship leaves at six and carries coffee.
2. The Ship in the middle has a black exterior.
3. The English ship leaves at nine.
4. The French ship with blue exterior is to the left of a ship that carries coffee.
5. To the right of the ship carrying cocoa is a ship going to Marseille.
6. The Brazilian ship is heading for Manila.
7. Next to the ship carrying rice is a ship with a green exterior.
8. A ship going to Genoa leaves at five.
9. The Spanish ship leaves at seven and is to the right of the ship going to Marseille.
10. The ship with a red exterior goes to Hamburg.
11. Next to the ship leaving at seven is a ship with a white exterior.
12. The ship on the border carries corn.
13. The ship with a black exterior leaves at eight.
14. The ship carrying corn is anchored next to the ship carrying rice.
15. The ship to Hamburg leaves at six.

Which ship goes to Port Said? Which ship carries tea?


(Note: 'to the right' means anywhere on the right side from the given point, not only right next to. Likewise for left.)


the answer:


Our Solution:
The Spanish ship goes to Port Said and the French ship carries tea. However, tea can be carried by the Brazilian ship, too.

French	5:00	tea	blue	Genoa
Greek	6:00	coffee	red	Hamburg
Brazilian	8:00	cocoa	black	Manila
English	9:00	rice	white	Marseille
Spanish	7:00	corn	green	Port Said


What I have tried:

can someone give me coding sample to create game in c++?
Posted
Updated 17-Nov-20 9:34am

Here's a tip : define a class for a ship and define the properties of the ship - they are enumerated in the puzzle. Define the possibilities for each property which are also enumerated. Lastly, go through each step and implement it in code. What that means is each ship object starts with all of the properties disabled. Each step of the puzzle will enable various properties for each object and in the end you just have to note the properties of interest meaning find the ship with a given property enabled.

The solution notes the properties of the ship actually : origin, departure, cargo, color, and destination.
 
Share this answer
 
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900