+ 1
Grid points?
https://code.sololearn.com/c4WM0RoUVVg6/?ref=app As of right now, all grids share a point. How can I make it so each grid has it's own point?
10 Respostas
+ 4
I have some suggestions:
1) Try to avoid verbs as class names. A more appriopriated name, for your class, would be Grid
2) Add an attribute data that store all cell-grid data. This make possible edits your grid
An very simple example here https://code.sololearn.com/cJbh34a9KrOl/#cpp
+ 3
Think about how work array access in c++ (and in many other languages). If you want access to first element, you have to use 0 like index, if you want access to second you have to use 1 and so on. Now, i think, that just because you are begginer you will benefits more if you dont try to confuse yourself by set another index access type (though more natural it will make you more confused if code will be more complex)... That, my thought, is the inly downside but choice is your
+ 2
It used to be a function, not a class. Was too lazy to rename. Lol
+ 2
This is actually brilliant. I was just going to give each grid it's own point, and if you didn't want a point present, just make it somewhere off the grid. But this is much better. Can you explain this code in depth?
+ 2
Daniel Cooper I updated my code with some comments.. If you dont understand something, ask đ
+ 2
Thank you. And I did notice that the points are 1 value off.
So 2,4 actually plots 3,5. How can this be fixed?
+ 2
This is because starting 0 index array offset. You can easly adjust the index inside putPoint method but i suggest to dont because actually its consistent with c++ language index accessing
+ 2
Would there be any downside to adjusting the index? Because I'm a new programmer and from my perspective, it seems like it'd make things easier to make putPoint accurately plot a point.
Also, how would I adjust the index?
Sorry if these questions are dumb. Still very new to all of this. Lol
+ 2
I see. I'll have to play around with this a bit to understand a bit better. But I think I get it. So if I want to accurately plot the points, I would just do data[x-1][y-1]= 'X'; right? Anyway, i'm gonna go play around with pointers. Thanks for the help!
+ 2
Daniel Cooper Yes đđđ