Can you guys add the *pseudocode* (please add /pseudocode *only*/) for some of t
ID: 3776575 • Letter: C
Question
Can you guys add the *pseudocode* (please add /pseudocode *only*/) for some of the essential functionality of this PaddleBallDisplay class stub below? public class PaddleBallDisplay extends JPanel { // Add the fields // The explicit-value constructor: public PaddleBallDisplay(PaddleBallController controller) { } // Method to do all the painting for the game public void paintComponent(Graphics g) { // Erase what is currently in the display area // Let the game controller object update the display } }
Explanation / Answer
to create PaddleBalDisplay game need ball class contoller of the ball class,ball_controller
class and main class.
Ball class:
Ball extends JPanel{
Timer time()= new Timer();
int x=0, y=0,x1=2,y1=2; // ball positions
ball(){
time.start();
}
//implement actionPerformed(){
public void actionPerformed(ActionEvent e) {
repaint();
}
public void paint(Graphics g){
paint(component);
compoenent.setColor();
}
}
Controller class:
public class Controller{
Ball b = new Ball();
Controller(){
//set layout
//board is object of display class
board.setLayout(new BirderLayout());
board.add(ball,BorderLayout.CENTER);
}
}
display of ball class
public class DisplayBall extends JFrame{
Displya(int height, int width){
setSize(height,width);setVisible(true);
}
}
in the ball controller class:
sepcify and implement mouseliesters interface for ball positions
import java.awt.*;
import java.awt.event.MouseMotionListener;
import javax.swing.JPanel;
public class Cont_ball extends JPanel implements MouseMotionListener{
int xpos,ypos,width,height;
collision(int xpos, int ypos, int width, int height){
}
//set the widh and heights here
addMouseMotionListener(this);
addMouseDragged(MouseEvent e){
xpos=e.getX();
repaint();
}
form the main call we can call all
public statis void amin(String rags[]){
Contoller ct = new Controller();
}