Sure thing. I'll get you started with the very first part, (1a) and how to get the X where you want it. Since this is your very first class, you most likely have been introduced to arrays. You want your array to be a 2D array to hold the information you want. Let's use an array of type char so we can use the "-" and "X" characters. We set an initial size to it too. Remember, an array needs a constant size. Let's try 5 by 5 for simplicity.
So, there's our treasure map array that is made up of 5 rows and 5 columns.
Let's initialize all of them to some initial value, the "-". This can be done with a nested for loop.
1 2 3 4 5 6 7 8
|
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
treasureMap[i][j] = '-'; //treasureMap[0][0] is now a "-", treasureMap[0][1], etc.
}
}
|
So, we have given each element in the array an initial value of "-".
Now, at some point we can ask the user for the row and column where they want to place the "X". Once they input that information, we can over right the spot that needs it to make it a X.
1 2
|
//Say they chose, row 1, column 2
treasureMap[1][2] = 'X';
|
If you need the row and column number displayed as you have in your question, it is probably best to make those numbers display with the printing function, which would print your map with the row and column numbers as you have displayed.