Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Game Design suggestions: Create a Battlefield Grid Class and instantiate two objects from it. One for the Computer Player and one for the Human Player.

image text in transcribed

image text in transcribed

image text in transcribed

Game Design suggestions:

Create a Battlefield Grid Class and instantiate two objects from it. One for the Computer Player and one for the Human Player.

Create a Firing Grid Class and instantiate two objects from it. One for the Computer Player and one for the Human Player

Create a Ship Class and instantiate a ship object for each ship type for both the HP and CP

.Use a two-dimensional vector of char type to represent the grids.Make the game as fault-tolerant as possible. You never know what I will enter.

After each round, display a summary showing the CP and HP status. Also, display the HP's Battlefield and Firing grids.

Summary For your Project, you will develop a simple battleship game. Battleship is a guessing game for two players. It is played on four grids. Two grids (one for each player) are used to mark each players' fleets of ships. The locations of the fleet (these first two grids) are concealed from the other player so that they do not know the positions of the opponent's ships. Players alternate turns by "firing" at the other player's ships. The objective of the game is to destroy the opposing player's entire fleet. In your game, "firing" will be allowing the player to take a guess at where on the grid their opponent may have placed a ship. Requirements You are to design the classes and implement the game. You are in full control of the choice of classes (please use classes appropriately or points will be deducted), data structures, algorithms, internal file format, detailed user interface scheme, or any other pertinent design decisions you need to make. The Battleship game you are implementing is a simplified version of the electronic Battleship game played in one player mode. The game is played on four grids, two for each player. Each player has a Battlefield Grid and a Firing Grid. The grids are a 10 by 10 square. The individual squares in the grid are identified by the x coordinate (indicated by a letter) followed by the y coordinate indicated by a number). For example: A B C D E F G H I J 1 2 3 4 5 6 7 00 9 10 The Battlefield Grid holds the position of each player's fleet and the status of the fleet. The Firing Grid hold the coordinates of each "Firing" during the game and whether the shot was a hit or miss. Each player will have five ships to place on their Battlefield Grid. Each player will vary in size (the number of squares they take up) based on Ship Type. The ships cannot overlap, so only one Ship can occupy any given square in the grid. The types and numbers of ships allowed are the same for each player. Table 1 - Ship types and sizes Size 4 Type Carrier Battleship Cruiser Submarine Destroyer in mm N The game is played in rounds. In each round, each player takes a turn to fire at a target square in the opponent's Battlefield Grid. The opponent then indicates whether the shot was a hit (a ship occupied the square) or a miss (there was no ship in the square). If the shot is a "miss", the attacked player marks their Battlefield Grid with a white peg (Xin our game); if a "hit" they mark their Battlefield Grid with a red peg (O in our game). The attacking player then indicates the hit or miss on their Tracking Grid with the appropriate color peg (red (0) for "hit", white (X) for "miss") so that they can understand where the opponent's Ship might be In the board game, once all the coordinates of a ship have been hit the ship is sunk, and the ship's owner announces, "You sunk my battleship! (Or whatever the particular Ship is that was destroyed). For our purposes, we will consider a battleship sunk if the opponent has a single hit, When all of one player's ships are sunk, the other player wins the game. For your game, you will create a one-person version of the game where the computer' will play for the second player Part 1 - Design the program. (30% of Total) - Build a UML Class Diagram for any classes you create. Describe the principle functions you will be using their purpose, parameters, and return type. Create a Process Flow Diagram that describes how control flows through your program. Part 2 - Develop and test the code. (70% of Total) This seems self explanatory, Game Setup At the beginning of the game, you will read a file that will be used to set up your Battlefield Grid. The file should be named "ship_placement.csv". This will be a comma-delimited file containing a line for each Ship in your fleet. Each line will be in the format: ShipType, StartPas, Direction StartType is a string identifying the type of Ship from Table 1. StartPos is the coordinates of the starting position of the Ship. For example, A5 or 09. Direction is a two position indicator describing how the ship should be positioned. The first position indicates whether the ship should be positioned horizontally or vertically (H or V). The second position indicates whether the ship should be laid out from left to right or right to left (L or R) in the case of a Horizontal positioning, or Down to Up or Up to Down (D or U) in the case of vertical positioning. For example, a line with the values "Battleship, D4, HR" would position a Battleship on the Battlefield Grid at squares D4, E4, F4, and G4. A line with the values "Cruiser, E9, VU" would position a Cruiser on the Battlefield Grid at squares E9, E8, and E7. De appropriate error checking on both the file input and the content. I will use various correct and incorrect files to test your code. Please keep in mind that ships can not overlap on the grid. After your Battlefield Grid is setup, randomly place the computer's ships on its Battlefield Grid. Again be careful not to overlap ships Game Play Randomly select who will start the game, the Computer Player (CP), or the Human Player (HP). Proceed in rounds with both the CP and the HP getting a turn to "fire" into the other player's Battle Grid in turns. Firing is done by selecting a square on the opposing player's Battlefield Grid. The HP will choose the square by entering the grid coordinates. The CP will randomly choose a square that has not yet been selected If the selected square is occupied by a ship, that Ship is considered sunk. It's position should be notated on the Firing Grid and it should be identified as "sunk". If the selected square is not occupied, that square should be marked as "missed" on the Firing Grid so it will not be chosen again. When prompling the HP for firing coordinates, also give them the option to quit the game if desired. Winning the Game. When a player has sunk all of the opposing plays ships, the game ends. Identify the winner and display the Battlefield and Firing grids of each player

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions