• Post Reply Bookmark Topic Watch Topic
  • New Topic

Grid, vector, magnitude app  RSS feed

 
Matthean Brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code for the GridApp main class. The issue here is trying to "get the box from the grid and push it using the vector object."



Code for the Grid class. The current error is in the constructor as I am suppose to create the grid but also set the box's instance variables as well. I have changed the code numerous times only to still get errors.



Code for the Vector class. Currently correct.



Code for the Box class. Currently correct.

 
Carey Brown
Saloon Keeper
Posts: 3323
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthean Brown wrote:Code for the Grid class. The current error is in the constructor as I am suppose to create the grid but also set the box's instance variables as well. I have changed the code numerous times only to still get errors.

It would be helpful if you posted the actual error message(s).
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Matthean Brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved the issues with the Grid class by merely trying to explain it. Maybe a weekend away helped for it to click. For the GridApp, the error is pointing to the box part of the statement as it is set to private. While I get that, I guess I don't understand the instruction to "get the box from the grid, and push it." Since the "g.getBox();" code returns the box from the grid, I wonder if I'm suppose to set it to something although I'm not sure what. I don't think I'm suppose to create a new box and I don't know how to call the push function from the grid's box's push function.

And thanks.
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a name for solving problems by explaining them: rubber duck programming.
Have you got any move methods in the Box object? Yes, you have. I can't see anything wrong with that, but you might be better using a Direction enum than Strings.
Now, I can see something possibly wrong; you are using += throughout. Shouldn't you have some -= signs there?
 
Matthean Brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since I haven't gotten a clean compile I wasn't able to pick up the logic error in needing to switch in the "-+" code. Direction is a String type as per assignment as enums haven't been taught yet. :P
 
Matthean Brown
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should be working in this version.



 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!