• Post Reply Bookmark Topic Watch Topic
  • New Topic

My first simple program, really need some pointers  RSS feed

 
mitchell cooper
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is my first simple program, I know its probs a bit wrong but its working. If anyone could point out how it could be done easier feel free to comment.
The program is taking inventory numbers and changing them, then writing to a jTable..
A few questions i do have is...

How would i go about Using each players Inventory in a different class or package...

How would i got about Adding a Jframe with a button that runs the program...

If any ways to simplify my code would be great thanks

Heres my code


 
Carey Brown
Bartender
Posts: 3022
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest separating the user interface code from the game logic. You should work on the game logic first using a simple text user interface. Then after you have the game logic in place and debugged, add the GUI on top of it.

Review your requirements. Nouns will become classes (e.g. 'Player'), and verbs will become methods. Look for noun relationships, such as a Game having two (or more) Players.

Your main() method should have very few lines of code in it. It should create object instances and use those to kick off the program.
 
mitchell cooper
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, ok when it come to moving the main how would i do it? where would i put it and how would i link it ?
 
Carey Brown
Bartender
Posts: 3022
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a basic template:


For the time being put all your code in the same directory. Then you can go to that directory and do a "javac *.java". That will link everything together.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!