Starting from:
$35

$29

Assignment 6 – Java Solution

Grading

The assignment will be marked for good programming style (indentation and appropriate comments), as well as clean compilation and correct function.

Help with Java

There is extensive documentation for Java on the web. Below link includes a list of Java tutorials.

The Java Language Tutorials (from Oracle - previously Sun)


Assignment Requirements

    1. (10%) The skeleton code creates a single basic ball only. Your game should support an arbitrary number of balls (the number of balls will be provided in the command line). Your game should maintain the instances of the ball objects in an Arraylist.

    2. (2%) The Ball class implements a basic ball that moves with random speed. You will change the BasicBall class so that every time the ball is hit, its speed (in x and y directions) should be randomized. Please note that when the speed of the ball is positive, the ball will move from left to right; and when the speed is negative it will move from right to left. The skeleton code assumes that the max absolute speed of the ball is 0.01.

    3. In the given skeleton code, the game terminates when the ball is out. You need to keep track of the number of the active balls in the game as new balls are introduced and as balls get out of the screen (in the skeleton code the variable numBallsinGame maintains the number of active balls). When all the balls are out, the game should terminate.

    4. (15%) You will define a class called Player which will store all player information and player’s game scores. These include:

        ◦ # of successful hits (in the current game)

        ◦ current player score (note that the hits to different ball types are worth different number of points: basic → 25; shrink→ 20; bounce → 15; split → 10).
        ◦ the type of ball with most hits (see below for the ball types).

The game window should display the above information and the number of balls in the game.

    5. You will introduce new ball types in your game by creating subclasses of the BasicBall class.

        ◦ (25%) ShrinkBall: This is a larger ball which gets smaller by 33% (i.e., 2/3 of the original size) each time the player hits it. Similar to BasicBall, after each hit, the ball will be moved to its initial location and it will be assigned a random speed. When the ball size is less than or equal to 25% of the initial size the ball, the ball will be reset to its original size and it will start from the middle of the screen with a random initial speed. A hit to a shrink ball will increase the player’s score by 20 points.

        ◦ (20%) BounceBall will bounce on the borders of the scene but it will be out after it bounces for a certain number of times. (The bounce count will be 3 for all bounce balls.) The ball should maintain the magnitude of its speed in each bounce. Please note that the direction (sign) of the speed will change due to the bounce. The other ball types won’t bounce on borders. After bouncing 3 times, the bounce ball will disappear out of the game window. Similar to other balls, after each hit, the ball will be moved to its initial location and it will be assigned a random speed. A hit to a bounce ball will increase the player’s score by 15 points.

        ◦ (25%) SplitBall will split into 2 unique balls every time the ball is hit. The 2 split-balls will always appear at the center of the game window and they will have the same radius as the original ball. Their initial speeds will be randomly assigned. Each ball generated in a split is itself a split- ball and can be split further when hit with a mouse click. A hit to a split ball will increase the player’s score by 10 points.

All properties and behavior common to all ball types should be defined in the BasicBall class. And the properties and behavior specific to a particular ball type should be included in the corresponding subclass. You need use Object Oriented Programming features as much as possible in your application.

    6. The following arguments will be passed to the game in the command line:
# of balls, ball type, ball radius – ball type and ball radius will be repeated

for each ball
For example:
4 basic 0.10 bounce 0.05 shrink 0.13 split 0.05

The code to retrieve these arguments is already provided in the skeleton code.

    7. (3%) Visual features and overall game design.

The following figure illustrates a snapshot of the game window while the game is active.

More products