中易网

求帮忙 帮我把下面的100+行的贪食蛇Java代码注释一下 尽量详细 谢 今晚之前最好

答案:2  悬赏:0  
解决时间 2021-04-28 13:49
class Snake extends LinkedList
{ public int snakeDirection = 2; public int snakeReDirection = 4; public Snake() { this.add( new Point( 3, 3 ) ); this.add( new Point( 4, 3 ) ); this.add( new Point( 5, 3 ) ); this.add( new Point( 6, 3 ) ); this.add( new Point( 7, 3 ) ); this.add( new Point( 8, 3 ) ); this.add( new Point( 9, 3 ) ); this.add( new Point( 10, 3 ) ); } public void changeDirection( Point temp, int direction ) { this.snakeDirection = direction; switch( direction ) { case 1://up this.snakeReDirection = 3; this.add( new Point( temp.x, temp.y - 1 ) ); break; case 2://right this.snakeReDirection = 4; this.add( new Point( temp.x + 1, temp.y ) ); break; case 3://down this.snakeReDirection = 1; this.add( new Point( temp.x, temp.y + 1 ) ); break; case 4://left this.snakeReDirection = 2; this.add( new Point( temp.x - 1, temp.y ) ); break; } } public boolean checkBeanIn( Point bean ) { Point temp = (Point) this.getLast(); if( temp.equals( bean ) ) { return true; } return false; } public void removeTail() { this.remove( 0 ); } public void drawSnake( Graphics g, int singleWidthX, int singleHeightY, int cooPos ) { g.setColor( ColorGroup.COLOR_SNAKE ); Iterator snakeSq = this.iterator(); while ( snakeSq.hasNext() ) { Point tempPoint = (Point)snakeSq.next(); this.drawSnakePiece( g, tempPoint.x, tempPoint.y, singleWidthX, singleHeightY, cooPos ); } } public void drawSnakePiece( Graphics g, int temp1, int temp2, int singleWidthX, int singleHeightY, int cooPos ) { g.fillRoundRect( singleWidthX * temp1 + 1, singleHeightY * temp2 + 1, singleWidthX - 2, singleHeightY - 2, cooPos, cooPos ); } public void clearEndSnakePiece( Graphics g, int temp1, int temp2, int singleWidthX, int singleHeightY, int cooPos ) { g.setColor( ColorGroup.COLOR_BACK ); g.fillRoundRect( singleWidthX * temp1 + 1, singleHeightY * temp2 + 1, singleWidthX - 2, singleHeightY - 2, cooPos, cooPos ); } }
最佳答案
没人会跟你加注释的。 你代码自己都不带理一下的
全部回答
让我来告诉你答案!没人会跟你加注释的。你代码自己都不带理一下的
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
韩运箱包店我想知道这个在什么地方
恨一个人要如何消除?
大众1.4t发动机egr阀在哪里?
巫妖王惩戒圣骑我还玩吗?
中国著名的白化病专家
什么网络电视可以看到 游戏风云与GTV频道?
从贵港寄信到钦州要多久?
昆山哪里有培训国家采购员的培训班?
农塘地址在哪,我要去那里办事
电子表格的问题
手机绑定网银每次收入和支出需要短信费?
张柏芝的几分之几网络歌曲可以放空间的
QQ号被盗,而且防盗问题又忘了,这样还可以找
born alone什么意思
山东协和职业技术学院(东校区)傍边那家网吧
推荐资讯
龙之谷魔导时间加速
带有彤字的诗句
我制造了两张藏宝图.一张挖宝时遇到危险后就
谁给我个QQ游戏人生的开通资格!
一包糖果,不论是分给8个人,还是分给10个人
人为什么会做梦呢..很神奇哦!!
创道地产府前花园分行这个地址在什么地方,我
怎么才能不忘记一个人!! 我想你一定知道!
特短的头发能接全头吗
QQ炫舞用什么下载器下得快
excel去掉页面底部的字
分开了.是否有机会一起
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?