Changing the Gridpanel class in Gridworld

元气小坏坏 提交于 2019-12-13 06:41:16

问题


I am trying to follow the steps to change the Gridworld appearance according to this. I've already imported source code for my gridworld jar file; ie. I can go and look at Bug.class or Gridpanel.class if I wanted to. However, I can't edit these files to produce the results that that pdf suggests. How do I do this? Did I import the source code incorrectly?


回答1:


I don't think you can edit an external resource like gridworld.jar. You are going to need to create 4 new packages:

  • actor
  • grid
  • gui
  • world

Then copy the class files from gridworld.jar packages into your corresponding ones. Now you can edit the files. Make sure you include any miscellaneous files that might also be in the gridworld.jar packages, their important.

With your own packages you no longer need the gridworld.jar external resource, and there is a difference in your import statements. Instead of

import gridworld.actor.Actor;

Do this:

import actor.Actor;

Note: You will need to change all of the import statements in the new package classes to reference the other new packages. I believe that there were also some errors, not project breaking, but I just added suppressors.



来源:https://stackoverflow.com/questions/23481990/changing-the-gridpanel-class-in-gridworld

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!