Advertisement
vnevermore

Askhsh 3

Feb 3rd, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. I klasi ipostiriksis:
  2.  
  3. public class Rectangle
  4. {
  5.     private int x,y;
  6.    
  7.     Rectangle()
  8.     {
  9.         x=2;
  10.         y=4;
  11.     }
  12.    
  13.     Rectangle(int par_x, int par_y)
  14.     {
  15.         x=par_x;
  16.         y=par_y;
  17.     }
  18.    
  19.     public int getEmvado()
  20.     {
  21.         return x*y;
  22.     }  
  23.    
  24. }
  25.  
  26.  
  27. i main klasi:
  28.  
  29. public class Askhsh
  30. {
  31.     public static void main(String[] args)
  32.     {
  33.         Rectangle no1 = new Rectangle();
  34.         Rectangle no2 = new Rectangle(3,5);
  35.        
  36.         System.out.println("To Emvado tou prwtou einai: " + no1.getEmvado());
  37.         System.out.println("To Emvado tou deuterou einai: " + no2.getEmvado());
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement