Advertisement
zsoltizbekk

2016.02.23_java

Feb 23rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. //main.java
  2.  
  3. package teszt;
  4.  
  5. import geom.Pont;
  6.  
  7. public class Teszt {
  8.    
  9.     public static void main(String[] args) {        
  10.         System.out.println("Hello vilag!");
  11.         Pont p1 = new Pont(3,5);
  12.         //System.out.println("(" + p1.x + "," + p1.y + ")");
  13.         System.out.println("(" + p1.getX() + "," + p1.getY() + ")");
  14.        
  15.         p1.setX(-3);
  16.         System.out.println("(" + p1.getX() + "," + p1.getY() + ")");
  17.     }
  18. }
  19.  
  20.  
  21. //pont.java
  22.  
  23. /*
  24.  * To change this license header, choose License Headers in Project Properties.
  25.  * To change this template file, choose Tools | Templates
  26.  * and open the template in the editor.
  27.  */
  28. package geom;
  29.  
  30. /**
  31.  *
  32.  * @author hallgato
  33.  */
  34.  
  35. public class Pont{
  36.    private int x;
  37.    private int y;
  38.    
  39.    //public Pont(){}
  40.  
  41.     public Pont(int x, int y) {
  42.         this.x = x;
  43.         this.y = y;
  44.     }
  45.  
  46.     public int getX() {
  47.         return x;
  48.     }
  49.  
  50.     public int getY() {
  51.         return y;
  52.     }
  53.  
  54.     public void setX(int x) {
  55.         this.x = x;
  56.     }
  57.  
  58.     public void setY(int y) {
  59.         this.y = y;
  60.     }
  61.    
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement