吃豆豆
一、 背景描述
在完成面向对象、Swing、线程的课程后,可以开始练习本项目的部署安排。安排本
练习的主要目的理解面向对象、能够用面向对象的思路去思考问题,结合 Swing 和现成的
知识完成本项目。
二、 实现要求
使用面向对象的方式,完成本项目。
三、 实现技术
a) 熟练使用 if、for 等语句进行逻辑操作。
b) 分析数据的属性和方法,能够熟练地写出该数据表示的类。
c) 使用 JFrame 创建一个窗体。
d) 掌握 ActionListener 等事件的注册、添加、操作等。
e) 使用 Grahpics 能够绘制一般的图形、根据需要定制自己需要的复杂图形。
四、 类图
a) 类图
Bi gMout hFi shFrame
pool : Fi shPool
mai n( args : St ri ng[ ] ) : stati c voi d
Bi gMout hFi sh
si ze : i nt
di rect i on : i nt
col or : Col or
speed : i nt
eyesi ze : i nt
eyeposx : i nt
eyeposy : i nt
eyecol or : Col or
posx : i nt
posy : i nt
maxmout h : i nt
mout hsi ze : i nt
UP : stati c i nt = 0
RI GHT : stati c i nt = 1
DOWN : stat i c i nt = 2
LEFT : stati c i nt = 3
move( ) : voi d
changeDi r(di r : i nt) : voi d
pai nt (g : Graphi cs2D) : voi d
changeCol or(col or : Col or) : voi d
UpLi stenerI mpl
acti onPerf ormed( e : Acti onEvent ) : voi d
Ri ght Li stenerI mpl
acti onPerf ormed( e : Acti onEvent ) : voi d
DownLi stenerI mpl
acti onPerf ormed( e : Acti onEvent ) : voi d
Lef tLi stenerI mpl
acti onPerf ormed( e : Acti onEvent ) : voi d
Fi shPool
5 sh : Bi gMout hFi sh
bean : Fi shBean
pai nt (g : Graphi cs) : voi d
Ti merLi stenerI mpl
acti onPerf ormed( e : Acti onEvent ) : voi d
内部类
内部类
内部类
内部类
内部类
Fi shBean
posx : i nt
posy : i nt
si ze : i nt
col or : Col or
newPos(w : i nt, h : i nt ) : voi d
pai nt (g : Graphi cs) : voi d
Fi shUt i l i ti es
i sI nteracti on( 5 sh : Bi gMouthFi sh, bean : Fi shBean) : stati c bool ean
b) 类图说明
类名称
BigMouthFishFrame
类描述 大嘴鱼界面类。完成大嘴鱼的界面的绘制。该类继承 JFrame。
包描述
main
函数描述
public static void main(String[] args)
程序的主函数。
BigMouthFishFrame()
构造函数。构造大嘴鱼界面。
类名称
BigMouthFish