Skip to content

Commit

Permalink
update java lessons
Browse files Browse the repository at this point in the history
  • Loading branch information
codershiyar committed Mar 5, 2022
1 parent dbc95a1 commit 8771f44
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 42 deletions.
56 changes: 38 additions & 18 deletions Lesson 12 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@

public class App {

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

try{
String[] languages = {"العربية" , "الانجليزية" , "الألمانية" ,"الهولندية" , "الكردية"};
System.out.println(languages[5]);
}catch(Exception error){
System.out.println("حدث خطا ما");
System.out.println(error);
}finally{
System.out.println("اكتمل جملة تراي وكاتش");
}

String[] languages = {"Arabic" , "Dutch" , "German" , "Kurdish" , "English"};
// System.out.println(languages[0]);
// System.out.println(languages[1]);
// System.out.println(languages[2]);
// System.out.println(languages[3]);
// System.out.println(languages[4]);
int numbering = 0;
for(String language : languages ){
++numbering;
System.out.println(numbering + ": " + language);
}

}
}
}

// for (type variableName : arrayName) {
// // code block to be executed - الكود الذي ترغب بتنفيذه
// }


// When executing Java code, different errors can occur: coding errors made by the programmer,
// errors due to wrong input, or other unforeseeable things.
// عند تنفيذ كود جافا ، يمكن أن تحدث أخطاء مختلفة: أخطاء في اكواد قام بها المبرمج
// ، أو أخطاء ناتجة عن إدخال خاطئ ، أو أشياء أخرى غير متوقعة
// -------------------------------------------------------------------------------------------------------------
// When an error occurs, Java will normally stop and generate an error message.
// عند حدوث خطأ ما ، ستتوقف جافا عادةً وتنشئ رسالة خطأ
// -------------------------------------------------------------------------------------------------------------
// The try statement allows you to define a block of code to be tested for errors while it is being executed.
// ضمن جملة تراي يمكنك وضع اوامر جافا الذي ترغب بان يتم تنفيذها
// The catch statement allows you to define a block of code to be executed, if an error occurs in the try block.
// ضمن جملة كاتش يمكنك وضع الاوامر جافا الذي ترغب بأن يتم تنفيذها في حال حدوث خطا ما في جملة تراي
// او يمكنك استخدامها لاخفاء الخطا لتجنب تعطيل تطبيق او برنامج او لعبة بسبب ذلك الخطا
// -------------------------------------------------------------------------------------------------------------
// The finally statement lets you execute code, after try...catch, regardless of the result:
// تتيح لك العبارة فاينالي تنفيذ التعليمات البرمجية ، بعد تراي ... كاتش ، بغض النظر عن النتيجة
// -------------------------------------------------------------------------------------------------------------
// The try and catch keywords come in pairs:
// try {
// Block of code to try

// }
// catch(Exception e) {
// Block of code to handle errors

// } finally { }
58 changes: 34 additions & 24 deletions Lesson 13 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@

import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);

public static void main(String[] args) {
// int counter = 1;
// int number= 7;
// while(counter<=20){
// System.out.println(counter + " * " + number + " = " + (counter * number) );
// counter++;
// }

String[] webLanguages = {"html","css" ,"JavaScript" , "PHP"};
try {
System.out.println("Enter your age: ");
int age = keyboard.nextInt();
System.out.println("Age: "+ age);
} catch (Exception e) {
//TODO: handle exception
System.out.println("Error invalid data");
}

int counter2 = 0;
while(counter2<webLanguages.length){
System.out.println("Language " + (counter2 + 1) + " : " + webLanguages[counter2]);
counter2++;
}
System.out.println("Enter your email: ");
keyboard.nextLine();
String email =keyboard.nextLine();
System.out.println("Email: " + email);

}
}
}


// Java While Loop
// ---------------------------------------------------------------------
// يستخدم لتكرار تنفيذ الأوامر الى ما يصبح الشرط الذي وضعته غير صحيح
// ---------------------------------------------------------------------
// while (condition الشرط) {
// // code block to be executed - الكود الذي ترغب بان يتم تنفيذها
// }
// Java User Input (Scanner) يتم استخدامها لجعل مستخدم يقوم بتحديد بيانات
// ------------------------------------------------------------------------------------------------------------------
// import java.util.Scanner; لكي نتمكن من استخدام سكنر يجب علينا استدعاء ملف سكنر في جافا
// Scanner keyboard = new Scanner(System.in); لانشاء متغير لقراء بيانات من لوحة مفاتيح
// ------------------------------------------------------------------------------------------------------------------
// nextLine() Reads a String value from the user يستخدم لقراءة بيانات من نوع بيانات نصي
// ------------------------------------------------------------------------------------------------------------------
// nextBoolean() Reads a boolean value from the user لقراءة بيانات من نوع صح و خطا
// ------------------------------------------------------------------------------------------------------------------
// nextByte() Reads a byte value from the user لقراءة بيانات من نوع ارقام ليس بها فاصلة من نوع بايت
// ------------------------------------------------------------------------------------------------------------------
// nextDouble() Reads a double value from the user يستخدم لقراءة اعداد الذي بها فاصلة ونوع بياناته يكون دوبول
// nextFloat() Reads a float value from the user يستخدم لقراءة اعداد الذي بها فاصلة ونوع بياناته يكون فلوت
// ------------------------------------------------------------------------------------------------------------------
// nextInt() Reads a int value from the user يستخدم لقراءة اعداد الذي ليس بها فاصلة من نوع إينت
// nextLong() Reads a long value from the user يستخدم لقراءة اعداد الذي ليس بها فاصلة من نوع اعداد طويلة
// nextShort() Reads a short value from the user يستخدم لقراءة اعداد الذي ليس بها فاصلة من نوع اعداد قصيرة
71 changes: 71 additions & 0 deletions Lesson 14 15 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import java.util.Scanner;

public class App {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// System.out.println("Enter your age: ");
// int age = scanner.nextInt();
// if(age>=18){
// System.out.println("You can access this page");
// }else if(age<=0){
// System.out.println("Invalid value");
// }
// else{
// System.out.println("Access denied");
// }
// System.out.println("Enter your email: ");
// String email = scanner.nextLine();

// System.out.println("Enter your password: ");
// String password = scanner.nextLine();

// if(email.equals("[email protected]") && password.equals("1212")){
// System.out.println("You logged in");
// }else{
// System.out.println("Login failed, try again");
// }
System.out.println("Enter 1 for Arabic or 2 for English: ");
int option = scanner.nextInt();
if(option == 1){
System.out.println("Selected Language is Arabic");
}else if(option == 2){
System.out.println("Selected Language is English");
}else{
System.out.println("Invalid option");
}
}
}
// Java Comparison Operators - العمليات المقارنة في جافا
// ------------------------------------------------------------------------------------------------------------
// Comparison operators are used to compare two values: يتم استخدام رموز عمليات مقارنة لمقارنة بين عددين
// ------------------------------------------------------------------------------------------------------------
// Operator - رمز Name - اسم
// ------------------------------------------------------------------------------------------------------------
// == Equal to يساوي
// != Not equal ليس متساوي
// > Greater than اكبر من
// < Less than اصغر من
// >= Greater than or equal to أكبر من أو يساوي
// <= Less than or equal to أصغر من أو يساوي
// Java Logical Operators
// ---------------------------------------------------------------------------------------------------------------
//Operator(الرمز) Name(الاسم) Description (الوصف)
// ---------------------------------------------------------------------------------------------------------------
// && and و Returns true if both statements are true يعود صحيح إذا كانت كلتا العبارتين صحيحين
// || or او Returns true if one of the statements is trueيعود صحيحًا إذا كان أحد العبارات صحيحًا
// ! not لا Reverse the result, returns false if the result is true
// اعكس النتيجة ، وإرجاع خطأ إذا كانت النتيجة صحيحة

// Java Conditions and If else Statements - شرح كيفية تنفيذ اوامر حسب شرط الذي تحدده
// ----------------------------------------------------------------------------------------------
// Use if to specify a block of code to be executed, if a specified condition is true
// استخدمه في حال اذا كنت ترغب بتنفيذ اوامر حسب الشرط الذي تحدده
// ----------------------------------------------------------------------------------------------
// Use else to specify a block of code to be executed, if the same condition is false
// استخدمه في حال اذا كنت ترغب بتنفيذ اوامر في حال الشرط الذي وضعته لم يتحقق
// ----------------------------------------------------------------------------------------------
// Use else if to specify a new condition to test, if the first condition is false
// استخدمه في حال لتحديد شرط اخر في حال الشرط اول لم يتحقق



25 changes: 25 additions & 0 deletions Lesson 17 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

public class App {

public static void main(String[] args) {

String[] languages = {"Arabic" , "Dutch" , "German" , "Kurdish" , "English"};
// System.out.println(languages[0]);
// System.out.println(languages[1]);
// System.out.println(languages[2]);
// System.out.println(languages[3]);
// System.out.println(languages[4]);
int numbering = 0;
for(String language : languages ){
++numbering;
System.out.println(numbering + ": " + language);
}

}
}

// for (type variableName : arrayName) {
// // code block to be executed - الكود الذي ترغب بتنفيذه
// }


30 changes: 30 additions & 0 deletions Lesson 18 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

public class App {

public static void main(String[] args) {
// int counter = 1;
// int number= 7;
// while(counter<=20){
// System.out.println(counter + " * " + number + " = " + (counter * number) );
// counter++;
// }

String[] webLanguages = {"html","css" ,"JavaScript" , "PHP"};

int counter2 = 0;
while(counter2<webLanguages.length){
System.out.println("Language " + (counter2 + 1) + " : " + webLanguages[counter2]);
counter2++;
}

}
}


// Java While Loop
// ---------------------------------------------------------------------
// يستخدم لتكرار تنفيذ الأوامر الى ما يصبح الشرط الذي وضعته غير صحيح
// ---------------------------------------------------------------------
// while (condition الشرط) {
// // code block to be executed - الكود الذي ترغب بان يتم تنفيذها
// }
File renamed without changes.
45 changes: 45 additions & 0 deletions Lesson 20 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
public class App {
public static void main(String[] args) {

String[] webLanguages ={"HTML","CSS" , "JavaScript" , "PHP"};

for(int counter = 0; counter<webLanguages.length; counter++ ){
System.out.println(counter+1 + ": " + webLanguages[(webLanguages.length-1)-counter]);
}

// for(int counter = 0; counter<webLanguages.length; counter++ ){
// System.out.println(counter+1 + ": " + webLanguages[counter]);
// }
// for(int counter =1; counter<=5; counter++){
// System.out.println(counter);
// }

}
}

// The For Loop - يتم استخدامها لتكرار تنفيذ اوامر حسب عدد مرات الذي تحدده
// -------------------------------------------------------------------------------------------------
// When you know exactly how many times you want to loop through a block of code, use the
// for loop instead of a while loop:
// عندما تعرف بالضبط عدد المرات التي تريد تكرار تنفيذ اوامر ، استخدم حلقة فور بدلاً من حلقة ويل
// -------------------------------------------------------------------------------------------------
// The for loop has the following syntax: قوانين لانشاء فور لوب بشكل صحيح
// --------------------------------------------------------------------------------
// for (statement 1; statement 2; statement 3) {
// // code block to be executed
// }
// --------------------------------------------------------------------------------
// Statement 1 is executed (one time) before the execution of the code block.
// يتم تنفيذه (مرة واحدة) , غالب يستخدم لانشاء متغير لاجل العداد تكرار
// --------------------------------------------------------------------------------
// Statement 2 defines the condition for executing the code block.
// يحدد شرط تنفيذ التعليمات البرمجية في حال شرط
// الذي تضعه صحيح سيتم تكرار تنفيذ اوامر الى ما يصبح ذلك شرط غير صحيح
// --------------------------------------------------------------------------------
// Statement 3 is executed (every time) after the code block has been executed.
// {} يتم تنفيذه (في كل مرة) بعد تنفيذ التعليمات البرمجية المتواجد ضمن




// String[] webLanguages ={"HTML","CSS" , "JavaScript" , "PHP"};
35 changes: 35 additions & 0 deletions Lesson 21 - الدرس/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
public class App {
public static void main(String[] args) {

// for(int counter =1; counter<=5; counter++){
// if(counter==3){
// break;
// }
// System.out.println(counter);
// }

int counter2= 1;
while (counter2<=5) {
if(counter2==3){
break;
}
System.out.println(counter2);
counter2++;
}


}
}




// Continue & Break keywords in Java شرح وظيفة امر مواصلة و قطع/كسر
// --------------------------------------------------------------------------------------------
// continue; تكسر تعليمة المتابعة تكرارًا مرة واحدة في كل مرة يتم تنفيذها في لووب
// The continue statement breaks one iteration (in the loop),if a specified condition occurs,
// and continues with the next iteration in the loop.
// --------------------------------------------------------------------------------------------
// break; يمكن أيضًا استخدام تعليمة بريك للقفز من لوب , يعني للإيقاف لوب
// The break statement can also be used to jump out of a loop.
// --------------------------------------------------------------------------------------------

0 comments on commit 8771f44

Please sign in to comment.