Skip to content

Commit

Permalink
-mlessons files from 1 to 41 added
Browse files Browse the repository at this point in the history
  • Loading branch information
codershiyar committed Dec 17, 2022
1 parent 1bf57ab commit 045efa1
Show file tree
Hide file tree
Showing 28 changed files with 903 additions and 70 deletions.
665 changes: 628 additions & 37 deletions Lesson 30 - الدرس/App.java

Large diffs are not rendered by default.

70 changes: 37 additions & 33 deletions Lesson 31 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
class App {
String name;
App app;

public class App{

App(){

}
public static void main(String[] args) {

void setApp(App app){
this.app = app;
}
App(String name){
this();
this.name = name;
System.out.println(this.getName());
setApp(getApp());
}

// replaceAll() من خلالها يمكنك استبداله جزء من النص بجزء جديد
// replaceFirst() يقوم بإستبداول قيمة يطابق مع الجزء المحدد من النص , بالجزء جديد
// isEmpty() يستخدم لتحقق إذا كان متغير من نوع بيانات نصي خالي من بيانات او لا
// lastIndexOf() تمركز اخر جزء يطابق مع الجزء المحدد
// startsWith() يستخدم لتحقق إن كان النص يبدأ بجزء الذي تحدده او لا
// endsWith() يستخدم لتحقق إن كان النص ينتهي بجزء الذي تحدده او لا
String text = "Java, I like Java.";
text = text.replaceFirst("not", "@");
boolean isEmpty = text.isEmpty();
int lastIndexOf = text.indexOf("Java");
App getApp(){ return this; }

App(){ System.out.println("Start App"); }
String getName(){return name;}

boolean startsWith = text.startsWith(" ");
boolean endsWith = text.endsWith(".");
// if(text.isEmpty()){
public static void main(String[] args) {
App app = new App("Learn Java");
}
}

// }else{
/* --------------------------------------------------------------------
this keyword in Java - شرح امر هذا في الجافا
------------------------------------------------------------------------
this يمكن استخدام هذا للإشارة إلى فاريبل مثيل في الاوبجكت الحالي
this يمكن استخدام هذا للإستدعاء ميتود في الاوبجكت الحالي
this() يمكن استخدامها للاستدعاء كونستروكتور كلاس
this يمكن تمريرها كا قيمة عند استدعاء ميتود
this يمكن تمريرها كا قيمة عند استدعاء كونستروكتور كلاس
this يمكن استخدام هذا لإرجاع اوبجكت مثيل من كلاس الحالي في ميتود
this can be used to refer current class instance variable.
this can be used to invoke current class method (implicitly)
this() can be used to invoke current class constructor.
this can be passed as an argument in the method call.
this can be passed as argument in the constructor call.
this can be used to return the current class instance from the method.
// }
System.out.println(endsWith);

}

}






*/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions Lesson 37 - الدرس/package1/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package package1;
import package2.App3;

public class App extends App3 {
public static void main(String[] args) {
System.out.println(App2.name);
printName();
}
}



/* ------------------------------------------------------------------------------------------------------
Access Modifier in Java شرح اوامر الذي يتيح لك بتحديد طريقة وصول إلى كلاس او متغير او ميتودس في الجافا
----------------------------------------------------------------------------------------------------------
No modifier دون تحديد اي طريقة وصول
Private (خاص)
Protected (محمي)
Public (عام)
Methods/Variables & Constructor class : No modifier/Private/Protected/Public
----------------------------------------------------------------------------------------------------------
Classes: No modifier / only public (abstract & final)
----------------------------------------------------------------------------------------------------------
*/
6 changes: 6 additions & 0 deletions Lesson 37 - الدرس/package1/App2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package package1;


public class App2{
public static String name = "Coder Shiyar";
}
7 changes: 7 additions & 0 deletions Lesson 37 - الدرس/package2/App3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package package2;
import package1.App2;
public class App3 {
protected static void printName(){
System.out.println(App2.name);
}
}
58 changes: 58 additions & 0 deletions Lesson 38 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
public class App {
public static void main(String[] args) {
AppInfo appInfo = new AppInfo();
appInfo.setName("Learn Java with Shiyar");
System.out.println(appInfo.getName());

AppInfo2 appInfo2 = new AppInfo2("I love ...");

System.out.println(appInfo2.getName());
}
}

class AppInfo{
private String name;

public String getName(){
return name;
}

public void setName(String name){
this.name = name;
}

}

class AppInfo2{
private String name;

AppInfo2(String name){
this.name = name;
}
public String getName(){
return name;
}

}

/* -------------------------------------------------------------------------------------------
Encapsulation in OOP in Java
/* -------------------------------------------------------------------------------------------
بالإختصار هو جعل متغيرات من نوع خاص ومنع وصول
إليهم بطريقة مباشرة خارج الكلاس الذي تم إنشاء تلك متغيرات بها
In short, it is to make variables of a private type and prevent access them directly
outside the class in which these variables are created
/* -------------------------------------------------------------------------------------------
Getters & Setters methods
/* -------------------------------------------------------------------------------------------
They are methods that you create to access these variables through other classes
In order to read or update its data
هم عبارة عن وظائف تقوم بإنشائها للوصول إلى تلك متغيرات من خلالها عبر كلاسات اخرى
بهدف قراءة بياناتها او تحديثها
There are various reasons as to why encapsulation is essential in Java:
Encapsulation allows us to modify the code or A part of the code without having to change any other functions or code.
Encapsulation controls how we access data.
We can modify the code based on the requirements using encapsulation.
Encapsulation makes our applications simpler.
*/
28 changes: 28 additions & 0 deletions Lesson 39 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.ArrayList;

public class App {
public static void main(String[] args) {
ArrayList<String> fruits = new ArrayList<>();
fruits.add("Apple");
fruits.add("Kiwi");
fruits.add("Banana");
// fruits.set(0, "Orange");
// fruits.remove(0);
// fruits.clear();
System.out.println(fruits.size());
}
}

/* ----(Java ArrayList)--------------------------------------------------------------------------------------------------
The ArrayList class is a resizable array كلاس اراي ليست يستخدم لإنشاء مصفوفات متطورة مقارنةً مع المصفوفات العادية
---------------------------------------------------------------------------------------------------------------------
Value = قيمة Position = تمركز Arrays = مصفوفات
---------------------------------------------------------------------------------------------------------------------
add(Value) To add items/elements to the ArrayList لإضافة قيمة جديدة
set(Position, Value) To modify an item, لتحديث احد قيم
get(Position) To access an element in the ArrayList لوصول إلى احد قيم
remove(Position) To remove an item/element لحذف احد قيم
clear() To remove all the elements in the ArrayList لحذف جميع قيم
size() To find out how many elements an ArrayList have لمعرفة عدد العناصر الموجودة في اراي
---------------------------------------------------------------------------------------------------------------------
*/
41 changes: 41 additions & 0 deletions Lesson 40 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import java.util.ArrayList;

public class App {
public static void main(String[] args) {
ArrayList<String> fruits = new ArrayList<>();
fruits.add("Apple");
fruits.add("Kiwi");
fruits.add("Banana");
// fruits.remove("Kiwi");
try {
System.out.println(fruits.get(fruits.size() - 4));
} catch (Exception e) {
// TODO: handle exception
System.out.println("لا يوجد اي قيمة في ذلك تمركز , لذلك ظهرت الخطأ");
}

int position = 0;
// for(String item : fruits ){
// position++;
// System.out.println(position+" : " +item);
// }
for(int i = 0; i<fruits.size(); ++i){
position++;
System.out.println(position+" : " + fruits.get(i));
}
}
}

/* ----(Java ArrayList)--------------------------------------------------------------------------------------------------
The ArrayList class is a resizable array كلاس اراي ليست يستخدم لإنشاء مصفوفات متطورة مقارنةً مع المصفوفات العادية
---------------------------------------------------------------------------------------------------------------------
Value = قيمة Position = تمركز Arrays = مصفوفات
---------------------------------------------------------------------------------------------------------------------
add(Value) To add items/elements to the ArrayList لإضافة قيمة جديدة
set(Position, Value) To modify an item, لتحديث احد قيم
get(Position) To access an element in the ArrayList لوصول إلى احد قيم
remove(Position) To remove an item/element لحذف احد قيم
clear() To remove all the elements in the ArrayList لحذف جميع قيم
size() To find out how many elements an ArrayList have لمعرفة عدد العناصر الموجودة في اراي
---------------------------------------------------------------------------------------------------------------------
*/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions Lesson 41 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.util.ArrayList;

public class App {
static ArrayList<Person> persons = new ArrayList<>();
static ArrayList<Order> orders = new ArrayList<>();
static ArrayList<IDCard> idCards = new ArrayList<>();
static ArrayList<Registration> registrations = new ArrayList<>();
static ArrayList<Student> students = new ArrayList<>();
static ArrayList<Course> courses = new ArrayList<>();
public static void main(String[] args) {

}
}
class IDCard{Person person;}

class Person{String name;}
class Order{Person person; int OrderNumber;}

class Student{String name;}
class Course{ String name;}
class Registration{ Student student; Course course;}
/* --------------------------------------------------------------------------------------------------------------------
Association in Java
--------------------------------------------------------------------------------------------------------------------
Association in Java is a connection or relation between two separate classes that are set up through their objects.
الاقتران في جافا هو اتصال أو علاقة بين كلاسين (فئتين) منفصلتين تم إعدادهما من خلال اوبجكت خاص بهم (كائناتهما)
--------------------------------------------------------------------------------------------------------------------
1: one to many 1 -> *
2: one to one 1 -> 1
3: many to many * -> *
--------------------------------------------------------------------------------------------------------------------
Person - Order طالب - طلبية
Person - ID card شخص - هوية شخصية
Student - Course طالب - كورس
*/
38 changes: 38 additions & 0 deletions next videos 1/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

public class App{

App(){

}
public static void main(String[] args) {


// replaceAll() من خلالها يمكنك استبداله جزء من النص بجزء جديد
// replaceFirst() يقوم بإستبداول قيمة يطابق مع الجزء المحدد من النص , بالجزء جديد
// isEmpty() يستخدم لتحقق إذا كان متغير من نوع بيانات نصي خالي من بيانات او لا
// lastIndexOf() تمركز اخر جزء يطابق مع الجزء المحدد
// startsWith() يستخدم لتحقق إن كان النص يبدأ بجزء الذي تحدده او لا
// endsWith() يستخدم لتحقق إن كان النص ينتهي بجزء الذي تحدده او لا
String text = "Java, I like Java.";
text = text.replaceFirst("not", "@");
boolean isEmpty = text.isEmpty();
int lastIndexOf = text.indexOf("Java");

boolean startsWith = text.startsWith(" ");
boolean endsWith = text.endsWith(".");
// if(text.isEmpty()){

// }else{

// }
System.out.println(endsWith);

}

}






File renamed without changes.

0 comments on commit 045efa1

Please sign in to comment.