Em Andamento

Battleship using Arrays in C++ program


Ye’ve been sailing the high seas for some time now. After a treacherous voyage through a raging storm, yer ship is off course afloat through unchartered waters. The morn’ after, the crew wakes up to find themselves amongst ravenous great white sharks1, Titanic-sinking icebergs, and an enormous British battleship loaded to the hilt with soldiers and artillery. Ironically, they’re on patrol looking for plunderin’, pillaging pirate ships. Not that your crew ever plunders or pillages, but these activities will definitely have to be put on hold until ye’ve navigated yer way out of these hostile waters!

1 Think “Jaws”.

2 Pirates certainly have enough gold and jewels to buy high powered canons and return enemy fire if they so desired but they typically spend it on ale and potato chips.

Here is a rundown of your current situation.

• One British battleship.

• Very hungry great white sharks that fancy pirates because they tend to taste like ale.

• Random icebergs. In addition, the entire perimeter of the oceanic area described is made up of icebergs that formed in the night.

• A single exit point from the wall of surrounding icebergs that will release your ship into the open sea for escape.

In planning, you pull out some clean scroll paper and plot out the immediately surrounding ocean. It’s represented by a grid that is 30 spaces wide and 15 lines long, each point representing a square nautical mile. You will be repeatedly asked what direction you want to move. Each time you move, you must try to avoid hitting, or being hit/eaten by an iceberg or a shark (remember, they’re very big and like to eat pirates), or being blasted by the Brits. You are within range of the Brits if you are in an adjacent square to their war vessel, including diagonal squares. It’s almost certain that your ship will be obliterated by cannon fire2.


• Ask the pirate for the name of the map file. This may not be hardcoded.

• Open the file and read in exactly 15 lines with exactly 30 integers per line.

• The map file is coded as follows:

o 0 = open sea

o 1 = iceberg

o 2 = shark

o 3 = British battleship

o 4 = the escape position

o 5 = your pirate ship

• Keyboard commands will move your ship as follows (lowercase):

o ‘n’ means north, or one row above your current position.

o ‘e’ means east, or one column to the right of your current position.

o ‘s’ means south, or one row below your current position.

o ‘w’ means west, or one column to the left of your current position.

o Any other keyboard entry means your ship stays in the same position as a penalty3.

• Each time you move, the battleship and all the sharks move one space toward you.

o Warning, they can also navigate diagonally, i.e., northeast, northwest, southeast and southwest. Your ship cannot do this with its outdated technology.

o The battleship destroys anything in its path – icebergs4, sharks, and, unfortunately, you. That means if a battleship moves to a position where an iceberg was, when it moves away, that map position becomes open sea. The same goes for sharks.

o If two sharks collide, only one is left.

• The ocean map should be displayed on the screen after each time you move and after the battleship and all of the sharks have moved.

• The scenario continues until you reach the exit point or until the sharks or the Brits have eliminated you5 or you carelessly navigate into an iceberg.

• Once the scenario has reached a conclusion, print out what happened. (Did the pirate ship escape? Get blown to bits? Become human sushi?)

Please Check the uploaded files.

Habilidades: Programação C++

Ver mais: battleship arrays, yer, using re, map cplusplus, human programming, find chips, escape southeast, programming arrays, cplusplus map, big w, big time, ye, voyage, vessel, two sea, sushi, space ships, sailing, print hold, potato, patrol, oceanic, nautical, jewels, great north

Acerca do Empregador:
( 2 comentários ) Stow, United States

ID do Projeto: #5129900

Premiar a:


Hi, I am placing my bid on your project because I have read the requirements and I am confident enough with my C++ skills. I am focused mostly on doing computer science homework here in freelancer.com and I would like Mais

$60 USD em 0 dias
(80 Avaliações)