Java - Global variable or something

I'm having problem understanding an assignment in Java. Basicly we are writing an interpreter and should be simple. I have not used Java for over 2 years so nearly all my knowledge is forgotten. Basicly, the classes I need to create look like theese. public interface Handler { void interpret(); } public class Program implements Handler{ @Override public void interpret() { // write the interpret logic here } } public class Stmt implements Handler { @Override public void interpret() { // write the interpret logic here } } public class Move extends Stmt implements Handler { public void interpret() { // write the interpret logic here } } public class Right extends Move implements Handler { public Right( Exp i ) { interpret(); } public void interpret() { // write the interpret logic here } } And the test program needs to be like this: Program pro_inst = new Program(); pro_inst.addStmt(new Start(new Exp(new Numbers(23)), new Exp(new Numbers( pro_inst.addStmt(new Forward(new Exp(new Numbers(15)) ) ); ... ... pro_inst.addStmt( new Stop()); ... .. I've fooled around for some hours but I struggle hard. For example, where do I assign variables and how can i edit them using the interpreter? I see that I'm creating new Objects all the time in my test program, should I return values or what? I need to have a variable x and y somewhere and they all need to be edited by the interpreter. Thank you if you read so far!

以上就是Java - Global variable or something的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏