Skip to content

Commit

Permalink
New lessons files added
Browse files Browse the repository at this point in the history
  • Loading branch information
codershiyar committed Sep 17, 2022
1 parent 3343ff0 commit 1bf57ab
Show file tree
Hide file tree
Showing 8 changed files with 922 additions and 33 deletions.
88 changes: 88 additions & 0 deletions Lesson 25 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import java.time.LocalDate;

public class App {

static void printMessage(String message){
System.out.println(message);
}

String getName(){
return "Coder Shiyar";
}

public static void main(String[] args) {
App.printMessage("Hi from main");
App app = new App();
System.out.println(app.getName());

System.out.println(LocalDate.now());
System.out.println("text".length());
}

}

// ---------------------------------------------------------------------------------------------------------------------
// Java Methods (members/function)
// وظيفة او مهمة
//----------------------------------------------------------------------------------------------------------------------
// 1: There are ready-made methods in Java that were developed by others وظائف جاهزة
// 2: methods that you can create yourself وظائف يمكنك انشائها بنفسك
//----------------------------------------------------------------------------------------------------------------------
// 3: void type النوع الذي فقط ينفذ اوامر التي تتواجد ضمنها عند استدعائها دون إعادة اي شي
// 4: return type النوع الذي يقوم بتنفيذ اوامر التي تتواجد ضمنها و ثم يقوم بإعادة بيانات
// ---------------------------------------------------------------------------------------------------------------------








/** Static and non-static methods in Java - مهمات/وظائف الثابتة وغير الثابتة في جافا
------------------------------------------------------------------------------------------------------------------------
1-A: You can make a method of static type if you want to call method's without having to create a class-object
يمكنك عمل ميتود من النوع ستاتيك إذا كنت تريد ان تتمكن من استدعاء ميتود دون الحاجة إلى إنشاء اي كلاس اوبجكت
1-B: You can make a variable of type non-static if you want to access a variable only via Class Object
and the variable data is not shared with other objects
يمكنك عمل ميتود من النوع غير ستاتيك إذا ترغب بإستدعاء ميتود عبر كلاس اوبجكت في ميتودس من نوع ستاتيك أو كلاس اخر
-------------------------------------------------------------------------------------------------------------------------
2-a: A static method can access only static methods and can not access non-static methods.
ضمن ميتود من نوع ستاتيك يمكنك وصول فقط الى ميتودس من نوع ستاتيك ولا يمكنك وصول إلى ميتودس ليست من نوع ستاتيك
بطريقة مباشرة. يمكنك انشاء كلاس اوبجكت ان كنت ترغب باستدعاء ميتود من نوع غير ستاتيك
2-b: A non-static method can access both static as well as non-static members.
يمكن للميتودس غير ستاتيك الوصول إلى كل من ميتودس ستاتك وغير ستاتيك
*/































62 changes: 62 additions & 0 deletions Lesson 26 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
public class App {
static String name = "Learn Java with Coder Shiyar";
double version = 1.0;


public static void main(String[] args) {
App app = new App();
app.version = 2.0;
System.out.println(app.version);

App app2 = new App();

System.out.println(App2.getName());

}

void printName(){
System.out.println(name);
}
}

class App2{

static String getName(){
return App.name;
}
}
/**
Static and non-static variables in Java - المتغيرات الثابتة وغير الثابتة في جافا
=========================================================================================================================
1-a: A static variable acts as a global variable and is shared among all the objects of the class.
يعمل المتغير من نوع ستاتيك كمتغير عام ويتم مشاركته بين جميع كائنات الفئة (كلاسات ابوجكتس)
1-b: A non-static variables are specific to instance object in which they are created.
تعتبر المتغيرات غير ستاتيك خاصة ب اوبجكت الذي تم إنشاؤه ولا يتم مشاركة بياناتها مع اوبجكتس اخرى
-------------------------------------------------------------------------------------------------------------------------
2-a: A static variable can be accessed by static methods as well as non-static methods.
متغيرات من نوع ستاتيك يمكنك وصول إليه من خلال ميتودس من نوع ستاتيك و غير ستاتيك
2-b: A non-static variable can not be accessed by static member functions.
متغيرات من نوع غير ستاتيك لا يمكنك وصول إليه من خلال ميتودس من نوع ستاتيك بطريقة مباشرة
*/











/**
Extra
--------------------------------------------------------------------------------------------------------------------------
Static variables occupies less space and memory allocation happens once.
A non-static variable may occupy more space. Memory allocation may happen at run time.
--------------------------------------------------------------------------------------------------------------------------
A static variable is declared using static keyword.
A normal variable is not required to have any special keyword.
**/
24 changes: 24 additions & 0 deletions Lesson 27 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.time.LocalDate;
class App{
public static void main(String[] args) {
LocalDate date = LocalDate.now();
date = date.plusYears(3);

System.out.println(date.getYear() + " - " + date.getMonthValue() + " - " + date.getDayOfMonth());
}
}

/*
import java.time.LocalDate; لاستدعاء الكلاس جاهز الذي يمكننا من خلالها حصول على التاريخ
------------------------------------------------------------------------------------------------------------
LocalDate.now() To get the current date - للحصول على التاريخ الحالي
getYear() To get the current year from date - للحصول على السنة الحالية من التاريخ
getMonthValue() To get the current month from date - للحصول على الشهر الحالي من التاريخ
getMonth() To get the name of the current month - للحصول على الاسم الشهر الحالي من التاريخ
getDayOfMonth() To get the current day of the month from date - للحصول على اليوم الحالي من الشهر الحالي
getDayOfYear() To get the current day of the month from date - للحصول على اليوم الحالي من السنة الحالية
------------------------------------------------------------------------------------------------------------
minusDays() To decrease days from the current date - للنقص ايام من التاريخ المحدد
plusDays() To increase days to the current date - للزيادة ايام إلى التاريخ المحدد
*/
40 changes: 40 additions & 0 deletions Lesson 28 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
class App{
public static void main(String[] args) {
LocalTime time = LocalTime.now();

LocalTime time2 = LocalTime.parse("18:11:59");

LocalDate date2 = LocalDate.parse("2024-06-11");
System.out.println(date2.getYear());

time = time.minusHours(2);

System.out.println(time2.toString());
System.out.println(LocalDateTime.now());

}
}

/*
import java.time.LocalTime; لاستدعاء الكلاس جاهز الذي يمكننا من خلالها حصول على الوقت
import java.time.LocalDateTime; لاستدعاء الكلاس جاهز الذي يمكننا من خلالها حصول على التاريخ والوقت
------------------------------------------------------------------------------------------------------------
LocalTime.now() To get the current time - للحصول على الوقت الحالي
getHour() To get the current hour from time - للحصول على الساعة الحالية من الوقت
getMinute() To get the current minute from time - للحصول على الدقيقة الحالية من الوقت
getSecond() To get the current second from time - للحصول على الثانية الحالية من الوقت
plusHours() To increase hours to the current time - للزيادة ساعات إلى الوقت المحدد
plusMinutes() To increase minutes to the current time - للزيادة دقائق إلى الوقت المحدد
plusSeconds() To increase seconds to the current time - للزيادة ثواني إلى الوقت المحدد
minusHours() To decrease hours from the current time - للنقص ساعات من الوقت المحدد
minusMinutes() To decrease minutes from the current time - للنقص دقائق من الوقت المحدد
minusSeconds() To decrease seconds from the current time - للنقص ثواني من الوقت المحدد
*/

0 comments on commit 1bf57ab

Please sign in to comment.