中易网

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

答案:2  悬赏:0  
解决时间 2021-04-28 13:49
  • 提问者网友:说不出醉人情话
  • 2021-04-27 20:34
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 ); } }
最佳答案
  • 二级知识专家网友:强势废物
  • 2021-04-27 20:39
没人会跟你加注释的。 你代码自己都不带理一下的
全部回答
  • 1楼网友:承载所有颓废
  • 2021-04-27 22:13
让我来告诉你答案!没人会跟你加注释的。你代码自己都不带理一下的
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息