This are API\'S and should be typed in the java.. thanks Ball Class API Class De
ID: 3834459 • Letter: T
Question
This are API'S and should be typed in the java.. thanks
Ball Class API Class Definition: public class Ball extends MovingGameQbject Constructors: Identifier: Ball int Position int yPosition int diameter, Color color Parameters sition an int representing the x coordinate of the Ball an int representing the y coordinate of the Ball diameter an int representing the diameter of the Ball color a Color object representing the color of the Ball Return Value Other: Methods petDiametero Identifier: Parameters Return Value: int The diameter of the Ball Other:Explanation / Answer
Ball.java:
import java.awt.Color;
public class Ball extends MovingGameObject {
private int diameter;
Ball(int xPos, int yPos, int diameter, Color color) {
super(xPos, yPos, 0, 0, color);
this.diameter = diameter;
}
public int getDiameter() {
return diameter;
}
}
Brick.java:
import java.awt.Color;
public class Brick extends GameObject{
private int width, height;
public Brick(int xPos, int yPos, int width, int height, Color color) {
super(xPos, yPos, color);
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
}
Obstacle.java:
import java.awt.Color;
public class Obstacle extends MovingGameObject {
int size;
Obstacle(int xPos, int yPos, int size, Color color) {
super(xPos, yPos, 0, 0, color);
this.size = size;
}
public int getSize() {
return size;
}
}
Paddle.java:
import java.awt.Color;
public class Paddle extends ControlledGameObject {
private int width;
private int height;
private int speed;
public Paddle(int xPos, int yPos, int width, int height, int speed, Color color,
KeyboardController controller) {
super(xPos, yPos, color, controller);
this.width = width;
this.height = height;
this.speed = speed;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
@Override
public void move() {
// Please implement this method, as i don't know anything about your KeyboardController class
}
}
PowerUp.java:
import java.awt.Color;
public class PowerUp extends MovingGameObject{
private char symbol;
PowerUp(int xPos, int yPos, char symbol, Color color) {
super(xPos, yPos, 0, 0, color);
this.symbol = symbol;
}
void onCollection(GamePanel game) {
// Please implement this, as i have no idea about your game panel class
}
}
I have given you the classes as you asked for, but the methods in PowerUp class and Paddle class, I could not implement. Because i don't knonw about the KeyboardControllerClass and GamePanel etc.
Thanks.
Please comment if something is not clear.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.