Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Goal : This lab was designed to teach you more object oriented programming and how to write a very simple game. You will show

Lab Goal : This lab was designed to teach you more object oriented programming and how to write a very
simple game. You will show that you understand inheritance as well by creating the Ball class.
Lab Description : Complete the code for the Ball class located in Ball.java. Test the Ball class
using the BallTestone.java and BallTestTwo.java files. As you are testing Ball, you will also be
retesting Block as Ball is and extension of Block.
The Ball is going to bounce around the screen. It will bounce around the screen because of checks placed in
the BallTest. You can change the boundaries to create a larger field for the Ball. Eventually, the Ball will
bounce off of the upper and lower walls and the paddles, but stop when it contacts the left and right walls.
public class Ball extends Block
{
private int xSpeed;
private int yspeed;
public Ball ()(
super (200,200);
xspeed =3;
yspeed =1;
}
//add other Ball constructors
//set methods
public void moveAndDraw (Graphics window)
1
//draw a white ball at
//old ball location
Speed);
??? sety
//draw ball at new location
}
//equals method
//get methods
public string tostring(){
return "";
}
}
Sample Output ( BallTestOne.java )
2002001010 java.awt.Color [r=0,g=0,b=0],31
100901010 java.awt.Color [r=0,g=0,b=0],31
1001003050 java.awt.Color [r=0,g=0,b=0],31
1001003050 java.awt.Color [r=0,g=0,b=255],31
1001003050 java.awt.Color [r=0,g=0,b=255],56
1001003050 java.awt.Color [r=0,g=0,b=255],56
false
Files Needed ::
Block. java
Ball. java
BallTestone. java
BallTestTwo. java
Tester.java
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago