• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Java DotCom Game has something wrong  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run The DotCom Game,This game can't judge input ,it caused every output is "miss".I didn't know the problem where is.


The First File (DotCom.java)




The Second File (DotComBust.java)




The Third File(GameHelper.java)



and  run result



Can someone help me? Thank you!
 
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't look like your locationCells field in DotCom is ever set.

Also, what is this code supposed to do in DotComBust?
 
Alex Vida
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:It doesn't look like your locationCells field in DotCom is ever set.

Also, what is this code supposed to do in DotComBust?

Sorry about too late to reply

1.I think locationCell is already set in DotCom in line7

2.the book didn't explain in detail
it says iterating DotCom in list
and is set DotCom's location.
 
Knute Snortum
Sheriff
Posts: 4289
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Vida wrote:1.I think locationCell is already set in DotCom in line7

That's where it is declared and initialized, but where do you call setLocationCells()?

2.the book didn't explain in detail
it says iterating DotCom in list
and is set DotCom's location.

It sets the variable newLocation, but it doesn't set the field locationCells in any of the DotComToSet objects.

By the way, "DotComToSet" is a bad name for an object.  Start with a lowercase letter: dotComToSet.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!