没有合适的资源?快使用搜索试试~ 我知道了~
Part 2:Bug Variations - 2015年软件工程实训 - SoYa Wiki1
需积分: 0 0 下载量 83 浏览量
2022-08-03
11:14:07
上传
评论
收藏 468KB PDF 举报
温馨提示
试读
5页
1. What is the role of the instance variable sideLength 2. What is the role of t
资源详情
资源评论
资源推荐
15/8/26 下午5:06Part 2:Bug Variations - 2015年软件程实训 - SoYa Wiki
第 1 (共 5 )http://my.ss.sysu.edu.cn/wiki/pages/viewpage.action?pageId=443613207
Aug 15, 2015
Part 2Bug Variations
Part 2: Bug Variations
Methods of the Bug Class
The Bug class provides three methods that specify how bugs move and turn.
public boolean canMove()
tests whether the bug can move forward into a location that is empty or contains aflower
public void move()
moves the bug forward, putting a flower into the location it previously occupied
public void turn()
turns the bug 45 degrees to the right without changing its location
These methods are used in the bug's act method.
Extending the Bug Class
public void act()
{
if (canMove())
move();
else
turn();
}
战神哥
- 粉丝: 42
- 资源: 325
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0