计算机类:DELPHI    Android    PB    c#    VF    VC    .NET    PHP    ASP    JSP    VB
  机械类: 工艺夹具    机电一体    电子通信    模具设计    数控编程    机械制造
  土木建筑类: 路桥工程    园林工程    给水排水    水利工程    结构设计    建筑设计
管理学 文学 教育学 经济学 医学其它
返回首页
当前位置: 主页 > 文科论文 > 其它 >

CP1300 Assignment 2 – Pong!

时间:2013-08-14 08:46来源:毕业设计论文网 作者:坤哥毕业设计 点击: 购买指南 在线支付
CP1300 Assignment 2 Pong! Pong is one of the first computer games ever created back in 1972. We are making a customized version of Pong not exactly the same as the original game-play. You are expected to make your implementation of Pong lo

CP1300 Assignment 2 – Pong!

Pong is one of the first computer games ever created back in 1972. We are making a customized version of Pong – not exactly the same as the original game-play. You are expected to make your implementation of Pong look and behave almost exactly like what is described here. You are free to define your own parameters for things like colours, fonts, the size and shape of the paddles, and the size of the ball. Note that the window should not be resizable!

Below is the initial state of our version of Pong. We see how our high scores are incorporated into the overall program. When the program is first executed, any previously saved high scores are loaded from a data file. When the program window is closed, the current list of high scores overwrites the high scores in the data file.

 

Next, if the “start match” button is pressed and the player names are not entered, then we should see a modal popup that indicates user error, something like:


 

But your version is expected to make this popup indicate which player name(s) need to be entered. The player names are non-empty strings of letters only. Putting a single space between letters is acceptable. The maximum length of a player name is 20 characters.

Once the player names are entered and the “start match” button is pressed, then the player names cannot be changed again until the “end match” button is pressed (i.e. the name fields are disabled). Notice also that the “start match” button becomes disabled until the “end match” button is pressed:

 

The game-play continues as follows:
• Pressing the space-bar starts the ball moving, it is placed in the centre of the window with a randomly chosen speed and direction
• The ball speed is independent in both directions!
• The left-side paddle can be controlled by pressing ‘q’ for moving up and ‘a’ for moving down
• The right-side paddle can be controlled by pressing ‘p’ for moving up and ‘l’ for moving down
• The paddles can be moved regardless if the ball is moving or not (while a match is active)
• When the ball hits the top or bottom edge of the window the ball’s direction is adjusted appropriately so that the ball remains completely within the bounds of the window and appears to “bounce” off the edge of the window
• If the ball reaches the left edge or right edge then it stops and the appropriate player’s score is incremented by one
• If the ball hits a paddle, then the ball “bounces” off that paddle such that the horizontal direction reverses and the ball’s speed has randomly changed

 

 

 

 

 

 

When the “end match” button is pressed, the player with the higher score has their score updated in the high scores table – as defined by the behaviour coded in Assignment 1. Notice that the high scores are now sorted into descending order of value. Also notice that the “start match” button and the player name fields become enabled, and the “end match” button becomes disabled, and that the Scores are reset to zero, but the player names are not cleared:
 

There are a number of other characteristics that you must incorporate into your program:
• Create a “test” package and a “software” package and use them appropriately
• Incorporate the source code for the Score class and HighScore class into your Netbeans project
• Adjust the Score class and HighScore class so that the methods don’t return true/false values, but rather they generate ScoreException objects and HighScoreException objects
• The Visual Shapes (Ball, Paddle, ScoreDisplay, …) should be derived types of Shape
o The Shape class
 Must be an abstract class
 It records speed, width, height, 2D position, and direction information
 It defines an abstract method called draw(Graphics)
o You should adapt the code for Ball code from Assignment 1 for this purpose!
• The game-play must be controlled by a Field object (a modified version of Assignment 1 code)
o The field has a fixed size of width = 600 and height = 400
o The Field implements a frame-by-frame animation for game-play and display updates
o The Field reacts to user input from the keyboard
• Adjust the Score class so that it uses the Comparable interface – this will allow you to easily sort the scores in the high score table!
• The Shape class can throw ShapeException objects:
o The speed value can only be in the range 0 – 10
o The range of widths of shapes can only be 3 – 200
o The range of heights of shapes can only be 3 – 200
• Note: Your exception classes should be derived from RuntimeException only!
• Add appropriate tests for classes (e.g. Shape, Ball, etc.) if you think its necessary
• The Pong class is the main class for the program – use it to setup the JFrame and the Field
o Pong’s main() method must contain local variables for the JFrame and the Field objects!

Planning:
Write up the algorithms in pseudocode for methods like moveBall(), loadHighScores() and saveHighScores(). For each non-trivial method, you need separate pseudocode. You will find the “Guide to Good Pseudocode” on LearnJCU helpful. Please write your method pseudocode above the code for the non-trivial methods.

You may show this part of the assignment to your tutor during practical time (after finishing your prac work) to get comments or suggestions. You can only get help from your tutors in practical time after your prac work is finished, and only if you show your planning.
No help will be given on code without seeing your planning first.

Program Code:
You need to hand in a complete Netbeans Java Project containing eleven (11) files – Shape.java, Ball.java, Paddle.java, ScoreDisplay.java, Field.java, Pong.java (the main class), Score.java, HighScores.java, and TestHighScores.java. Please name the Project based on your first and last name. For example: JackBlack_Assig2Solution
Submission:
Submit a zipped copy of the Netbeans project by uploading it in LearnJCU.
Due:
The assignment is to be submitted before 9am Monday of Week 16. Submissions received after this date will incur late penalties as described in the subject guide.
Coding:
Part of the challenge (and assessment) for this assignment is for you to decide what programming constructs to use to solve the problem. Here are some guidelines:
• Use methods appropriately. Its useful to add a comment above each method that indicates what it does (e.g. “accessor method – gets the value for the score object”). Carefully think about the inputs and outputs for methods and ensure that they are useful and reusable, as discussed in class. There are accessor methods (get the value of member fields), mutator methods (set the value of member fields), helper methods (provide support to other methods or are otherwise not classified as an accessor or mutator)
• Anonymous inner classes are useful for handling button events
o To access a local variable inside an anonymous inner class, use final
• JFrame has a WindowListener interface for handling the window closing event
• The StringBuilder class is useful for creating a string from many smaller strings.
• The String class has many useful methods such as split(), format(), and so on

Marking Scheme
Take note of the following marking criteria so that you know what needs to be done for marks.
Don't just try and get your program to work, but instead do proper planning followed by careful coding. Make sure you give attention to what is rewarded here. You may notice that you don’t get a whole lot of marks for just getting it to work.
Requirement Marks Out Of
Algorithm – Pseudocode – for non-trivial methods
 (clear, complete, well-formatted, consistent, accurate)  4
Program Execution
 Tests verify the stability of Score class and HighScore class  1
 Tests verify the stability of the Shape class  1
 Tests verify the stability of the Field class  1
 Additional tests provide more useful verification of the classes  2
 Displaying a popup message box when player names are invalid  2
 Creating an interesting “look-and-feel” for the paddles, ball, etc.  1
 Similarity of tests to sample output (as per Assignment 1 style)  1
Quality of Code
 Meaningful variable names  1
 Appropriate use of methods (e.g. helper methods)  1
 Code readability: formatting, indentation, line spacing, etc.  1
 Useful, descriptive comments (good amount and quality)  2
Code Constructs
 Using KeyEvents to achieve smooth paddle motion  2
 The Pong class main() method has JFrame and Field local vars  2
 Appropriate uses of anonymous inner class(es)  2
 Appropriate background threading and synchronisation  2
 Appropriate throwing of exceptions  2
Class Design
 Appropriate UML class diagrams for all classes in the program  2
Deduction 
 Shape class is not abstract, Project submission was invalid, etc.  -1
Total  30

 

以上是部分资料介绍, 需要完整的请联系客服购买. QQ咨询 购买指南 在线支付
毕业设计论文购买流程:
1.在坤哥毕业设计找到您想要的毕业设计论文,记住毕业设计的名称。
2.联系在线客服,将您的毕业设计论文名称发送给客服,客服如果不在线给客服留言或者留下您的联系电话。
3.与客服确认您所要的毕业设计。为了保证毕业设计的可用性,我们承诺每个地区只出售一次,购买前请主动告知您的地区位置。
4.付款,可通过本站商家验证的支付宝,也可通过银行转账等方式。
5.付款之后通知客服,客服核实后将您所要的设计按照您的要求发送于您。
6.毕业设计或论文使用过程遇到任何问题请联系客人服,我们会在第一时间帮您解决。
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
推荐内容