Now that we've gone through and sort of determine kind of what each major section has in terms of the
data and so before we midships then or adds in the players in this guess I'll say.
So let's actually start making the real types that we all need.
So first thing I'm going to start with is kind of in the ship's order.
Ships part it says five types listed above.
OK.
So we have the aircraft carrier battleship cruiser destroyer and submarine.
So we have this ship type and it can only have five values.
It has a very fixed and finite set of values.
So that to me means that I should be using an Ina.
So I'm going to make you know I'm going to call it the ship type
and I'm going to actually add one more ship type and that is the ship type none.
So it kind of has.
There is no ship sets and you'll you'll see why I want to have this probably a bit later.
But for now just know that we need none and then was going to say all the rest of ours.
Aircraft carrier in it.
And that I'm using s t i typically prefix all of my arms with the kind of first letter of each word.
So I usually use s t from the same ship type.
I'll ship this case as the cruiser
steede destroyer.
It's these submarine.
So one of my types will be the actual ship type just like we have a pier.
OK.
So the next thing is what else is a ship kind of have it's just kind of cherry pick some the orientation
OK so can either be vertical or horizontal.
So again just like with the ship type we can only have two values vertical or horizontal.
So again I say we all need enough for this.
So say ship orientation type and anime's going to say so aren't all so again for ship orientation.
It is so vertical.
And I'm not going to have a S-O none right because I can't there's no possible way that you can have
a ship that has no orientation on board.
We don't need that.
So now what we have in our ship is a position right.
So this one is a road between a NJ which is one in 10 right and columns between 1 and 10.
So how I'm going to represent this is through a struct because it has two different two different values
K row and a column.
And for mine I'm just going to we're just going to be integers.
Ok --.
Zeeshan
in a row.
In going to call.
So all the ships will have some kind of position
so the last thing we probably need is the use.
It's really and of course that will just be an integer so we don't really need to make anything magical
for that one.
So we're actually going to move on to actually creating a ship so to say ship is a struct because it
holds multiple values as a position as an orientation and has a type.
Just like I showed up here.
So I'm going to represent our ship with a struct.
And I'm going to say ship type
like that it has a size shape size
ship and teach and I say you teach an
and it has a position.
So see how we use what we kind of broke down in the understanding phase and translate it into real types
and what we'll use as real data in our game.
So doing this really well.
Like I said in the first section what your input is really will define how your algorithms will interpret
that data and can interpret that input in a specific way to the specific data.
So that's why we really do this first because this is what's really going to guide us in terms of what
the algorithms should do based on this data.
So this is why understanding and creating the input is usually first before actually doing the algorithms.
So now that we have our ship k we should move on to our board and notice that I didn't really specify
what this is yet.
With our ship and and that's because it really depends on where the ship is in on the board.
So really this damaged spot on the ship depends on the board position that it's at.
So I'm not going to have that represented here.
I'm actually going to postpone that into the board snacks.
So what do we need for the board.
OK.
So the boards there's two different kinds of boards.
One is the gas board has three states hit miss.
And you know maybe none I guess.
So one thing we need is kind of our guest type and we need them just like before.
Type
and we're going to say guess type none if we haven't guessed there right.
Zero.
And guess I missed.
Right.
And guess type hit.
So those are three different states that this guess or can be and the other part is our shipboard.
So what would define a ship or what type would we need.
So just like the guest board the guest can only be in three states and we're going to make our guest
bored out of this type and speak to the array of this type.
But what about our shipboard needs a ship and it needs I guess whether it was hit or not.
So for that I'm going to make a structure and call it a ship part type
and it's a ship part time because this is only me one kind of square on the board.
And the ship part time is going to have a ship type.
We had with the ship.
Right.
Same type and I'm going to have a boolean saying whether it's hit or not.
So is hit.
So that's all is really going to have.
Because if you played it before you know and your bottom board is that you have a ship placed at a certain
position which is going to be set in the ship itself this position in orientation and whether it's hit
or not.
So that should cover that.
Now now we have the player right where
in each case it's going to be another struct they're and that's where we'll have a name player name
and we don't know how long the names can easily see ten for now or we're going to make Hanssens for
these in a second.
It's going to have a number of ships.
Ship
and there's only five.
Again I'll make a constant for this in a second.
And we'll have a guest aboard.
So we're going to use GPS type to make or board.
And we know how big it is so we should just use a basic 2-D.
Guess board
and make constants from this second sets at 10 by 10 right.
So here 10 grid
and we have the ship or two which are going to make and ship parts part time
we could design the data in a different way for this but this is what I came up with it seems pretty
well.
So now we have a bunch of constants here.
And I kind of want to get rid of those.
So I'll show you one interesting thing you can do with them.
And then having kind of an anonymous and we're going to need a few kind of constants so you need an
aircraft
carrier size right is five spots.
So it's set up here right size there.
And I mean do you have for each ship ship size
that and notice I'm like actually setting all the values directly.
So if you if you have an anonymous you know you probably want to set them all directly.
And these really just amount to constant integers.
Really.
That's why that's why I'm using cruiser size three destroyer sizes the
green
to.
And our board size is 10 or so a 10 by 10 grids and the number of ships you have is five cents a ship's
that and we when to say the layer name size
is going to be eight characters.
Because I'm going to have is like Player 1 player 2 and she's 1 2 3 4 5 6 7 plus 1 for it all character
right C C string.
So that's why it's eight characters and I don't have one extra one called Max ships.
It's as well.
And I'm going to use the aircraft carrier size for it.
Because a ship is maximum size five very big is an aircraft carrier.
So that's actually the data that's really all the data that we have.
The and it's just I actually said all your names.
Yes that's right.
All right in ship's
size
size like this one supports It's
something kind of interesting you can do with domes just have anonymous names that just have a bunch
of values that it can be.
And really this just amounts to being constants.
So now that we've finished our data this should give us an idea of how our algorithms are going to work.
So we have to have two players.
Two variables of type player and these players have a name that ships their boards rank.
So there's you plan for boards but there's two players two boards per player right.
So each player has that.
There are two different boards.
And
that's really it.
So this is really going to determine how are our top down design and ultimately how our implementation
is going to be done.
So in the next lecture I'm going to go over some of the top down design.