Your lab should have a class for the PaddleBall Controller; this Controller clas
ID: 639738 • Letter: Y
Question
Your lab should have a class for the PaddleBall Controller; this Controller class manages all aspects of the game including various game parameters. It determines the diameter of the ball and the distance the ball travels with each move. The Controller class contains a ball object, a paddle object, and a display object. In addition, the controller is responsible for managing the events that drive the game.
Can you add the *pseudocode* (please add /pseudocode *only*/) for some of the essential functionality of this PaddleBallController class stub below?
public class PaddleBallController implements ActionListener, MouseMotionListener {
// Add the fields
// The constructor:
public PaddleBallController() {
// Create the Ball, Paddle, and Display objects/fields
// Setup a new Timer
// Register the mouse event handler
}
// Method to have the game ball and game paddle draw themselves
public void drawGame(Graphics g) {
}
// Deal with Timer Events
public void actionPerformed(ActionEvent e) {
// Ball moves within size of the display area
// Determine if the ball is in contact with the paddle
// Is the top of the ball now in contact with the paddle?
// Cause the GUI/Display Object to redraw itself
}
// Check for user moving the Paddle via MouseEvents
public void mouseDragged(MouseEvent me) {
}
public void mouseMoved(MouseEvent me) {
}
}
Explanation / Answer
i tried ...hope it helps
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.