SHARE
TWEET

Untitled

a guest Sep 14th, 2017 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. The Ball Class:
  2.  
  3. The data that defines a ball is given below:
  4. x:  its x position
  5. y:  its y position
  6. r:  its radius
  7. dx: its speed in the x direction
  8. dy: its speed in the y direction
  9.  
  10.  
  11. a. What is a constructor?
  12. [2]
  13.  
  14. Write two constructors for this class:
  15.  
  16. one that has no default values;
  17.  
  18. my lecturers answer:
  19.  
  20.   Ball ( int xx, int yy, int rr, float dx, float dy)
  21. {
  22.   this.x = xx;
  23.   this.y = yy;
  24.   this.r = rr;
  25.   this.dx =  dx;
  26.   this.dy = y;
  27. }
RAW Paste Data
Top