Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. public class Point2D {
  2.     private float x = 0.0f;
  3.     private float y = 0.0f;
  4.  
  5.     public Point2D(float x, float y) {
  6.         this.x = x;
  7.         this.y = y;
  8.     }
  9.  
  10.     public Point2D() {
  11.     }
  12.  
  13.     public float getX() {
  14.         return x;
  15.     }
  16.  
  17.     public void setX(float x) {
  18.         this.x = x;
  19.     }
  20.  
  21.     public float getY() {
  22.         return y;
  23.     }
  24.  
  25.     public void setY(float y) {
  26.         this.y = y;
  27.     }
  28.  
  29.     public void setXY(float x, float y) {
  30.         this.x=x;
  31.         this.y = y;
  32.     }
  33.  
  34.     public float[] getXY(){
  35.         float[] result = { this.x , this.y };
  36.         System.out.println(result);
  37.         return result;
  38.     }
  39.  
  40.     @Override
  41.     public String toString() {
  42.         return '(' +
  43.                 "x=" + x +
  44.                 ", y=" + y +
  45.                 ')';
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement