diff --git "a/Lesson 12 - \330\247\331\204\330\257\330\261\330\263/App.java" "b/Lesson 12 - \330\247\331\204\330\257\330\261\330\263/App.java" index a6a555c..761c6f6 100644 --- "a/Lesson 12 - \330\247\331\204\330\257\330\261\330\263/App.java" +++ "b/Lesson 12 - \330\247\331\204\330\257\330\261\330\263/App.java" @@ -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 { } \ No newline at end of file diff --git "a/Lesson 13 - \330\247\331\204\330\257\330\261\330\263/App.java" "b/Lesson 13 - \330\247\331\204\330\257\330\261\330\263/App.java" index a8ab217..c22d610 100644 --- "a/Lesson 13 - \330\247\331\204\330\257\330\261\330\263/App.java" +++ "b/Lesson 13 - \330\247\331\204\330\257\330\261\330\263/App.java" @@ -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=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("admin@gmail.com") && 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 +// استخدمه في حال لتحديد شرط اخر في حال الشرط اول لم يتحقق + + + diff --git "a/Lesson 17 - \330\247\331\204\330\257\330\261\330\263/App.java" "b/Lesson 17 - \330\247\331\204\330\257\330\261\330\263/App.java" new file mode 100644 index 0000000..a6a555c --- /dev/null +++ "b/Lesson 17 - \330\247\331\204\330\257\330\261\330\263/App.java" @@ -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 - الكود الذي ترغب بتنفيذه +// } + + diff --git "a/Lesson 18 - \330\247\331\204\330\257\330\261\330\263/App.java" "b/Lesson 18 - \330\247\331\204\330\257\330\261\330\263/App.java" new file mode 100644 index 0000000..a8ab217 --- /dev/null +++ "b/Lesson 18 - \330\247\331\204\330\257\330\261\330\263/App.java" @@ -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