XX 学院毕业设计(论文)
I
摘 要
近年来,Java 作为一种新的编程语言,以其简单性、可移植性和平台无关性等优点,
得到了广泛地应用,特别是 Java 与万维网的完美结合,使其成为网络编程和嵌入式编程
领域的首选编程语言。eclipse 是 IBM 公司用于快速开发 Java 应用的一款优秀的集成开
发环境,它以其友好的开发界面、强大的组件支持以及开源等优点,得到广大程序员的
接受和认可。
“贪吃蛇”游戏是一个经典的游戏,它因操作简单、娱乐性强而广受欢迎。本文基
于 Java 技术和 eclipse 开发环境,开发了一个操作简单、界面美观、功能较齐全的“贪
吃蛇”游戏。整个游戏程序分为二个功能模块,八个类模块,实现了游戏的开始、暂停、
结束。通过本游戏的开发,达到学习 Java 技术和熟悉软件开发流程的目的。
本文在介绍 Java 相关技术和国内外发展现状的基础上,对“贪吃蛇”游戏的整个生命周
期的各个开发阶段进行了详细地介绍。首先,分析了开发本游戏软件的可行性,重点分
析本设计所采用的技术的可行性。其次,从游戏主界面等几方面,分析了本游戏的功能
需求;从可使用性和安全性方面分析了属性需求。然后,进行了游戏的概要设计和详细
设计,这也是本文的重点。概要设计给出二个功能模块的主框架以及八个类模块的函数
调用关系;详细设计介绍了 Java2 标准运行环境的配置,重点给出各个类模块的程序列
表,介绍了各个类包含的变量、使用的方法,展示了游戏的界面。为了保证程序代码的
正确性和功能实现的可靠性,本文还介绍了游戏软件的程序调试过程和功能测试结果。
关键词:Java;eclipse;贪吃蛇;开发流程
XX 学院毕业设计(论文)
II
Snake game design and development
Abstract
In recent years , Java , as a new programming language , with its simplicity ,
portability and platform independence and other advantages , had been used widely ,
especially Java and the perfect combination of the world wide web, to make it a network
programming and embedded programming field preferred programming language. Eclipse is
IBM used for fast development Java application of a good integrated development
environment, with its friendly development interface, powerful components support and
open source etc, and receive the accepted and approved by the programmer.
"Snake" game is a classic game , it was simple operation , strong and popular
entertainment. This paper , based on the Java technology and eclipse development
environment, develop a simple operation , interface aesthetics , the function is more
complete "snake" game. The whole game program is divided into two function module ,
eight class module, realize the games to begin, pause, over. Through the development of
the game , to learn Java technology and familiar with the purpose of the software
development process.
Based on the introduction of Java related technology and the domestic and foreign
development present situation, on the basis of "snake" game of the whole life cycle of each
development phases are introduced in detail. First of all , analyzes the feasibility of this
game software development , this paper analyzes the design of the feasibility of the
technology. Second , from the game in such aspects as the interface , and analyzes the
function requirements of this game; Can use sex and safety from analyzes the attribute
demand. Then, the summary of game design and detailed design, this also is the focus of
this paper. General design gives two function module's main frame and eight class module
function call relationship; The detailed design Java2 standard operation environment is
introduced the configuration, each module of the key given a list of programs, in each
kind of variable contains, and use of the method, show the game interface. In order to
guarantee the correctness of the program code and function of the realization of the reliability,
this paper also introduces the game software program debugging process and function test
results.
Key Words:Java;Eclipse;Snake;Development process
XX 学院毕业设计(论文)
III
目 录
摘要....................................................................I
Abstract...............................................................II
引 言................................................................1
第一章 系统开发环境.....................................................2
1.1 开发工具......................................................................................................................2
1.2 应用环境......................................................................................................................2
第二章 系统需求分析.....................................................2
2.1 需求分析......................................................................................................................2
2.2 可行性分析..................................................................................................................3
第三章 系统概要设计.....................................................3
3.1 设计目标......................................................................................................................3
3.2 系统功能模块..............................................................................................................3
3.3 系统数据结构设计......................................................................................................4
3.3.1 蛇、石头、食物的表示.................................................................................4
3.3.2 蛇的移动...........................................................................................................5
3.3.3 存储蛇身的数据结构.......................................................................................5
3.3.4 蛇的移动方向...................................................................................................5
3.3.5 如何显示蛇身...................................................................................................6
3.3.6 蛇身的移动方向...............................................................................................6
3.3.7 吃到食物判定...................................................................................................6
第四章 系统详细设计.....................................................6
4.1 程序设计......................................................................................................................6
4.1.1 主类 MainFrame...............................................................................................6
4.1.2 类 MainFrame...................................................................................................7
4.1.3 类 Snake............................................................................................................7
4.1.4 类 Food .............................................................................................................8
4.1.5 类 Controller .....................................................................................................8
4.1.6 类 Ground .........................................................................................................9
4.1.7 类 GameListener...............................................................................................9
4.1.8 类 SnakeListener...............................................................................................9
XX 学院毕业设计(论文)
IV
4.1.9 类 Globel...........................................................................................................9
4.1.10 类 GameOptionPanel.....................................................................................9
4.2 各功能界面截图..........................................................................................................9
4.2.1 贪吃蛇游戏的基本运行界面...........................................................................9
4.2.2 程序开始运行界面.........................................................................................11
第五章 系统测试........................................................15
5.1 测试的意义................................................................................................................15
5.2 测试过程....................................................................................................................16
5.3 测试结果....................................................................................................................16
参考文献...............................................................16
结 论...............................................................17
致 谢...............................................................17
仰恩大学毕业设计(论文)
1
引 言
本文档为“编程实习——贪吃蛇游戏”的全程设计说明书。包括需求分析、概要设
计、详细设计等方面。
本文档的预期读者为:
(1)评审小组老师
(2)项目开发小组人员
(3)与本项目相关的其他人员等
贪吃蛇是世界知名的益智类小游戏,选择这个题目一方面的原因是为了将我们自己
的所学知识加以运用;另一方面,虽然很小就接触这个游戏,但是它的制作方法对我们
而言还是很神秘的。我们希望通过自己的所学知识把它剖析开来,通过自己的动手实践,
真正的了解它的本质和精髓。 希望通过这次实践,我们能从中提高自己的编程能力。
并从中学会从零开始分析设计程序。
本游戏的开发语言为 Java。开发工具选用 Eclipse。 Java 是一种简单的,面向对象
的,分布式的,解释型的,健壮安全的,结构中立的,可移植的,性能优异、多线程的
动态语言。这里采用 Java 作为开发语言主要是基于 Java 的面向对象和可移植性。 Eclipse
是一个开放源代码的、基于 Java 的可扩展开发平台。就其本身而言,它只是一个框架
和一组服务,用于通过插件组件构建开发环境。
数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或多种
特定关系的数据元素的集合。通常情况下,精心选择的数据结构可以带来更高的运行或
者存储效率。数据结构往往同高效的检索算法和索引技术有关。
类是 面向对象程序设计语言中的一个概念。
类(Class)实际上是对某种类型的对象定义变量和方法的原型。它表示对现实生活
中一类具有共同特征的事物的抽象,是面向对象编程的基础。
类是对某个对象的定义。它包含有关对象动作方式的信息,包括它的名称、方法、
属性和事件。实际上它本身并不是对象,因为它不存在于内存中。当引用类的代码运行
时,类的一个新的实例,即对象,就在内存中创建了。虽然只有一个类,但能从这个类
在内存中创建多个相同类型的对象。