Question: write a class for this Task 4. The Ball class Ball = -x:double = 0.0 -y: double 0.0 - xSpeed: double = 0.0 -ySpeed: double

write a class for this Task 4. The Ball class Ball =write a class for this

Task 4. The Ball class Ball = -x:double = 0.0 -y: double 0.0 - xSpeed: double = 0.0 -ySpeed: double 0.0 +Ball(x:double, y:double xSpeed: double, ySpeed: double) +getX(): double +setx(x:double):void +getY(): double +setY(y:double):void +getXSpeed(): double +setxSpeed (xSpeed: double):void +getYSpeed(): double +setYSpeed(ySpeed: double):void +setXY(x: double, y:double):void +setXYSpeed(xSpeed: double, ySpeed: double):void +move():void +print():void A Ball class models a moving ball, designed as shown in the class diagram, contains the following members: 1. Four private data members x, y, xSpeed and ySpeed to maintain the position and speed of the ball. 2. A constructor, and public getters and setters for the private data members. 3. A function setXYO, which sets the position of the ball and setXY Speed to set the speed of the ball. 4. A function move(), which increases x and y by xSpeed and ySpeed, respectively. 5. A function print, which prints "Ball @ (x,y) with speed (xSpeed, ySpeed)", to 2 decimal places

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!