Advertisement
Osan_Salah

Untitled

Jan 29th, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public class Main {
  2.     public static void main(String[] args) {
  3.         Sq object1 = new Sq(); /// lera nrxm nayawate kawata yakam constractora
  4.         Sq object2 = new Sq(5); /// lera 1 nrxm yawa pey
  5.         Sq object3 = new Sq(5, 10); // lera 2 nrxm yawa pey
  6.     }
  7. }
  8.  
  9. class Sq { //// 1. classm drwstkrd
  10.     int x;
  11.     int y; /// 2. 2 variablem nwsy ba int nawyan x w y a
  12.  
  13.     Sq() { //// ba constractor wam lekrd agar nrxy nayame
  14.         this.x = 1;
  15.         this.y = 1;
  16.     }
  17.  
  18.     Sq(int n1) { //// ba constractor wam le krd agar 1 nrxm ya pey tanha x bgore
  19.         this.x = n1;
  20.         this.y = 1;
  21.     }
  22.  
  23.     Sq(int n1, int n2) { /// ba constractor wamlekrd agar 2 nrxm ya pey hardwky bgore
  24.         this.x = n1;
  25.         this.x = n2;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement