diff --git a/Ahmad/.gitignore b/Ahmad/.gitignore new file mode 100644 index 0000000..22df333 --- /dev/null +++ b/Ahmad/.gitignore @@ -0,0 +1,4 @@ +/.metadata/ + + +../Buchalka/ \ No newline at end of file diff --git a/Ahmad/2_puzzles/.gitignore b/Ahmad/2_puzzles/.gitignore new file mode 100644 index 0000000..e10e727 --- /dev/null +++ b/Ahmad/2_puzzles/.gitignore @@ -0,0 +1 @@ +/.metadata/ diff --git a/Darby/Servers/.project b/Ahmad/2_puzzles/.project similarity index 88% rename from Darby/Servers/.project rename to Ahmad/2_puzzles/.project index 0fa764d..84e37cf 100644 --- a/Darby/Servers/.project +++ b/Ahmad/2_puzzles/.project @@ -1,6 +1,6 @@ - Servers + puzzles_2 diff --git a/Ahmad/2_puzzles/assignment_01/.classpath b/Ahmad/2_puzzles/assignment_01/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Darby/spring-demo-one/.gitignore b/Ahmad/2_puzzles/assignment_01/.gitignore similarity index 100% rename from Darby/spring-demo-one/.gitignore rename to Ahmad/2_puzzles/assignment_01/.gitignore diff --git a/Ahmad/2_puzzles/assignment_01/.project b/Ahmad/2_puzzles/assignment_01/.project new file mode 100644 index 0000000..d85502a --- /dev/null +++ b/Ahmad/2_puzzles/assignment_01/.project @@ -0,0 +1,17 @@ + + + assignment_01 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Darby/spring-demo-one/.settings/org.eclipse.m2e.core.prefs b/Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.m2e.core.prefs similarity index 100% rename from Darby/spring-demo-one/.settings/org.eclipse.m2e.core.prefs rename to Ahmad/2_puzzles/assignment_01/.settings/org.eclipse.m2e.core.prefs diff --git a/Darby/spring-demo-one/pom.xml b/Ahmad/2_puzzles/assignment_01/pom.xml similarity index 100% rename from Darby/spring-demo-one/pom.xml rename to Ahmad/2_puzzles/assignment_01/pom.xml diff --git a/Darby/spring-demo-one/src/beanScope-applicationContext.xml b/Ahmad/2_puzzles/assignment_01/src/beanScope-applicationContext.xml similarity index 100% rename from Darby/spring-demo-one/src/beanScope-applicationContext.xml rename to Ahmad/2_puzzles/assignment_01/src/beanScope-applicationContext.xml diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/BeanScopeDemoApp.java b/Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/BeanScopeDemoApp.java similarity index 100% rename from Darby/spring-demo-one/src/com/luv2code/springdemo/BeanScopeDemoApp.java rename to Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/BeanScopeDemoApp.java diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/RandomFortuneService.java b/Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/RandomFortuneService.java similarity index 100% rename from Darby/spring-demo-one/src/com/luv2code/springdemo/RandomFortuneService.java rename to Ahmad/2_puzzles/assignment_01/src/com/luv2code/springdemo/RandomFortuneService.java diff --git a/Ahmad/2_puzzles/assignment_02/.classpath b/Ahmad/2_puzzles/assignment_02/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_02/.gitignore b/Ahmad/2_puzzles/assignment_02/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_02/.project b/Ahmad/2_puzzles/assignment_02/.project new file mode 100644 index 0000000..721d129 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.project @@ -0,0 +1,17 @@ + + + assignment_02 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java b/Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java new file mode 100644 index 0000000..13acb2b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/src/assignment_02/App.java @@ -0,0 +1,59 @@ +package assignment_02; + +import ignore.TestingUtils; + +public class App { + + + /** + * You are driving a little too fast, and a police officer stops you. + * Write code to compute the fine you would have to pay. + * If your speed is 60 or less, the result is 0 since there is no fine. + * If speed is between 61 and 80 inclusive, the fine is 100 dollars. + * If speed is 81 or more, the result is 200. + * Unless it is a holiday -- on that day, your speed can be 5 higher in all cases.
+ *
+ * + * EXPECTATIONS:
+ speedingFine(60, false) ---> 0
+ speedingFine (65, false) ---> 100
+ speedingFine (65, true) ---> 0
+ */ + public static int speedingFine(int speed, boolean isHoliday) { + + + int min = 60; + int max = 80; + int fine = 0; + + if (isHoliday == true) { + min += 5; + max += 5; + } + + if (speed > max){ + fine = 200; + } + if(speed > min && speed <= max) { + fine = 100; + } + + return fine; + } + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } + + +} diff --git a/Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java new file mode 100644 index 0000000..b905171 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_02/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_02.App; + +public class TestingUtils { + public static void runTests(){ + + + int [] params1 = {60,65,65,80,85,85,70,75,75,40,40,90}; + + boolean[] params2 = { false, false, true, false, false, true, false, false, true, false, true, false }; + + int[] expected = { 0, 100, 0, 100, 200, 100, 100, 100, 100, 0, 0, 200 }; + + for(int i=0; i < params1.length; i++){ + int result = App.speedingFine(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object expected, Object result){ + return "PASS: speedingFine("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: speedingFine("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_03/.classpath b/Ahmad/2_puzzles/assignment_03/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_03/.gitignore b/Ahmad/2_puzzles/assignment_03/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_03/.project b/Ahmad/2_puzzles/assignment_03/.project new file mode 100644 index 0000000..7b70b77 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.project @@ -0,0 +1,17 @@ + + + assignment_03 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java b/Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java new file mode 100644 index 0000000..c595390 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/src/assignment_03/App.java @@ -0,0 +1,39 @@ +package assignment_03; + +import ignore.TestingUtils; + +public class App { + + + /** + * Given three ints, a b c, return true if it is possible to add two of + * the ints to get the third. There should only be a single line of code in the method body.
+ *
+ * + * EXPECTATIONS:
+ twoSumOne(1, 2, 3) ---> true
+ twoSumOne(3, 1, 2) ---> true
+ twoSumOne(3, 2, 2) ---> false
+ */ + public static boolean twoSumOne(int a, int b, int c) { + + return (a + b == c) || (b + c == a) || (a + c == b); + + } + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } + + +} diff --git a/Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java new file mode 100644 index 0000000..095c61b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_03/src/ignore/TestingUtils.java @@ -0,0 +1,39 @@ +package ignore; + +import assignment_03.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 3, 3, 2, 5, 5, 2, 9, 9, 5, 3, 3 }; + + int[] params2 = { 2, 1, 2, 3, 3, 3, 5, 5, 4, 4, 3, 3 }; + + int[] params3 = { 3, 2, 2, 1, -2, -3, 3, 5, 5, 9, 0, 2 }; + + boolean[] expected = { true, true, false, true, true, false, true, false, true, true, true, false }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.twoSumOne(params1[i], params2[i], params3[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ + return "PASS: twoSumOne("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: twoSumOne("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_04/.classpath b/Ahmad/2_puzzles/assignment_04/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_04/.gitignore b/Ahmad/2_puzzles/assignment_04/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_04/.project b/Ahmad/2_puzzles/assignment_04/.project new file mode 100644 index 0000000..05868e0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.project @@ -0,0 +1,17 @@ + + + assignment_04 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java b/Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java new file mode 100644 index 0000000..1ba3c70 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/src/assignment_04/App.java @@ -0,0 +1,52 @@ +package assignment_04; + +import ignore.TestingUtils; + +public class App { + + /** + The birds in Florida like to sing during favorable temperatures. + In particular, they sing if the temperature is between 60 and 90 (inclusive). + Unless it is summer, then the upper limit is 100 instead of 90. + Given an int temperature and a boolean isSummer, + return true if the birds are singing and false otherwise.
+
+ + * EXPECTATIONS:
+ birdsSinging(70, false) ---> true
+ birdsSinging(95, false) ---> false
+ birdsSinging(95, true) ---> true
+ */ + public static boolean birdsSinging(int temp, boolean isSummer) { + + int min = 60; + int max = 90; + boolean singing = false; + + if (isSummer) { + max += 10; + } + + if (temp >= min && temp <= max) { + singing = true; + } + + + return singing; + } + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } +} + + diff --git a/Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java new file mode 100644 index 0000000..3130948 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_04/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_04.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 70, 95, 95, 90, 90, 50, 50, 100, 100, 105, 59, 59, 60 }; + + boolean[] params2 = { false, false, true, false, true, false, true, false, true, true, false, true, false }; + + boolean[] expected = { true, false, true, true, true, false, false, false, true, false, false, false, true }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.birdsSinging(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object expected, Object result){ + return "PASS: birdsSinging("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: birdsSinging("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_05/.classpath b/Ahmad/2_puzzles/assignment_05/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_05/.gitignore b/Ahmad/2_puzzles/assignment_05/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_05/.project b/Ahmad/2_puzzles/assignment_05/.project new file mode 100644 index 0000000..3ddfb2c --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.project @@ -0,0 +1,17 @@ + + + assignment_05 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java b/Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java new file mode 100644 index 0000000..361f3b3 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/src/assignment_05/App.java @@ -0,0 +1,54 @@ +package assignment_05; + +import ignore.TestingUtils; + +public class App { + + /** + Given three ints, first, second, third, + return true if second is greater than first, and third is greater than second. + + However, with the exception that if the parameter "itsOk" is true, + second does not need to be greater than first but still better be less than third. +
+
+ + * EXPECTATIONS:
+ isOrdered(1, 2, 4, false) ---> true
+ isOrdered(1, 2, 1, false) ---> false
+ isOrdered(1, 1, 2, true) ---> true
+ */ + public static boolean isOrdered(int first, int second, int third, boolean itsOk) { + + boolean value = (itsOk) ? (second < third) : (second > first && third > second); + +// boolean ordered = false; +// +// if(!itsOk && second > first && third > second) { +// ordered = true; +// } +// if(itsOk && second < third) { +// ordered = true; +// } + + + return value; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } +} + + diff --git a/Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java new file mode 100644 index 0000000..b5185ec --- /dev/null +++ b/Ahmad/2_puzzles/assignment_05/src/ignore/TestingUtils.java @@ -0,0 +1,41 @@ +package ignore; + +import assignment_05.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 1, 1, 3, 2, 3, 4, 4, 2, 7, 7, 7 }; + + int[] params2 = { 2, 2, 1, 2, 3, 2, 2, 5, 4, 9, 5, 5 }; + + int[] params3 = { 4, 1, 2, 4, 4, 4, 2, 2, 6, 10, 6, 4 }; + + boolean[] params4 = { false, false, true, false, false, true, true, true, true, false, true, true }; + + boolean[] expected = { true, false, true, false, true, true, false, false, true, true, true, false }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.isOrdered(params1[i], params2[i], params3[i], params4[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i],params3[i], params4[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], params4[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object params4, Object expected, Object result){ + return "PASS: isOrdered("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+", "+ params4.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object params4, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: isOrdered("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+", "+ params4.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_06/.classpath b/Ahmad/2_puzzles/assignment_06/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_06/.gitignore b/Ahmad/2_puzzles/assignment_06/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_06/.project b/Ahmad/2_puzzles/assignment_06/.project new file mode 100644 index 0000000..97391bf --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.project @@ -0,0 +1,17 @@ + + + assignment_06 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java new file mode 100644 index 0000000..5ab7e6d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/src/assignment_06/App.java @@ -0,0 +1,48 @@ +package assignment_06; + +import ignore.TestingUtils; + +public class App { + + /** + We'll say a number is cool if it's a multiple of 11 or if it is one more than a multiple of 11. + Return true if the given non-negative number is cool. Use the % "modulus" operator + we spoke about in the prerequisite section. Watch the lesson on modulus if you need to review +
+
+ + * EXPECTATIONS:
+ isCool(22) ---> true
+ isCool(23) ---> true
+ isCool(24) ---> false
+ */ + public static boolean isCool(int n) { + + boolean cool = false; + + if(n % 11 == 0 || n % 11 == 1) { + cool = true; + } + + return cool; + } + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + + diff --git a/Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java new file mode 100644 index 0000000..63f9a10 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_06/src/ignore/TestingUtils.java @@ -0,0 +1,35 @@ +package ignore; + +import assignment_06.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 22, 23, 24, 21, 11, 12, 10, 9, 8, 0, 1, 2, 121, 122, 123, 46, 49, 52, 54, 55 }; + boolean[] expected = { true, true, false, false, true, true, false, false, false, true, true, false, true, true, + false, false, false, false, false, true }; + + for(int i=0; i < params1.length; i++){ + boolean result = App.isCool(params1[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: isCool("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: isCool("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_07/.classpath b/Ahmad/2_puzzles/assignment_07/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_07/.gitignore b/Ahmad/2_puzzles/assignment_07/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_07/.project b/Ahmad/2_puzzles/assignment_07/.project new file mode 100644 index 0000000..75ef8a6 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.project @@ -0,0 +1,17 @@ + + + assignment_07 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java new file mode 100644 index 0000000..d76c8fa --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/src/assignment_07/App.java @@ -0,0 +1,53 @@ +package assignment_07; + +import ignore.TestingUtils; + +public class App { + + /** + Given an int n, return the string form of the number followed by "!". + So if the int is for example 13 this method should return "13!". + However the catch is that if the number is divisible by 3 the method should return "Fizz!" + instead of the number, and if the number is divisible by 5 it should return "Buzz!", + and if divisible by both 3 and 5, use "FizzBuzz!". You’ll need to use the % "mod" + for computing the remainder after division, so 23 % 10 yields 3. + +
+
+ + * EXPECTATIONS:
+ fizzyWizzy(1) ---> "1!"
+ fizzyWizzy(2) ---> "2!"
+ fizzyWizzy(3) ---> "Fizz!"
+ */ + public static String fizzyWizzy(int n) { + + boolean fizz = n % 3 == 0; + boolean buzz = n % 5 ==0; + + if(fizz & buzz) return "FizzBuzz!"; + if(fizz) return "Fizz!"; + if(buzz) return "Buzz!"; + + return n + "!"; + } + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + + diff --git a/Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java new file mode 100644 index 0000000..e91cf46 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_07/src/ignore/TestingUtils.java @@ -0,0 +1,35 @@ +package ignore; + +import assignment_07.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 18, 19, 21, 44, 45, 100 }; + String[] expected = { "1!", "2!", "Fizz!", "4!", "Buzz!", "Fizz!", "7!", "8!", "Fizz!", "FizzBuzz!", "16!", + "Fizz!", "19!", "Fizz!", "44!", "FizzBuzz!", "Buzz!" }; + + for(int i=0; i < params1.length; i++){ + String result = App.fizzyWizzy(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: fizzyWizzy("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: fizzyWizzy("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_08/.classpath b/Ahmad/2_puzzles/assignment_08/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_08/.gitignore b/Ahmad/2_puzzles/assignment_08/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_08/.project b/Ahmad/2_puzzles/assignment_08/.project new file mode 100644 index 0000000..1d1e6db --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.project @@ -0,0 +1,17 @@ + + + assignment_08 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java new file mode 100644 index 0000000..f923aab --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/src/assignment_08/App.java @@ -0,0 +1,48 @@ +package assignment_08; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given 3 int arguments - a, b, c, return their sum. However, if one of the arguments + is the same as any of the other ones, that number should not count towards the sum. + So basically you only sum unique numbers, not duplicates +
+
+ + * EXPECTATIONS:
+ sumUnique(1, 2, 3) ---> 6
+ sumUnique(3, 2, 3) ---> 2
+ sumUnique(3, 3, 3) ---> 0
+ */ + + public static int sumUnique(int a, int b, int c) { + + if (a == b && b ==c) {return 0;}; + if ( a == b ) {return c;}; + if ( a == c ) {return b;}; + if ( b == c ) {return a;}; + + return a + b + c; + + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java new file mode 100644 index 0000000..9d3ecbe --- /dev/null +++ b/Ahmad/2_puzzles/assignment_08/src/ignore/TestingUtils.java @@ -0,0 +1,39 @@ +package ignore; + +import assignment_08.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 1, 3, 3, 9, 2, 2, 2, 4, 1 }; + + int[] params2 = { 2, 2, 3, 2, 2, 9, 9, 2, 3 }; + + int[] params3 = { 3, 3, 3, 2, 9, 2, 3, 3, 1 }; + + int[] expected = { 6, 2, 0, 9, 9, 9, 14, 9, 3 }; + + for(int i=0; i < params1.length; i++){ + int result = App.sumUnique(params1[i], params2[i], params3[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ + return "PASS: sumUnique("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: sumUnique("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_09/.classpath b/Ahmad/2_puzzles/assignment_09/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_09/.gitignore b/Ahmad/2_puzzles/assignment_09/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_09/.project b/Ahmad/2_puzzles/assignment_09/.project new file mode 100644 index 0000000..41d732d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.project @@ -0,0 +1,17 @@ + + + assignment_09 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java b/Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java new file mode 100644 index 0000000..2a9b52e --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/src/assignment_09/App.java @@ -0,0 +1,50 @@ +package assignment_09; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given 2 positive int arguments (a, b), return whichever argument is + nearest to the number 21 without going over. + Return 0 if they both go over 21. +
+
+ + * EXPECTATIONS:
+ nearestTwentyOne(19, 21) ---> 21
+ nearestTwentyOne(21, 19) ---> 21
+ nearestTwentyOne(19, 22) ---> 19
+ nearestTwentyOne(32, 22) ---> 0
+ */ + + public static int nearestTwentyOne(int a, int b) { + + if(a > 21 && b > 21) return 0; + if(a > 21 && b <- 21) return b; + if(a <= 21 && b > 21) return a; + + if (a > b) + return a; + else + return b; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java new file mode 100644 index 0000000..9123745 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_09/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_09.App; + +public class TestingUtils { + public static void runTests(){ + + + int[] params1 = { 19, 21, 19, 22, 22, 22, 33, 1, 34, 17, 18, 16, 3, 3, 21 }; + + int[] params2 = { 21, 19, 22, 19, 50, 22, 1, 2, 33, 19, 17, 23, 4, 2, 20 }; + + int[] expected = { 21, 21, 19, 19, 0, 0, 1, 2, 0, 19, 18, 16, 4, 3, 21 }; + + for(int i=0; i < params1.length; i++){ + int result = App.nearestTwentyOne(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object expected, Object result){ + return "PASS: nearestTwentyOne("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: nearestTwentyOne("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_10/.classpath b/Ahmad/2_puzzles/assignment_10/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_10/.gitignore b/Ahmad/2_puzzles/assignment_10/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_10/.project b/Ahmad/2_puzzles/assignment_10/.project new file mode 100644 index 0000000..b1f6869 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.project @@ -0,0 +1,17 @@ + + + assignment_10 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java b/Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java new file mode 100644 index 0000000..96df596 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/src/assignment_10/App.java @@ -0,0 +1,60 @@ +package assignment_10; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given 3 int arguments, a b c, return their sum. However, if one of the arguments is 13 + then it does not count towards the sum and arguments to it's right do not count either. + So for example, if b is 13, then both b and c do not count. +
+
+ + * EXPECTATIONS:
+ partialSum(1, 2, 3) ---> 6
+ partialSum(1, 2, 13) ---> 3
+ partialSum(1, 13, 3) ---> 1
+ */ + + public static int partialSum(int a, int b, int c) { + +// int sum = 0; +// int[] nums = {a, b, c}; +// +// for (int i = 0; i < nums.length; i++) { +// if (nums[i] == 13) { +// break; +// } +// sum += nums[i]; +// } +// +// +// return sum; + + if (a == 13) return 0; + if (b == 13) return a; + if (c == 13) return a + b; + + return a + b + c; + + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java new file mode 100644 index 0000000..6bfb20b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_10/src/ignore/TestingUtils.java @@ -0,0 +1,38 @@ +package ignore; + +import assignment_10.App; + +public class TestingUtils { + public static void runTests(){ + + int[] params1 = { 1, 1, 1, 1, 6, 13, 13, 13, 9, 8, 7, 3 }; + + int[] params2 = { 2, 2, 13, 13, 5, 2, 2, 13, 4, 13, 2, 3 }; + + int[] params3 = { 3, 13, 3, 13, 2, 3, 13, 2, 13, 2, 1, 13 }; + + int[] expected = { 6, 3, 1, 1, 13, 0, 0, 0, 13, 8, 10, 6 }; + + for(int i=0; i < params1.length; i++){ + int result = App.partialSum(params1[i], params2[i], params3[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], params3[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], params3[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object params3, Object expected, Object result){ + return "PASS: partialSum("+ params1.toString()+ ", "+ params2.toString()+ ", "+ params3.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object params3, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: partialSum("+ params1.toString()+ ", "+ params2.toString()+", "+ params3.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_11/.classpath b/Ahmad/2_puzzles/assignment_11/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_11/.gitignore b/Ahmad/2_puzzles/assignment_11/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_11/.project b/Ahmad/2_puzzles/assignment_11/.project new file mode 100644 index 0000000..7eb9a73 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.project @@ -0,0 +1,17 @@ + + + assignment_11 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_11/src/assignment_11/App.java b/Ahmad/2_puzzles/assignment_11/src/assignment_11/App.java new file mode 100644 index 0000000..0229858 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_11/src/assignment_11/App.java @@ -0,0 +1,46 @@ +package assignment_11; + +import ignore.TestingUtils; + +public class App { + + + /** + + Given a string, return a string where for every char in the original, append another. +
+
+ + * EXPECTATIONS:
+ repeatChar("The") --->"TThhee"
+ repeatChar("AAbb") ---> "AAAAbbbb"
+ repeatChar("Hi-There") ---> "HHii--TThheerree"
+ */ + + public static String repeatChar(String str) { + String result = ""; + + for(int i =0; i " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: repeatChar("+ params1.toString()+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_12/.classpath b/Ahmad/2_puzzles/assignment_12/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_12/.gitignore b/Ahmad/2_puzzles/assignment_12/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_12/.project b/Ahmad/2_puzzles/assignment_12/.project new file mode 100644 index 0000000..c5b011e --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.project @@ -0,0 +1,17 @@ + + + assignment_12 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_12/src/assignment_12/App.java b/Ahmad/2_puzzles/assignment_12/src/assignment_12/App.java new file mode 100644 index 0000000..b023a78 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/src/assignment_12/App.java @@ -0,0 +1,60 @@ +package assignment_12; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Return a version of the given string, where for every star (*) + in the string the star and the chars immediately to its left and right are gone. + So "ab*cd" yields "ad" and "ab**cd" also yields "ad".
+
+ + * EXPECTATIONS:
+ starKill("cd*zq") --->"cq"
+ starKill("ab**cd") ---> "ad"
+ starKill("wacy*xko") ---> "wacko"
+ */ + + public static String starKill(String str) { + + int len = str.length(); + String result = ""; + + for(int i = 0; i < len; i++) { + + if( i == 0 && str.charAt(i) != '*') { + result += str.charAt(i); + } + + if( i > 0 && str.charAt(i) != '*' && str.charAt(i - 1) != '*' ) { + result += str.charAt(i); + } + + if(i > 0 && str.charAt(i) == '*' && str.charAt(i-1) != '*') + result = result.substring(0, result.length() -1); + } + + return result; + + } + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_12/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_12/src/ignore/TestingUtils.java new file mode 100644 index 0000000..44664a1 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_12/src/ignore/TestingUtils.java @@ -0,0 +1,36 @@ +package ignore; + +import assignment_12.App; + +public class TestingUtils { + public static void runTests(){ + + String[] params1 = { "ab*cd", "ab**cd", "sm*eilly", "sm*eil*ly", "sm**eil*ly", "sm***eil*ly", "stringy*", + "*stringy", "*str*in*gy", "abc", "a*bc", "ab", "a*b", "a", "a*", "*a", "*", "" }; + + String[] expected = { "ad", "ad", "silly", "siy", "siy", "siy", "string", "tringy", "ty", "abc", "c", "ab", "", + "a", "", "", "", "" }; + + for(int i=0; i < params1.length; i++){ + String result = App.starKill(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: starKill("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: starKill("+ params1.toString()+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_13/.classpath b/Ahmad/2_puzzles/assignment_13/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_13/.gitignore b/Ahmad/2_puzzles/assignment_13/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_13/.project b/Ahmad/2_puzzles/assignment_13/.project new file mode 100644 index 0000000..46bb0f6 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.project @@ -0,0 +1,17 @@ + + + assignment_13 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_13/src/assignment_13/App.java b/Ahmad/2_puzzles/assignment_13/src/assignment_13/App.java new file mode 100644 index 0000000..5f8dcfd --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/src/assignment_13/App.java @@ -0,0 +1,47 @@ +package assignment_13; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given an array of strings, return the count of the number of strings with the given length
+
+ + * EXPECTATIONS:
+ wordsCount({"a", "bb", "b", "ccc"}, 1) ---> 2
+ wordsCount({"a", "bb", "b", "ccc"}, 3) ---> 1
+ wordsCount({"a", "bb", "b", "ccc"}, 4) ---> 0
+ */ + + public static int wordsCount(String[] words, int len) { + + int count = 0; + + for(int i = 0; i < words.length; i++) { + + if (words[i].length() == len) + count += 1; + } + + return count; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_13/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_13/src/ignore/TestingUtils.java new file mode 100644 index 0000000..b6c1c0b --- /dev/null +++ b/Ahmad/2_puzzles/assignment_13/src/ignore/TestingUtils.java @@ -0,0 +1,41 @@ +package ignore; + +import java.util.Arrays; + +import assignment_13.App; + +public class TestingUtils { + public static void runTests(){ + + String[] [] params1 = { { "a", "bb", "b", "ccc" }, { "a", "bb", "b", "ccc" }, { "a", "bb", "b", "ccc" }, + { "xx", "yyy", "x", "yy", "z" }, { "xx", "yyy", "x", "yy", "z" }, { "xx", "yyy", "x", "yy", "z" } }; + + int [] params2 = {1,3,4,1,2,3}; + + int[] expected = { 2, 1, 0, 2, 2, 1 }; + + for(int i=0; i < params1.length; i++){ + int result = App.wordsCount(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(String[] params1, Object params2, Object expected, Object result){ + String str = ""; + + return "PASS: wordsCount("+Arrays.toString(params1)+", "+ params2+ ") -> " + result.toString(); + } + + + private static String printFailResult(String[] params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: wordsCount("+Arrays.toString(params1)+", "+ params2+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_14/.classpath b/Ahmad/2_puzzles/assignment_14/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_14/.gitignore b/Ahmad/2_puzzles/assignment_14/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_14/.project b/Ahmad/2_puzzles/assignment_14/.project new file mode 100644 index 0000000..15f497d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.project @@ -0,0 +1,17 @@ + + + assignment_14 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_14/src/assignment_14/App.java b/Ahmad/2_puzzles/assignment_14/src/assignment_14/App.java new file mode 100644 index 0000000..726763c --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/src/assignment_14/App.java @@ -0,0 +1,56 @@ +package assignment_14; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given 2 arrays that are the same length containing strings, compare the 1st string in one array + to the 1st string in the other array, the 2nd to the 2nd and so on. + Count the number of times that the 2 strings are non-empty and start with the same char. + The strings may be any length, including 0. +
+
+ + * EXPECTATIONS:
+ matchingChar({"aa", "bb", "cc"}, {"aaa", "xx", "bb"}) ---> 1
+ matchingChar({"aa", "bb", "cc"}, {"aaa", "b", "bb"}) ---> 2
+ matchingChar({"aa", "bb", "cc"}, {"", "", "ccc"}) ---> 1
+ */ + + public static int matchingChar(String[] a, String[] b) { + + int count = 0; + + for (int i = 0; i < a.length; i++) { + String str1 = a[i]; + String str2 = b[i]; + + if(!str1.equals("") && !str2.equals("")) { + if(str1.charAt(0) == str2.charAt(0)) + count++; + } + } + + + return count; + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} diff --git a/Ahmad/2_puzzles/assignment_14/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_14/src/ignore/TestingUtils.java new file mode 100644 index 0000000..2f452c6 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_14/src/ignore/TestingUtils.java @@ -0,0 +1,45 @@ +package ignore; + +import java.util.Arrays; + +import assignment_14.App; + +public class TestingUtils { + public static void runTests(){ + + String[][] params1 = { { "aa", "bb", "cc" }, { "aa", "bb", "cc" }, { "aa", "bb", "cc" }, { "", "", "ccc" }, + { "", "", "" }, { "aa", "bb", "cc" }, { "aa", "", "ccc" }, { "x", "y", "z" }, { "", "y", "z" }, + { "x", "y", "z" }, { "x", "y", "z" }, { "b", "x", "y", "z" }, { "aaa", "bb", "c" } }; + + String[][] params2 = { { "aaa", "xx", "bb" }, { "aaa", "b", "bb" }, { "", "", "ccc" }, { "aa", "bb", "cc" }, + { "", "bb", "cc" }, { "", "", "" }, { "", "bb", "cc" }, { "y", "z", "x" }, { "", "y", "x" }, + { "xx", "yyy", "zzz" }, { "xx", "yyy", "" }, { "a", "xx", "yyy", "zzz" }, { "aaa", "xx", "bb" } }; + + + int[] expected = { 1, 2, 1, 1, 0, 0, 1, 0, 1, 3, 2, 3, 1 }; + + for(int i=0; i < params1.length; i++){ + int result = App.matchingChar(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(String[] params1, String[] params2, Object expected, Object result){ + String str = ""; + + return "PASS: matchingChar("+Arrays.toString(params1)+", "+ Arrays.toString(params2)+ ") -> " + result.toString(); + } + + + private static String printFailResult(String[] params1, String[] params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: matchingChar("+Arrays.toString(params1)+", "+ Arrays.toString(params2)+") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_15/.classpath b/Ahmad/2_puzzles/assignment_15/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_15/.gitignore b/Ahmad/2_puzzles/assignment_15/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_15/.project b/Ahmad/2_puzzles/assignment_15/.project new file mode 100644 index 0000000..ce2a280 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.project @@ -0,0 +1,17 @@ + + + assignment_15 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_15/src/assignment_15/App.java b/Ahmad/2_puzzles/assignment_15/src/assignment_15/App.java new file mode 100644 index 0000000..2c58417 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/src/assignment_15/App.java @@ -0,0 +1,59 @@ +package assignment_15; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given a string, return the length of the longest streak of the same chars in the string. + +
+
+ + * EXPECTATIONS:
+ longestStreak("hayyeu") ---> 2
+ longestStreak("XPNzzzddOOOxx") ---> 3
+ longestStreak("") ---> 0
+ */ + + public static int longestStreak(String str) { + + int max = 0; + + + + for (int i = 0; i < str.length(); i++) { + int count = 0; + + for(int j = i; j < str.length(); j++) { + if(str.charAt(i) == str.charAt(j)) + count++; + else + break; + } + if (count > max) + max = count; + } + return max; + + } + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_15/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_15/src/ignore/TestingUtils.java new file mode 100644 index 0000000..a6e9675 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_15/src/ignore/TestingUtils.java @@ -0,0 +1,36 @@ +package ignore; + +import assignment_15.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "hoopla", "abbCCCddBBBxx", "", "xyz", "xxyz", "xyzz", "abbbcbbbxbbbx", "XXBBBbbxx", + "XXBBBBbbxx", "XXBBBbbxxXXXX", "XX2222BBBbbXX2222" }; + + int[] expected = { 2, 3, 0, 1, 2, 2, 3, 3, 4, 4, 4 }; + + for(int i=0; i < params1.length; i++){ + int result = App.longestStreak(params1[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: longestStreak("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: longestStreak("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_16/.classpath b/Ahmad/2_puzzles/assignment_16/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_16/.gitignore b/Ahmad/2_puzzles/assignment_16/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_16/.project b/Ahmad/2_puzzles/assignment_16/.project new file mode 100644 index 0000000..5eff228 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.project @@ -0,0 +1,17 @@ + + + assignment_16 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_16/src/assignment_16/App.java b/Ahmad/2_puzzles/assignment_16/src/assignment_16/App.java new file mode 100644 index 0000000..481c44a --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/src/assignment_16/App.java @@ -0,0 +1,60 @@ +package assignment_16; + +import ignore.TestingUtils; + +public class App { + + + /** + * + Given a string, compute recursively (no loops) the number of times + lowercase "yo" appears in the string. +
+
+ + * EXPECTATIONS:
+ yoYo("xhyoxx") ---> 1
+ yoYo("nyonnyon")---> 2
+ yoYo("yo") ---> 1
+ */ + + public static int yoYo(String str) { + +// int count = 0; +// for (int i = 0; i < str.length() -1; i++) { +// if(str.charAt(i) == 'y' && str.charAt(i+1) == 'o') +// count++; +// } +// return count; + + + if(str.length() < 2) + return 0; + + if(str.substring(0, 2).equals("yo")) + return 1 + yoYo(str.substring(1)); + + else + + return yoYo(str.substring(1)); + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_16/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_16/src/ignore/TestingUtils.java new file mode 100644 index 0000000..dcd2da7 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_16/src/ignore/TestingUtils.java @@ -0,0 +1,36 @@ +package ignore; + +import assignment_16.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "xxyoxx", "yyoxyoy", "yo", "yoyoy", "y", "", "oyoyoyoyoy", + "oyoyoyoyoyo", "yoAAyo12yo", "xyoxhxiyohhyoh", "yogurt"}; + + int[] expected = { 1, 2, 1, 2, 0, 0, 4, 5, 3, 3, 1 }; + + for(int i=0; i < params1.length; i++){ + int result = App.yoYo(params1[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: yoYo("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: yoYo("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_17/.classpath b/Ahmad/2_puzzles/assignment_17/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_17/.gitignore b/Ahmad/2_puzzles/assignment_17/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_17/.project b/Ahmad/2_puzzles/assignment_17/.project new file mode 100644 index 0000000..93a391d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.project @@ -0,0 +1,17 @@ + + + assignment_17 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_17/src/assignment_17/App.java b/Ahmad/2_puzzles/assignment_17/src/assignment_17/App.java new file mode 100644 index 0000000..f094dae --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/src/assignment_17/App.java @@ -0,0 +1,55 @@ +package assignment_17; + +import ignore.TestingUtils; + +public class App { + + + /** + * + + Given a string, compute recursively a new string where all the + lowercase 'o' chars have been moved to the end of the string. + +
+
+ + * EXPECTATIONS:
+ endoo("oore") ---> reoo
+ endoo("oohoi") ---> hiooo
+ endoo("oanotgo") ---> antgooo
+ */ + + public static String endoo(String str) { + + // complete the body of this method + if(str.equals("")) + return str; + + if(str.charAt(0) == 'o') + return endoo(str.substring(1)) + 'o'; + + else + return str.charAt(0) + endoo(str.substring(1)); + + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_17/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_17/src/ignore/TestingUtils.java new file mode 100644 index 0000000..9268991 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_17/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_17.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "oore", "oohioo", "ohiohio", "hiy", "h", "", "o", + "oo", "boo", "boao", "aoaoao", "oohoi", "oanotgo"}; + + String[] expected = { "reoo", "hioooo", "hihiooo", "hiy", "h", "", "o", + "oo", "boo", "baoo", "aaaooo", "hiooo", "antgooo" }; + + for(int i=0; i < params1.length; i++){ + String result = App.endoo(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: endoo("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: endoo("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_18/.classpath b/Ahmad/2_puzzles/assignment_18/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_18/.gitignore b/Ahmad/2_puzzles/assignment_18/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_18/.project b/Ahmad/2_puzzles/assignment_18/.project new file mode 100644 index 0000000..a47c0f3 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.project @@ -0,0 +1,17 @@ + + + assignment_18 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_18/src/assignment_18/App.java b/Ahmad/2_puzzles/assignment_18/src/assignment_18/App.java new file mode 100644 index 0000000..6f0e0ab --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/src/assignment_18/App.java @@ -0,0 +1,55 @@ +package assignment_18; + +import ignore.TestingUtils; + +public class App { + + + /** + * + + Given a string, compute recursively a new string where identical chars + that are adjacent in the original string are separated from each other by a "-". + +
+
+ + * EXPECTATIONS:
+ repeatHyphen("hello") ---> hel-lo
+ repeatHyphen("xxyy") ---> x-xy-y
+ repeatHyphen("aaaa") ---> a-a-a-a
+ */ + + public static String hyphenSplit(String str) { + + // complete the body of this method + if(str.length() < 2) { + return str; + } + + if(str.charAt(0) == str.charAt(1)) { + return str.charAt(0) + "-" + hyphenSplit(str.substring(1)); + } + + return str.charAt(0) + hyphenSplit(str.substring(1)); + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_18/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_18/src/ignore/TestingUtils.java new file mode 100644 index 0000000..c19f5d8 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_18/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_18.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "hello", "xxyy", "aaaa", "aaab", "aa", "a", "", + "noadjacent", "abba", "abbba"}; + + String[] expected = { "hel-lo", "x-xy-y", "a-a-a-a", "a-a-ab", "a-a", "a", "", + "noadjacent", "ab-ba", "ab-b-ba"}; + + for(int i=0; i < params1.length; i++){ + String result = App.hyphenSplit(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: hyphenSplit("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: hyphenSplit("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_19/.classpath b/Ahmad/2_puzzles/assignment_19/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_19/.gitignore b/Ahmad/2_puzzles/assignment_19/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_19/.project b/Ahmad/2_puzzles/assignment_19/.project new file mode 100644 index 0000000..24241d2 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.project @@ -0,0 +1,17 @@ + + + assignment_19 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_19/src/assignment_19/App.java b/Ahmad/2_puzzles/assignment_19/src/assignment_19/App.java new file mode 100644 index 0000000..a90646f --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/src/assignment_19/App.java @@ -0,0 +1,53 @@ +package assignment_19; + +import ignore.TestingUtils; + +public class App { + + + /** + * + + Given a string that contains a single pair of brackets, compute recursively a new string made of + only of the brackets and their contents, so "xyz[abc]123" yields "[abc]". + +
+
+ + * EXPECTATIONS:
+ insideBrackets("xyz[abc]123") ---> [abc]
+ insideBrackets("x[hello]") ---> [hello]
+ insideBrackets("[xy]1") ---> [xy]
+ */ + + public static String insideBrackets(String str) { + + // complete the body of this method + if(str.charAt(0) != '[') + return insideBrackets(str.substring(1)); + + if(str.charAt(str.length() - 1) != ']') + return insideBrackets(str.substring(0, str.length() -1)); + + return str; + } + + + + + + + + + + + + + + //----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + + } +} + diff --git a/Ahmad/2_puzzles/assignment_19/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_19/src/ignore/TestingUtils.java new file mode 100644 index 0000000..0245395 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_19/src/ignore/TestingUtils.java @@ -0,0 +1,38 @@ +package ignore; + +import assignment_19.App; + +public class TestingUtils { + public static void runTests(){ + + + String[] params1 = { "xyz[abc]123", "x[hello]", "[xy]1", "not really [possible]", "[abc]", "[abc]xyz", "[abc]x", + "[x]", "[]", "res [ipsa] loquitor", "hello[not really]there", "ab[ab]ab"}; + + String[] expected = { "[abc]", "[hello]", "[xy]", "[possible]", "[abc]", "[abc]", "[abc]", + "[x]", "[]", "[ipsa]", "[not really]", "[ab]"}; + + + for(int i=0; i < params1.length; i++){ + String result = App.insideBrackets(params1[i]); + if(result.equals(expected[i])) { + System.out.println(printPassResult(params1[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object expected, Object result){ + return "PASS: insideBrackets("+ params1.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: insideBrackets("+ params1.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } +} \ No newline at end of file diff --git a/Ahmad/2_puzzles/assignment_n/.classpath b/Ahmad/2_puzzles/assignment_n/.classpath new file mode 100644 index 0000000..57bca72 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/2_puzzles/assignment_n/.gitignore b/Ahmad/2_puzzles/assignment_n/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/2_puzzles/assignment_n/.project b/Ahmad/2_puzzles/assignment_n/.project new file mode 100644 index 0000000..f4c113f --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.project @@ -0,0 +1,17 @@ + + + assignment_n + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.core.resources.prefs b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.jdt.core.prefs b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8c9943d --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/Ahmad/2_puzzles/assignment_n/src/assignment_n/App.java b/Ahmad/2_puzzles/assignment_n/src/assignment_n/App.java new file mode 100644 index 0000000..635bb70 --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/src/assignment_n/App.java @@ -0,0 +1,34 @@ +package assignment_n; + + +import ignore.TestingUtils; + +public class App { + + /** + * Add both parameters (a & b) together and + * subtract the number 3 and return the result
+ *
+ * + * EXPECTATIONS:
+ sumMinus3(2, 5) ---> 4
+ sumMinus3(2, 1) ---> 0
+ sumMinus3(0, 2) ---> -1
+ */ + public static int sumMinus3(int a, int b) { + + return a+b-3; + } + + + + + + + +//----------------------STARTING POINT OF PROGRAM. IGNORE BELOW --------------------// + public static void main(String args[]){ + TestingUtils.runTests(); + } + +} diff --git a/Ahmad/2_puzzles/assignment_n/src/ignore/TestingUtils.java b/Ahmad/2_puzzles/assignment_n/src/ignore/TestingUtils.java new file mode 100644 index 0000000..a659c5f --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/src/ignore/TestingUtils.java @@ -0,0 +1,37 @@ +package ignore; + +import assignment_n.App; + +public class TestingUtils { + + public static void runTests(){ + + int [] params1 = {2,0,7,3,1}; + int [] params2 = {1,3,4,5,2}; + + int [] expected = {0,0,8,5,0}; + + for(int i=0; i < params1.length; i++){ + int result = App.sumMinus3(params1[i], params2[i]); + if(result == expected[i]) { + System.out.println(printPassResult(params1[i], params2[i], expected[i], result)); + } else{ + System.out.println(printFailResult(params1[i], params2[i], expected[i], result)); + } + } + } + + private static String printPassResult(Object params1, Object params2, Object expected, Object result){ + return "PASS: sumMinus3("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString(); + } + + + private static String printFailResult(Object params1, Object params2, Object expected, Object result){ + String ret = "**********************" + "\n"; + ret += "FAIL: sumMinus3("+ params1.toString()+ ", "+ params2.toString()+ ") -> " + result.toString() + + " Expected: "+ expected.toString(); + ret += "\n" + "**********************"; + return ret; + } + +} diff --git a/Ahmad/2_puzzles/assignment_n/src/module-info.java b/Ahmad/2_puzzles/assignment_n/src/module-info.java new file mode 100644 index 0000000..25f26ce --- /dev/null +++ b/Ahmad/2_puzzles/assignment_n/src/module-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * + */ +module assignment_20 { +} \ No newline at end of file diff --git a/Ahmad/cert/.gitignore b/Ahmad/cert/.gitignore new file mode 100644 index 0000000..e10e727 --- /dev/null +++ b/Ahmad/cert/.gitignore @@ -0,0 +1 @@ +/.metadata/ diff --git a/Ahmad/cert/.idea/.gitignore b/Ahmad/cert/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/Ahmad/cert/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/Ahmad/cert/.idea/cert.iml b/Ahmad/cert/.idea/cert.iml new file mode 100644 index 0000000..16e0a48 --- /dev/null +++ b/Ahmad/cert/.idea/cert.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Ahmad/cert/.idea/libraries/lib.xml b/Ahmad/cert/.idea/libraries/lib.xml new file mode 100644 index 0000000..df50372 --- /dev/null +++ b/Ahmad/cert/.idea/libraries/lib.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Ahmad/cert/.idea/misc.xml b/Ahmad/cert/.idea/misc.xml new file mode 100644 index 0000000..c6b6842 --- /dev/null +++ b/Ahmad/cert/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Ahmad/cert/.idea/modules.xml b/Ahmad/cert/.idea/modules.xml new file mode 100644 index 0000000..dadb392 --- /dev/null +++ b/Ahmad/cert/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Ahmad/cert/.idea/vcs.xml b/Ahmad/cert/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/Ahmad/cert/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Ahmad/cert/.idea/workspace.xml b/Ahmad/cert/.idea/workspace.xml new file mode 100644 index 0000000..d8042bf --- /dev/null +++ b/Ahmad/cert/.idea/workspace.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1595522228059 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.lock b/Ahmad/cert/.metadata/.lock new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.mylyn/.repositories.xml.zip b/Ahmad/cert/.metadata/.mylyn/.repositories.xml.zip new file mode 100644 index 0000000..6377e05 Binary files /dev/null and b/Ahmad/cert/.metadata/.mylyn/.repositories.xml.zip differ diff --git a/Ahmad/cert/.metadata/.mylyn/.taskListIndex/segments_1 b/Ahmad/cert/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000..6363afd Binary files /dev/null and b/Ahmad/cert/.metadata/.mylyn/.taskListIndex/segments_1 differ diff --git a/Ahmad/cert/.metadata/.mylyn/.taskListIndex/write.lock b/Ahmad/cert/.metadata/.mylyn/.taskListIndex/write.lock new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.mylyn/.tasks.xml.zip b/Ahmad/cert/.metadata/.mylyn/.tasks.xml.zip new file mode 100644 index 0000000..61a05bc Binary files /dev/null and b/Ahmad/cert/.metadata/.mylyn/.tasks.xml.zip differ diff --git a/Ahmad/cert/.metadata/.mylyn/repositories.xml.zip b/Ahmad/cert/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 0000000..7e1e047 Binary files /dev/null and b/Ahmad/cert/.metadata/.mylyn/repositories.xml.zip differ diff --git a/Ahmad/cert/.metadata/.mylyn/tasks.xml.zip b/Ahmad/cert/.metadata/.mylyn/tasks.xml.zip new file mode 100644 index 0000000..3e32500 Binary files /dev/null and b/Ahmad/cert/.metadata/.mylyn/tasks.xml.zip differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/5065205de6cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/5065205de6cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..ad72333 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/5065205de6cc001a1c9583c41c40e4f0 @@ -0,0 +1,39 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty() == LIMIT) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/80bcf8eb48cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/80bcf8eb48cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..405e519 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/80bcf8eb48cc001a1c9583c41c40e4f0 @@ -0,0 +1,37 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); +// try { +// Thread.sleep(2000); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + inventoryTask.join(); + displayTask.start(); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/e09ccb1e11cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/e09ccb1e11cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..ba69047 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/10/e09ccb1e11cd001a1d8e8781d501fb14 @@ -0,0 +1,44 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + // executor.shutdownNow(); // Terminates the executor immediately.. + + try { + executor.awaitTermination(10, TimeUnit.SECONDS); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + +// while(!executor.isTerminated()) { +// } + + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/12/40717a9086d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/12/40717a9086d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..0155bd1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/12/40717a9086d0001a1a4afd166bbfcbff @@ -0,0 +1,138 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/12/c07b6a694bd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/12/c07b6a694bd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..ce36f20 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/12/c07b6a694bd1001a1a4afd166bbfcbff @@ -0,0 +1,74 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/13/a08c1d8686d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/13/a08c1d8686d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..cc49d2b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/13/a08c1d8686d0001a1a4afd166bbfcbff @@ -0,0 +1,138 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + System.out.println(reverser.work("Vehicle")); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/15/40d11d2a01cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/15/40d11d2a01cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..2acd61e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/15/40d11d2a01cd001a1c9583c41c40e4f0 @@ -0,0 +1,20 @@ +package arrayBlockingQueue; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; + +public class Application { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + BlockingQueue questionQueue = new ArrayBlockingQueue(5); + + Thread t1 = new Thread(new Producer(questionQueue)); + Thread t2 = new Thread(new Consumer(questionQueue)); + + t1.start(); + t2.start(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/16/f03f1e0e4ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/16/f03f1e0e4ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..9844148 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/16/f03f1e0e4ad1001a1a4afd166bbfcbff @@ -0,0 +1,57 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(c -> x.startsWith("C")) + .sorted() + .forEach(x -> System.out.print(x + ", ")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/19/20b84bfc49d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/19/20b84bfc49d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..df7b997 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/19/20b84bfc49d1001a1a4afd166bbfcbff @@ -0,0 +1,57 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(c -> x.startsWith("C")) + .sorted() + .forEach(x -> System.out.print(x + ", ")); + + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1b/8084e906d5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1b/8084e906d5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..aaaf9c1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1b/8084e906d5d0001a1a4afd166bbfcbff @@ -0,0 +1,22 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1d/80ba70df48cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1d/80ba70df48cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..e93ebb2 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1d/80ba70df48cc001a1c9583c41c40e4f0 @@ -0,0 +1,37 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); +// try { +// Thread.sleep(2000); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + inverntoryTask.join(); + displayTask.start(); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1d/d0c833854ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1d/d0c833854ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..2703679 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1d/d0c833854ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractical.files; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("/Lambdas/src/streamsPractical/files/wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1f/00ba3ccf86d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1f/00ba3ccf86d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..d16edbd --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1f/00ba3ccf86d0001a1a4afd166bbfcbff @@ -0,0 +1,142 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface GenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1f/80cfb67e02cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1f/80cfb67e02cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8b1ad3e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/1f/80cfb67e02cd001a1c9583c41c40e4f0 @@ -0,0 +1,5 @@ +package arrayBlockingQueue; + +public class Consumer Implements Runnable { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/20/20ff968a0acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/20/20ff968a0acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..6093aa7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/20/20ff968a0acd001a1d8e8781d501fb14 @@ -0,0 +1,24 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Consumer implements Runnable { + + BlockingQueue questionQueue; + + public Consumer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + while(true) { + try { + System.out.println("ANSWERED QUESTION: " + questionQueue.take()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/23/1023239386d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/23/1023239386d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..a07f6ed --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/23/1023239386d0001a1a4afd166bbfcbff @@ -0,0 +1,139 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(10)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/24/8076394d0acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/24/8076394d0acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..e55c160 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/24/8076394d0acd001a1d8e8781d501fb14 @@ -0,0 +1,23 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Consumer implements Runnable() { + + BlockingQueue questionQueue; + + public Consumer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + questionNo++; + try { + questionQueue.put(questionNo); + } catch (InterruptedException e) { + + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/25/b0371f6a49d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/25/b0371f6a49d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..876b45e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/25/b0371f6a49d1001a1a4afd166bbfcbff @@ -0,0 +1,48 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6 ,8 ,10}) + .map((x) -> x * x) + .average() + ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/26/20a9af3887d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/26/20a9af3887d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..9de4e70 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/26/20a9af3887d0001a1a4afd166bbfcbff @@ -0,0 +1,143 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + //StringWorker reverser = (s) -> { + MyGenericInterface reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface MyGenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/26/805e193ebdcf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/26/805e193ebdcf001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/28/50edfa6a49cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/28/50edfa6a49cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..eec1eb8 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/28/50edfa6a49cc001a1c9583c41c40e4f0 @@ -0,0 +1,33 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); +// Thread.sleep(2000); +// inventoryTask.join(); + + displayTask.start(); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/28/a021ec7dd5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/28/a021ec7dd5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..37671aa --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/28/a021ec7dd5d0001a1a4afd166bbfcbff @@ -0,0 +1,52 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + printCarsPriceRange(cars, 18000, 22000); + printCarByColor(cars, "Red"); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/29/50b2264908d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/29/50b2264908d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..ecd05de --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/29/50b2264908d0001a1a4afd166bbfcbff @@ -0,0 +1,6 @@ +package lambdasPractice; + +@FunctionalInterface +public interface ALambdaInterface { + public void walk(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2b/605b623c4cd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2b/605b623c4cd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..2824ce9 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2b/605b623c4cd1001a1a4afd166bbfcbff @@ -0,0 +1,95 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + rows.map(x -> x.split(", ")) + .filter(x -> x.length > 3) + .filter(x -> Integer.parseInt(x[1].trim()) > 15) + .foreEach(x -> System.out.println(x[0].trim() + " " + x[2].trim() + " " + x[3].trim())); + rows.close(); + + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + int rowCount = (int) rows + .map(x -> x.split(",")) + .filter(x -> x.length > 3) + .count(); + System.out.println(rowCount + " good rows."); + rows.close(); + + + + // + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2d/807c0e2b67d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2d/807c0e2b67d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..15a6ec7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2d/807c0e2b67d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// }; +// return arg1/arg2; +// }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60cb2bd8e4cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60cb2bd8e4cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..7ab9c3f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60cb2bd8e4cc001a1c9583c41c40e4f0 @@ -0,0 +1,18 @@ +package producerConsumer; + +import java.util.ArrayList; + +public class Application { + + public static void main(String[] args) { + + List questionList = new ArrayList(); + + Thread t1 = new Thread(new Producer(questionList)); + Thread t2 = new Thread(new Consumer(questionList)); + + t1.start(); + t2.start(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3/d0a78b52e6cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3/d0a78b52e6cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8dd1fb1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3/d0a78b52e6cc001a1c9583c41c40e4f0 @@ -0,0 +1,39 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion() throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty() == LIMIT) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/30/00dea66986d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/30/00dea66986d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..bb4259b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/30/00dea66986d0001a1a4afd166bbfcbff @@ -0,0 +1,125 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/31/6070845f0fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/31/6070845f0fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..1e865bf --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/31/6070845f0fcd001a1d8e8781d501fb14 @@ -0,0 +1,12 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/32/304a88c30ed0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/32/304a88c30ed0001a1a4afd166bbfcbff new file mode 100644 index 0000000..ddb01e8 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/32/304a88c30ed0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + helloVar.someMethod(); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + + Calculate sumVar = (a, b) -> return arg1+arg2; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/33/e0bae0fe49d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/33/e0bae0fe49d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..d7988db --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/33/e0bae0fe49d1001a1a4afd166bbfcbff @@ -0,0 +1,57 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(c -> x.startsWith("C")) + .sorted() + .forEach(x -> System.out.print(x + ", ")); + } + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/34/100c72cd4ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/34/100c72cd4ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..f255101 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/34/100c72cd4ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("/files/wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/35/500937fdd7d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/35/500937fdd7d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..d227737 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/35/500937fdd7d0001a1a4afd166bbfcbff @@ -0,0 +1,73 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + System.out.println("Printing cars that are blue"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getColor().equals("Blue"); + } + + }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000) + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(Car c); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/36/50605efc4ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/36/50605efc4ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..3188a9a --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/36/50605efc4ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/37/70bdcdb30fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/37/70bdcdb30fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..496be3e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/37/70bdcdb30fcd001a1d8e8781d501fb14 @@ -0,0 +1,23 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor); + + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/38/00bfeca045d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/38/00bfeca045d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..4fe7215 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/38/00bfeca045d1001a1a4afd166bbfcbff @@ -0,0 +1,82 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + + Function priceAndColor (c) -> " price = " + c.getPrice() + " color = " + c.getColor(); + +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + // public static void printCars(List cars, CarCondition condition) { + public static void printCars(List cars, Predicate predicate) { + for(Car c: cars) { + if(predicate.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/39/10d5fa5949d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/39/10d5fa5949d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..2501aab --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/39/10d5fa5949d1001a1a4afd166bbfcbff @@ -0,0 +1,48 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6 ,8 ,10}) + .map((x) -> * x) + .average() + ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30d6f7f90ed0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30d6f7f90ed0001a1a4afd166bbfcbff new file mode 100644 index 0000000..dc2fe5c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30d6f7f90ed0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + helloVar.someMethod(); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3c/30012bf686d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3c/30012bf686d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..c1630cb --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3c/30012bf686d0001a1a4afd166bbfcbff @@ -0,0 +1,143 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + //StringWorker reverser = (s) -> { + MyGenericInterface reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface GenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3d/009ea3770acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3d/009ea3770acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..6116eea --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3d/009ea3770acd001a1d8e8781d501fb14 @@ -0,0 +1,34 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + try { + synchronized(this) { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + questionQueue.put(nextQuestion); + } + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } +} +// +// +// +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3d/80fdcaabd5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3d/80fdcaabd5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..65618ae --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3d/80fdcaabd5d0001a1a4afd166bbfcbff @@ -0,0 +1,55 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + printCars(cars, new CarCondition() { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3e/c01b7519d8d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3e/c01b7519d8d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..5d1b5cf --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/3e/c01b7519d8d0001a1a4afd166bbfcbff @@ -0,0 +1,73 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + System.out.println("Printing cars that are blue"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getColor().equals("Blue"); + } + + }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(Car c); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4/600e808fe6cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4/600e808fe6cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..03c3555 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4/600e808fe6cc001a1c9583c41c40e4f0 @@ -0,0 +1,38 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty()) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.notify(); + } + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(questionNo++); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4/702d28a847d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4/702d28a847d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/42/007d21f9e5cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/42/007d21f9e5cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8090fb2 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/42/007d21f9e5cc001a1c9583c41c40e4f0 @@ -0,0 +1,41 @@ +package producerConsumer; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo.remove(0)); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + + @Override + public void run() { + while(true) { + try { + readQuestion(questionNo++); + } catch (InterruptedException e) { + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/43/6073874f66d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/43/6073874f66d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..dc39e51 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/43/6073874f66d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/45/5060ea14d4d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/45/5060ea14d4d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..f8b82e0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/45/5060ea14d4d0001a1a4afd166bbfcbff @@ -0,0 +1,21 @@ +package practicalLamdbaExample; + +import java.util.Arrays; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500), + ); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/45/a02efe7186d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/45/a02efe7186d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..3b3642f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/45/a02efe7186d0001a1a4afd166bbfcbff @@ -0,0 +1,138 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + System.out.println(reverser.work("Vehicle")); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/47/e089b1f10bcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/47/e089b1f10bcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..6468d0d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/47/e089b1f10bcd001a1d8e8781d501fb14 @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/48/10b7cfe193cf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/48/10b7cfe193cf001a1a4afd166bbfcbff new file mode 100644 index 0000000..6495daf --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/48/10b7cfe193cf001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package lambdasPractice; + +public class Human { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/48/502fad0f84d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/48/502fad0f84d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..4fbcfeb --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/48/502fad0f84d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/49/3072021886d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/49/3072021886d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..94e77bf --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/49/3072021886d0001a1a4afd166bbfcbff @@ -0,0 +1,116 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + System.out.println(reverser.work("Vehicle"); + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4b/00cc7f25e9cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4b/00cc7f25e9cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4c/80b9fa4210cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4c/80b9fa4210cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..b79397c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4c/80b9fa4210cd001a1d8e8781d501fb14 @@ -0,0 +1,27 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + executor.shutdown(); // Rejects any new tasks from being submitted + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4d/f000dc45e3cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4d/f000dc45e3cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..fbf652d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4d/f000dc45e3cc001a1c9583c41c40e4f0 @@ -0,0 +1,32 @@ +package producerConsumer; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/605f0f6a4acc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/605f0f6a4acc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/70b4ba6e49cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/70b4ba6e49cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..7ad4ad0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/70b4ba6e49cc001a1c9583c41c40e4f0 @@ -0,0 +1,33 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); + Thread.sleep(2000); +// inventoryTask.join(); + + displayTask.start(); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/a090cbc00dd0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/a090cbc00dd0001a1a4afd166bbfcbff new file mode 100644 index 0000000..0df3224 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/4f/a090cbc00dd0001a1a4afd166bbfcbff @@ -0,0 +1,88 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + Calculate sumVar = (a, b) -> a+b; + helloVar.someMethod(); + System.out.println(sumVar.compute(4, 6)); + } + + //// + public int sum(int arg1, int arg2) { + return arg1+arg2; + } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10, 2)); + + } + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5/3029ad454bd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5/3029ad454bd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..57fc9f1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5/3029ad454bd1001a1a4afd166bbfcbff @@ -0,0 +1,66 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted().filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/51/00e7444586d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/51/00e7444586d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..df0f80a --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/51/00e7444586d0001a1a4afd166bbfcbff @@ -0,0 +1,116 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/53/90566ad4e4cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/53/90566ad4e4cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..9b01877 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/53/90566ad4e4cc001a1c9583c41c40e4f0 @@ -0,0 +1,16 @@ +package producerConsumer; + +public class Application { + + public static void main(String[] args) { + + List questionList = new ArrayList(); + + Thread t1 = new Thread(new Producer(questionList)); + Thread t2 = new Thread(new Consumer(questionList)); + + t1.start(); + t2.start(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/54/401e09394cd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/54/401e09394cd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..f102902 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/54/401e09394cd1001a1a4afd166bbfcbff @@ -0,0 +1,86 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + int rowCount = (int) rows + .map(x -> x.split(",")) + .filter(x -> x.length > 3) + .count(); + System.out.println(rowCount + " good rows."); + rows.close(); + + + + // + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/54/c0566a35e5cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/54/c0566a35e5cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..1cc614f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/54/c0566a35e5cc001a1c9583c41c40e4f0 @@ -0,0 +1,42 @@ +package producerConsumer; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo.remove(0)); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + + @Override + public void run() { + + while(true) { + try { + readQuestion(); + } catch (InterruptedException e) { + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/55/80eee48afecc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/55/80eee48afecc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..fcc2cc0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/55/80eee48afecc001a1c9583c41c40e4f0 @@ -0,0 +1,33 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + + try { + synchronized(this) { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + questionQueue.put(nextQuestion); + } + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } +}} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/57/40fe2e0166d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/57/40fe2e0166d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..efb50a0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/57/40fe2e0166d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivider(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/57/80c19f9fd5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/57/80c19f9fd5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..b03d565 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/57/80c19f9fd5d0001a1a4afd166bbfcbff @@ -0,0 +1,55 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + printCars(cars, new CarCondition() { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/59/d0fc3b7ad3d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/59/d0fc3b7ad3d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5a/8044c52fbccf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5a/8044c52fbccf001a1a4afd166bbfcbff new file mode 100644 index 0000000..8f32c04 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5a/8044c52fbccf001a1a4afd166bbfcbff @@ -0,0 +1,7 @@ +package lambdasPractice; + +public class Robot { + public void walk() { + System.out.println("Robot Walking"); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5c/605a9bf885d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5c/605a9bf885d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..9d10723 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5c/605a9bf885d0001a1a4afd166bbfcbff @@ -0,0 +1,113 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += str.charAt(i); + } + return reuslt; + }; + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5c/d080f44a10cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5c/d080f44a10cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..b100e73 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5c/d080f44a10cd001a1d8e8781d501fb14 @@ -0,0 +1,32 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + executor.shutdown(); // Rejects any new tasks from being submitted + + + while(!executor.isTerminated()) { + System.out.println("submitted all tasks ..."); + } + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5e/202672d4e1cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5e/202672d4e1cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..a791601 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5e/202672d4e1cc001a1c9583c41c40e4f0 @@ -0,0 +1,20 @@ +package producerConsumer; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + public Producer(List questionList) { + this.questionList = questionList; + } + + @Override + public void run(int questionNo) { + with(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5e/601d19485cce001a1a9cc199e4fddddb b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5e/601d19485cce001a1a9cc199e4fddddb new file mode 100644 index 0000000..07d2c19 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5e/601d19485cce001a1a9cc199e4fddddb @@ -0,0 +1,44 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + // executor.shutdownNow(); // Terminates the executor immediately.. + +// try { +// executor.awaitTermination(2, TimeUnit.SECONDS); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + + while(!executor.isTerminated()) { + } + + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/30054a330ed0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/30054a330ed0001a1a4afd166bbfcbff new file mode 100644 index 0000000..dd6339a --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/30054a330ed0001a1a4afd166bbfcbff @@ -0,0 +1,86 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + +// ALambdaInterface helloVar = () -> System.out.println("hello there"); +// Calculate sumVar = (a, b) -> a+b; +// helloVar.someMethod(); +// System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10, 2)); + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/30055e624cd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/30055e624cd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..41b537d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/30055e624cd1001a1a4afd166bbfcbff @@ -0,0 +1,95 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + rows.map(x -> x.split(", ")) + .filter(x -> x.length > 3) + .filter(x -> Integer.parseInt(x[1].trim()) > 15) + .forEach(x -> System.out.println(x[0].trim() + " " + x[2].trim() + " " + x[3].trim())); + rows.close(); + + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + int rowCount = (int) rows + .map(x -> x.split(",")) + .filter(x -> x.length > 3) + .count(); + System.out.println(rowCount + " good rows."); + rows.close(); + + + + // + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/e08fe3a048d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/e08fe3a048d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..c6b29b1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/5f/e08fe3a048d1001a1a4afd166bbfcbff @@ -0,0 +1,24 @@ +package streamsPractical.files; + +import java.util.stream.IntStream; + +public class App { + + public static void main(String[] args) { + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/6/e0c2ee1be9cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/6/e0c2ee1be9cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/60/a0344e8e45d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/60/a0344e8e45d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..018ce93 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/60/a0344e8e45d1001a1a4afd166bbfcbff @@ -0,0 +1,76 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + // public static void printCars(List cars, CarCondition condition) { + public static void printCars(List cars, Predicate predicate) { + for(Car c: cars) { + if(predicate.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/61/007d67bc09cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/61/007d67bc09cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..b9be092 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/61/007d67bc09cd001a1d8e8781d501fb14 @@ -0,0 +1,48 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + questionNo++; + try { + questionQueue.put(questionNo); + } catch (InterruptedException e) { + + } + } + + private synchronized int getNextQuestion() { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + return nextQuestion; + } + +} +// +// try { +// synchronized(this) { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// questionQueue.put(nextQuestion); +// } +// } catch (InterruptedException e) { +// System.out.println("Error: " + e); +// } +// } +// +// +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/63/d0257473d3d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/63/d0257473d3d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..7023803 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/63/d0257473d3d0001a1a4afd166bbfcbff @@ -0,0 +1,48 @@ +package practicalLamdbaExample; + +public class Car { + String make, model, color; + int price; + public Car(String make, String model, String color, int price) { + super(); + this.make = make; + this.model = model; + this.color = color; + this.price = price; + } + public String getMake() { + return make; + } + public void setMake(String make) { + this.make = make; + } + public String getModel() { + return model; + } + public void setModel(String model) { + this.model = model; + } + public String getColor() { + return color; + } + public void setColor(String color) { + this.color = color; + } + public int getPrice() { + return price; + } + public void setPrice(int price) { + this.price = price; + } + + public void printCar() { + System.out.println(this); + } + + @Override + public String toString() { + return "Car [make=" + make + ", model=" + model + ", color=" + color + ", price=" + price + "]"; + } + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/64/406ccf1349d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/64/406ccf1349d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..187bafc --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/64/406ccf1349d1001a1a4afd166bbfcbff @@ -0,0 +1,32 @@ +package streamsPractical.files; + +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/66/409a7fd086d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/66/409a7fd086d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..507fb1d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/66/409a7fd086d0001a1a4afd166bbfcbff @@ -0,0 +1,142 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + MyGenericeInterfae reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface GenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/67/d08dacc700cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/67/d08dacc700cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..dff6da1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/67/d08dacc700cd001a1c9583c41c40e4f0 @@ -0,0 +1,34 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Overrides + public void run() { + + try { + synchronized(this) { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + questionQueue.put(nextQuestion); + } + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + + +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } +}} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/68/a00ec5f40fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/68/a00ec5f40fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..ed26c46 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/68/a00ec5f40fcd001a1d8e8781d501fb14 @@ -0,0 +1,23 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + executor.shutdown(); // Rejects any new tasks from being submitted + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/6e/f012aa6b84d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/6e/f012aa6b84d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..d511a9e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/6e/f012aa6b84d0001a1a4afd166bbfcbff @@ -0,0 +1,104 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method + public String reverse(String str) { + String result = ""; + for(int i = str.length() - 1; i >=0; i--) { + result = str +str.charAt(i); + } + return result; + }; + + (str) -> { + String result =""; + } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7/003a757effcc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7/003a757effcc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..08faf54 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7/003a757effcc001a1c9583c41c40e4f0 @@ -0,0 +1,33 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue = new ArrayBlockingQueue(); + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + + try { + synchronized(this) { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + questionQueue.put(nextQuestion); + } + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } +}} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/71/c03094b34ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/71/c03094b34ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..a54a6ad --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/71/c03094b34ad1001a1a4afd166bbfcbff @@ -0,0 +1,6 @@ +APPL, 92, 145, 422, 600 +FB, 122, 221 +AMZN, 329, 690, 849 +GOOG, +NVDA, 110, 217 +AMD, 9, 7, 12, 14, 18 \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/72/401f2f1284d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/72/401f2f1284d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..63cdfe8 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/72/401f2f1284d0001a1a4afd166bbfcbff @@ -0,0 +1,99 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // reverse a string + public String reverse(String str) { + String result = ''; + for(int i = str.length() - 1; i >=0; i--) { + result = str +str.charAt(i); + } + } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/72/80b39e92e6cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/72/80b39e92e6cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..25cd7d1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/72/80b39e92e6cc001a1c9583c41c40e4f0 @@ -0,0 +1,38 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty()) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.notify(); + } + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/74/90ae1e7ebdcf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/74/90ae1e7ebdcf001a1a4afd166bbfcbff new file mode 100644 index 0000000..340ad5d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/74/90ae1e7ebdcf001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package lambdasPractice; + +public interface ALambdaInterface { + public void someMethod(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/76/6060a823bccf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/76/6060a823bccf001a1a4afd166bbfcbff new file mode 100644 index 0000000..f1da235 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/76/6060a823bccf001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package lambdasPractice; + +public interface Walkable { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/76/a05f40cd48d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/76/a05f40cd48d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..b74972f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/76/a05f40cd48d1001a1a4afd166bbfcbff @@ -0,0 +1,31 @@ +package streamsPractical.files; + +import java.util.stream.IntStream; + +public class App { + + public static void main(String[] args) { + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/77/404b67980dd0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/77/404b67980dd0001a1a4afd166bbfcbff new file mode 100644 index 0000000..6bb6e63 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/77/404b67980dd0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + Calculate sumVar = (a, b) -> a+b; + helloVar.someMethod(); + System.out.println(sumVar.compute(4, 6)); + + //// + public int sum(int arg1, int arg2) { + return arg1+arg2; + } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10, 2)); + + } + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7c/501110684ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7c/501110684ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..288a6bd --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7c/501110684ad1001a1a4afd166bbfcbff @@ -0,0 +1,57 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7f/907639ba84d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7f/907639ba84d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..787b63a --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/7f/907639ba84d0001a1a4afd166bbfcbff @@ -0,0 +1,108 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += str.charAt(i); + } + }; + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8/3078fd20e9cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8/3078fd20e9cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/009657580fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/009657580fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..4def4f7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/009657580fcd001a1d8e8781d501fb14 @@ -0,0 +1,5 @@ +package threadPools; + +public class ThreadPoolDemo { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/b070e258eacc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/b070e258eacc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..ae3dd17 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/b070e258eacc001a1c9583c41c40e4f0 @@ -0,0 +1,5 @@ +package arrayBlockingQueue; + +public class Producer { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/d094da0ad5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/d094da0ad5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..04a21ba --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/80/d094da0ad5d0001a1a4afd166bbfcbff @@ -0,0 +1,40 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + printCarsPriceRange(cars, 18000, 22000); + printCarByColor(cars, "Red");' + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/82/30dead044ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/82/30dead044ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..5477d59 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/82/30dead044ad1001a1a4afd166bbfcbff @@ -0,0 +1,57 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(c -> x.startsWith("C")) + .sorted() + .forEach(x -> System.out.print(x + ", ")); + }} + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/83/b06d52a7d5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/83/b06d52a7d5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..31f2315 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/83/b06d52a7d5d0001a1a4afd166bbfcbff @@ -0,0 +1,55 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + printCars(cars, new CarCondition() { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface condition { + public boolean test(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/85/90f7c65607d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/85/90f7c65607d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..340ad5d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/85/90f7c65607d0001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package lambdasPractice; + +public interface ALambdaInterface { + public void someMethod(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/86/c04905a9e3cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/86/c04905a9e3cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..c95052e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/86/c04905a9e3cc001a1c9583c41c40e4f0 @@ -0,0 +1,5 @@ +package producerConsumer; + +public class Consumer { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8a/80702cec47d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8a/80702cec47d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8b/c08413c9e8cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8b/c08413c9e8cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..9a39e59 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8b/c08413c9e8cc001a1c9583c41c40e4f0 @@ -0,0 +1,39 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion() throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty()) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.notify(); + } + } + + @Override + public void run() { + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8c/10dc8e4d84d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8c/10dc8e4d84d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..df8ba2b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8c/10dc8e4d84d0001a1a4afd166bbfcbff @@ -0,0 +1,100 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // reverse a string + public String reverse(String str) { + String result = ''; + for(int i = str.length() - 1; i >=0; i--) { + result = str +str.charAt(i); + } + return result; + } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8c/806dc81cbccf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8c/806dc81cbccf001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8d/000d1aa34ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8d/000d1aa34ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..58b8165 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8d/000d1aa34ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractical.files; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("/files/wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/106ae37ae6cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/106ae37ae6cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..b24196b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/106ae37ae6cc001a1c9583c41c40e4f0 @@ -0,0 +1,37 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty() == LIMIT) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.notify(); + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/9095d3e6e3cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/9095d3e6e3cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..ad72333 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/9095d3e6e3cc001a1c9583c41c40e4f0 @@ -0,0 +1,39 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty() == LIMIT) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/e09c8c7cbdcf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/e09c8c7cbdcf001a1a4afd166bbfcbff new file mode 100644 index 0000000..a3422b7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/e09c8c7cbdcf001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package lambdasPractice; + +public class ALambdaInterface { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/f076dd1a0acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/f076dd1a0acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..01de9c2 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/8e/f076dd1a0acd001a1d8e8781d501fb14 @@ -0,0 +1,24 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Consumer public Consumer(BlockingQueue questionQueue) { + + int questionNo; + BlockingQueue questionQueue; + + public Consumer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + questionNo++; + try { + questionQueue.put(questionNo); + } catch (InterruptedException e) { + + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/91/30a34b9ed5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/91/30a34b9ed5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..b93ec96 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/91/30a34b9ed5d0001a1a4afd166bbfcbff @@ -0,0 +1,55 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + printCars(cars, new CarCOndition() { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/92/c06d821111cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/92/c06d821111cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..24bab8b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/92/c06d821111cd001a1d8e8781d501fb14 @@ -0,0 +1,38 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + // executor.shutdownNow(); // Terminates the executor immediately.. + + executor.awaitTermination(10, TimeUnit.SECONDS); + + +// while(!executor.isTerminated()) { +// } + + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/30965f4c08d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/30965f4c08d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..54144df --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/30965f4c08d0001a1a4afd166bbfcbff @@ -0,0 +1,8 @@ +package lambdasPractice; + +@FunctionalInterface +public interface ALambdaInterface { + public void walk(); + + public void someMethod(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/e03f795c07d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/e03f795c07d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..6455060 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/e03f795c07d0001a1a4afd166bbfcbff @@ -0,0 +1,6 @@ +package lambdasPractice; + +@FunctionalInterface +public interface ALambdaInterface { + public void someMethod(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/f0062b130ccd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/93/f0062b130ccd001a1d8e8781d501fb14 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/806a0c82ffcc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/806a0c82ffcc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8fb5b65 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/806a0c82ffcc001a1c9583c41c40e4f0 @@ -0,0 +1,34 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Overrides + public void run() { + + try { + synchronized(this) { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + questionQueue.put(nextQuestion); + } + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + + +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/d05a6c8684d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/d05a6c8684d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..5c3592e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/d05a6c8684d0001a1a4afd166bbfcbff @@ -0,0 +1,107 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method + public String reverse(String str) { + String result = ""; + for(int i = str.length() - 1; i >=0; i--) { + result = str +str.charAt(i); + } + return result; + + (str) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += str.charAt(i); + } + } + } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/f007a5158bd0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/94/f007a5158bd0001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/95/000708ee86d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/95/000708ee86d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..1065c0d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/95/000708ee86d0001a1a4afd166bbfcbff @@ -0,0 +1,142 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + MyGenericInterface reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface GenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/96/604446eb85d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/96/604446eb85d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..5c5f882 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/96/604446eb85d0001a1a4afd166bbfcbff @@ -0,0 +1,109 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + reverser = (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += str.charAt(i); + } + return reuslt; + }; + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/96/d03a318101cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/96/d03a318101cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..cb6bd3f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/96/d03a318101cd001a1c9583c41c40e4f0 @@ -0,0 +1,34 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + +} +// @Overrides +// public void run() { +// +// try { +// synchronized(this) { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// questionQueue.put(nextQuestion); +// } +// } catch (InterruptedException e) { +// System.out.println("Error: " + e); +// } +// } +// +// +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/97/409abe2ad4d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/97/409abe2ad4d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..54208a8 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/97/409abe2ad4d0001a1a4afd166bbfcbff @@ -0,0 +1,21 @@ +package practicalLamdbaExample; + +import java.util.Arrays; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/99/50a335c30ecd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/99/50a335c30ecd001a1d8e8781d501fb14 new file mode 100644 index 0000000..6e11ea9 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/99/50a335c30ecd001a1d8e8781d501fb14 @@ -0,0 +1,5 @@ +package threadPools; + +public class MessageProcessor { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/99/a07b835a0dd0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/99/a07b835a0dd0001a1a4afd166bbfcbff new file mode 100644 index 0000000..ca972aa --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/99/a07b835a0dd0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + Calculate sumVar = (a, b) -> a+b; + helloVar.someMethod(); + System.out.println(sumVar.compute(4, 6)); + + //// + public int sum(int arg1, int arg2) { + return arg1+arg2; + } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a ==0 ) { + return 0; + } + return a/b; + } + + + + } + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9b/40c4234949d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9b/40c4234949d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..6e91c43 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9b/40c4234949d1001a1a4afd166bbfcbff @@ -0,0 +1,39 @@ +package streamsPractical.files; + +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9c/0080f5a284d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9c/0080f5a284d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..b5f7cc4 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9c/0080f5a284d0001a1a4afd166bbfcbff @@ -0,0 +1,107 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method + public String reverse(String str) { + String result = ""; + for(int i = str.length() - 1; i >=0; i--) { + result = str +str.charAt(i); + } + return result; + + (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += str.charAt(i); + } + }; + } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9c/10694edb0ed0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9c/10694edb0ed0001a1a4afd166bbfcbff new file mode 100644 index 0000000..45b9b79 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9c/10694edb0ed0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + helloVar.someMethod(); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9d/b0fc3ebf4bd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9d/b0fc3ebf4bd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..e3333c3 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/9d/b0fc3ebf4bd1001a1a4afd166bbfcbff @@ -0,0 +1,75 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a/90da84aee9cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a/90da84aee9cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..fb572f9 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a/90da84aee9cc001a1c9583c41c40e4f0 @@ -0,0 +1,10 @@ +package arrayBlockingQueue; + +public class Application { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a1/102a4d7f4ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a1/102a4d7f4ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..1d4e509 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a1/102a4d7f4ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractical.files; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("/wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a3/c01e4816d8d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a3/c01e4816d8d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..3ba3935 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a3/c01e4816d8d0001a1a4afd166bbfcbff @@ -0,0 +1,73 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + System.out.println("Printing cars that are blue"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getColor().equals("Blue"); + } + + }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(Car c); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a3/f077d5e50ecd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a3/f077d5e50ecd001a1d8e8781d501fb14 new file mode 100644 index 0000000..32d074c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a3/f077d5e50ecd001a1d8e8781d501fb14 @@ -0,0 +1,27 @@ +package threadPools; + +public class MessageProcessor { + + private int message; + + public MessageProcessor(int message) { + this.message = message; + } + + @Override + public void run() { + System.out.println(Thread.currentThread().getName() + " [RECEIVED] Message = " + message); + respondToMessage(); // make thread sleep to simulate doing some work + System.out.println(Thread.currentThread().getName() + "(DONE) Processing Message = " + message); + } + + private void respondToMessage() { + + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + System.out.println("Unable to process message " + message); + } + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a4/30a2b45e0dd0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a4/30a2b45e0dd0001a1a4afd166bbfcbff new file mode 100644 index 0000000..6139438 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a4/30a2b45e0dd0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + Calculate sumVar = (a, b) -> a+b; + helloVar.someMethod(); + System.out.println(sumVar.compute(4, 6)); + + //// + public int sum(int arg1, int arg2) { + return arg1+arg2; + } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + } + + + + } + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a4/8060e9f5d7d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a4/8060e9f5d7d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..6754299 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a4/8060e9f5d7d0001a1a4afd166bbfcbff @@ -0,0 +1,71 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + System.out.println("Printing cars that are blue"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getColor().equals("Blue"); + } + + }); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(Car c); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a6/4042202a01cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a6/4042202a01cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..67f3174 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a6/4042202a01cd001a1c9583c41c40e4f0 @@ -0,0 +1,5 @@ +package arrayBlockingQueue; + +public class Consumer { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a7/403b5bf085d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a7/403b5bf085d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..80384d6 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a7/403b5bf085d0001a1a4afd166bbfcbff @@ -0,0 +1,113 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + reverser = (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += str.charAt(i); + } + return reuslt; + }; + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a8/80a0bdb586d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a8/80a0bdb586d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..cde81dd --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a8/80a0bdb586d0001a1a4afd166bbfcbff @@ -0,0 +1,139 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/40e6d584dad0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/40e6d584dad0001a1a4afd166bbfcbff new file mode 100644 index 0000000..754535b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/40e6d584dad0001a1a4afd166bbfcbff @@ -0,0 +1,73 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + System.out.println("Printing cars that are blue"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getColor().equals("Blue"); + } + + }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/c0a3ced2ebcc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/c0a3ced2ebcc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..15f33e1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/c0a3ced2ebcc001a1c9583c41c40e4f0 @@ -0,0 +1,31 @@ +package arrayBlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + + try { + synchronized(this) { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + questionQueue.put(nextQuestion); + } + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/d0028c0886d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/d0028c0886d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..1231f2f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/a9/d0028c0886d0001a1a4afd166bbfcbff @@ -0,0 +1,113 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/30fdad6e0dd0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/30fdad6e0dd0001a1a4afd166bbfcbff new file mode 100644 index 0000000..abac643 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/30fdad6e0dd0001a1a4afd166bbfcbff @@ -0,0 +1,86 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + Calculate sumVar = (a, b) -> a+b; + helloVar.someMethod(); + System.out.println(sumVar.compute(4, 6)); + + //// + public int sum(int arg1, int arg2) { + return arg1+arg2; + } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + + } + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/90f2ad03e5cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/90f2ad03e5cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..9b458d3 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/90f2ad03e5cc001a1c9583c41c40e4f0 @@ -0,0 +1,42 @@ +package producerConsumer; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo.remove(0)); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/f0671a5abdcf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/f0671a5abdcf001a1a4afd166bbfcbff new file mode 100644 index 0000000..f5c80a3 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/aa/f0671a5abdcf001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package lambdasPractice; + +public interface ALambdaClass { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ae/00c8d52be1cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ae/00c8d52be1cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..ab525f6 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ae/00c8d52be1cc001a1c9583c41c40e4f0 @@ -0,0 +1,5 @@ +package producerConsumer; + +public class Producer { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/af/2009cdd147d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/af/2009cdd147d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/af/f02643870fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/af/f02643870fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..4e076c7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/af/f02643870fcd001a1d8e8781d501fb14 @@ -0,0 +1,13 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b/703215c9e8cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b/703215c9e8cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..4ad3f7c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b/703215c9e8cc001a1c9583c41c40e4f0 @@ -0,0 +1,43 @@ +package producerConsumer; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + } + + @Override + public void run() { + while(true) { + try { + readQuestion(questionNo++); + } catch (InterruptedException e) { + } + + } + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/505517c9e8cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/505517c9e8cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..7181d61 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/505517c9e8cc001a1c9583c41c40e4f0 @@ -0,0 +1,19 @@ +package producerConsumer; + +import java.util.ArrayList; +import java.util.List; + +public class Application { + + public static void main(String[] args) { + + List questionList = new ArrayList(); + + Thread t1 = new Thread(new Producer(questionList)); + Thread t2 = new Thread(new Consumer(questionList)); + + t1.start(); + t2.start(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/70434124e7cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/70434124e7cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..ac8559c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/70434124e7cc001a1c9583c41c40e4f0 @@ -0,0 +1,38 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion() throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty()) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.notify(); + } + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/900e1edd43d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/900e1edd43d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..93b5c01 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/900e1edd43d1001a1a4afd166bbfcbff @@ -0,0 +1,74 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/c031bf25d5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/c031bf25d5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..de60d5b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b0/c031bf25d5d0001a1a4afd166bbfcbff @@ -0,0 +1,40 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + printCarsPriceRange(cars, 18000, 22000); + printCarByColor(cars, "Red"); + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b1/10ffca0549cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b1/10ffca0549cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8389df4 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b1/10ffca0549cc001a1c9583c41c40e4f0 @@ -0,0 +1,42 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); +// try { +// Thread.sleep(2000); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + try { + inventoryTask.join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + displayTask.start(); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b2/505f18a34ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b2/505f18a34ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..58b8165 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b2/505f18a34ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractical.files; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("/files/wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60ba5bdfe1cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60ba5bdfe1cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..95b8057 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b2/60ba5bdfe1cc001a1c9583c41c40e4f0 @@ -0,0 +1,32 @@ +package producerConsumer; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/40d384284ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/40d384284ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..b1c38ef --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/40d384284ad1001a1a4afd166bbfcbff @@ -0,0 +1,57 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("C")) + .sorted() + .forEach(x -> System.out.print(x + ", ")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/80898a5766d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/80898a5766d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..154d229 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/80898a5766d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// }; +// return arg1/arg2; +// }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider(10,2)); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/80b35e80bdcf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/80b35e80bdcf001a1a4afd166bbfcbff new file mode 100644 index 0000000..a7747c0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b4/80b35e80bdcf001a1a4afd166bbfcbff @@ -0,0 +1,4 @@ + +public interface ALambdaInterface { + public void someMethod(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b6/d0533b754acc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b6/d0533b754acc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b7/f0a848c80fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b7/f0a848c80fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..0e0b4bc --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/b7/f0a848c80fcd001a1d8e8781d501fb14 @@ -0,0 +1,23 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0667d1856cf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0667d1856cf001a1a4afd166bbfcbff new file mode 100644 index 0000000..6468d0d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0667d1856cf001a1a4afd166bbfcbff @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/be/9048784967d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/be/9048784967d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..6a2704b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/be/9048784967d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(arg1, arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/be/c0812d6d4cd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/be/c0812d6d4cd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..45ae7fe --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/be/c0812d6d4cd1001a1a4afd166bbfcbff @@ -0,0 +1,95 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + rows.map(x -> x.split(",")) + .filter(x -> x.length > 3) + .filter(x -> Integer.parseInt(x[1].trim()) > 15) + .forEach(x -> System.out.println(x[0].trim() + " " + x[2].trim() + " " + x[3].trim())); + rows.close(); + + + // + Stream rows1 = Files.lines(Paths.get("files/stockDataCsv.text")); + int rowCount = (int) rows + .map(x -> x.split(",")) + .filter(x -> x.length > 3) + .count(); + System.out.println(rowCount + " good rows."); + rows.close(); + + + + // + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c/000965b4fcc6001a1eb4e8d2c924f3ed b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c/000965b4fcc6001a1eb4e8d2c924f3ed new file mode 100644 index 0000000..487af58 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c/000965b4fcc6001a1eb4e8d2c924f3ed @@ -0,0 +1,38 @@ +package inventory; + +import java.util.ArrayList; +import java.util.List; + +public class InventoryManager { + + List soldProductList = new ArrayList(); + List purchasedProductsList = new ArrayList(); + + public void populatSoldProducts() { + for(int i = 0; i < 1000; i++) { + Product prod = new Product (i, "text_product_" + i); + soldProductList.add(prod); + System.out.println("ADDED: " + prod); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + public void displaySoldProducts() { + for (Product product : soldProductList) { + System.out.println("PRINTING THE SOLD: " + product); + Thread.sleep(10); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + } + + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c2/e0b936fb10cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c2/e0b936fb10cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..7049b7e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c2/e0b936fb10cd001a1d8e8781d501fb14 @@ -0,0 +1,35 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + executor.shutdownNow(); + + + while(!executor.isTerminated()) { + } + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c4/70a225744ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c4/70a225744ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..c8fd9e2 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c4/70a225744ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractical.files; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c4/c08154344ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c4/c08154344ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..e7f9b0a --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c4/c08154344ad1001a1a4afd166bbfcbff @@ -0,0 +1,58 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("C")) + .sorted() + .forEach(x -> System.out.print(x + ", ")); + } + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c5/3048c91701cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c5/3048c91701cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8b9e3c7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/c5/3048c91701cd001a1c9583c41c40e4f0 @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ca/7036a33102cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ca/7036a33102cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..ba13be7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ca/7036a33102cd001a1c9583c41c40e4f0 @@ -0,0 +1,19 @@ +package arrayBlockingQueue; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; + +public class Application { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + BlockingQueue questionQueue = new ArrayBlockingQueue(5); + Thread t1 = new Thread(new Producer(questionQueue)); + Thread t2 = new Thread(new Consumer(questionQueue)); + + t1.start(); + t2.start(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ca/e00c279345d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ca/e00c279345d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..dbc1963 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ca/e00c279345d1001a1a4afd166bbfcbff @@ -0,0 +1,81 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + + Function priceAndColor (c) -> " price = " + c.getPrice() + " color = " + c.getColor(); + +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + // public static void printCars(List cars, CarCondition condition) { + public static void printCars(List cars, Predicate predicate) { + for(Car c: cars) { + if(predicate.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cb/307f46f485d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cb/307f46f485d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..3901046 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cb/307f46f485d0001a1a4afd166bbfcbff @@ -0,0 +1,113 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + reverser = (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += str.charAt(i); + } + return reuslt; + }; + } + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cb/40e0a73a11cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cb/40e0a73a11cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..1816f2f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cb/40e0a73a11cd001a1d8e8781d501fb14 @@ -0,0 +1,44 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + // executor.shutdownNow(); // Terminates the executor immediately.. + + try { + executor.awaitTermination(2, TimeUnit.SECONDS); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + +// while(!executor.isTerminated()) { +// } + + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cc/30928a4cd6d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cc/30928a4cd6d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..366eef0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cc/30928a4cd6d0001a1a4afd166bbfcbff @@ -0,0 +1,55 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + printCars(cars, new CarCondition() { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(Car c); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ce/800f5c0f0acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ce/800f5c0f0acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..499519f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ce/800f5c0f0acd001a1d8e8781d501fb14 @@ -0,0 +1,48 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + questionNo++; + try { + questionQueue.put(questionNo); + } catch (InterruptedException e) { + + } + } + + private synchronized int getNextQuestion() { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + return nextQuestion; + } + +} +// +// try { +// synchronized(this) { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// questionQueue.put(nextQuestion); +// } +// } catch (InterruptedException e) { +// System.out.println("Error: " + e); +// } +// } +// +// +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/0045019944d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/0045019944d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..8154f7e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/0045019944d1001a1a4afd166bbfcbff @@ -0,0 +1,75 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + // public static void printCars(List cars, CarCondition condition) { + public static void printCars(List cars, Predicate predicate) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/5077125649d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/5077125649d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..91f33ac --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/5077125649d1001a1a4afd166bbfcbff @@ -0,0 +1,47 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6 ,8 ,10}) + .map((x) -> * x) + .average() + ifPresent(n -> System.out.print(n)); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/b06e111d0fd0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/b06e111d0fd0001a1a4afd166bbfcbff new file mode 100644 index 0000000..29dc486 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/cf/b06e111d0fd0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d/403c2c840acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d/403c2c840acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..c8ba159 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d/403c2c840acd001a1d8e8781d501fb14 @@ -0,0 +1,23 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Consumer implements Runnable { + + BlockingQueue questionQueue; + + public Consumer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + + try { + System.out.println("ANSWERED QUESTION: " + questionQueue.take()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d0/007f260a0fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d0/007f260a0fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d0/307ca048d5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d0/307ca048d5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..a5d4e95 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d0/307ca048d5d0001a1a4afd166bbfcbff @@ -0,0 +1,48 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + printCarsPriceRange(cars, 18000, 22000); + printCarByColor(cars, "Red"); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.text(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d2/70b0862bbccf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d2/70b0862bbccf001a1a4afd166bbfcbff new file mode 100644 index 0000000..a4cf18f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d2/70b0862bbccf001a1a4afd166bbfcbff @@ -0,0 +1,7 @@ +package lambdasPractice; + +public class Human { + public void walk() { + System.out.println("Human Walking"); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d2/b05cd04256cf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d2/b05cd04256cf001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90e7e82387d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90e7e82387d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..cda3129 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90e7e82387d0001a1a4afd166bbfcbff @@ -0,0 +1,143 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + //StringWorker reverser = (s) -> { + MyGenericInterface reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface MyGenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d7/80309a8a49d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d7/80309a8a49d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..d66beb4 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/d7/80309a8a49d1001a1a4afd166bbfcbff @@ -0,0 +1,48 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/db/500b74ab0ed0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/db/500b74ab0ed0001a1a4afd166bbfcbff new file mode 100644 index 0000000..876bc34 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/db/500b74ab0ed0001a1a4afd166bbfcbff @@ -0,0 +1,86 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + +// ALambdaInterface helloVar = () -> System.out.println("hello there"); +// Calculate sumVar = (a, b) -> a+b; +// helloVar.someMethod(); +// System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dc/4050740811cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dc/4050740811cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..e2f3c82 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dc/4050740811cd001a1d8e8781d501fb14 @@ -0,0 +1,38 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + // executor.shutdownNow(); // Terminates the executor immediately.. + + executor.awaitTermination(10 timeout, seconds) + + +// while(!executor.isTerminated()) { +// } + + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dc/5027c988e6cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dc/5027c988e6cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..25cd7d1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dc/5027c988e6cc001a1c9583c41c40e4f0 @@ -0,0 +1,38 @@ +package producerConsumer; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty()) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.notify(); + } + } + + @Override + public void run() { + + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + } + } + +} \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dd/d030406ad3d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dd/d030406ad3d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..88da42c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/dd/d030406ad3d0001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package practicalLamdbaExample; + +public class Car { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/00adfa6402cd001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/00adfa6402cd001a1c9583c41c40e4f0 new file mode 100644 index 0000000..cb05172 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/00adfa6402cd001a1c9583c41c40e4f0 @@ -0,0 +1,33 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer Implements Runnable { + + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + +} +// @Overrides +// public void run() { +// +// try { +// synchronized(this) { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// questionQueue.put(nextQuestion); +// } +// } catch (InterruptedException e) { +// System.out.println("Error: " + e); +// } +// } +// +// +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/402e93674cd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/402e93674cd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..c5f5c95 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/402e93674cd1001a1a4afd166bbfcbff @@ -0,0 +1,95 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + rows.map(x -> x.split(",")) + .filter(x -> x.length > 3) + .filter(x -> Integer.parseInt(x[1].trim()) > 15) + .forEach(x -> System.out.println(x[0].trim() + " " + x[2].trim() + " " + x[3].trim())); + rows.close(); + + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + int rowCount = (int) rows + .map(x -> x.split(",")) + .filter(x -> x.length > 3) + .count(); + System.out.println(rowCount + " good rows."); + rows.close(); + + + + // + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/a0e4e8774dd1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/a0e4e8774dd1001a1a4afd166bbfcbff new file mode 100644 index 0000000..d06a457 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/de/a0e4e8774dd1001a1a4afd166bbfcbff @@ -0,0 +1,95 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + rows.map(x -> x.split(",")) + .filter(x -> x.length > 3) + .filter(x -> Integer.parseInt(x[1].trim()) > 15) + .forEach(x -> System.out.println(x[0].trim() + " " + x[2].trim() + " " + x[3].trim())); + rows.close(); + + + // + Stream rows1 = Files.lines(Paths.get("files/stockDataCsv.text")); + int rowCount = (int) rows1 + .map(x -> x.split(",")) + .filter(x -> x.length > 3) + .count(); + System.out.println(rowCount + " good rows."); + rows1.close(); + + + + // + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/00734055d5d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/00734055d5d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..8448e96 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/00734055d5d0001a1a4afd166bbfcbff @@ -0,0 +1,52 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + printCarsPriceRange(cars, 18000, 22000); + printCarByColor(cars, "Red"); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.text(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/4063299ed7d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/4063299ed7d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..6e5f672 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/4063299ed7d0001a1a4afd166bbfcbff @@ -0,0 +1,70 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getColor().equals("Blue"); + } + + }); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(Car c); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/701cb2f70fcd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/701cb2f70fcd001a1d8e8781d501fb14 new file mode 100644 index 0000000..1c2a127 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/701cb2f70fcd001a1d8e8781d501fb14 @@ -0,0 +1,27 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor4); + + executor.shutdown(); // Rejects any new tasks from being submitted + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/c062b513d4d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/c062b513d4d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..fbc5d25 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/df/c062b513d4d0001a1a4afd166bbfcbff @@ -0,0 +1,10 @@ +package practicalLamdbaExample; + +public class App { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e0/40fe314656cf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e0/40fe314656cf001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e0544afe65d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e0544afe65d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..dc39e51 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e1/e0544afe65d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + }; + return arg1/arg2; + }; + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println("w"); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e3/c0ed706248d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e3/c0ed706248d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..a9dc9e6 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e3/c0ed706248d1001a1a4afd166bbfcbff @@ -0,0 +1,17 @@ +package streamsPractical.files; + +import java.util.stream.IntStream; + +public class App { + + public static void main(String[] args) { + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e4/102dd2bb86d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e4/102dd2bb86d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..d2302a7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e4/102dd2bb86d0001a1a4afd166bbfcbff @@ -0,0 +1,142 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface GenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e4/1037615b10cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e4/1037615b10cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..1dc9789 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e4/1037615b10cd001a1d8e8781d501fb14 @@ -0,0 +1,32 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + executor.shutdown(); // Rejects any new tasks from being submitted + + + while(!executor.isTerminated()) { + } + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e5/009a0e1d87d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e5/009a0e1d87d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..9de4e70 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e5/009a0e1d87d0001a1a4afd166bbfcbff @@ -0,0 +1,143 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + //StringWorker reverser = (s) -> { + MyGenericInterface reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface MyGenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e5/d027b9620acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e5/d027b9620acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..0b2e56b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e5/d027b9620acd001a1d8e8781d501fb14 @@ -0,0 +1,23 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Consumer implements Runnable() { + + BlockingQueue questionQueue; + + public Consumer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + + try { + System.out.println("ANSWERED QUESTION: " + questionQueue.take()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e6/c01e1df749d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e6/c01e1df749d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..35173f7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e6/c01e1df749d1001a1a4afd166bbfcbff @@ -0,0 +1,48 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e7/9057ba8886d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e7/9057ba8886d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..35f5e0c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e7/9057ba8886d0001a1a4afd166bbfcbff @@ -0,0 +1,138 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e7/e04de24343d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e7/e04de24343d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..3d0b5af --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e7/e04de24343d1001a1a4afd166bbfcbff @@ -0,0 +1,74 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e9/40b4553c67d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e9/40b4553c67d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..392f9d2 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e9/40b4553c67d0001a1a4afd166bbfcbff @@ -0,0 +1,87 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + } + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e9/90d5fd704ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e9/90d5fd704ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..ab34475 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/e9/90d5fd704ad1001a1a4afd166bbfcbff @@ -0,0 +1,64 @@ +package streamsPractical.files; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ea/a03cfd2e48d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ea/a03cfd2e48d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..a3653cf --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ea/a03cfd2e48d1001a1a4afd166bbfcbff @@ -0,0 +1,16 @@ +package streamsPractical.files; + +import java.util.stream.IntStream; + +public class App { + + public static void main(String[] args) { + + // Integer Stream with Skip + IntStream + .range(1, 10) + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ea/e075b63b4ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ea/e075b63b4ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..72fa873 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ea/e075b63b4ad1001a1a4afd166bbfcbff @@ -0,0 +1,57 @@ +package streamsPractical.files; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) { + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", ")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/eb/908520a793cf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/eb/908520a793cf001a1a4afd166bbfcbff new file mode 100644 index 0000000..b588bb7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/eb/908520a793cf001a1a4afd166bbfcbff @@ -0,0 +1,5 @@ +package lambdasPractice; + +public class Robot { + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30236a180ed0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30236a180ed0001a1a4afd166bbfcbff new file mode 100644 index 0000000..6fa8a55 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30236a180ed0001a1a4afd166bbfcbff @@ -0,0 +1,86 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom obejct walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + + ALambdaInterface helloVar = () -> System.out.println("hello there"); + Calculate sumVar = (a, b) -> a+b; + helloVar.someMethod(); + System.out.println(sumVar.compute(4, 6)); + } + + //// + public int sum(int arg1, int arg2) { + return arg1+arg2; + } + + + // public method + public int nonZeroDivide(int arg1, int arg2) { + if(arg1==0) { + return 0; + } + return arg1/arg2; + } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10, 2)); + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f/1038dbbfeacc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f/1038dbbfeacc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8b1c2cc --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f/1038dbbfeacc001a1c9583c41c40e4f0 @@ -0,0 +1,22 @@ +package arrayBlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + + questionNo++; + try { + questionQueue.put(questionNo); + } catch (InterruptedException e) { + + } + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f0/b02de7999dcb001a1633b267bb8c22b9 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f0/b02de7999dcb001a1633b267bb8c22b9 new file mode 100644 index 0000000..47bfca8 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f0/b02de7999dcb001a1633b267bb8c22b9 @@ -0,0 +1,30 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); + displayTask.start(); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f2/d0d8351511cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f2/d0d8351511cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..9c408a3 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f2/d0d8351511cd001a1d8e8781d501fb14 @@ -0,0 +1,39 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + // executor.shutdownNow(); // Terminates the executor immediately.. + + executor.awaitTermination(10, TimeUnit.SECONDS); + + +// while(!executor.isTerminated()) { +// } + + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f3/901b1ba445d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f3/901b1ba445d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..98bdd04 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f3/901b1ba445d1001a1a4afd166bbfcbff @@ -0,0 +1,82 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + + Function priceAndColor = (c) -> " price = " + c.getPrice() + " color = " + c.getColor(); + +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + // public static void printCars(List cars, CarCondition condition) { + public static void printCars(List cars, Predicate predicate) { + for(Car c: cars) { + if(predicate.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f4/f098f29c9dcb001a1633b267bb8c22b9 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f4/f098f29c9dcb001a1633b267bb8c22b9 new file mode 100644 index 0000000..7ba2740 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f4/f098f29c9dcb001a1633b267bb8c22b9 @@ -0,0 +1,31 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); + Thread.sleep(200); + displayTask.start(); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/30d192b34ad1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/30d192b34ad1001a1a4afd166bbfcbff new file mode 100644 index 0000000..452d905 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/30d192b34ad1001a1a4afd166bbfcbff @@ -0,0 +1,12 @@ +Hello +POwerade +Samantha +Bitcoin +Camera +Dry Cleaner +Computer Application +Health Insurance +Keyboard +Bottle +White Board +Education \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/8031c61d48d1001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/8031c61d48d1001a1a4afd166bbfcbff new file mode 100644 index 0000000..febbab5 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/8031c61d48d1001a1a4afd166bbfcbff @@ -0,0 +1,10 @@ +package streamsPractical.files; + +public class App { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/e0a805d386d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/e0a805d386d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..f300755 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f5/e0a805d386d0001a1a4afd166bbfcbff @@ -0,0 +1,142 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + MyGenericeInterface reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface GenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f6/7033d35d4acc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f6/7033d35d4acc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..8b9e3c7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f6/7033d35d4acc001a1c9583c41c40e4f0 @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f8/50dedc859dcb001a1633b267bb8c22b9 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f8/50dedc859dcb001a1633b267bb8c22b9 new file mode 100644 index 0000000..b075135 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f8/50dedc859dcb001a1633b267bb8c22b9 @@ -0,0 +1,17 @@ +package client; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f8/7088c132e6cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f8/7088c132e6cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..d3f3724 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f8/7088c132e6cc001a1c9583c41c40e4f0 @@ -0,0 +1,42 @@ +package producerConsumer; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + } + + @Override + public void run() { + while(true) { + try { + readQuestion(questionNo++); + } catch (InterruptedException e) { + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/30c443bc10cd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/30c443bc10cd001a1d8e8781d501fb14 new file mode 100644 index 0000000..dde5602 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/30c443bc10cd001a1d8e8781d501fb14 @@ -0,0 +1,32 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + + + while(!executor.isTerminated()) { + } + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/408e746e4acc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/408e746e4acc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/a0345a74e4cc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/a0345a74e4cc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..2c59eb5 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/a0345a74e4cc001a1c9583c41c40e4f0 @@ -0,0 +1,10 @@ +package producerConsumer; + +public class Application { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/b03b900e86d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/b03b900e86d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..746fa08 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/f9/b03b900e86d0001a1a4afd166bbfcbff @@ -0,0 +1,116 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + StringWorker reverser = (s) -> { + String result =""; + for(int i = s.length(); i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + System.out.println(reverser.work("Vehicle"); + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fb/9023ce68bdcf001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fb/9023ce68bdcf001a1a4afd166bbfcbff new file mode 100644 index 0000000..e69de29 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fc/10b3451f0acd001a1d8e8781d501fb14 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fc/10b3451f0acd001a1d8e8781d501fb14 new file mode 100644 index 0000000..6641c89 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fc/10b3451f0acd001a1d8e8781d501fb14 @@ -0,0 +1,24 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Consumer implements Runnable() { + + int questionNo; + BlockingQueue questionQueue; + + public Consumer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + questionNo++; + try { + questionQueue.put(questionNo); + } catch (InterruptedException e) { + + } + } + +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fe/60211123d8d0001a1a4afd166bbfcbff b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fe/60211123d8d0001a1a4afd166bbfcbff new file mode 100644 index 0000000..de2c429 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/fe/60211123d8d0001a1a4afd166bbfcbff @@ -0,0 +1,73 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + System.out.println("Printing cars between price 18000 and 22000"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getPrice() >= 18000 && c.getPrice() <= 22000; + } + }); + + System.out.println("Printing cars that are blue"); + printCars(cars, new CarCondition() { + + @Override + public boolean test(Car c) { + return c.getColor().equals("Blue"); + } + + }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + public static void printCars(List cars, CarCondition condition) { + for(Car c: cars) { + if(condition.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface CarCondition { + public boolean test(T t); +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ff/20c91c4bebcc001a1c9583c41c40e4f0 b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ff/20c91c4bebcc001a1c9583c41c40e4f0 new file mode 100644 index 0000000..86140a1 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.history/ff/20c91c4bebcc001a1c9583c41c40e4f0 @@ -0,0 +1,28 @@ +package arrayBlockingQueue; + +public class Producer Implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + + questionNo++; + try { + questionQueue.put(questionNo); + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + + private synchronized int getNextQuestion() { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + return nextQuestion; + } +} diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/.markers new file mode 100644 index 0000000..18061e4 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..a007781 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Sun Jul 12 15:41:58 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..b51efe8 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Collections/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/.markers new file mode 100644 index 0000000..fe2eacf Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..5c4e64e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Jul 14 06:12:51 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..e3c0fa5 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Generics/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/.markers new file mode 100644 index 0000000..07d23fd Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..86fa515 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Fri Jul 10 22:33:18 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..c8a4685 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/IO_and_Exceptions/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/62/77/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/62/77/history.index new file mode 100644 index 0000000..bf9cc9c Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/62/77/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/history.index new file mode 100644 index 0000000..25c7e9d Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/properties.index new file mode 100644 index 0000000..edd0459 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/7/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/77/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/77/history.index new file mode 100644 index 0000000..ddb064d Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/77/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/77/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/77/properties.index new file mode 100644 index 0000000..514a519 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/77/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/af/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/af/history.index new file mode 100644 index 0000000..9a6b071 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/af/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/62/77/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/62/77/history.index new file mode 100644 index 0000000..390fb63 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/62/77/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/b2/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/b2/history.index new file mode 100644 index 0000000..3030376 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/b2/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/ca/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/ca/history.index new file mode 100644 index 0000000..dd676ac Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/ca/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/e7/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/e7/history.index new file mode 100644 index 0000000..6bf56d2 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/e4/e7/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.markers new file mode 100644 index 0000000..cdb8a22 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..7d4578b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Sun Jul 26 11:38:47 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..965d17c Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/Lambdas/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/.markers new file mode 100644 index 0000000..9d58d85 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..bce7099 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Wed Jul 08 08:25:23 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..5fe7531 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/OOP/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/af/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/af/history.index new file mode 100644 index 0000000..913a1f7 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/af/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/e4/3/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/e4/3/history.index new file mode 100644 index 0000000..c157ff1 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/e4/3/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.markers new file mode 100644 index 0000000..2275305 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..43bdb88 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Thu Jul 23 12:25:16 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..039f4b5 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/arrayBlockingQueue/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/.markers new file mode 100644 index 0000000..0b94f44 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..beeefe5 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Jul 14 14:38:42 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..399d1f4 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/data-analysis/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/af/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/af/history.index new file mode 100644 index 0000000..452c3ff Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/af/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/3/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/3/history.index new file mode 100644 index 0000000..968f0dd Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/3/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/a8/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/a8/history.index new file mode 100644 index 0000000..cdbc570 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/a8/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/e2/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/e2/history.index new file mode 100644 index 0000000..6e235e0 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/e4/e2/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..2d4cbb3 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Wed Jul 22 14:37:16 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..c0c02e8 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/producerConsumer/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..8aa97d4 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Mon Jul 13 08:08:55 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..e244b31 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/stock-analysis/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/af/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/af/history.index new file mode 100644 index 0000000..5b90954 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/af/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/e4/ed/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/e4/ed/history.index new file mode 100644 index 0000000..facfa3d Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/e4/ed/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.markers new file mode 100644 index 0000000..c82aeb4 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..368d7f0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Thu Jul 23 13:42:57 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..bb4b12a Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadPools/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..9235f58 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Jul 14 16:07:00 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..79edce8 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingExamples/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.indexes/e4/35/history.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.indexes/e4/35/history.index new file mode 100644 index 0000000..bdb90b3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.indexes/e4/35/history.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.markers b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.markers new file mode 100644 index 0000000..0a1a68e Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/.markers differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/org.eclipse.egit.core/GitProjectData.properties b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..b492636 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Wed Jul 15 07:10:06 EDT 2020 +.gitdir=../../../.git diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/org.eclipse.jdt.core/state.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..57f5fc7 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.projects/threadingInventoryManager/org.eclipse.jdt.core/state.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 0000000..25cb955 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000..e7d4fed Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/9.tree b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/9.tree new file mode 100644 index 0000000..b971e0c Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.root/9.tree differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000..989f31e Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..dffc6b5 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +version=1 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs new file mode 100644 index 0000000..9dd00d6 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\r\n\r\n +preferredTargets=default\:default| diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs new file mode 100644 index 0000000..74425ae --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs @@ -0,0 +1,3 @@ +GitRepositoriesView.GitDirectories=C\:\\Users\\User\\Documents\\git\\Java\\.git; +GitRepositoriesView.GitDirectories.relative=C\:\\Users\\User\\Documents\\git\\Java\\.git; +eclipse.preferences.version=1 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..4d872eb --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs new file mode 100644 index 0000000..31df02c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.junit.content_assist_favorite_static_members_migrated=true diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 0000000..cec0726 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_VM_XML=\r\n\r\n \r\n \r\n \r\n\r\n diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..878411c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,12 @@ +content_assist_disabled_computers=org.eclipse.jdt.ui.textProposalCategory\u0000org.eclipse.jdt.ui.javaPostfixProposalCategory\u0000org.eclipse.jdt.ui.javaAllProposalCategory\u0000org.eclipse.jdt.ui.javaTypeProposalCategory\u0000org.eclipse.jdt.ui.javaNoTypeProposalCategory\u0000org.eclipse.jdt.ui.javaChainProposalCategory\u0000 +content_assist_lru_history= +content_assist_number_of_computers=18 +content_assist_proposals_background=255,255,255 +content_assist_proposals_foreground=0,0,0 +eclipse.preferences.version=1 +org.eclipse.jdt.internal.ui.navigator.layout=2 +org.eclipse.jdt.internal.ui.navigator.librariesnode=true +org.eclipse.jdt.ui.formatterprofiles.version=18 +spelling_locale_initialized=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jsch.core.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jsch.core.prefs new file mode 100644 index 0000000..d56c53f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jsch.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jsch.core.hasChangedDefaultWin32SshHome=true diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs new file mode 100644 index 0000000..67b1d96 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.discovery.pref.projects= diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs new file mode 100644 index 0000000..43e97e4 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +mylyn.attention.migrated=true diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs new file mode 100644 index 0000000..2a6fe50 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.java.ui.run.count.3_10_0=1 +org.eclipse.mylyn.java.ui.run.count.3_1_0=1 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs new file mode 100644 index 0000000..8d462a6 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 0000000..2b60c21 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +migrated.task.repositories.secure.store=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true +org.eclipse.mylyn.tasks.ui.welcome.message=true diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs new file mode 100644 index 0000000..61f3bb8 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +overviewRuler_migration=migrated_3.1 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs new file mode 100644 index 0000000..8aaf7f2 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -0,0 +1,5 @@ +PROBLEMS_FILTERS_MIGRATE=true +eclipse.preferences.version=1 +platformState=1590282607464 +quickStart=false +tipsAndTricks=true diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.navigator.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.navigator.prefs new file mode 100644 index 0000000..4f60fc3 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.navigator.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ui.navigator.ProjectExplorer.filterActivation=\:org.eclipse.jdt.java.ui.filters.HidePackageDeclaration\:org.eclipse.jdt.java.ui.filters.HideOutputFolder\:org.eclipse.buildship.ui.navigator.filter.gradle.subProject\:org.eclipse.ui.navigator.resources.nested.HideTopLevelProjectIfNested\:org.eclipse.buildship.ui.navigator.filter.gradle.buildfolder\:org.eclipse.jdt.java.ui.filters.HideEmptyInnerPackages\:org.eclipse.jdt.java.ui.filters.HideInnerClassFiles\:org.eclipse.ui.navigator.resources.filters.startsWithDot\:org.eclipse.jdt.java.ui.filters.HideEmptyLibraryContainers\:org.eclipse.jdt.java.ui.filters.HideImportDeclaration\:org.eclipse.jdt.java.ui.filters.HideSyntheticMembers\:org.eclipse.mylyn.tasks.ui.navigator.filters.tasks\:org.eclipse.ui.navigator.resources.nested.HideFolderWhenProjectIsShownAsNested\: diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs new file mode 100644 index 0000000..08076f2 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +showIntro=false diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs new file mode 100644 index 0000000..aa3dc02 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -0,0 +1,3 @@ +//org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false +PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery; +eclipse.preferences.version=1 diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/AggregatorApp.launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/AggregatorApp.launch new file mode 100644 index 0000000..f23106f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/AggregatorApp.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App (1).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App (1).launch new file mode 100644 index 0000000..3b63c04 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App (1).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App (2).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App (2).launch new file mode 100644 index 0000000..5b593cf --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App (2).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App.launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App.launch new file mode 100644 index 0000000..5cdaaf5 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/App.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (1).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (1).launch new file mode 100644 index 0000000..bac4be8 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (1).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (10).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (10).launch new file mode 100644 index 0000000..61f14d3 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (10).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (11).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (11).launch new file mode 100644 index 0000000..2335dd6 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (11).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (12).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (12).launch new file mode 100644 index 0000000..95c8d21 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (12).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (13).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (13).launch new file mode 100644 index 0000000..df1e530 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (13).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (2).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (2).launch new file mode 100644 index 0000000..8ae795c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (2).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (3).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (3).launch new file mode 100644 index 0000000..a0dd7f7 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (3).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (4).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (4).launch new file mode 100644 index 0000000..a03dd87 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (4).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (5).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (5).launch new file mode 100644 index 0000000..3f7a262 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (5).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (6).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (6).launch new file mode 100644 index 0000000..c486021 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (6).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (7).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (7).launch new file mode 100644 index 0000000..2f21dab --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (7).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (8).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (8).launch new file mode 100644 index 0000000..c60ee97 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (8).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (9).launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (9).launch new file mode 100644 index 0000000..394e82b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application (9).launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application.launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application.launch new file mode 100644 index 0000000..ae058e4 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Application.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Dealership.launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Dealership.launch new file mode 100644 index 0000000..2e0279b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Dealership.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Earth.launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Earth.launch new file mode 100644 index 0000000..bcd0b55 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/Earth.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/StockFileApplication.launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/StockFileApplication.launch new file mode 100644 index 0000000..5e6075e --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/StockFileApplication.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/ThreadPoolDemo.launch b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/ThreadPoolDemo.launch new file mode 100644 index 0000000..930381c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.core/.launches/ThreadPoolDemo.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml new file mode 100644 index 0000000..663e690 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml @@ -0,0 +1,8 @@ + +
+
+ + + +
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml new file mode 100644 index 0000000..5033785 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/Ahmad/cert/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 0000000..f987c2b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2407 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + + + topLevel + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + + + + org.eclipse.e4.primaryNavigationStack + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + + + + + + View + categoryTag:Mylyn + + + + org.eclipse.e4.secondaryNavigationStack + Minimized + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Ant + + + + + + org.eclipse.e4.secondaryDataStack + General + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + active + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + active + activeOnClose + + + + Editor + removeOnHide + org.eclipse.ui.DefaultTextEditor + + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Git + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + + + TrimStack + Draggable + + + + + TrimStack + Draggable + + + TrimStack + Draggable + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Team + + + + + View + categoryTag:Team + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1280503464.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1280503464.index new file mode 100644 index 0000000..0eaa753 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1280503464.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/147422107.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/147422107.index new file mode 100644 index 0000000..26f2b92 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/147422107.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1554272215.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1554272215.index new file mode 100644 index 0000000..011d5e7 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1554272215.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1671692264.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1671692264.index new file mode 100644 index 0000000..63b3067 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/1671692264.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/2090482743.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/2090482743.index new file mode 100644 index 0000000..21e0aa2 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/2090482743.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/2502015350.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/2502015350.index new file mode 100644 index 0000000..d38ed2e Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/2502015350.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3347677258.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3347677258.index new file mode 100644 index 0000000..b3e5a93 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3347677258.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3352537029.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3352537029.index new file mode 100644 index 0000000..de6e052 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3352537029.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3615940599.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3615940599.index new file mode 100644 index 0000000..74b3f1a Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3615940599.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3933804599.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3933804599.index new file mode 100644 index 0000000..d39ef08 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/3933804599.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/51683060.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/51683060.index new file mode 100644 index 0000000..89ac84e Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/51683060.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/756117498.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/756117498.index new file mode 100644 index 0000000..e13d0c3 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/756117498.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/772561704.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/772561704.index new file mode 100644 index 0000000..93f1680 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/772561704.index differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000..2c4b07c Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps new file mode 100644 index 0000000..5c1f31f Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt new file mode 100644 index 0000000..8586397 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000..63ce447 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt new file mode 100644 index 0000000..26a427f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt @@ -0,0 +1,13 @@ +INDEX VERSION 1.131+C:\Users\User\Documents\git\Java\Ahmad\cert\.metadata\.plugins\org.eclipse.jdt.core +3347677258.index +772561704.index +2090482743.index +3933804599.index +1280503464.index +3352537029.index +51683060.index +1554272215.index +3615940599.index +756117498.index +147422107.index +2502015350.index diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000..26ddd25 Binary files /dev/null and b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml new file mode 100644 index 0000000..b14d036 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml @@ -0,0 +1,4 @@ + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml new file mode 100644 index 0000000..0586af0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml @@ -0,0 +1,4 @@ + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000..a4ee3cb --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000..98d443c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 0000000..b11dc3f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,96 @@ + +
+ + +
+ + + + + +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ + +
+
+ + + + + + + + + + + + + +
+
+ + +
+
+ + + + + +
+
+ + + + + +
+
+ + + + +
+
+ +
+
+ + + + + +
+
+ + +
+
+ + + + + + +
+
+ + + + + +
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Collections/2020/7/29/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Collections/2020/7/29/refactorings.history new file mode 100644 index 0000000..f7ec999 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Collections/2020/7/29/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Collections/2020/7/29/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Collections/2020/7/29/refactorings.index new file mode 100644 index 0000000..d60510f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Collections/2020/7/29/refactorings.index @@ -0,0 +1,2 @@ +1594602476519 Delete element +1594641977215 Delete element diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Generics/2020/7/29/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Generics/2020/7/29/refactorings.history new file mode 100644 index 0000000..2a4316f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Generics/2020/7/29/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Generics/2020/7/29/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Generics/2020/7/29/refactorings.index new file mode 100644 index 0000000..54c88c6 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Generics/2020/7/29/refactorings.index @@ -0,0 +1,11 @@ +1594721580422 Delete element +1594721620561 Delete element +1594721650636 Delete element +1594726578922 Copy compilation unit +1594726609336 Delete element +1594727963257 Infer generic type arguments +1594728053515 Copy compilation unit +1594728070977 Delete element +1594728138664 Copy compilation unit +1594750455225 Rename type 'Applicaiton' +1594750472841 Rename type 'Applicaition' diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/28/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/28/refactorings.history new file mode 100644 index 0000000..776cf64 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/28/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/28/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/28/refactorings.index new file mode 100644 index 0000000..d36be53 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/28/refactorings.index @@ -0,0 +1,2 @@ +1594434811111 Delete element +1594505929822 Rename type 'MyFIleUtils' diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/29/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/29/refactorings.history new file mode 100644 index 0000000..d7770a0 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/29/refactorings.history @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/29/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/29/refactorings.index new file mode 100644 index 0000000..03a6f25 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/IO_and_Exceptions/2020/7/29/refactorings.index @@ -0,0 +1 @@ +1594580829187 Rename package 'fileReader' diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Lambdas/2020/7/31/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Lambdas/2020/7/31/refactorings.history new file mode 100644 index 0000000..9c143f4 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Lambdas/2020/7/31/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Lambdas/2020/7/31/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Lambdas/2020/7/31/refactorings.index new file mode 100644 index 0000000..3b529ff --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/Lambdas/2020/7/31/refactorings.index @@ -0,0 +1,6 @@ +1595822275583 Delete element +1595991518248 Delete element +1595992882315 Delete element +1595992908252 Move compilation unit +1595992935907 Move files +1595992940171 Delete element diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/OOP/2020/7/28/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/OOP/2020/7/28/refactorings.history new file mode 100644 index 0000000..734f6fb --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/OOP/2020/7/28/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/OOP/2020/7/28/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/OOP/2020/7/28/refactorings.index new file mode 100644 index 0000000..bc27356 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/OOP/2020/7/28/refactorings.index @@ -0,0 +1,2 @@ +1594211140011 Delete element +1594211207040 Delete element diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/producerConsumer/2020/7/30/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/producerConsumer/2020/7/30/refactorings.history new file mode 100644 index 0000000..f05435d --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/producerConsumer/2020/7/30/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/producerConsumer/2020/7/30/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/producerConsumer/2020/7/30/refactorings.index new file mode 100644 index 0000000..8ccc161 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/producerConsumer/2020/7/30/refactorings.index @@ -0,0 +1,2 @@ +1595511076673 Rename package 'producerConsumer' +1595521547605 Move package diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingExamples/2020/7/29/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingExamples/2020/7/29/refactorings.history new file mode 100644 index 0000000..f5e3ecb --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingExamples/2020/7/29/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingExamples/2020/7/29/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingExamples/2020/7/29/refactorings.index new file mode 100644 index 0000000..704bf9f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingExamples/2020/7/29/refactorings.index @@ -0,0 +1,3 @@ +1594757228135 Delete element +1594810114127 Move compilation unit +1594811417767 Move package diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingInventoryManager/2020/7/29/refactorings.history b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingInventoryManager/2020/7/29/refactorings.history new file mode 100644 index 0000000..50f2bba --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingInventoryManager/2020/7/29/refactorings.history @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingInventoryManager/2020/7/29/refactorings.index b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingInventoryManager/2020/7/29/refactorings.index new file mode 100644 index 0000000..671617a --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/threadingInventoryManager/2020/7/29/refactorings.index @@ -0,0 +1,3 @@ +1594811412438 Delete element +1594811430708 Rename package 'threadSafetyWithCollections' +1594811607183 Rename type 'inventoryManager' diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml new file mode 100644 index 0000000..e0a3513 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml @@ -0,0 +1,16 @@ + +
+
+ + +
+
+ + + +
+
+ + +
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml new file mode 100644 index 0000000..e33758c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml @@ -0,0 +1,43 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/Ahmad/cert/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 0000000..1f73e14 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 0000000..5ca0b77 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml new file mode 100644 index 0000000..50f1edb --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 0000000..e9eb509 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,19 @@ + +
+
+ + +
+
+ + + + +
+
+ + + + +
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.intro/introstate b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 0000000..02f134f --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml new file mode 100644 index 0000000..6e63e5b --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml @@ -0,0 +1,23 @@ + +
+
+ + + + + + + + + + + +
+
+ + + + + +
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 0000000..3a7283c --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,7 @@ + +
+
+
+
+
+
diff --git a/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 0000000..bfe6551 --- /dev/null +++ b/Ahmad/cert/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Ahmad/cert/.metadata/version.ini b/Ahmad/cert/.metadata/version.ini new file mode 100644 index 0000000..1f497df --- /dev/null +++ b/Ahmad/cert/.metadata/version.ini @@ -0,0 +1,3 @@ +#Sun Jul 26 11:38:08 EDT 2020 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.15.0.v20200305-0155 diff --git a/Ahmad/cert/Collections/.classpath b/Ahmad/cert/Collections/.classpath new file mode 100644 index 0000000..038a0e7 --- /dev/null +++ b/Ahmad/cert/Collections/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/Collections/.gitignore b/Ahmad/cert/Collections/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/Collections/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/Collections/.project b/Ahmad/cert/Collections/.project new file mode 100644 index 0000000..c461daf --- /dev/null +++ b/Ahmad/cert/Collections/.project @@ -0,0 +1,17 @@ + + + Collections + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/Collections/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/Collections/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/Collections/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/Collections/bin/collectionMethods/Application.class b/Ahmad/cert/Collections/bin/collectionMethods/Application.class new file mode 100644 index 0000000..5704210 Binary files /dev/null and b/Ahmad/cert/Collections/bin/collectionMethods/Application.class differ diff --git a/Ahmad/cert/Collections/bin/collectionMethods/Employee.class b/Ahmad/cert/Collections/bin/collectionMethods/Employee.class new file mode 100644 index 0000000..9c26c63 Binary files /dev/null and b/Ahmad/cert/Collections/bin/collectionMethods/Employee.class differ diff --git a/Ahmad/cert/Collections/bin/maps/Application.class b/Ahmad/cert/Collections/bin/maps/Application.class new file mode 100644 index 0000000..e53f492 Binary files /dev/null and b/Ahmad/cert/Collections/bin/maps/Application.class differ diff --git a/Ahmad/cert/Collections/bin/traversingHashSets/Animal.class b/Ahmad/cert/Collections/bin/traversingHashSets/Animal.class new file mode 100644 index 0000000..5312cde Binary files /dev/null and b/Ahmad/cert/Collections/bin/traversingHashSets/Animal.class differ diff --git a/Ahmad/cert/Collections/bin/traversingHashSets/Application.class b/Ahmad/cert/Collections/bin/traversingHashSets/Application.class new file mode 100644 index 0000000..7dbe94a Binary files /dev/null and b/Ahmad/cert/Collections/bin/traversingHashSets/Application.class differ diff --git a/Ahmad/cert/Collections/bin/traversingLists/Application.class b/Ahmad/cert/Collections/bin/traversingLists/Application.class new file mode 100644 index 0000000..89f8bbe Binary files /dev/null and b/Ahmad/cert/Collections/bin/traversingLists/Application.class differ diff --git a/Ahmad/cert/Collections/bin/traversingLists/Vehicle.class b/Ahmad/cert/Collections/bin/traversingLists/Vehicle.class new file mode 100644 index 0000000..4cd72df Binary files /dev/null and b/Ahmad/cert/Collections/bin/traversingLists/Vehicle.class differ diff --git a/Ahmad/cert/Collections/src/collectionMethods/Application.java b/Ahmad/cert/Collections/src/collectionMethods/Application.java new file mode 100644 index 0000000..b413fff --- /dev/null +++ b/Ahmad/cert/Collections/src/collectionMethods/Application.java @@ -0,0 +1,48 @@ +package collectionMethods; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +public class Application { + + public static void main(String[] args) { + +// ArrayList list1 = new ArrayList(); +// HashSet list1 = new HashSet(); +// HashSet hashSet = new HashSet(); + HashSet hashSet = new HashSet(); + + hashSet.add(new Employee("Mike", 3500, "Accounting")); + hashSet.add(new Employee("Peter", 3000, "Admin")); + hashSet.add(new Employee("Paula", 4000, "IT")); + hashSet.add(new Employee("Joan", 2000, "Maint")); + + ArrayList myList = new ArrayList(hashSet); + + Collections.sort(myList); + + System.out.println(myList); + + +// List li = new ArrayList(list1); +// // converts hashset to list +// +// ArrayList newList = new ArrayList(); +// newList.add(10); +// newList.add(67); +// newList.add(15); +// +// list1.addAll(newList); +//// list1.removeAll(newList); +//// list1.clear(); +//// boolean hasValue = list1.contains(67); +// +// boolean hasValue = list1.retainAll(newList); +// //deletes anything not inside newList +// +// System.out.println(list1); +// System.out.println(hasValue); + } +} diff --git a/Ahmad/cert/Collections/src/collectionMethods/Employee.java b/Ahmad/cert/Collections/src/collectionMethods/Employee.java new file mode 100644 index 0000000..277d597 --- /dev/null +++ b/Ahmad/cert/Collections/src/collectionMethods/Employee.java @@ -0,0 +1,55 @@ +package collectionMethods; + +public class Employee implements Comparable{ + + String name; + int salary; + String department; + + + + @Override + public String toString() { + return "Employee [name=" + name + ", salary=" + salary + ", department=" + department + "]"; + } + + + @Override + public int compareTo(Employee o) { + // TODO Auto-generated method stub + return 0; + } + + + public Employee(String name, int salary, String department) { + super(); + this.name = name; + this.salary = salary; + this.department = department; + } + + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public int getSalary() { + return salary; + } + public void setSalary(int salary) { + this.salary = salary; + } + public String getDepartment() { + return department; + } + public void setDepartment(String department) { + this.department = department; + } + + + + + +} diff --git a/Ahmad/cert/Collections/src/maps/Application.java b/Ahmad/cert/Collections/src/maps/Application.java new file mode 100644 index 0000000..71f779c --- /dev/null +++ b/Ahmad/cert/Collections/src/maps/Application.java @@ -0,0 +1,32 @@ +package maps; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TreeMap; + +public class Application { + + public static void main(String[] args) { + +// HashMap dictionary = new HashMap(); +// LinkedHashMap dictionary = new LinkedHashMap(); + TreeMap dictionary = new TreeMap(); + + dictionary.put("Brave", "ready to face and endure danger or pain; showing courage."); + dictionary.put("Brilliant", "exceptionally clever or talented."); + dictionary.put("Joy", "a feeling of great pleasure and happiness."); + dictionary.put("Confidence", "the state of feeling certain about the truth of something."); + +// for(String word: dictionary.keySet()) { +// System.out.println(dictionary.get(word)); +// } + + for( Map.Entry entry: dictionary.entrySet()) { + System.out.println(entry.getKey()); + System.out.println(entry.getValue()); + } + + } + +} diff --git a/Ahmad/cert/Collections/src/traversingHashSets/Animal.java b/Ahmad/cert/Collections/src/traversingHashSets/Animal.java new file mode 100644 index 0000000..49dfcd9 --- /dev/null +++ b/Ahmad/cert/Collections/src/traversingHashSets/Animal.java @@ -0,0 +1,55 @@ +package traversingHashSets; + +public class Animal { + String name; + int age; + + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + age; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Animal other = (Animal) obj; + if (age != other.age) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + + + @Override + public String toString() { + return "Animal [name=" + name + ", age=" + age + "]"; + } + + + + public Animal(String name, int age) { + super(); + this.name = name; + this.age = age; + } + + +} diff --git a/Ahmad/cert/Collections/src/traversingHashSets/Application.java b/Ahmad/cert/Collections/src/traversingHashSets/Application.java new file mode 100644 index 0000000..1535277 --- /dev/null +++ b/Ahmad/cert/Collections/src/traversingHashSets/Application.java @@ -0,0 +1,37 @@ +package traversingHashSets; + +import java.util.HashSet; +import java.util.LinkedHashSet; + +public class Application { + + public static void main(String[] args) { +// LinkedHashSet animals = new LinkedHashSet(); + // linked HS maintains order of items entered + + HashSet animals = new HashSet(); + + Animal animal1 = new Animal("Dog", 12); + Animal animal2 = new Animal("Cat", 8); + Animal animal3 = new Animal("Bird", 3); + Animal animal4 = new Animal("Dog", 12); + Animal animal5 = new Animal("Kangaroo", 24); + + animals.add(animal1); + animals.add(animal2); + animals.add(animal3); + animals.add(animal4); + animals.add(animal5); + + System.out.println(animal1.equals(animal4)); + System.out.println(animal1.hashCode()); + System.out.println(animal4.hashCode()); + + System.out.println("****** \n"); + + for(Animal value : animals){ + System.out.println(value); + } + } + +} diff --git a/Ahmad/cert/Collections/src/traversingLists/Application.java b/Ahmad/cert/Collections/src/traversingLists/Application.java new file mode 100644 index 0000000..8bc0383 --- /dev/null +++ b/Ahmad/cert/Collections/src/traversingLists/Application.java @@ -0,0 +1,52 @@ +package traversingLists; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class Application { + + public static void main(String[] args) { + ArrayList animals = new ArrayList(); + animals.add("Lion"); + animals.add("Cat"); + animals.add("Dog"); + animals.add("Bird"); + +// for(int i =0; i < animals.size(); i++) { +// System.out.println(animals.get(i)); +// } +// +// System.out.println("*******"); +// +// for(String value : animals) { +// System.out.println(value); +// } + +// ArrayList vehicles = new ArrayList(); +// LinkedList vehicles = new LinkedList(); + List vehicles = new LinkedList(); + + + Vehicle vehicle2 = new Vehicle("Toyota", "Camary", 12000, false); + + vehicles.add(new Vehicle("Honda", "accord", 12000, false)); + vehicles.add(vehicle2); + vehicles.add(new Vehicle("Jeep", "Wrangler", 2500, true)); + +// for(Vehicle car : vehicles){ +// System.out.println(car); +// } + + printElements(vehicles); + System.out.println("*******"); + printElements(animals); + } + + public static void printElements(List someList) { + for(int i = 0; i < someList.size(); i++) { + System.out.println(someList.get(i)); + } + } + +} diff --git a/Ahmad/cert/Collections/src/traversingLists/Vehicle.java b/Ahmad/cert/Collections/src/traversingLists/Vehicle.java new file mode 100644 index 0000000..3c99043 --- /dev/null +++ b/Ahmad/cert/Collections/src/traversingLists/Vehicle.java @@ -0,0 +1,47 @@ +package traversingLists; + +public class Vehicle { + + String make; + String modle; + int price; + boolean fourWDrive; + + @Override + public String toString() { + return "Vehicle [make=" + make + ", modle=" + modle + ", price=" + price + ", fourWDrive=" + fourWDrive + "]"; + } + + public Vehicle(String make, String modle, int price, boolean fourWDrive) { + super(); + this.make = make; + this.modle = modle; + this.price = price; + this.fourWDrive = fourWDrive; + } + + public String getMake() { + return make; + } + public void setMake(String make) { + this.make = make; + } + public String getModle() { + return modle; + } + public void setModle(String modle) { + this.modle = modle; + } + public int getPrice() { + return price; + } + public void setPrice(int price) { + this.price = price; + } + public boolean isFourWDrive() { + return fourWDrive; + } + public void setFourWDrive(boolean fourWDrive) { + this.fourWDrive = fourWDrive; + } +} diff --git a/Ahmad/cert/Generics/.classpath b/Ahmad/cert/Generics/.classpath new file mode 100644 index 0000000..4ed3c97 --- /dev/null +++ b/Ahmad/cert/Generics/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/Generics/.gitignore b/Ahmad/cert/Generics/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/Generics/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/Generics/.project b/Ahmad/cert/Generics/.project new file mode 100644 index 0000000..35f7874 --- /dev/null +++ b/Ahmad/cert/Generics/.project @@ -0,0 +1,17 @@ + + + Generics + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/Generics/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/Generics/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/Generics/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/Generics/bin/generics/Application.class b/Ahmad/cert/Generics/bin/generics/Application.class new file mode 100644 index 0000000..0769ab4 Binary files /dev/null and b/Ahmad/cert/Generics/bin/generics/Application.class differ diff --git a/Ahmad/cert/Generics/bin/generics/Container.class b/Ahmad/cert/Generics/bin/generics/Container.class new file mode 100644 index 0000000..8aac33b Binary files /dev/null and b/Ahmad/cert/Generics/bin/generics/Container.class differ diff --git a/Ahmad/cert/Generics/bin/genericsWithWildcards/Accountant.class b/Ahmad/cert/Generics/bin/genericsWithWildcards/Accountant.class new file mode 100644 index 0000000..ff9d2a1 Binary files /dev/null and b/Ahmad/cert/Generics/bin/genericsWithWildcards/Accountant.class differ diff --git a/Ahmad/cert/Generics/bin/genericsWithWildcards/Application.class b/Ahmad/cert/Generics/bin/genericsWithWildcards/Application.class new file mode 100644 index 0000000..b7a0d5f Binary files /dev/null and b/Ahmad/cert/Generics/bin/genericsWithWildcards/Application.class differ diff --git a/Ahmad/cert/Generics/bin/genericsWithWildcards/Container.class b/Ahmad/cert/Generics/bin/genericsWithWildcards/Container.class new file mode 100644 index 0000000..94b799f Binary files /dev/null and b/Ahmad/cert/Generics/bin/genericsWithWildcards/Container.class differ diff --git a/Ahmad/cert/Generics/bin/genericsWithWildcards/Employee.class b/Ahmad/cert/Generics/bin/genericsWithWildcards/Employee.class new file mode 100644 index 0000000..2737b7c Binary files /dev/null and b/Ahmad/cert/Generics/bin/genericsWithWildcards/Employee.class differ diff --git a/Ahmad/cert/Generics/bin/genericsWithWildcards/override.class b/Ahmad/cert/Generics/bin/genericsWithWildcards/override.class new file mode 100644 index 0000000..df05cc9 Binary files /dev/null and b/Ahmad/cert/Generics/bin/genericsWithWildcards/override.class differ diff --git a/Ahmad/cert/Generics/src/generics/Application.java b/Ahmad/cert/Generics/src/generics/Application.java new file mode 100644 index 0000000..28a6278 --- /dev/null +++ b/Ahmad/cert/Generics/src/generics/Application.java @@ -0,0 +1,42 @@ +package generics; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + + +public class Application { + + public static void main(String[] args) { + Container container = new Container<>(12, "Hello"); + int val1 = container.getItem1(); + String val2 = container.getItem2(); + + SetmySet1 = new HashSet(); + mySet1.add("first"); + mySet1.add("second"); + mySet1.add("whatever"); + + SetmySet2 = new HashSet(); + mySet1.add("first"); + mySet1.add("second"); + mySet1.add("Computer"); + + Set resultSet = union(mySet1, mySet2); + + Iterator itr = resultSet.iterator(); + while(itr.hasNext()) { + String var = itr.next(); + System.out.println(var); + } + + } + + public static Set union(Set set1, Set set2){ + Set result = new HashSet(set1); + result.addAll(set2); + return result; + } + +} diff --git a/Ahmad/cert/Generics/src/generics/Container.java b/Ahmad/cert/Generics/src/generics/Container.java new file mode 100644 index 0000000..009e76f --- /dev/null +++ b/Ahmad/cert/Generics/src/generics/Container.java @@ -0,0 +1,37 @@ +package generics; + +public class Container { + + i1 item1; + i2 item2; + + public Container(i1 item1, i2 item2) { + super(); + this.item1 = item1; + this.item2 = item2; + }; + + public void printItems() { + System.out.println("Printing Contents of container: "); + System.out.println("Item 1: " + item1); + System.out.println("Item 1: " + item2); + } + + public i1 getItem1() { + return item1; + } + + public void setItem1(i1 item1) { + this.item1 = item1; + } + + public i2 getItem2() { + return item2; + } + + public void setItem2(i2 item2) { + this.item2 = item2; + } + + +} diff --git a/Ahmad/cert/Generics/src/genericsWithWildcards/Accountant.java b/Ahmad/cert/Generics/src/genericsWithWildcards/Accountant.java new file mode 100644 index 0000000..6913be8 --- /dev/null +++ b/Ahmad/cert/Generics/src/genericsWithWildcards/Accountant.java @@ -0,0 +1,8 @@ +package genericsWithWildcards; + +public class Accountant extends Employee { + + public void work() { + System.out.println("Accountant working"); + } +} diff --git a/Ahmad/cert/Generics/src/genericsWithWildcards/Application.java b/Ahmad/cert/Generics/src/genericsWithWildcards/Application.java new file mode 100644 index 0000000..51a2dac --- /dev/null +++ b/Ahmad/cert/Generics/src/genericsWithWildcards/Application.java @@ -0,0 +1,47 @@ +package genericsWithWildcards; + +import java.util.ArrayList; +import java.util.List; + +public class Application { + + public static void main(String[] args) { + + Object myObject = new Object(); + String myVar = "hello"; + myObject = myVar; + + Employee emp = new Employee(); + Accountant acc = new Accountant(); + emp = acc; + + ArrayList employees = new ArrayList(); + employees.add(new Employee()); + ArrayList accountants = new ArrayList(); + accountants.add(new Accountant()); + //employees = accountants; + + ArrayList employees2 = new ArrayList<>(); + ArrayList accountants2 = new ArrayList(); + employees2 = accountants2; + + // upper bound + ArrayList employees3 = new ArrayList<>(); + ArrayList accountants3 = new ArrayList(); + employees3 = accountants3; + + // lower bound + ArrayList employees4 = new ArrayList<>(); + ArrayList accountants4 = new ArrayList(); + employees4 = accountants4; + + makeEmployeeWork(accountants); + } + + public static void makeEmployeeWork(List employees) { + for(Employee emp : employees) { + emp.work(); + } + } + +} diff --git a/Ahmad/cert/Generics/src/genericsWithWildcards/Container.java b/Ahmad/cert/Generics/src/genericsWithWildcards/Container.java new file mode 100644 index 0000000..76c8ce1 --- /dev/null +++ b/Ahmad/cert/Generics/src/genericsWithWildcards/Container.java @@ -0,0 +1,37 @@ +package genericsWithWildcards; + +public class Container { + + i1 item1; + i2 item2; + + public Container(i1 item1, i2 item2) { + super(); + this.item1 = item1; + this.item2 = item2; + }; + + public void printItems() { + System.out.println("Printing Contents of container: "); + System.out.println("Item 1: " + item1); + System.out.println("Item 1: " + item2); + } + + public i1 getItem1() { + return item1; + } + + public void setItem1(i1 item1) { + this.item1 = item1; + } + + public i2 getItem2() { + return item2; + } + + public void setItem2(i2 item2) { + this.item2 = item2; + } + + +} diff --git a/Ahmad/cert/Generics/src/genericsWithWildcards/Employee.java b/Ahmad/cert/Generics/src/genericsWithWildcards/Employee.java new file mode 100644 index 0000000..4c0fcb1 --- /dev/null +++ b/Ahmad/cert/Generics/src/genericsWithWildcards/Employee.java @@ -0,0 +1,9 @@ +package genericsWithWildcards; + +public class Employee { + + @override + public void work() { + System.out.println("E,ployee working"); + } +} diff --git a/Ahmad/cert/Generics/src/genericsWithWildcards/override.java b/Ahmad/cert/Generics/src/genericsWithWildcards/override.java new file mode 100644 index 0000000..aee73cb --- /dev/null +++ b/Ahmad/cert/Generics/src/genericsWithWildcards/override.java @@ -0,0 +1,5 @@ +package genericsWithWildcards; + +public @interface override { + +} diff --git a/Ahmad/cert/IO_and_Exceptions/.classpath b/Ahmad/cert/IO_and_Exceptions/.classpath new file mode 100644 index 0000000..adeb0a3 --- /dev/null +++ b/Ahmad/cert/IO_and_Exceptions/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/IO_and_Exceptions/.gitignore b/Ahmad/cert/IO_and_Exceptions/.gitignore new file mode 100644 index 0000000..112a8b8 --- /dev/null +++ b/Ahmad/cert/IO_and_Exceptions/.gitignore @@ -0,0 +1,3 @@ +/bin/ + +../../../Buchalka/ diff --git a/Ahmad/cert/IO_and_Exceptions/.project b/Ahmad/cert/IO_and_Exceptions/.project new file mode 100644 index 0000000..29f649d --- /dev/null +++ b/Ahmad/cert/IO_and_Exceptions/.project @@ -0,0 +1,17 @@ + + + IO_and_Exceptions + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/IO_and_Exceptions/bin/default_package/Application.class b/Ahmad/cert/IO_and_Exceptions/bin/default_package/Application.class new file mode 100644 index 0000000..33e2c6d Binary files /dev/null and b/Ahmad/cert/IO_and_Exceptions/bin/default_package/Application.class differ diff --git a/Ahmad/cert/IO_and_Exceptions/bin/default_package/MyFileUtils$fooRuntimeErr.class b/Ahmad/cert/IO_and_Exceptions/bin/default_package/MyFileUtils$fooRuntimeErr.class new file mode 100644 index 0000000..6c4c70d Binary files /dev/null and b/Ahmad/cert/IO_and_Exceptions/bin/default_package/MyFileUtils$fooRuntimeErr.class differ diff --git a/Ahmad/cert/IO_and_Exceptions/bin/default_package/MyFileUtils.class b/Ahmad/cert/IO_and_Exceptions/bin/default_package/MyFileUtils.class new file mode 100644 index 0000000..a2d92d4 Binary files /dev/null and b/Ahmad/cert/IO_and_Exceptions/bin/default_package/MyFileUtils.class differ diff --git a/Ahmad/cert/IO_and_Exceptions/bin/learningFileReader/Application.class b/Ahmad/cert/IO_and_Exceptions/bin/learningFileReader/Application.class new file mode 100644 index 0000000..b239dc4 Binary files /dev/null and b/Ahmad/cert/IO_and_Exceptions/bin/learningFileReader/Application.class differ diff --git a/Ahmad/cert/IO_and_Exceptions/myFile.txt b/Ahmad/cert/IO_and_Exceptions/myFile.txt new file mode 100644 index 0000000..08ede7a --- /dev/null +++ b/Ahmad/cert/IO_and_Exceptions/myFile.txt @@ -0,0 +1,3 @@ +First random data +second sample set +third in the order of firsts \ No newline at end of file diff --git a/Ahmad/cert/IO_and_Exceptions/src/default_package/Application.java b/Ahmad/cert/IO_and_Exceptions/src/default_package/Application.java new file mode 100644 index 0000000..fa00124 --- /dev/null +++ b/Ahmad/cert/IO_and_Exceptions/src/default_package/Application.java @@ -0,0 +1,49 @@ +package default_package; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +public class Application { + + public static void main(String[] args) { + +// for(int i=0; i<=3; i++){ +// Scanner input = new Scanner(System.in); +// System.out.println("Enter some text: "); +// String enteredText = input.nextLine(); +// System.out.println(enteredText); +// } + + try { + File file = new File("myfile.txt"); + Scanner input = null; + input = new Scanner(file); + + while(input.hasNextLine()) { + String line = input.nextLine(); + System.out.println(line); + } + input.close(); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + // System.out.println("File not found."); + + } + + + MyFileUtils myUtil = new MyFileUtils(); + try { + System.out.println(myUtil.subtract10FromLargerNumber(5)); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + + +} diff --git a/Ahmad/cert/IO_and_Exceptions/src/default_package/MyFileUtils.java b/Ahmad/cert/IO_and_Exceptions/src/default_package/MyFileUtils.java new file mode 100644 index 0000000..d4dc8d2 --- /dev/null +++ b/Ahmad/cert/IO_and_Exceptions/src/default_package/MyFileUtils.java @@ -0,0 +1,17 @@ +package default_package; + +public class MyFileUtils { + + public int subtract10FromLargerNumber(int number) throws Exception { + if(number < 10) { + throw new fooRuntimeErr("Foo runtime exception..."); + } + return number -10; + } + + public class fooRuntimeErr extends Exception { + public fooRuntimeErr(String message) { + super(message); + } + } +} diff --git a/Ahmad/cert/IO_and_Exceptions/src/learningFileReader/Application.java b/Ahmad/cert/IO_and_Exceptions/src/learningFileReader/Application.java new file mode 100644 index 0000000..73c423f --- /dev/null +++ b/Ahmad/cert/IO_and_Exceptions/src/learningFileReader/Application.java @@ -0,0 +1,49 @@ +package learningFileReader; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; + +public class Application { + + public static void main(String[] args) { + + File file = new File("myfile.txt"); + BufferedReader bufferedReader = null; + FileReader fileReader = null; + + try(FileReader fileReader1 = new FileReader(file); + BufferedReader bufferedReader1 = new BufferedReader(fileReader1);) { + + String line = bufferedReader1.readLine(); + + while(line != null) { + System.out.println(line); + line = bufferedReader1.readLine(); + } + + + } catch (FileNotFoundException e) { + System.out.println("File not found"); + } catch (IOException e) { + System.out.println("Problem reading the file " + file.getName()); + +// } finally { +// try { +// if(bufferedReader != null) { +// bufferedReader.close(); +// } +// if(fileReader != null) { +// fileReader.close(); +// } +// } catch (IOException e) { +// System.out.println("unable to close file " + file.getName()); +// } catch(NullPointerException ex) { +// System.out.println(" file was probably never opened" + ex); +// } + } + } + +} diff --git a/Ahmad/cert/Lambdas/.classpath b/Ahmad/cert/Lambdas/.classpath new file mode 100644 index 0000000..f104eb5 --- /dev/null +++ b/Ahmad/cert/Lambdas/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Ahmad/cert/Lambdas/.gitignore b/Ahmad/cert/Lambdas/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/Lambdas/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/Lambdas/.project b/Ahmad/cert/Lambdas/.project new file mode 100644 index 0000000..6c60625 --- /dev/null +++ b/Ahmad/cert/Lambdas/.project @@ -0,0 +1,17 @@ + + + Lambdas + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/Lambdas/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/Lambdas/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..021167a --- /dev/null +++ b/Ahmad/cert/Lambdas/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/ALambdaInterface.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/ALambdaInterface.class new file mode 100644 index 0000000..cc4598b Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/ALambdaInterface.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/App.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/App.class new file mode 100644 index 0000000..c5ebf40 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/App.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/Calculate.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/Calculate.class new file mode 100644 index 0000000..f5041e6 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/Calculate.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/Human.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/Human.class new file mode 100644 index 0000000..baf9740 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/Human.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/MyGenericInterface.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/MyGenericInterface.class new file mode 100644 index 0000000..59877bb Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/MyGenericInterface.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/NumberWorker.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/NumberWorker.class new file mode 100644 index 0000000..4c86666 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/NumberWorker.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/Robot.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/Robot.class new file mode 100644 index 0000000..6880e13 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/Robot.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/StringWorker.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/StringWorker.class new file mode 100644 index 0000000..b0fc40d Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/StringWorker.class differ diff --git a/Ahmad/cert/Lambdas/bin/lambdasPractice/Walkable.class b/Ahmad/cert/Lambdas/bin/lambdasPractice/Walkable.class new file mode 100644 index 0000000..880e1c3 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/lambdasPractice/Walkable.class differ diff --git a/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/App.class b/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/App.class new file mode 100644 index 0000000..513de57 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/App.class differ diff --git a/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/Car.class b/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/Car.class new file mode 100644 index 0000000..5d02acd Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/Car.class differ diff --git a/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/Condition.class b/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/Condition.class new file mode 100644 index 0000000..216d319 Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/practicalLamdbaExample/Condition.class differ diff --git a/Ahmad/cert/Lambdas/bin/stockDataCsv.text b/Ahmad/cert/Lambdas/bin/stockDataCsv.text new file mode 100644 index 0000000..a54a6ad --- /dev/null +++ b/Ahmad/cert/Lambdas/bin/stockDataCsv.text @@ -0,0 +1,6 @@ +APPL, 92, 145, 422, 600 +FB, 122, 221 +AMZN, 329, 690, 849 +GOOG, +NVDA, 110, 217 +AMD, 9, 7, 12, 14, 18 \ No newline at end of file diff --git a/Ahmad/cert/Lambdas/bin/streamsPractice/App.class b/Ahmad/cert/Lambdas/bin/streamsPractice/App.class new file mode 100644 index 0000000..d416cfd Binary files /dev/null and b/Ahmad/cert/Lambdas/bin/streamsPractice/App.class differ diff --git a/Ahmad/cert/Lambdas/bin/wordFile.txt b/Ahmad/cert/Lambdas/bin/wordFile.txt new file mode 100644 index 0000000..452d905 --- /dev/null +++ b/Ahmad/cert/Lambdas/bin/wordFile.txt @@ -0,0 +1,12 @@ +Hello +POwerade +Samantha +Bitcoin +Camera +Dry Cleaner +Computer Application +Health Insurance +Keyboard +Bottle +White Board +Education \ No newline at end of file diff --git a/Ahmad/cert/Lambdas/files/stockDataCsv.text b/Ahmad/cert/Lambdas/files/stockDataCsv.text new file mode 100644 index 0000000..a54a6ad --- /dev/null +++ b/Ahmad/cert/Lambdas/files/stockDataCsv.text @@ -0,0 +1,6 @@ +APPL, 92, 145, 422, 600 +FB, 122, 221 +AMZN, 329, 690, 849 +GOOG, +NVDA, 110, 217 +AMD, 9, 7, 12, 14, 18 \ No newline at end of file diff --git a/Ahmad/cert/Lambdas/files/wordFile.txt b/Ahmad/cert/Lambdas/files/wordFile.txt new file mode 100644 index 0000000..452d905 --- /dev/null +++ b/Ahmad/cert/Lambdas/files/wordFile.txt @@ -0,0 +1,12 @@ +Hello +POwerade +Samantha +Bitcoin +Camera +Dry Cleaner +Computer Application +Health Insurance +Keyboard +Bottle +White Board +Education \ No newline at end of file diff --git a/Ahmad/cert/Lambdas/src/lambdasPractice/ALambdaInterface.java b/Ahmad/cert/Lambdas/src/lambdasPractice/ALambdaInterface.java new file mode 100644 index 0000000..acb9c10 --- /dev/null +++ b/Ahmad/cert/Lambdas/src/lambdasPractice/ALambdaInterface.java @@ -0,0 +1,8 @@ +package lambdasPractice; + +@FunctionalInterface +public interface ALambdaInterface { + //public void walk(); + + public void someMethod(); +} diff --git a/Ahmad/cert/Lambdas/src/lambdasPractice/App.java b/Ahmad/cert/Lambdas/src/lambdasPractice/App.java new file mode 100644 index 0000000..68ed144 --- /dev/null +++ b/Ahmad/cert/Lambdas/src/lambdasPractice/App.java @@ -0,0 +1,143 @@ +package lambdasPractice; + +public class App { + + public static void main(String[] args) { + + Human tom = new Human(); + // tom.walk(); + walker(tom); + + Robot wally = new Robot(); + //wally.walk(); + walker(wally); + +// // anonymous class definition +// walker(new Walkable() { +// +// @Override +// public void walk() { +// System.out.println("Custom object walking ..."); +// // behavior not tied to any class +// } +// }); + + // lambda expression + // walker(() -> System.out.println("Custom object walking ....")); +//// ALambdaInterface aBlockOfCode = () -> { +//// System.out.println("Custom object walking ...."); +//// }; + + Walkable aBlockOfCode = () -> { + System.out.println("Custom object walking..."); + System.out.println("the object tripped..."); + }; + + walker(aBlockOfCode); + ALambdaInterface helloVar = () -> System.out.println("hello there"); + helloVar.someMethod(); + + + Calculate sumVar = (a, b) -> a + b; + System.out.println(sumVar.compute(4, 6)); + + + //// +// public int sum(int arg1, int arg2) { +// return arg1+arg2; +// } + + + // public method +// public int nonZeroDivide(int arg1, int arg2) { +// if(arg1==0) { +// return 0; +// } +// return arg1/arg2; +// } + + // lambda expression + Calculate nonZeroDivider = (a, b) -> { + if(a == 0 ) { + return 0; + } + return a/b; + }; + + System.out.println(nonZeroDivider.compute(10,2)); + + //StringWorker reverser = (s) -> { + MyGenericInterface reverser = (s) -> { + String result =""; + for(int i = s.length()-1; i >=0; i--) { + result += s.charAt(i); + } + return result; + }; + + + NumberWorker computedNumber = (n) -> { + int result = 1; + for(int i =1; i<= n; i++) { + result =i*result; + } + return result; + }; + + System.out.println(reverser.work("Vehicle")); + System.out.println(computedNumber.compute(4)); + } + + // public factorial method + public int factorial(int num) { + int result = 1; + for(int i =1; i<= num; i++) { + result =i*result; + } + return result; + } + + + + + + +// public void sayHello() { +// System.out.println("hello there"); +// } + +// public static void walker(Human human) { +// human.walk(); +// } + + + // public reverse-String method +// public String reverse(String str) { +// String result = ""; +// for(int i = str.length() - 1; i >=0; i--) { +// result = str +str.charAt(i); +// } +// return result; + + + + public static void walker(Walkable walkableEntity) { + walkableEntity.walk(); + } +} + +interface Calculate{ + public int compute(int a, int b); +} + +interface StringWorker { + public String work(String str); +} + +interface NumberWorker{ + public int compute(int a); +} + +interface MyGenericInterface{ + public T work(T t); +} diff --git a/Ahmad/cert/Lambdas/src/lambdasPractice/Human.java b/Ahmad/cert/Lambdas/src/lambdasPractice/Human.java new file mode 100644 index 0000000..998f68c --- /dev/null +++ b/Ahmad/cert/Lambdas/src/lambdasPractice/Human.java @@ -0,0 +1,7 @@ +package lambdasPractice; + +public class Human implements Walkable { + public void walk() { + System.out.println("Human Walking"); + } +} diff --git a/Ahmad/cert/Lambdas/src/lambdasPractice/Robot.java b/Ahmad/cert/Lambdas/src/lambdasPractice/Robot.java new file mode 100644 index 0000000..7f297fe --- /dev/null +++ b/Ahmad/cert/Lambdas/src/lambdasPractice/Robot.java @@ -0,0 +1,7 @@ +package lambdasPractice; + +public class Robot implements Walkable { + public void walk() { + System.out.println("Robot Walking"); + } +} diff --git a/Ahmad/cert/Lambdas/src/lambdasPractice/Walkable.java b/Ahmad/cert/Lambdas/src/lambdasPractice/Walkable.java new file mode 100644 index 0000000..db5febc --- /dev/null +++ b/Ahmad/cert/Lambdas/src/lambdasPractice/Walkable.java @@ -0,0 +1,5 @@ +package lambdasPractice; + +public interface Walkable { + public void walk(); +} diff --git a/Ahmad/cert/Lambdas/src/practicalLamdbaExample/App.java b/Ahmad/cert/Lambdas/src/practicalLamdbaExample/App.java new file mode 100644 index 0000000..98bdd04 --- /dev/null +++ b/Ahmad/cert/Lambdas/src/practicalLamdbaExample/App.java @@ -0,0 +1,82 @@ +package practicalLamdbaExample; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; + +public class App { + + public static void main(String[] args) { + + List cars = Arrays.asList( + new Car("Honda", "Acord", "Red", 22300), + new Car("Honda", "Civic", "Blue", 17700), + new Car("Toyota", "Land Cruiser", "White", 48500), + new Car("Toyota", "Corolla", "Black", 16200), + new Car("Toyota", "Camry", "Blue", 24000), + new Car("Nissan", "Sentra", "White", 17300), + new Car("Mistubishi", "Lancer", "White", 20000), + new Car("Jeep", "Wrangler", "Red", 24500) + ); + + Function priceAndColor = (c) -> " price = " + c.getPrice() + " color = " + c.getColor(); + +// printCarsPriceRange(cars, 18000, 22000); +// printCarByColor(cars, "Red"); + + + + System.out.println("Printing cars between price 18000 and 22000"); + System.out.println("Printing cars that are blue"); + +// printCars(cars, new CarCondition() { +// @Override +// public boolean test(Car c) { +// return c.getPrice() >= 18000 && c.getPrice() <= 22000; +// } +// }); + + +// printCars(cars, new CarCondition() { +// +// @Override +// public boolean test(Car c) { +// return c.getColor().equals("Blue"); +// } +// +// }); + + printCars(cars, (c) -> c.getPrice() >= 18000 && c.getPrice() <= 22000); + } + + // public static void printCars(List cars, CarCondition condition) { + public static void printCars(List cars, Predicate predicate) { + for(Car c: cars) { + if(predicate.test(c)) { + c.printCar(); + } + } + } + + public static void printCarsPriceRange(List cars, int low, int high) { + for(Car c: cars) { + if(low <= c.getPrice() && c.getPrice() <= high) { + c.printCar(); + } + } + } + + public static void printCarByColor(List cars, String color) { + for(Car c: cars) { + if(c.getColor().contentEquals(color)) { + c.printCar(); + } + } + } +} + +@FunctionalInterface +interface Condition { + public boolean test(T t); +} diff --git a/Ahmad/cert/Lambdas/src/practicalLamdbaExample/Car.java b/Ahmad/cert/Lambdas/src/practicalLamdbaExample/Car.java new file mode 100644 index 0000000..1f0f10b --- /dev/null +++ b/Ahmad/cert/Lambdas/src/practicalLamdbaExample/Car.java @@ -0,0 +1,48 @@ +package practicalLamdbaExample; + +public class Car { + String make, model, color; + int price; + public Car(String make, String model, String color, int price) { + super(); + this.make = make; + this.model = model; + this.color = color; + this.price = price; + } + public String getMake() { + return make; + } + public void setMake(String make) { + this.make = make; + } + public String getModel() { + return model; + } + public void setModel(String model) { + this.model = model; + } + public String getColor() { + return color; + } + public void setColor(String color) { + this.color = color; + } + public int getPrice() { + return price; + } + public void setPrice(int price) { + this.price = price; + } + + public void printCar() { + System.out.println(this); + } + + @Override + public String toString() { + return "Car [make=" + make + ", model=" + model + ", color=" + color + ", price=" + price + "]"; + } + + +} diff --git a/Ahmad/cert/Lambdas/src/streamsPractice/App.java b/Ahmad/cert/Lambdas/src/streamsPractice/App.java new file mode 100644 index 0000000..e446a69 --- /dev/null +++ b/Ahmad/cert/Lambdas/src/streamsPractice/App.java @@ -0,0 +1,95 @@ +package streamsPractice; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class App { + + public static void main(String[] args) throws IOException { + + // Filter streams w. first val greater than 15 + Stream rows = Files.lines(Paths.get("files/stockDataCsv.text")); + rows.map(x -> x.split(",")) //convert to list + .filter(x -> x.length > 3) // filter length greater than 3 + .filter(x -> Integer.parseInt(x[1].trim()) > 15) // convert to ints, val greater than 15 + .forEach(x -> System.out.println(x[0].trim() + " " + x[2].trim() + " " + x[3].trim())); // print remaining stream elms + rows.close(); + + + // Return rowCount mathcing length greater than 3 + Stream rows1 = Files.lines(Paths.get("files/stockDataCsv.text")); + int rowCount = (int) rows1 + .map(x -> x.split(",")) + .filter(x -> x.length > 3) + .count(); + System.out.println(rowCount + " good rows."); + rows1.close(); + + + + // Filter words that contain 'th' + List words = Files.lines(Paths.get("files/wordFile.txt")) + .filter(x -> x.contains("th")) + .collect(Collectors.toList()); // converts stream of words to collection + words.forEach(x -> System.out.print(x + ", ")); + System.out.println(); + + // Filter words w. length greater than 6 + Stream lines = Files.lines(Paths.get("files/wordFile.txt")); + lines.sorted() + .filter(l -> l.length() > 6) + .forEach(x -> System.out.print(x + ", ")); + lines.close(); + + // Stream from a list, filter and print + List listOfItems = Arrays.asList("Computer", "Toothpaste", "Box", "Pencil", "Car", "Tent", "Door", "Toy"); + listOfItems.stream() + .map(x -> x.toLowerCase()) + .filter(x -> x.startsWith("c")) + .sorted() + .forEach(x -> System.out.print(x + ", \n")); + + // Average of squares of an int array + Arrays.stream(new int[] {2, 4, 6, 8, 10}) + .map((x) -> x * x) + .average() + .ifPresent(n -> System.out.print(n)); + System.out.println(); + + + // Stream from Array, sort, filter and print + String[] items = {"car", "computer", "toothpaste", "box", "pencil", "tent", "door", "toy"}; + Stream.of(items) + .filter((x) -> x.startsWith("t")) + .sorted().forEach(x -> System.out.println(x + ", ")); + System.out.println(); + + // Stream.of, sorted and findFirst + Stream.of("Hello", "bottle", "Africa") + .sorted() + .findFirst() + .ifPresent((x) -> System.out.println(x)); + + + // Integer stream with sum + int val = IntStream + .range(1, 5) + .sum(); + System.out.println(val); + + + // Integer Stream with Skip + IntStream + .range(1, 10) + .skip(5) // skip 5 elements of the stream + .forEach((x) -> System.out.println(x)); + System.out.println(); + } + +} diff --git a/Ahmad/cert/OOP/.classpath b/Ahmad/cert/OOP/.classpath new file mode 100644 index 0000000..038a0e7 --- /dev/null +++ b/Ahmad/cert/OOP/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/OOP/.gitignore b/Ahmad/cert/OOP/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/OOP/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/OOP/.project b/Ahmad/cert/OOP/.project new file mode 100644 index 0000000..7b61216 --- /dev/null +++ b/Ahmad/cert/OOP/.project @@ -0,0 +1,17 @@ + + + OOP + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/OOP/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/OOP/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/OOP/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/OOP/bin/car_dealership/Customer.class b/Ahmad/cert/OOP/bin/car_dealership/Customer.class new file mode 100644 index 0000000..503c395 Binary files /dev/null and b/Ahmad/cert/OOP/bin/car_dealership/Customer.class differ diff --git a/Ahmad/cert/OOP/bin/car_dealership/Dealership.class b/Ahmad/cert/OOP/bin/car_dealership/Dealership.class new file mode 100644 index 0000000..a8e214a Binary files /dev/null and b/Ahmad/cert/OOP/bin/car_dealership/Dealership.class differ diff --git a/Ahmad/cert/OOP/bin/car_dealership/Employee.class b/Ahmad/cert/OOP/bin/car_dealership/Employee.class new file mode 100644 index 0000000..eeb358f Binary files /dev/null and b/Ahmad/cert/OOP/bin/car_dealership/Employee.class differ diff --git a/Ahmad/cert/OOP/bin/car_dealership/Vehicle.class b/Ahmad/cert/OOP/bin/car_dealership/Vehicle.class new file mode 100644 index 0000000..ce45cb3 Binary files /dev/null and b/Ahmad/cert/OOP/bin/car_dealership/Vehicle.class differ diff --git a/Ahmad/cert/OOP/bin/oop/Earth.class b/Ahmad/cert/OOP/bin/oop/Earth.class new file mode 100644 index 0000000..7028162 Binary files /dev/null and b/Ahmad/cert/OOP/bin/oop/Earth.class differ diff --git a/Ahmad/cert/OOP/bin/oop/Human.class b/Ahmad/cert/OOP/bin/oop/Human.class new file mode 100644 index 0000000..6fcd1fa Binary files /dev/null and b/Ahmad/cert/OOP/bin/oop/Human.class differ diff --git a/Ahmad/cert/OOP/src/car_dealership/Customer.java b/Ahmad/cert/OOP/src/car_dealership/Customer.java new file mode 100644 index 0000000..5a1227b --- /dev/null +++ b/Ahmad/cert/OOP/src/car_dealership/Customer.java @@ -0,0 +1,46 @@ +package car_dealership; + +public class Customer { + + private String name; + private String address; + private double cashOnHand; + + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public String getAddress() { + return address; + } + + + public void setAddress(String address) { + address += "Dealership City"; + this.address = address; + } + + + public double getCashOnHand() { + return cashOnHand; + } + + + public void setCashOnHand(double cashOnHand) { + cashOnHand += 5000; + this.cashOnHand = cashOnHand; + } + + + public void purchaseCar(Vehicle vehicle, Employee emp, boolean finance) { + emp.handleCustomer(this, finance, vehicle); + + } +} diff --git a/Ahmad/cert/OOP/src/car_dealership/Dealership.java b/Ahmad/cert/OOP/src/car_dealership/Dealership.java new file mode 100644 index 0000000..f25d42a --- /dev/null +++ b/Ahmad/cert/OOP/src/car_dealership/Dealership.java @@ -0,0 +1,24 @@ +package car_dealership; + +public class Dealership { + + public static void main(String[] args) { + + Customer cust1 = new Customer(); + cust1.setName("Tom"); + cust1.setAddress("123 Something St, "); + cust1.setCashOnHand(12000); + + + Vehicle vehicle = new Vehicle("Honda", "Accord", 1500); +// vehicle.setMake("Honda"); +// vehicle.setModel("Accord"); +// vehicle.setPrice(15000); + + Employee emp = new Employee(); + + cust1.purchaseCar(vehicle, emp, false); + + } + +} diff --git a/Ahmad/cert/OOP/src/car_dealership/Employee.java b/Ahmad/cert/OOP/src/car_dealership/Employee.java new file mode 100644 index 0000000..ec29cad --- /dev/null +++ b/Ahmad/cert/OOP/src/car_dealership/Employee.java @@ -0,0 +1,29 @@ +package car_dealership; + +public class Employee { + + public void handleCustomer(Customer cust, boolean finance, Vehicle vehicle) { + if(finance == true) { + double loanAmount = vehicle.getPrice() - cust.getCashOnHand(); + runCreditHistory(cust, loanAmount); + }else if (vehicle.getPrice() <= cust.getCashOnHand()) { + // customer pays in cash + processTransaction(cust, vehicle); + } else { + System.out.println("Customer will need more money to purchase vehicle: " + vehicle); + } + } + + public void runCreditHistory(Customer cust, double loanAmount) { + System.out.println("Ran credit history for Customer ..."); + System.out.println("Customer has been approved to purchase the vehicle"); + } + + + private void processTransaction(Customer cust, Vehicle vehicle) { + System.out.println("Customer has purchased the vehicle: " + + vehicle + " for the price " + vehicle.getPrice()); + } + + +} diff --git a/Ahmad/cert/OOP/src/car_dealership/Vehicle.java b/Ahmad/cert/OOP/src/car_dealership/Vehicle.java new file mode 100644 index 0000000..958dd95 --- /dev/null +++ b/Ahmad/cert/OOP/src/car_dealership/Vehicle.java @@ -0,0 +1,49 @@ +package car_dealership; + +public class Vehicle { + + private String make; + private String model; + private double price; + + // src: generate constructor using fields + public Vehicle(String make, String model, double price) { + super(); + this.make = make; + this.model = model; + this.price = price; + } + + public String getMake() { + return make; + } + + public void setMake(String make) { + this.make = make; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public void setPrice(double price) { + this.price = price; + } + + public double getPrice() { + // TODO Auto-generated method stub + return price; + } + + + @Override + public String toString() { + return "Vehicle [make=" + make + ", model=" + model + ", price=" + price + "]"; + } + + +} diff --git a/Ahmad/cert/OOP/src/oop/Earth.java b/Ahmad/cert/OOP/src/oop/Earth.java new file mode 100644 index 0000000..3fa15ff --- /dev/null +++ b/Ahmad/cert/OOP/src/oop/Earth.java @@ -0,0 +1,17 @@ +package oop; + +public class Earth { + + public static void main(String[] args) { + + Human tom; + + tom = new Human(); + tom.age=5; + tom.eyeColor="brown"; + tom.heightInInches=72; + tom.name="Tom Zabo"; + + tom.speak(); + } +} diff --git a/Ahmad/cert/OOP/src/oop/Human.java b/Ahmad/cert/OOP/src/oop/Human.java new file mode 100644 index 0000000..0855fce --- /dev/null +++ b/Ahmad/cert/OOP/src/oop/Human.java @@ -0,0 +1,30 @@ +package oop; + +public class Human { + + String name; + int age; + int heightInInches; + String eyeColor; + + public void speak(){ + System.out.println("Hello, my name is " + name); + System.out.println("I am " + heightInInches + " inches tall"); + System.out.println("I am " + age + " years old"); + System.out.println("My eye color is " + eyeColor); + } + + public void eat() { + System.out.println("eating..."); + } + + public void walk() { + System.out.println("walking..."); + } + + public void work() { + System.out.println("working..."); + } + + +} diff --git a/Ahmad/cert/arrayBlockingQueue/.classpath b/Ahmad/cert/arrayBlockingQueue/.classpath new file mode 100644 index 0000000..038a0e7 --- /dev/null +++ b/Ahmad/cert/arrayBlockingQueue/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/arrayBlockingQueue/.gitignore b/Ahmad/cert/arrayBlockingQueue/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/arrayBlockingQueue/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/arrayBlockingQueue/.project b/Ahmad/cert/arrayBlockingQueue/.project new file mode 100644 index 0000000..440f8af --- /dev/null +++ b/Ahmad/cert/arrayBlockingQueue/.project @@ -0,0 +1,17 @@ + + + arrayBlockingQueue + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/arrayBlockingQueue/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/arrayBlockingQueue/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/arrayBlockingQueue/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Application.class b/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Application.class new file mode 100644 index 0000000..4e45d8a Binary files /dev/null and b/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Application.class differ diff --git a/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Consumer.class b/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Consumer.class new file mode 100644 index 0000000..ee6f849 Binary files /dev/null and b/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Consumer.class differ diff --git a/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Producer.class b/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Producer.class new file mode 100644 index 0000000..2fe9196 Binary files /dev/null and b/Ahmad/cert/arrayBlockingQueue/bin/arrayBlockingQueue/Producer.class differ diff --git a/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Application.java b/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Application.java new file mode 100644 index 0000000..2acd61e --- /dev/null +++ b/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Application.java @@ -0,0 +1,20 @@ +package arrayBlockingQueue; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; + +public class Application { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + BlockingQueue questionQueue = new ArrayBlockingQueue(5); + + Thread t1 = new Thread(new Producer(questionQueue)); + Thread t2 = new Thread(new Consumer(questionQueue)); + + t1.start(); + t2.start(); + } + +} diff --git a/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Consumer.java b/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Consumer.java new file mode 100644 index 0000000..beb9bc8 --- /dev/null +++ b/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Consumer.java @@ -0,0 +1,25 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Consumer implements Runnable { + + BlockingQueue questionQueue; + + public Consumer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + while(true) { + try { + Thread.sleep(1000); + System.out.println("ANSWERED QUESTION: " + questionQueue.take()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + +} diff --git a/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Producer.java b/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Producer.java new file mode 100644 index 0000000..b50ce8a --- /dev/null +++ b/Ahmad/cert/arrayBlockingQueue/src/arrayBlockingQueue/Producer.java @@ -0,0 +1,36 @@ +package arrayBlockingQueue; + +import java.util.concurrent.BlockingQueue; + +public class Producer implements Runnable { + + int questionNo; + BlockingQueue questionQueue; + + public Producer(BlockingQueue questionQueue) { + this.questionQueue = questionQueue; + } + + @Override + public void run() { + while(true) { + try { + synchronized(this) { + int nextQuestion = questionNo++; + System.out.println("Got new Question: " + nextQuestion); + questionQueue.put(nextQuestion); + } + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + } +} +// +// +// +// private synchronized int getNextQuestion() { +// int nextQuestion = questionNo++; +// System.out.println("Got new Question: " + nextQuestion); +// return nextQuestion; +// } diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/.DS_Store b/Ahmad/cert/data-analysis/.DS_Store similarity index 97% rename from Darby/spring-demo-one/src/com/luv2code/springdemo/.DS_Store rename to Ahmad/cert/data-analysis/.DS_Store index 5008ddf..5172429 100644 Binary files a/Darby/spring-demo-one/src/com/luv2code/springdemo/.DS_Store and b/Ahmad/cert/data-analysis/.DS_Store differ diff --git a/Ahmad/cert/data-analysis/.classpath b/Ahmad/cert/data-analysis/.classpath new file mode 100644 index 0000000..b5891cf --- /dev/null +++ b/Ahmad/cert/data-analysis/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/data-analysis/.project b/Ahmad/cert/data-analysis/.project new file mode 100644 index 0000000..d61c177 --- /dev/null +++ b/Ahmad/cert/data-analysis/.project @@ -0,0 +1,17 @@ + + + stock-analysis + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/data-analysis/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/data-analysis/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/data-analysis/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/data-analysis/bin/.DS_Store b/Ahmad/cert/data-analysis/bin/.DS_Store new file mode 100644 index 0000000..1c68439 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/.DS_Store differ diff --git a/Ahmad/cert/data-analysis/bin/aggregators/Aggregator.class b/Ahmad/cert/data-analysis/bin/aggregators/Aggregator.class new file mode 100644 index 0000000..e40a89f Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/aggregators/Aggregator.class differ diff --git a/Ahmad/cert/data-analysis/bin/aggregators/AggregatorProcessor.class b/Ahmad/cert/data-analysis/bin/aggregators/AggregatorProcessor.class new file mode 100644 index 0000000..46a7696 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/aggregators/AggregatorProcessor.class differ diff --git a/Ahmad/cert/data-analysis/bin/aggregators/MaxAggregator.class b/Ahmad/cert/data-analysis/bin/aggregators/MaxAggregator.class new file mode 100644 index 0000000..db03e87 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/aggregators/MaxAggregator.class differ diff --git a/Ahmad/cert/data-analysis/bin/aggregators/MeanAggregator.class b/Ahmad/cert/data-analysis/bin/aggregators/MeanAggregator.class new file mode 100644 index 0000000..0f8bd84 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/aggregators/MeanAggregator.class differ diff --git a/Ahmad/cert/data-analysis/bin/aggregators/MinAggregator.class b/Ahmad/cert/data-analysis/bin/aggregators/MinAggregator.class new file mode 100644 index 0000000..7f5f905 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/aggregators/MinAggregator.class differ diff --git a/Ahmad/cert/data-analysis/bin/client/AggregatorApp.class b/Ahmad/cert/data-analysis/bin/client/AggregatorApp.class new file mode 100644 index 0000000..8858d70 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/client/AggregatorApp.class differ diff --git a/Ahmad/cert/data-analysis/bin/client/Application.class b/Ahmad/cert/data-analysis/bin/client/Application.class new file mode 100644 index 0000000..b2815b6 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/client/Application.class differ diff --git a/Ahmad/cert/data-analysis/bin/client/StockFileApplication.class b/Ahmad/cert/data-analysis/bin/client/StockFileApplication.class new file mode 100644 index 0000000..355fe66 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/client/StockFileApplication.class differ diff --git a/Ahmad/cert/data-analysis/bin/fileprocessors/StockFileData.class b/Ahmad/cert/data-analysis/bin/fileprocessors/StockFileData.class new file mode 100644 index 0000000..c3bacb0 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/fileprocessors/StockFileData.class differ diff --git a/Ahmad/cert/data-analysis/bin/fileprocessors/StockFileReader.class b/Ahmad/cert/data-analysis/bin/fileprocessors/StockFileReader.class new file mode 100644 index 0000000..8671c55 Binary files /dev/null and b/Ahmad/cert/data-analysis/bin/fileprocessors/StockFileReader.class differ diff --git a/Ahmad/cert/data-analysis/src/.DS_Store b/Ahmad/cert/data-analysis/src/.DS_Store new file mode 100644 index 0000000..1c68439 Binary files /dev/null and b/Ahmad/cert/data-analysis/src/.DS_Store differ diff --git a/Ahmad/cert/data-analysis/src/aggregators/Aggregator.java b/Ahmad/cert/data-analysis/src/aggregators/Aggregator.java new file mode 100644 index 0000000..79e9ac1 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/aggregators/Aggregator.java @@ -0,0 +1,34 @@ +package aggregators; + +import java.util.ArrayList; +import java.util.List; + +public abstract class Aggregator { + + List numbers; + + public Aggregator(){ + numbers = new ArrayList(); + } + + public Aggregator(List numbers){ + numbers = new ArrayList(numbers); + } + + /** + * add data to the given collection + * + */ + public void add(Double number) { + numbers.add(number); + } + /** + * Any class that is a derivative of the abstract class + * Aggregator must implement the calculate method. + * @return double + */ + public abstract double calculate(); + + public abstract List getValues(); + +} diff --git a/Ahmad/cert/data-analysis/src/aggregators/AggregatorProcessor.java b/Ahmad/cert/data-analysis/src/aggregators/AggregatorProcessor.java new file mode 100644 index 0000000..a65b3bf --- /dev/null +++ b/Ahmad/cert/data-analysis/src/aggregators/AggregatorProcessor.java @@ -0,0 +1,34 @@ +package aggregators; + +import java.io.IOException; +import java.util.List; + +import fileprocessors.StockFileReader; + +public class AggregatorProcessor { + + T aggregator; + String file; + + public AggregatorProcessor(T aggregator, String file) { + super(); + this.aggregator = aggregator; + this.file = file; + } + + public double runAggregator(int colIdx) throws IOException { + StockFileReader fileReader = new StockFileReader(file); + List lines = fileReader.readFileData(); + colIdx--; + + for(String line : lines){ + String [] numbers = line.split(","); + double value = Double.parseDouble(numbers[colIdx]); + aggregator.add(value); + } + + double number = aggregator.calculate(); + return number; + } + +} diff --git a/Ahmad/cert/data-analysis/src/aggregators/MaxAggregator.java b/Ahmad/cert/data-analysis/src/aggregators/MaxAggregator.java new file mode 100644 index 0000000..b330965 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/aggregators/MaxAggregator.java @@ -0,0 +1,24 @@ +package aggregators; + +import java.util.List; + +public class MaxAggregator extends Aggregator{ + + + @Override + public double calculate() { + double max = numbers.get(0); + for(double number : numbers){ + if(number > max){ + max = number; + } + } + return max; + } + + @Override + public List getValues() { + return numbers; + } + +} diff --git a/Ahmad/cert/data-analysis/src/aggregators/MeanAggregator.java b/Ahmad/cert/data-analysis/src/aggregators/MeanAggregator.java new file mode 100644 index 0000000..ad91e59 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/aggregators/MeanAggregator.java @@ -0,0 +1,24 @@ +package aggregators; + +import java.util.List; + +public class MeanAggregator extends Aggregator{ + + public double calculate() { + double result = 0; + if(!numbers.isEmpty()){ + double value = 0.00; + for(Number number : numbers){ + value+=number.doubleValue(); + } + result = value/numbers.size(); + } + return result; + } + + @Override + public List getValues() { + return numbers; + } + +} diff --git a/Ahmad/cert/data-analysis/src/aggregators/MinAggregator.java b/Ahmad/cert/data-analysis/src/aggregators/MinAggregator.java new file mode 100644 index 0000000..cfe7c82 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/aggregators/MinAggregator.java @@ -0,0 +1,23 @@ +package aggregators; + +import java.util.List; + +public class MinAggregator extends Aggregator{ + + @Override + public double calculate() { + double min = numbers.get(0); + for(double number : numbers){ + if(number < min){ + min = number; + } + } + return min; + } + + @Override + public List getValues() { + return numbers; + } + +} diff --git a/Ahmad/cert/data-analysis/src/client/AggregatorApp.java b/Ahmad/cert/data-analysis/src/client/AggregatorApp.java new file mode 100644 index 0000000..647b603 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/client/AggregatorApp.java @@ -0,0 +1,32 @@ +package client; + +import java.io.IOException; + +import aggregators.AggregatorProcessor; +import aggregators.MaxAggregator; +import aggregators.MinAggregator; + +public class AggregatorApp { + + public static void main(String[] args) throws IOException { + + /** + You'll need to uncomment the below code. You'll notice it does not compile! + + There are 2 objectives in this assignment. + + 1). Make sure the code compiles correctly after you uncomment it below. + 2). Make sure it runs as explained in the assignment video! + + -->> YOUR WORK SHOULD BE DONE IN THE AggregatorProcessor CLASS. + **/ + + MaxAggregator agg = new MaxAggregator(); + AggregatorProcessor aggsProcessor = new AggregatorProcessor(agg, "table.csv"); + double value = aggsProcessor.runAggregator(1); + System.out.println(value); + + + } + +} diff --git a/Ahmad/cert/data-analysis/src/client/Application.java b/Ahmad/cert/data-analysis/src/client/Application.java new file mode 100644 index 0000000..0b1d34f --- /dev/null +++ b/Ahmad/cert/data-analysis/src/client/Application.java @@ -0,0 +1,9 @@ +package client; + +public class Application { + + public static void main(String[] args) { + + } + +} diff --git a/Ahmad/cert/data-analysis/src/client/StockFileApplication.java b/Ahmad/cert/data-analysis/src/client/StockFileApplication.java new file mode 100644 index 0000000..7dcf5f4 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/client/StockFileApplication.java @@ -0,0 +1,36 @@ +package client; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import fileprocessors.StockFileData; +import fileprocessors.StockFileReader; + +public class StockFileApplication { + + public static void main(String args[]) throws IOException{ + StockFileReader fr = new StockFileReader("table.csv"); + + List> dataResult = populateStockFileData(fr.getHeaders(), fr.readFileData()); + StockFileData fileData = new StockFileData(); + fileData.addData(dataResult); + fileData.printData(); + System.out.println(dataResult.size()); + } + /** + * Complete the method body so that it returns the given structure needed to + * populate the data field in the StockFileData class. + * @param headers + * @param lines + * @return List + */ + public static List> populateStockFileData(List headers, List lines){ + List> dataResult = new ArrayList<>(); + // Insert your code here.. + return dataResult; + } + + +} diff --git a/Ahmad/cert/data-analysis/src/fileprocessors/StockFileData.java b/Ahmad/cert/data-analysis/src/fileprocessors/StockFileData.java new file mode 100644 index 0000000..112cb80 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/fileprocessors/StockFileData.java @@ -0,0 +1,18 @@ +package fileprocessors; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +public class StockFileData { + + List> data = new LinkedList<>(); + + public void printData(){ + System.out.println(data); + } + + public void addData(List> dataIn){ + data = dataIn; + } +} diff --git a/Ahmad/cert/data-analysis/src/fileprocessors/StockFileReader.java b/Ahmad/cert/data-analysis/src/fileprocessors/StockFileReader.java new file mode 100644 index 0000000..2e662c0 --- /dev/null +++ b/Ahmad/cert/data-analysis/src/fileprocessors/StockFileReader.java @@ -0,0 +1,52 @@ +package fileprocessors; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class StockFileReader { + + String filePath = null; + + public StockFileReader(String filePath){ + this.filePath = filePath; + } + + public List getHeaders() throws IOException{ + String line = readFirstLine(filePath); + String [] header = line.split(","); + List values = new ArrayList(); + values = Arrays.asList(header); + return values; + } + + static String readFirstLine(String path) throws IOException { + try (BufferedReader br = + new BufferedReader(new FileReader(path))) { + return br.readLine(); + } + } + /** + * Complete the body of this method. + * @return List + * @throws IOException + */ + public List readFileData() throws IOException{ + List lines = new ArrayList(); + try(BufferedReader br = new BufferedReader(new FileReader(filePath))){ + //skip the first line: + br.readLine(); + String line = null; + // populate data from next line onwards + while((line = br.readLine()) != null){ + lines.add(line); + } + } + return lines; + } + + +} diff --git a/Ahmad/cert/data-analysis/table.csv b/Ahmad/cert/data-analysis/table.csv new file mode 100644 index 0000000..be133f3 --- /dev/null +++ b/Ahmad/cert/data-analysis/table.csv @@ -0,0 +1,252 @@ +Open,High,Low,Close,Volume,Adj Close +142.440002,142.679993,141.850006,142.270004,17245200,142.270004 +141.220001,142.919998,141.160004,142.440002,23251100,142.440002 +141.880005,142,140.449997,140.679993,17271300,140.679993 +141.410004,142.039993,141.110001,141.199997,14660800,141.199997 +141.479996,141.880005,140.869995,141.830002,16424000,141.830002 +141.910004,142.380005,141.050003,141.050003,17652900,141.050003 +141.600006,142.149994,141.009995,141.800003,20238900,141.800003 +142.940002,143.350006,140.059998,141.630005,30275300,141.630005 +143.600006,143.880005,142.899994,143.169998,18473000,143.169998 +143.729996,144.179993,143.270004,143.339996,16621300,143.339996 +144.289993,144.520004,143.449997,143.660004,21118000,143.660004 +144.220001,145.460007,143.809998,144.020004,27481500,144.020004 +143.25,144.889999,143.169998,144.770004,19765700,144.770004 +143.710007,144.119995,143.050003,143.699997,19985700,143.699997 +143.720001,144.270004,143.009995,143.660004,19661700,143.660004 +144.190002,144.5,143.5,143.929993,21207300,143.929993 +143.679993,144.490005,143.190002,144.119995,29190000,144.119995 +140.910004,144.039993,140.619995,143.800003,33374800,143.800003 +139.389999,141.220001,138.619995,140.880005,23575100,140.880005 +141.5,141.740005,140.350006,140.639999,22395600,140.639999 +141.259995,141.580002,140.610001,140.919998,20346300,140.919998 +139.850006,141.600006,139.759995,141.419998,25860200,141.419998 +142.110001,142.800003,139.729996,139.839996,39529900,139.839996 +140.399994,141.5,140.229996,141.460007,21542000,141.460007 +141,141,139.889999,139.990005,43885000,139.990005 +140.720001,141.020004,140.259995,140.690002,19232000,140.690002 +139.410004,140.75,139.029999,140.460007,25691800,140.460007 +139.300003,139.649994,138.839996,138.990005,15309100,138.990005 +138.850006,139.429993,138.820007,139.199997,17421700,139.199997 +139.25,139.360001,138.639999,139.139999,19612800,139.139999 +138.740005,138.789993,137.050003,138.679993,22155900,138.679993 +138.949997,139.800003,138.820007,139,18707200,139 +139.059998,139.979996,138.789993,139.520004,17446300,139.520004 +139.369995,139.770004,138.600006,139.339996,21750000,139.339996 +138.779999,139.830002,138.589996,139.779999,21108100,139.779999 +140,140.279999,138.759995,138.960007,26211000,138.960007 +137.889999,140.149994,137.600006,139.789993,36414600,139.789993 +137.080002,137.440002,136.699997,136.990005,23482900,136.990005 +137.139999,137.440002,136.279999,136.929993,20257400,136.929993 +135.910004,136.660004,135.279999,136.660004,21776600,136.660004 +137.380005,137.479996,136.300003,136.529999,20788200,136.529999 +136.429993,137.119995,136.110001,137.110001,20836900,137.110001 +136.229996,136.75,135.979996,136.699997,24507200,136.699997 +135.100006,135.830002,135.100006,135.720001,22198200,135.720001 +135.669998,135.899994,134.839996,135.350006,22584600,135.350006 +135.520004,136.270004,134.619995,135.509995,35623100,135.509995 +133.470001,135.089996,133.25,135.020004,33226200,135.020004 +133.080002,133.820007,132.75,133.289993,23035400,133.289993 +132.460007,132.940002,132.050003,132.119995,20065500,132.119995 +131.649994,132.449997,131.119995,132.419998,28349900,132.419998 +131.350006,132.220001,131.220001,132.039993,23004100,131.469994 +130.539993,132.089996,130.449997,131.529999,38183800,130.962201 +129.130005,130.5,128.899994,130.289993,26845900,129.727549 +128.309998,129.190002,128.160004,129.080002,24507300,128.522781 +127.980003,129.389999,127.779999,128.529999,33710400,127.975152 +127.029999,130.490005,127.010002,128.75,111985000,128.194203 +121.150002,121.389999,120.620003,121.349998,49201000,120.826147 +120.93,121.629997,120.660004,121.629997,30377500,121.104937 +122.139999,122.349998,121.599998,121.949997,20562900,121.423555 +121.669998,122.440002,121.599998,121.940002,26337600,121.413604 +120.419998,122.099998,120.279999,121.879997,32377600,121.353858 +119.550003,120.099998,119.5,119.970001,23211000,119.452107 +120,120.809998,119.769997,120.080002,22050200,119.561633 +120.449997,120.449997,119.730003,120,32597900,119.481976 +119.400002,120.089996,119.370003,119.779999,25597300,119.262925 +120,120.5,119.709999,119.989998,23713000,119.472017 +118.339996,120.239998,118.220001,120,34439800,119.481976 +119.110001,119.620003,118.809998,119.040001,26111900,118.526121 +118.900002,119.300003,118.209999,119.25,27086200,118.735214 +118.739998,119.93,118.599998,119.75,27588600,119.233055 +118.769997,119.379997,118.300003,119.110001,24462100,118.595819 +117.949997,119.43,117.940002,118.989998,33561900,118.476334 +116.779999,118.160004,116.470001,117.910004,31751900,117.401002 +115.919998,116.860001,115.809998,116.610001,22193600,116.106611 +115.849998,116.510002,115.75,116.019997,21118100,115.519154 +115.800003,116.330002,114.760002,116.150002,28781900,115.648597 +116.650002,117.199997,115.43,115.82,30586300,115.32002 +116.449997,117.110001,116.400002,116.730003,15039500,116.226096 +117.519997,118.019997,116.199997,116.760002,20905900,116.255965 +116.519997,117.800003,116.489998,117.260002,18296900,116.753806 +115.589996,116.519997,115.589996,116.519997,14181200,116.016995 +116.349998,116.510002,115.639999,116.290001,26085900,115.787993 +116.800003,117.400002,116.779999,117.059998,23783200,116.554665 +116.739998,117.5,116.68,116.949997,21425000,116.445139 +115.800003,117.379997,115.75,116.639999,27779400,116.13648 +116.470001,116.5,115.650002,115.970001,44351100,115.469374 +115.379997,116.730003,115.230003,115.82,46524500,115.32002 +115.040001,116.199997,114.980003,115.190002,34031800,114.692743 +113.839996,115.919998,113.75,115.190002,43733800,114.692743 +113.290001,115,112.489998,113.300003,26374400,112.810902 +112.309998,114.699997,112.309998,113.949997,34402600,113.45809 +110.860001,112.43,110.599998,112.120003,27068300,111.635996 +109.260002,111.190002,109.160004,111.029999,29998700,110.550697 +109.5,110.360001,109.190002,109.949997,26195500,109.475358 +110,110.029999,108.25,109.110001,34324500,108.638987 +109.169998,110.089996,108.849998,109.900002,26528000,109.425578 +110.370003,110.940002,109.029999,109.489998,37086900,109.017344 +111.599998,112.199997,110.269997,110.519997,36162300,110.042897 +110.779999,112.029999,110.07,111.459999,28528800,110.978841 +111.43,112.470001,111.389999,111.57,27194000,111.088367 +111.129997,111.870003,110.949997,111.790001,11475900,111.307418 +111.360001,111.510002,110.330002,111.230003,27426400,110.749838 +111.949997,112.419998,111.400002,111.800003,25965500,111.317377 +110.120003,111.989998,110.010002,111.730003,29264600,111.24768 +109.720001,110.540001,109.660004,110.059998,28428900,109.584883 +109.809998,110.349998,108.830002,109.949997,27632000,109.475358 +106.699997,110.230003,106.599998,109.989998,58840500,109.515186 +106.57,107.68,106.160004,107.110001,32264500,106.647621 +107.709999,107.809998,104.080002,105.709999,51175500,105.253663 +107.120003,108.870003,106.550003,108.43,34094100,107.961922 +111.089996,111.089996,105.830002,107.790001,57134500,107.324686 +109.879997,111.32,108.050003,110.879997,59176400,110.401343 +110.309998,111.720001,109.699997,111.059998,24054500,110.580566 +110.080002,110.510002,109.459999,110.410004,32560000,109.933378 +108.529999,110.25,108.110001,108.839996,30837000,108.370149 +110.980003,111.459999,109.550003,109.830002,26932600,109.35588 +111.400002,112.349998,111.230003,111.589996,28331700,110.540737 +113.459999,113.769997,110.529999,111.489998,43825800,110.441678 +113.650002,114.230003,113.199997,113.540001,26419400,112.472406 +113.870003,115.209999,113.449997,113.720001,37861700,112.650713 +115.389999,115.860001,114.099998,114.480003,34562000,113.403569 +114.309998,115.699997,113.309998,115.589996,66134200,114.503125 +117.949997,118.360001,117.309998,118.25,48129000,117.138118 +117.099998,117.739998,117,117.650002,23538700,116.543761 +116.809998,116.910004,116.279999,116.599998,23192700,115.503631 +116.860001,117.379997,116.330002,117.059998,24125800,115.959304 +117.25,117.760002,113.800003,117.120003,20034600,116.018745 +118.18,118.209999,117.449997,117.470001,24553500,116.365453 +117.330002,117.839996,116.779999,117.550003,23624900,116.444703 +117.879997,118.169998,117.129997,117.629997,35652200,116.523945 +116.790001,117.440002,115.720001,116.980003,35192400,115.880062 +117.349998,117.980003,116.75,117.339996,37586800,116.23667 +117.699997,118.690002,116.199997,116.300003,64041000,115.206456 +115.019997,116.75,114.720001,116.050003,36236000,114.958807 +114.309998,114.559998,113.510002,114.059998,24358400,112.987513 +113.699997,114.339996,113.129997,113.889999,28779300,112.819113 +113.400002,113.660004,112.690002,113.050003,21453100,111.987015 +113.059998,114.309998,112.629997,113,29736800,111.937482 +112.709999,113.050003,112.279999,112.519997,21701800,111.461992 +112.459999,113.370003,111.800003,113.050003,36379100,111.987015 +113.160004,113.800003,111.800003,112.18,35887000,111.125193 +113.690002,114.639999,113.43,113.949997,29641100,112.878547 +113,113.18,112.339996,113.089996,24607400,112.026632 +111.639999,113.389999,111.550003,112.879997,29869400,111.818608 +114.419998,114.790001,111.550003,112.709999,52481200,111.650208 +114.349998,114.940002,114,114.620003,31074000,113.542252 +113.849998,113.989998,112.440002,113.550003,36003200,112.482314 +113.050003,114.120003,112.510002,113.57,34514300,112.502122 +115.190002,116.18,113.25,113.580002,47023000,112.51203 +115.120003,116.129997,114.040001,114.919998,79886900,113.839427 +113.860001,115.730003,113.489998,115.57,89983600,114.483317 +108.730003,113.029999,108.599998,111.769997,110888700,110.719044 +107.510002,108.790001,107.239998,107.949997,62176200,106.934963 +102.650002,105.720001,102.529999,105.440002,45292800,104.44857 +104.639999,105.720001,103.129997,103.129997,46557000,102.160285 +107.25,107.269997,105.239998,105.519997,53002000,104.527812 +107.830002,108.760002,107.07,108.360001,42364300,107.341112 +107.900002,108.300003,107.510002,107.699997,26880400,106.687314 +107.699997,108,106.82,107.730003,26802500,106.717038 +106.139999,106.800003,105.620003,106.730003,26701500,105.726441 +105.660004,106.57,105.639999,106.099998,29662400,105.10236 +105.800003,106.5,105.5,106,24863900,105.003302 +106.620003,107.440002,106.290001,106.82,24970300,105.815591 +107.410004,107.949997,106.309998,106.940002,27766300,105.934466 +107.389999,107.879997,106.68,107.57,25086200,106.558539 +108.57,108.75,107.68,108.029999,23675100,107.014213 +108.589996,109.32,108.529999,108.849998,21257700,107.826502 +108.860001,109.099998,107.849998,108.510002,25820200,107.489703 +108.769997,109.690002,108.360001,109.360001,25368100,108.331709 +109.230003,109.599998,109.019997,109.080002,21984700,108.054343 +109.099998,109.370003,108.339996,109.220001,25356000,108.193026 +109.629997,110.230003,109.209999,109.379997,33794400,108.351518 +108.139999,109.540001,108.080002,109.480003,25868200,108.450584 +107.779999,108.440002,107.779999,108.18,18660400,107.162804 +108.519997,108.93,107.849998,107.93,27484500,106.915155 +108.709999,108.900002,107.760002,108,24008500,106.984496 +108.230003,108.940002,108.010002,108.809998,26315200,107.786878 +107.519997,108.370003,107.160004,108.370003,28037200,107.35102 +106.269997,107.650002,106.18,107.480003,40553400,106.469389 +105.580002,106,105.279999,105.870003,27408700,104.874527 +104.809998,105.839996,104.769997,105.790001,30202600,104.230638 +106.050003,106.07,104,104.480003,33816600,102.93995 +104.410004,106.150002,104.410004,106.050003,38167900,104.486808 +104.190002,104.550003,103.68,104.209999,27733700,102.673926 +102.830002,104.449997,102.82,104.339996,39869800,102.802007 +104.269997,104.349998,102.75,102.949997,92344800,101.432497 +96.82,97.970001,96.419998,96.669998,56239800,95.245066 +98.25,98.839996,96.919998,97.339996,40382900,95.905188 +99.260002,99.300003,98.309998,98.660004,28313700,97.205739 +99.830002,101,99.129997,99.43,32702000,97.964385 +100,100.459999,99.739998,99.959999,26276000,98.486572 +99.559998,100,99.339996,99.870003,23779900,98.397902 +98.699997,100.129997,98.599998,99.830002,36493900,98.358491 +98.919998,99.300003,98.5,98.779999,30137000,97.323965 +97.389999,98.989998,97.32,98.790001,38919000,97.33382 +97.410004,97.669998,96.839996,96.870003,25892200,95.442123 +97.169998,97.699997,97.120003,97.419998,24167500,95.984011 +96.75,97.650002,96.730003,96.980003,23794900,95.550502 +96.489998,96.889999,96.050003,96.68,28912100,95.254921 +95.699997,96.5,95.620003,95.940002,25139600,94.525831 +94.599998,95.660004,94.370003,95.529999,30949100,94.12187 +95.389999,95.400002,94.459999,94.989998,27705200,93.589829 +95.489998,96.470001,95.330002,95.889999,26026500,94.476565 +94.440002,95.769997,94.300003,95.599998,35836400,94.190838 +93.970001,94.550003,93.629997,94.400002,36531000,93.00853 +92.900002,93.660004,92.139999,93.589996,40444900,92.210464 +93,93.050003,91.5,92.040001,45489600,90.683316 +92.910004,94.660004,92.650002,93.400002,75311400,92.02327 +95.940002,96.290001,95.25,96.099998,32240200,94.683468 +96.25,96.889999,95.349998,95.550003,29219100,94.14158 +94.940002,96.349998,94.68,95.910004,35546400,94.496274 +96,96.57,95.029999,95.099998,34411900,93.698208 +96.620003,96.650002,95.300003,95.330002,61008200,93.924821 +96.449997,97.75,96.07,97.550003,31326800,96.1121 +97.82,98.410004,97.029999,97.139999,29445200,95.708139 +97.32,98.480003,96.75,97.459999,31931900,96.023422 +98.690002,99.120003,97.099998,97.339996,38020500,95.905188 +98.529999,99.349998,98.480003,98.830002,31712900,97.373231 +98.5,99.989998,98.459999,99.650002,26601400,98.181144 +99.019997,99.559998,98.68,98.940002,20848100,97.48161 +99.25,99.870003,98.959999,99.029999,22409500,97.57028 +97.989998,101.889999,97.550003,98.629997,23292500,97.176174 +97.790001,98.269997,97.449997,97.919998,28062900,96.476641 +97.599998,97.839996,96.629997,97.720001,40191600,96.279592 +99.019997,99.540001,98.330002,98.459999,29173300,97.008682 +99.599998,100.400002,98.82,99.860001,42307200,98.388047 +99.440002,100.470001,99.25,100.349998,36229500,98.870823 +99.68,100.730003,98.639999,100.410004,56331200,98.929943 +98.669998,99.739998,98.110001,99.620003,38168800,98.151587 +97.220001,98.089996,96.839996,97.900002,35140200,96.456939 +95.870003,97.190002,95.669998,96.43,38018600,95.008606 +94.639999,95.43,94.519997,95.220001,32026000,93.816442 +94.639999,94.639999,93.57,94.199997,30442100,92.811473 +94.160004,95.209999,93.889999,94.559998,42062400,93.166167 +94.550003,94.699997,93.010002,93.489998,46916900,92.111939 +92.389999,94.389999,91.650002,93.879997,61259800,92.49619 +90,91.669998,90,90.519997,44392800,89.185717 +92.720001,92.779999,89.470001,90.339996,76314700,89.00837 +93.480003,93.57,92.459999,92.510002,28719100,91.146389 +93.330002,93.57,92.110001,93.419998,33686800,92.042972 +93,93.769997,92.589996,92.790001,32936400,91.422261 +93.370003,93.449997,91.849998,92.720001,43458200,91.353293 +94,94.07,92.68,93.239998,35890500,91.865625 +95.199997,95.900002,93.82,94.190002,41025500,92.240024 +94.199997,95.739998,93.68,95.18,56831300,93.209527 +93.970001,94.080002,92.400002,93.639999,48160100,91.701408 +93.989998,94.720001,92.510002,93.739998,68531500,91.799336 +97.610001,97.879997,94.25,94.830002,82242700,92.866774 +96,98.709999,95.68,97.82,114602100,95.794871 +103.910004,105.300003,103.910004,104.349998,56016200,102.189682 +105,105.650002,104.510002,105.080002,28031600,102.904573 \ No newline at end of file diff --git a/Ahmad/cert/producerConsumer/.classpath b/Ahmad/cert/producerConsumer/.classpath new file mode 100644 index 0000000..038a0e7 --- /dev/null +++ b/Ahmad/cert/producerConsumer/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/producerConsumer/.gitignore b/Ahmad/cert/producerConsumer/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/producerConsumer/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/producerConsumer/.project b/Ahmad/cert/producerConsumer/.project new file mode 100644 index 0000000..39124d5 --- /dev/null +++ b/Ahmad/cert/producerConsumer/.project @@ -0,0 +1,17 @@ + + + producerConsumer + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/producerConsumer/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/producerConsumer/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/producerConsumer/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/producerConsumer/bin/waitNotify/Application.class b/Ahmad/cert/producerConsumer/bin/waitNotify/Application.class new file mode 100644 index 0000000..3e90936 Binary files /dev/null and b/Ahmad/cert/producerConsumer/bin/waitNotify/Application.class differ diff --git a/Ahmad/cert/producerConsumer/bin/waitNotify/Consumer.class b/Ahmad/cert/producerConsumer/bin/waitNotify/Consumer.class new file mode 100644 index 0000000..23eab2c Binary files /dev/null and b/Ahmad/cert/producerConsumer/bin/waitNotify/Consumer.class differ diff --git a/Ahmad/cert/producerConsumer/bin/waitNotify/Producer.class b/Ahmad/cert/producerConsumer/bin/waitNotify/Producer.class new file mode 100644 index 0000000..6a35c92 Binary files /dev/null and b/Ahmad/cert/producerConsumer/bin/waitNotify/Producer.class differ diff --git a/Ahmad/cert/producerConsumer/src/waitNotify/Application.java b/Ahmad/cert/producerConsumer/src/waitNotify/Application.java new file mode 100644 index 0000000..8ebb9c9 --- /dev/null +++ b/Ahmad/cert/producerConsumer/src/waitNotify/Application.java @@ -0,0 +1,19 @@ +package waitNotify; + +import java.util.ArrayList; +import java.util.List; + +public class Application { + + public static void main(String[] args) { + + List questionList = new ArrayList(); + + Thread t1 = new Thread(new Producer(questionList)); + Thread t2 = new Thread(new Consumer(questionList)); + + t1.start(); + t2.start(); + } + +} diff --git a/Ahmad/cert/producerConsumer/src/waitNotify/Consumer.java b/Ahmad/cert/producerConsumer/src/waitNotify/Consumer.java new file mode 100644 index 0000000..db77228 --- /dev/null +++ b/Ahmad/cert/producerConsumer/src/waitNotify/Consumer.java @@ -0,0 +1,39 @@ +package waitNotify; + +import java.util.List; + +public class Consumer implements Runnable{ + + List questionList = null; + + public Consumer(List questionList) { + this.questionList = questionList; + } + + public void answerQuestion() throws InterruptedException { + synchronized(questionList) { + while(questionList.isEmpty()) { + System.out.println("No Question to Answer ... Waiting for producer to get questions"); + questionList.wait(); + } + } + + synchronized(questionList) { + Thread.sleep(5000); + System.out.println("ANSWERED Question: " + questionList.remove(0)); + questionList.notify(); + } + } + + @Override + public void run() { + while(true) { + try { + answerQuestion(); + } catch (InterruptedException e) { + System.out.println("Error: " + e); + } + } + + } +} diff --git a/Ahmad/cert/producerConsumer/src/waitNotify/Producer.java b/Ahmad/cert/producerConsumer/src/waitNotify/Producer.java new file mode 100644 index 0000000..c7d5c9e --- /dev/null +++ b/Ahmad/cert/producerConsumer/src/waitNotify/Producer.java @@ -0,0 +1,43 @@ +package waitNotify; + +import java.util.List; + +public class Producer implements Runnable{ + + List questionList = null; + final int LIMIT = 5; + private int questionNo; + + Object myObject = new Object(); + + public Producer(List questionList) { + this.questionList = questionList; + } + + public void readQuestion(int questionNo) throws InterruptedException { + synchronized(questionList) { + while(questionList.size() == LIMIT) { + System.out.println("Questions have piled up.. wait for answers"); + questionList.wait(); + } + } + + synchronized(questionList) { + System.out.println("New Question: " + questionNo); + questionList.add(questionNo); + Thread.sleep(100); + questionList.notify(); + } + } + + @Override + public void run() { + while(true) { + try { + readQuestion(questionNo++); + } catch (InterruptedException e) { + } + + } + } +} diff --git a/Ahmad/cert/stock-analysis/.classpath b/Ahmad/cert/stock-analysis/.classpath new file mode 100644 index 0000000..b5891cf --- /dev/null +++ b/Ahmad/cert/stock-analysis/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/stock-analysis/.project b/Ahmad/cert/stock-analysis/.project new file mode 100644 index 0000000..d61c177 --- /dev/null +++ b/Ahmad/cert/stock-analysis/.project @@ -0,0 +1,17 @@ + + + stock-analysis + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/stock-analysis/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/stock-analysis/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/stock-analysis/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/stock-analysis/bin/aggregators/Aggregator.class b/Ahmad/cert/stock-analysis/bin/aggregators/Aggregator.class new file mode 100644 index 0000000..5d218e7 Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/aggregators/Aggregator.class differ diff --git a/Ahmad/cert/stock-analysis/bin/aggregators/MaxAggregator.class b/Ahmad/cert/stock-analysis/bin/aggregators/MaxAggregator.class new file mode 100644 index 0000000..97531ce Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/aggregators/MaxAggregator.class differ diff --git a/Ahmad/cert/stock-analysis/bin/aggregators/MeanAggregator.class b/Ahmad/cert/stock-analysis/bin/aggregators/MeanAggregator.class new file mode 100644 index 0000000..ab251fc Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/aggregators/MeanAggregator.class differ diff --git a/Ahmad/cert/stock-analysis/bin/aggregators/MinAggregator.class b/Ahmad/cert/stock-analysis/bin/aggregators/MinAggregator.class new file mode 100644 index 0000000..0db1953 Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/aggregators/MinAggregator.class differ diff --git a/Ahmad/cert/stock-analysis/bin/client/Application.class b/Ahmad/cert/stock-analysis/bin/client/Application.class new file mode 100644 index 0000000..f8c197b Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/client/Application.class differ diff --git a/Ahmad/cert/stock-analysis/bin/client/StockFileApplication.class b/Ahmad/cert/stock-analysis/bin/client/StockFileApplication.class new file mode 100644 index 0000000..761bd44 Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/client/StockFileApplication.class differ diff --git a/Ahmad/cert/stock-analysis/bin/fileprocessors/StockFileData.class b/Ahmad/cert/stock-analysis/bin/fileprocessors/StockFileData.class new file mode 100644 index 0000000..c3bacb0 Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/fileprocessors/StockFileData.class differ diff --git a/Ahmad/cert/stock-analysis/bin/fileprocessors/StockFileReader.class b/Ahmad/cert/stock-analysis/bin/fileprocessors/StockFileReader.class new file mode 100644 index 0000000..19e5b6c Binary files /dev/null and b/Ahmad/cert/stock-analysis/bin/fileprocessors/StockFileReader.class differ diff --git a/Ahmad/cert/stock-analysis/src/aggregators/Aggregator.java b/Ahmad/cert/stock-analysis/src/aggregators/Aggregator.java new file mode 100644 index 0000000..d23529a --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/aggregators/Aggregator.java @@ -0,0 +1,34 @@ +package aggregators; + +import java.util.ArrayList; +import java.util.List; + +public abstract class Aggregator { + + List numbers; + + public Aggregator(){ + numbers = new ArrayList(); + } + + public Aggregator(List numbers){ + numbers = new ArrayList(numbers); + } + + /** + * add data to the given collection + * + */ + public void add(double number) { + numbers.add(number); + } + /** + * Any class that is a derivative of the abstract class + * Aggregator must implement the calculate method. + * @return double + */ + public abstract double calculate(); + + public abstract List getValues(); + +} diff --git a/Ahmad/cert/stock-analysis/src/aggregators/MaxAggregator.java b/Ahmad/cert/stock-analysis/src/aggregators/MaxAggregator.java new file mode 100644 index 0000000..d1d9d80 --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/aggregators/MaxAggregator.java @@ -0,0 +1,28 @@ +package aggregators; + +import java.util.ArrayList; +import java.util.List; + +public class MaxAggregator extends Aggregator{ + + public MaxAggregator(List numbers) { + this.numbers = new ArrayList(); + } + + @Override + public double calculate() { + double max = numbers.get(0); + for(Double number : numbers){ + if(number > max){ + max = number; + } + } + return max; + } + + @Override + public List getValues() { + return numbers; + } + +} diff --git a/Ahmad/cert/stock-analysis/src/aggregators/MeanAggregator.java b/Ahmad/cert/stock-analysis/src/aggregators/MeanAggregator.java new file mode 100644 index 0000000..1666dcd --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/aggregators/MeanAggregator.java @@ -0,0 +1,24 @@ +package aggregators; + +import java.util.List; + +public class MeanAggregator extends Aggregator{ + + public double calculate() { + double result = 0; + if(!numbers.isEmpty()){ + double value = 0.00; + for(Double number : numbers){ + value+=number; + } + result = value/numbers.size(); + } + return result; + } + + @Override + public List getValues() { + return numbers; + } + +} diff --git a/Ahmad/cert/stock-analysis/src/aggregators/MinAggregator.java b/Ahmad/cert/stock-analysis/src/aggregators/MinAggregator.java new file mode 100644 index 0000000..2170376 --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/aggregators/MinAggregator.java @@ -0,0 +1,28 @@ +package aggregators; + +import java.util.ArrayList; +import java.util.List; + +public class MinAggregator extends Aggregator{ + + public MinAggregator(List numbers) { + this.numbers = new ArrayList(numbers); + } + + @Override + public double calculate() { + double min = numbers.get(0); + for(Double number : numbers){ + if(number < min){ + min = number; + } + } + return min; + } + + @Override + public List getValues() { + return numbers; + } + +} diff --git a/Ahmad/cert/stock-analysis/src/client/Application.java b/Ahmad/cert/stock-analysis/src/client/Application.java new file mode 100644 index 0000000..4be742b --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/client/Application.java @@ -0,0 +1,27 @@ +package client; + +import aggregators.Aggregator; +import aggregators.MeanAggregator; +import aggregators.MinAggregator; + +public class Application { + + public static void main(String[] args) { + + Aggregator values = new MeanAggregator(); + values.add(100.93); + values.add(101.32); + values.add(103.41); + values.add(107.87); + values.add(100.90); + values.add(98.76); + + Aggregator minValue = new MinAggregator(values.getValues()); + + double result = minValue.calculate(); + + System.out.println(result); + + } + +} diff --git a/Ahmad/cert/stock-analysis/src/client/StockFileApplication.java b/Ahmad/cert/stock-analysis/src/client/StockFileApplication.java new file mode 100644 index 0000000..717c482 --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/client/StockFileApplication.java @@ -0,0 +1,47 @@ +package client; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import fileprocessors.StockFileData; +import fileprocessors.StockFileReader; + +public class StockFileApplication { + + public static void main(String args[]) throws IOException{ + StockFileReader fr = new StockFileReader("table.csv"); + + List> dataResult = populateStockFileData(fr.getHeaders(), fr.readFileData()); + StockFileData fileData = new StockFileData(); + fileData.addData(dataResult); + fileData.printData(); + System.out.println(dataResult.size()); + } + + /** + * Complete the method body so that it returns the given structure needed to + * populate the data field in the StockFileData class. + * @param headers + * @param lines + * @return List + */ + + public static List> populateStockFileData(List headers, List lines){ + List> dataResult = new ArrayList<>(); + for(String line : lines) { + String [] values = line.split(","); + int cnt = 0; + HashMap headerValueMap = new HashMap<>(); + for(String value: values) { + double dval = Double.parseDouble(value); + headerValueMap.put(headers.get(cnt), dval); + cnt++; + } + dataResult.add(headerValueMap); + } + // Insert your code here.. + return dataResult; + } +} diff --git a/Ahmad/cert/stock-analysis/src/fileprocessors/StockFileData.java b/Ahmad/cert/stock-analysis/src/fileprocessors/StockFileData.java new file mode 100644 index 0000000..112cb80 --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/fileprocessors/StockFileData.java @@ -0,0 +1,18 @@ +package fileprocessors; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +public class StockFileData { + + List> data = new LinkedList<>(); + + public void printData(){ + System.out.println(data); + } + + public void addData(List> dataIn){ + data = dataIn; + } +} diff --git a/Ahmad/cert/stock-analysis/src/fileprocessors/StockFileReader.java b/Ahmad/cert/stock-analysis/src/fileprocessors/StockFileReader.java new file mode 100644 index 0000000..0cca076 --- /dev/null +++ b/Ahmad/cert/stock-analysis/src/fileprocessors/StockFileReader.java @@ -0,0 +1,56 @@ +package fileprocessors; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class StockFileReader { + + String filePath = null; + + public StockFileReader(String filePath){ + this.filePath = filePath; + } + + public List getHeaders() throws IOException{ + String line = readFirstLine(filePath); + String [] header = line.split(","); + List values = new ArrayList(); + values = Arrays.asList(header); + return values; + } + + static String readFirstLine(String path) throws IOException { + try (BufferedReader br = + new BufferedReader(new FileReader(path))) { + return br.readLine(); + } + } + + /** + * Complete the body of this method. + * @return List + * @throws IOException + */ + + + public List readFileData() throws IOException{ + List lines = new ArrayList(); + try(BufferedReader br = new BufferedReader(new FileReader(filePath))){ + // skip the first line + br.readLine(); + String line = null; + // advance from the second line onwards + while((line = br.readLine()) != null) { + lines.add(line); + } + } + + return lines; + } + + +} diff --git a/Ahmad/cert/stock-analysis/table.csv b/Ahmad/cert/stock-analysis/table.csv new file mode 100644 index 0000000..be133f3 --- /dev/null +++ b/Ahmad/cert/stock-analysis/table.csv @@ -0,0 +1,252 @@ +Open,High,Low,Close,Volume,Adj Close +142.440002,142.679993,141.850006,142.270004,17245200,142.270004 +141.220001,142.919998,141.160004,142.440002,23251100,142.440002 +141.880005,142,140.449997,140.679993,17271300,140.679993 +141.410004,142.039993,141.110001,141.199997,14660800,141.199997 +141.479996,141.880005,140.869995,141.830002,16424000,141.830002 +141.910004,142.380005,141.050003,141.050003,17652900,141.050003 +141.600006,142.149994,141.009995,141.800003,20238900,141.800003 +142.940002,143.350006,140.059998,141.630005,30275300,141.630005 +143.600006,143.880005,142.899994,143.169998,18473000,143.169998 +143.729996,144.179993,143.270004,143.339996,16621300,143.339996 +144.289993,144.520004,143.449997,143.660004,21118000,143.660004 +144.220001,145.460007,143.809998,144.020004,27481500,144.020004 +143.25,144.889999,143.169998,144.770004,19765700,144.770004 +143.710007,144.119995,143.050003,143.699997,19985700,143.699997 +143.720001,144.270004,143.009995,143.660004,19661700,143.660004 +144.190002,144.5,143.5,143.929993,21207300,143.929993 +143.679993,144.490005,143.190002,144.119995,29190000,144.119995 +140.910004,144.039993,140.619995,143.800003,33374800,143.800003 +139.389999,141.220001,138.619995,140.880005,23575100,140.880005 +141.5,141.740005,140.350006,140.639999,22395600,140.639999 +141.259995,141.580002,140.610001,140.919998,20346300,140.919998 +139.850006,141.600006,139.759995,141.419998,25860200,141.419998 +142.110001,142.800003,139.729996,139.839996,39529900,139.839996 +140.399994,141.5,140.229996,141.460007,21542000,141.460007 +141,141,139.889999,139.990005,43885000,139.990005 +140.720001,141.020004,140.259995,140.690002,19232000,140.690002 +139.410004,140.75,139.029999,140.460007,25691800,140.460007 +139.300003,139.649994,138.839996,138.990005,15309100,138.990005 +138.850006,139.429993,138.820007,139.199997,17421700,139.199997 +139.25,139.360001,138.639999,139.139999,19612800,139.139999 +138.740005,138.789993,137.050003,138.679993,22155900,138.679993 +138.949997,139.800003,138.820007,139,18707200,139 +139.059998,139.979996,138.789993,139.520004,17446300,139.520004 +139.369995,139.770004,138.600006,139.339996,21750000,139.339996 +138.779999,139.830002,138.589996,139.779999,21108100,139.779999 +140,140.279999,138.759995,138.960007,26211000,138.960007 +137.889999,140.149994,137.600006,139.789993,36414600,139.789993 +137.080002,137.440002,136.699997,136.990005,23482900,136.990005 +137.139999,137.440002,136.279999,136.929993,20257400,136.929993 +135.910004,136.660004,135.279999,136.660004,21776600,136.660004 +137.380005,137.479996,136.300003,136.529999,20788200,136.529999 +136.429993,137.119995,136.110001,137.110001,20836900,137.110001 +136.229996,136.75,135.979996,136.699997,24507200,136.699997 +135.100006,135.830002,135.100006,135.720001,22198200,135.720001 +135.669998,135.899994,134.839996,135.350006,22584600,135.350006 +135.520004,136.270004,134.619995,135.509995,35623100,135.509995 +133.470001,135.089996,133.25,135.020004,33226200,135.020004 +133.080002,133.820007,132.75,133.289993,23035400,133.289993 +132.460007,132.940002,132.050003,132.119995,20065500,132.119995 +131.649994,132.449997,131.119995,132.419998,28349900,132.419998 +131.350006,132.220001,131.220001,132.039993,23004100,131.469994 +130.539993,132.089996,130.449997,131.529999,38183800,130.962201 +129.130005,130.5,128.899994,130.289993,26845900,129.727549 +128.309998,129.190002,128.160004,129.080002,24507300,128.522781 +127.980003,129.389999,127.779999,128.529999,33710400,127.975152 +127.029999,130.490005,127.010002,128.75,111985000,128.194203 +121.150002,121.389999,120.620003,121.349998,49201000,120.826147 +120.93,121.629997,120.660004,121.629997,30377500,121.104937 +122.139999,122.349998,121.599998,121.949997,20562900,121.423555 +121.669998,122.440002,121.599998,121.940002,26337600,121.413604 +120.419998,122.099998,120.279999,121.879997,32377600,121.353858 +119.550003,120.099998,119.5,119.970001,23211000,119.452107 +120,120.809998,119.769997,120.080002,22050200,119.561633 +120.449997,120.449997,119.730003,120,32597900,119.481976 +119.400002,120.089996,119.370003,119.779999,25597300,119.262925 +120,120.5,119.709999,119.989998,23713000,119.472017 +118.339996,120.239998,118.220001,120,34439800,119.481976 +119.110001,119.620003,118.809998,119.040001,26111900,118.526121 +118.900002,119.300003,118.209999,119.25,27086200,118.735214 +118.739998,119.93,118.599998,119.75,27588600,119.233055 +118.769997,119.379997,118.300003,119.110001,24462100,118.595819 +117.949997,119.43,117.940002,118.989998,33561900,118.476334 +116.779999,118.160004,116.470001,117.910004,31751900,117.401002 +115.919998,116.860001,115.809998,116.610001,22193600,116.106611 +115.849998,116.510002,115.75,116.019997,21118100,115.519154 +115.800003,116.330002,114.760002,116.150002,28781900,115.648597 +116.650002,117.199997,115.43,115.82,30586300,115.32002 +116.449997,117.110001,116.400002,116.730003,15039500,116.226096 +117.519997,118.019997,116.199997,116.760002,20905900,116.255965 +116.519997,117.800003,116.489998,117.260002,18296900,116.753806 +115.589996,116.519997,115.589996,116.519997,14181200,116.016995 +116.349998,116.510002,115.639999,116.290001,26085900,115.787993 +116.800003,117.400002,116.779999,117.059998,23783200,116.554665 +116.739998,117.5,116.68,116.949997,21425000,116.445139 +115.800003,117.379997,115.75,116.639999,27779400,116.13648 +116.470001,116.5,115.650002,115.970001,44351100,115.469374 +115.379997,116.730003,115.230003,115.82,46524500,115.32002 +115.040001,116.199997,114.980003,115.190002,34031800,114.692743 +113.839996,115.919998,113.75,115.190002,43733800,114.692743 +113.290001,115,112.489998,113.300003,26374400,112.810902 +112.309998,114.699997,112.309998,113.949997,34402600,113.45809 +110.860001,112.43,110.599998,112.120003,27068300,111.635996 +109.260002,111.190002,109.160004,111.029999,29998700,110.550697 +109.5,110.360001,109.190002,109.949997,26195500,109.475358 +110,110.029999,108.25,109.110001,34324500,108.638987 +109.169998,110.089996,108.849998,109.900002,26528000,109.425578 +110.370003,110.940002,109.029999,109.489998,37086900,109.017344 +111.599998,112.199997,110.269997,110.519997,36162300,110.042897 +110.779999,112.029999,110.07,111.459999,28528800,110.978841 +111.43,112.470001,111.389999,111.57,27194000,111.088367 +111.129997,111.870003,110.949997,111.790001,11475900,111.307418 +111.360001,111.510002,110.330002,111.230003,27426400,110.749838 +111.949997,112.419998,111.400002,111.800003,25965500,111.317377 +110.120003,111.989998,110.010002,111.730003,29264600,111.24768 +109.720001,110.540001,109.660004,110.059998,28428900,109.584883 +109.809998,110.349998,108.830002,109.949997,27632000,109.475358 +106.699997,110.230003,106.599998,109.989998,58840500,109.515186 +106.57,107.68,106.160004,107.110001,32264500,106.647621 +107.709999,107.809998,104.080002,105.709999,51175500,105.253663 +107.120003,108.870003,106.550003,108.43,34094100,107.961922 +111.089996,111.089996,105.830002,107.790001,57134500,107.324686 +109.879997,111.32,108.050003,110.879997,59176400,110.401343 +110.309998,111.720001,109.699997,111.059998,24054500,110.580566 +110.080002,110.510002,109.459999,110.410004,32560000,109.933378 +108.529999,110.25,108.110001,108.839996,30837000,108.370149 +110.980003,111.459999,109.550003,109.830002,26932600,109.35588 +111.400002,112.349998,111.230003,111.589996,28331700,110.540737 +113.459999,113.769997,110.529999,111.489998,43825800,110.441678 +113.650002,114.230003,113.199997,113.540001,26419400,112.472406 +113.870003,115.209999,113.449997,113.720001,37861700,112.650713 +115.389999,115.860001,114.099998,114.480003,34562000,113.403569 +114.309998,115.699997,113.309998,115.589996,66134200,114.503125 +117.949997,118.360001,117.309998,118.25,48129000,117.138118 +117.099998,117.739998,117,117.650002,23538700,116.543761 +116.809998,116.910004,116.279999,116.599998,23192700,115.503631 +116.860001,117.379997,116.330002,117.059998,24125800,115.959304 +117.25,117.760002,113.800003,117.120003,20034600,116.018745 +118.18,118.209999,117.449997,117.470001,24553500,116.365453 +117.330002,117.839996,116.779999,117.550003,23624900,116.444703 +117.879997,118.169998,117.129997,117.629997,35652200,116.523945 +116.790001,117.440002,115.720001,116.980003,35192400,115.880062 +117.349998,117.980003,116.75,117.339996,37586800,116.23667 +117.699997,118.690002,116.199997,116.300003,64041000,115.206456 +115.019997,116.75,114.720001,116.050003,36236000,114.958807 +114.309998,114.559998,113.510002,114.059998,24358400,112.987513 +113.699997,114.339996,113.129997,113.889999,28779300,112.819113 +113.400002,113.660004,112.690002,113.050003,21453100,111.987015 +113.059998,114.309998,112.629997,113,29736800,111.937482 +112.709999,113.050003,112.279999,112.519997,21701800,111.461992 +112.459999,113.370003,111.800003,113.050003,36379100,111.987015 +113.160004,113.800003,111.800003,112.18,35887000,111.125193 +113.690002,114.639999,113.43,113.949997,29641100,112.878547 +113,113.18,112.339996,113.089996,24607400,112.026632 +111.639999,113.389999,111.550003,112.879997,29869400,111.818608 +114.419998,114.790001,111.550003,112.709999,52481200,111.650208 +114.349998,114.940002,114,114.620003,31074000,113.542252 +113.849998,113.989998,112.440002,113.550003,36003200,112.482314 +113.050003,114.120003,112.510002,113.57,34514300,112.502122 +115.190002,116.18,113.25,113.580002,47023000,112.51203 +115.120003,116.129997,114.040001,114.919998,79886900,113.839427 +113.860001,115.730003,113.489998,115.57,89983600,114.483317 +108.730003,113.029999,108.599998,111.769997,110888700,110.719044 +107.510002,108.790001,107.239998,107.949997,62176200,106.934963 +102.650002,105.720001,102.529999,105.440002,45292800,104.44857 +104.639999,105.720001,103.129997,103.129997,46557000,102.160285 +107.25,107.269997,105.239998,105.519997,53002000,104.527812 +107.830002,108.760002,107.07,108.360001,42364300,107.341112 +107.900002,108.300003,107.510002,107.699997,26880400,106.687314 +107.699997,108,106.82,107.730003,26802500,106.717038 +106.139999,106.800003,105.620003,106.730003,26701500,105.726441 +105.660004,106.57,105.639999,106.099998,29662400,105.10236 +105.800003,106.5,105.5,106,24863900,105.003302 +106.620003,107.440002,106.290001,106.82,24970300,105.815591 +107.410004,107.949997,106.309998,106.940002,27766300,105.934466 +107.389999,107.879997,106.68,107.57,25086200,106.558539 +108.57,108.75,107.68,108.029999,23675100,107.014213 +108.589996,109.32,108.529999,108.849998,21257700,107.826502 +108.860001,109.099998,107.849998,108.510002,25820200,107.489703 +108.769997,109.690002,108.360001,109.360001,25368100,108.331709 +109.230003,109.599998,109.019997,109.080002,21984700,108.054343 +109.099998,109.370003,108.339996,109.220001,25356000,108.193026 +109.629997,110.230003,109.209999,109.379997,33794400,108.351518 +108.139999,109.540001,108.080002,109.480003,25868200,108.450584 +107.779999,108.440002,107.779999,108.18,18660400,107.162804 +108.519997,108.93,107.849998,107.93,27484500,106.915155 +108.709999,108.900002,107.760002,108,24008500,106.984496 +108.230003,108.940002,108.010002,108.809998,26315200,107.786878 +107.519997,108.370003,107.160004,108.370003,28037200,107.35102 +106.269997,107.650002,106.18,107.480003,40553400,106.469389 +105.580002,106,105.279999,105.870003,27408700,104.874527 +104.809998,105.839996,104.769997,105.790001,30202600,104.230638 +106.050003,106.07,104,104.480003,33816600,102.93995 +104.410004,106.150002,104.410004,106.050003,38167900,104.486808 +104.190002,104.550003,103.68,104.209999,27733700,102.673926 +102.830002,104.449997,102.82,104.339996,39869800,102.802007 +104.269997,104.349998,102.75,102.949997,92344800,101.432497 +96.82,97.970001,96.419998,96.669998,56239800,95.245066 +98.25,98.839996,96.919998,97.339996,40382900,95.905188 +99.260002,99.300003,98.309998,98.660004,28313700,97.205739 +99.830002,101,99.129997,99.43,32702000,97.964385 +100,100.459999,99.739998,99.959999,26276000,98.486572 +99.559998,100,99.339996,99.870003,23779900,98.397902 +98.699997,100.129997,98.599998,99.830002,36493900,98.358491 +98.919998,99.300003,98.5,98.779999,30137000,97.323965 +97.389999,98.989998,97.32,98.790001,38919000,97.33382 +97.410004,97.669998,96.839996,96.870003,25892200,95.442123 +97.169998,97.699997,97.120003,97.419998,24167500,95.984011 +96.75,97.650002,96.730003,96.980003,23794900,95.550502 +96.489998,96.889999,96.050003,96.68,28912100,95.254921 +95.699997,96.5,95.620003,95.940002,25139600,94.525831 +94.599998,95.660004,94.370003,95.529999,30949100,94.12187 +95.389999,95.400002,94.459999,94.989998,27705200,93.589829 +95.489998,96.470001,95.330002,95.889999,26026500,94.476565 +94.440002,95.769997,94.300003,95.599998,35836400,94.190838 +93.970001,94.550003,93.629997,94.400002,36531000,93.00853 +92.900002,93.660004,92.139999,93.589996,40444900,92.210464 +93,93.050003,91.5,92.040001,45489600,90.683316 +92.910004,94.660004,92.650002,93.400002,75311400,92.02327 +95.940002,96.290001,95.25,96.099998,32240200,94.683468 +96.25,96.889999,95.349998,95.550003,29219100,94.14158 +94.940002,96.349998,94.68,95.910004,35546400,94.496274 +96,96.57,95.029999,95.099998,34411900,93.698208 +96.620003,96.650002,95.300003,95.330002,61008200,93.924821 +96.449997,97.75,96.07,97.550003,31326800,96.1121 +97.82,98.410004,97.029999,97.139999,29445200,95.708139 +97.32,98.480003,96.75,97.459999,31931900,96.023422 +98.690002,99.120003,97.099998,97.339996,38020500,95.905188 +98.529999,99.349998,98.480003,98.830002,31712900,97.373231 +98.5,99.989998,98.459999,99.650002,26601400,98.181144 +99.019997,99.559998,98.68,98.940002,20848100,97.48161 +99.25,99.870003,98.959999,99.029999,22409500,97.57028 +97.989998,101.889999,97.550003,98.629997,23292500,97.176174 +97.790001,98.269997,97.449997,97.919998,28062900,96.476641 +97.599998,97.839996,96.629997,97.720001,40191600,96.279592 +99.019997,99.540001,98.330002,98.459999,29173300,97.008682 +99.599998,100.400002,98.82,99.860001,42307200,98.388047 +99.440002,100.470001,99.25,100.349998,36229500,98.870823 +99.68,100.730003,98.639999,100.410004,56331200,98.929943 +98.669998,99.739998,98.110001,99.620003,38168800,98.151587 +97.220001,98.089996,96.839996,97.900002,35140200,96.456939 +95.870003,97.190002,95.669998,96.43,38018600,95.008606 +94.639999,95.43,94.519997,95.220001,32026000,93.816442 +94.639999,94.639999,93.57,94.199997,30442100,92.811473 +94.160004,95.209999,93.889999,94.559998,42062400,93.166167 +94.550003,94.699997,93.010002,93.489998,46916900,92.111939 +92.389999,94.389999,91.650002,93.879997,61259800,92.49619 +90,91.669998,90,90.519997,44392800,89.185717 +92.720001,92.779999,89.470001,90.339996,76314700,89.00837 +93.480003,93.57,92.459999,92.510002,28719100,91.146389 +93.330002,93.57,92.110001,93.419998,33686800,92.042972 +93,93.769997,92.589996,92.790001,32936400,91.422261 +93.370003,93.449997,91.849998,92.720001,43458200,91.353293 +94,94.07,92.68,93.239998,35890500,91.865625 +95.199997,95.900002,93.82,94.190002,41025500,92.240024 +94.199997,95.739998,93.68,95.18,56831300,93.209527 +93.970001,94.080002,92.400002,93.639999,48160100,91.701408 +93.989998,94.720001,92.510002,93.739998,68531500,91.799336 +97.610001,97.879997,94.25,94.830002,82242700,92.866774 +96,98.709999,95.68,97.82,114602100,95.794871 +103.910004,105.300003,103.910004,104.349998,56016200,102.189682 +105,105.650002,104.510002,105.080002,28031600,102.904573 \ No newline at end of file diff --git a/Ahmad/cert/threadPools/.classpath b/Ahmad/cert/threadPools/.classpath new file mode 100644 index 0000000..6ee61f2 --- /dev/null +++ b/Ahmad/cert/threadPools/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/threadPools/.gitignore b/Ahmad/cert/threadPools/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/threadPools/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/threadPools/.project b/Ahmad/cert/threadPools/.project new file mode 100644 index 0000000..60729f4 --- /dev/null +++ b/Ahmad/cert/threadPools/.project @@ -0,0 +1,17 @@ + + + threadPools + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/threadPools/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/threadPools/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..021167a --- /dev/null +++ b/Ahmad/cert/threadPools/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=9 diff --git a/Ahmad/cert/threadPools/bin/threadPools/MessageProcessor.class b/Ahmad/cert/threadPools/bin/threadPools/MessageProcessor.class new file mode 100644 index 0000000..b05a87c Binary files /dev/null and b/Ahmad/cert/threadPools/bin/threadPools/MessageProcessor.class differ diff --git a/Ahmad/cert/threadPools/bin/threadPools/ThreadPoolDemo.class b/Ahmad/cert/threadPools/bin/threadPools/ThreadPoolDemo.class new file mode 100644 index 0000000..c92709c Binary files /dev/null and b/Ahmad/cert/threadPools/bin/threadPools/ThreadPoolDemo.class differ diff --git a/Ahmad/cert/threadPools/src/threadPools/MessageProcessor.java b/Ahmad/cert/threadPools/src/threadPools/MessageProcessor.java new file mode 100644 index 0000000..6d8b39b --- /dev/null +++ b/Ahmad/cert/threadPools/src/threadPools/MessageProcessor.java @@ -0,0 +1,27 @@ +package threadPools; + +public class MessageProcessor implements Runnable { + + private int message; + + public MessageProcessor(int message) { + this.message = message; + } + + @Override + public void run() { + System.out.println(Thread.currentThread().getName() + " [RECEIVED] Message = " + message); + respondToMessage(); // make thread sleep to simulate doing some work + System.out.println(Thread.currentThread().getName() + "(DONE) Processing Message = " + message); + } + + private void respondToMessage() { + + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + System.out.println("Unable to process message " + message); + } + + } +} diff --git a/Ahmad/cert/threadPools/src/threadPools/ThreadPoolDemo.java b/Ahmad/cert/threadPools/src/threadPools/ThreadPoolDemo.java new file mode 100644 index 0000000..07d2c19 --- /dev/null +++ b/Ahmad/cert/threadPools/src/threadPools/ThreadPoolDemo.java @@ -0,0 +1,44 @@ +package threadPools; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +public class ThreadPoolDemo { + + public static void main(String[] args) { + + ExecutorService executor = Executors.newFixedThreadPool(2); + + Runnable processor = new MessageProcessor(2); + executor.execute(processor); + + Runnable processor2 = new MessageProcessor(3); + executor.execute(processor2); + + Runnable processor3 = new MessageProcessor(4); + executor.execute(processor3); + + Runnable processor4 = new MessageProcessor(4); + executor.execute(processor4); + + // executor.shutdown(); // Rejects any new tasks from being submitted + // Gracefully shuts down the service + + // executor.shutdownNow(); // Terminates the executor immediately.. + +// try { +// executor.awaitTermination(2, TimeUnit.SECONDS); +// } catch (InterruptedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + + + while(!executor.isTerminated()) { + } + + System.out.println("submitted all tasks ..."); + + } +} diff --git a/Ahmad/cert/threadingExamples/.classpath b/Ahmad/cert/threadingExamples/.classpath new file mode 100644 index 0000000..038a0e7 --- /dev/null +++ b/Ahmad/cert/threadingExamples/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/threadingExamples/.gitignore b/Ahmad/cert/threadingExamples/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/threadingExamples/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/threadingExamples/.project b/Ahmad/cert/threadingExamples/.project new file mode 100644 index 0000000..eb69370 --- /dev/null +++ b/Ahmad/cert/threadingExamples/.project @@ -0,0 +1,17 @@ + + + threadingExamples + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/threadingExamples/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/threadingExamples/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/threadingExamples/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/threadingExamples/bin/threadingExamples/Application$1.class b/Ahmad/cert/threadingExamples/bin/threadingExamples/Application$1.class new file mode 100644 index 0000000..acd7517 Binary files /dev/null and b/Ahmad/cert/threadingExamples/bin/threadingExamples/Application$1.class differ diff --git a/Ahmad/cert/threadingExamples/bin/threadingExamples/Application$2.class b/Ahmad/cert/threadingExamples/bin/threadingExamples/Application$2.class new file mode 100644 index 0000000..c572f7b Binary files /dev/null and b/Ahmad/cert/threadingExamples/bin/threadingExamples/Application$2.class differ diff --git a/Ahmad/cert/threadingExamples/bin/threadingExamples/Application.class b/Ahmad/cert/threadingExamples/bin/threadingExamples/Application.class new file mode 100644 index 0000000..68fd5ec Binary files /dev/null and b/Ahmad/cert/threadingExamples/bin/threadingExamples/Application.class differ diff --git a/Ahmad/cert/threadingExamples/bin/threadingExamples/Task.class b/Ahmad/cert/threadingExamples/bin/threadingExamples/Task.class new file mode 100644 index 0000000..e127f4c Binary files /dev/null and b/Ahmad/cert/threadingExamples/bin/threadingExamples/Task.class differ diff --git a/Ahmad/cert/threadingExamples/bin/threadingSafety/Application.class b/Ahmad/cert/threadingExamples/bin/threadingSafety/Application.class new file mode 100644 index 0000000..25afb7a Binary files /dev/null and b/Ahmad/cert/threadingExamples/bin/threadingSafety/Application.class differ diff --git a/Ahmad/cert/threadingExamples/bin/threadingSafety/Sequence.class b/Ahmad/cert/threadingExamples/bin/threadingSafety/Sequence.class new file mode 100644 index 0000000..7aa9ead Binary files /dev/null and b/Ahmad/cert/threadingExamples/bin/threadingSafety/Sequence.class differ diff --git a/Ahmad/cert/threadingExamples/bin/threadingSafety/Worker.class b/Ahmad/cert/threadingExamples/bin/threadingSafety/Worker.class new file mode 100644 index 0000000..7690070 Binary files /dev/null and b/Ahmad/cert/threadingExamples/bin/threadingSafety/Worker.class differ diff --git a/Ahmad/cert/threadingExamples/src/threadingExamples/Application.java b/Ahmad/cert/threadingExamples/src/threadingExamples/Application.java new file mode 100644 index 0000000..a9c1126 --- /dev/null +++ b/Ahmad/cert/threadingExamples/src/threadingExamples/Application.java @@ -0,0 +1,80 @@ +package threadingExamples; + +public class Application { + + public static void main(String[] args) { + + // first thread + System.out.println("Starting Thread 1"); +// Task taskRunner = new Task("Thread-A"); + Thread t1 = new Thread(new Runnable() { + @Override + public void run() { + for (int i =0; i < 1000; i++) { + System.out.println("number: "+ i + Thread.currentThread().getName()); + + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }); + +// taskRunner.start(); +// taskRunner.run(); + t1.start(); + + + // second thread + System.out.println("Starting Thread 2"); +// Task taskRunner2 = new Task("Thread-B"); + Thread t2 = new Thread(new Runnable() { + + + @Override + public void run() { + for (int i =0; i < 1000; i++) { + System.out.println("number: "+ i + Thread.currentThread().getName()); + + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }); +// taskRunner2.start(); +// taskRunner2.run(); + t2.start(); + + } + +} + + +//class Task extends Thread { +class Task implements Runnable { + + String name; + + public Task(String name) { + this.name = name; + } + + public void run() { + Thread.currentThread().setName(this.name); + for (int i =0; i < 1000; i++) { + System.out.println("number: "+ i + Thread.currentThread().getName()); + + + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } +} diff --git a/Ahmad/cert/threadingExamples/src/threadingSafety/Application.java b/Ahmad/cert/threadingExamples/src/threadingSafety/Application.java new file mode 100644 index 0000000..df1fd21 --- /dev/null +++ b/Ahmad/cert/threadingExamples/src/threadingSafety/Application.java @@ -0,0 +1,34 @@ +package threadingSafety; + +public class Application { + + public static void main(String[] args) { + + Sequence sequence = new Sequence(); + + Worker worker1 = new Worker(sequence); + worker1.start(); + + Worker worker2 = new Worker(sequence); + worker2.start(); + + for(int i = 0; i < 100; i++) { + System.out.println(sequence.getNext()); + } + } +} + + +class Worker extends Thread { + Sequence sequence = null; + + public Worker(Sequence sequence) { + this.sequence = sequence; + } + + public void run() { + for(int i=0; i < 100; i++) { + System.out.println(Thread.currentThread().getName() + " got value: " + sequence); + } + } +} \ No newline at end of file diff --git a/Ahmad/cert/threadingExamples/src/threadingSafety/Sequence.java b/Ahmad/cert/threadingExamples/src/threadingSafety/Sequence.java new file mode 100644 index 0000000..3fc4c48 --- /dev/null +++ b/Ahmad/cert/threadingExamples/src/threadingSafety/Sequence.java @@ -0,0 +1,15 @@ +package threadingSafety; + +public class Sequence { + + private int value = 0; + + public synchronized int getNext() { +// synchronized (this) { + value = value + 1; + return value; +// } + } + +} + diff --git a/Ahmad/cert/threadingInventoryManager/.classpath b/Ahmad/cert/threadingInventoryManager/.classpath new file mode 100644 index 0000000..038a0e7 --- /dev/null +++ b/Ahmad/cert/threadingInventoryManager/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Ahmad/cert/threadingInventoryManager/.gitignore b/Ahmad/cert/threadingInventoryManager/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Ahmad/cert/threadingInventoryManager/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Ahmad/cert/threadingInventoryManager/.project b/Ahmad/cert/threadingInventoryManager/.project new file mode 100644 index 0000000..d5513c2 --- /dev/null +++ b/Ahmad/cert/threadingInventoryManager/.project @@ -0,0 +1,17 @@ + + + threadingInventoryManager + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Ahmad/cert/threadingInventoryManager/.settings/org.eclipse.jdt.core.prefs b/Ahmad/cert/threadingInventoryManager/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ef28d2b --- /dev/null +++ b/Ahmad/cert/threadingInventoryManager/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=13 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=13 diff --git a/Ahmad/cert/threadingInventoryManager/bin/client/Application$1.class b/Ahmad/cert/threadingInventoryManager/bin/client/Application$1.class new file mode 100644 index 0000000..c3918e2 Binary files /dev/null and b/Ahmad/cert/threadingInventoryManager/bin/client/Application$1.class differ diff --git a/Ahmad/cert/threadingInventoryManager/bin/client/Application$2.class b/Ahmad/cert/threadingInventoryManager/bin/client/Application$2.class new file mode 100644 index 0000000..525de4d Binary files /dev/null and b/Ahmad/cert/threadingInventoryManager/bin/client/Application$2.class differ diff --git a/Ahmad/cert/threadingInventoryManager/bin/client/Application.class b/Ahmad/cert/threadingInventoryManager/bin/client/Application.class new file mode 100644 index 0000000..ea9b001 Binary files /dev/null and b/Ahmad/cert/threadingInventoryManager/bin/client/Application.class differ diff --git a/Ahmad/cert/threadingInventoryManager/bin/inventory/InventoryManager.class b/Ahmad/cert/threadingInventoryManager/bin/inventory/InventoryManager.class new file mode 100644 index 0000000..08b6359 Binary files /dev/null and b/Ahmad/cert/threadingInventoryManager/bin/inventory/InventoryManager.class differ diff --git a/Ahmad/cert/threadingInventoryManager/bin/inventory/Product.class b/Ahmad/cert/threadingInventoryManager/bin/inventory/Product.class new file mode 100644 index 0000000..5ce4949 Binary files /dev/null and b/Ahmad/cert/threadingInventoryManager/bin/inventory/Product.class differ diff --git a/Ahmad/cert/threadingInventoryManager/src/client/Application.java b/Ahmad/cert/threadingInventoryManager/src/client/Application.java new file mode 100644 index 0000000..de982f7 --- /dev/null +++ b/Ahmad/cert/threadingInventoryManager/src/client/Application.java @@ -0,0 +1,38 @@ +package client; + +import inventory.InventoryManager; + +public class Application { + + public static void main(String[] args) { + + InventoryManager manager = new InventoryManager(); + + Thread inventoryTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + Thread displayTask = new Thread(new Runnable() { + + @Override + public void run() { + manager.populateSoldProducts(); + } + }); + + inventoryTask.start(); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// inventoryTask.join(); + + displayTask.start(); + } +} diff --git a/Ahmad/cert/threadingInventoryManager/src/inventory/InventoryManager.java b/Ahmad/cert/threadingInventoryManager/src/inventory/InventoryManager.java new file mode 100644 index 0000000..41c93f9 --- /dev/null +++ b/Ahmad/cert/threadingInventoryManager/src/inventory/InventoryManager.java @@ -0,0 +1,39 @@ +package inventory; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public class InventoryManager { + + List soldProductList = new CopyOnWriteArrayList(); + List purchasedProductsList = new ArrayList(); + + public void populateSoldProducts() { + for(int i = 0; i < 1000; i++) { + Product prod = new Product (i, "text_product_" + i); + soldProductList.add(prod); + System.out.println("ADDED: " + prod); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + public void displaySoldProducts() throws InterruptedException { + for (Product product : soldProductList) { + System.out.println("PRINTING THE SOLD: " + product); + Thread.sleep(10); + try { + Thread.sleep(10); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + } + + +} diff --git a/Ahmad/cert/threadingInventoryManager/src/inventory/Product.java b/Ahmad/cert/threadingInventoryManager/src/inventory/Product.java new file mode 100644 index 0000000..d026a00 --- /dev/null +++ b/Ahmad/cert/threadingInventoryManager/src/inventory/Product.java @@ -0,0 +1,17 @@ +package inventory; + +public class Product { + + int id; + String name; + + public Product(int id, String name) { + super(); + this.id = id; + this.name = name; + } + + public String toString() { + return "id: " + id + " | name: " + name; + } +} diff --git a/Darby/Servers/.settings/org.eclipse.wst.server.core.prefs b/Darby/Servers/.settings/org.eclipse.wst.server.core.prefs deleted file mode 100644 index d4de01e..0000000 --- a/Darby/Servers/.settings/org.eclipse.wst.server.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Wed Jun 24 13:39:15 EDT 2020 -org.eclipse.wst.server.core.isServerProject=true -eclipse.preferences.version=1 diff --git a/Darby/Servers/Tomcat v9.0 Server at localhost-config/catalina.policy b/Darby/Servers/Tomcat v9.0 Server at localhost-config/catalina.policy deleted file mode 100644 index 0567324..0000000 --- a/Darby/Servers/Tomcat v9.0 Server at localhost-config/catalina.policy +++ /dev/null @@ -1,260 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// ============================================================================ -// catalina.policy - Security Policy Permissions for Tomcat -// -// This file contains a default set of security policies to be enforced (by the -// JVM) when Catalina is executed with the "-security" option. In addition -// to the permissions granted here, the following additional permissions are -// granted to each web application: -// -// * Read access to the web application's document root directory -// * Read, write and delete access to the web application's working directory -// ============================================================================ - - -// ========== SYSTEM CODE PERMISSIONS ========================================= - - -// These permissions apply to javac -grant codeBase "file:${java.home}/lib/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to all shared system extensions -grant codeBase "file:${java.home}/jre/lib/ext/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to javac when ${java.home} points at $JAVA_HOME/jre -grant codeBase "file:${java.home}/../lib/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to all shared system extensions when -// ${java.home} points at $JAVA_HOME/jre -grant codeBase "file:${java.home}/lib/ext/-" { - permission java.security.AllPermission; -}; - - -// ========== CATALINA CODE PERMISSIONS ======================================= - - -// These permissions apply to the daemon code -grant codeBase "file:${catalina.home}/bin/commons-daemon.jar" { - permission java.security.AllPermission; -}; - -// These permissions apply to the logging API -// Note: If tomcat-juli.jar is in ${catalina.base} and not in ${catalina.home}, -// update this section accordingly. -// grant codeBase "file:${catalina.base}/bin/tomcat-juli.jar" {..} -grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { - permission java.io.FilePermission - "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; - - permission java.io.FilePermission - "${catalina.base}${file.separator}conf${file.separator}logging.properties", "read"; - permission java.io.FilePermission - "${catalina.base}${file.separator}logs", "read, write"; - permission java.io.FilePermission - "${catalina.base}${file.separator}logs${file.separator}*", "read, write, delete"; - - permission java.lang.RuntimePermission "shutdownHooks"; - permission java.lang.RuntimePermission "getClassLoader"; - permission java.lang.RuntimePermission "setContextClassLoader"; - - permission java.lang.management.ManagementPermission "monitor"; - - permission java.util.logging.LoggingPermission "control"; - - permission java.util.PropertyPermission "java.util.logging.config.class", "read"; - permission java.util.PropertyPermission "java.util.logging.config.file", "read"; - permission java.util.PropertyPermission "org.apache.juli.AsyncLoggerPollInterval", "read"; - permission java.util.PropertyPermission "org.apache.juli.AsyncMaxRecordCount", "read"; - permission java.util.PropertyPermission "org.apache.juli.AsyncOverflowDropType", "read"; - permission java.util.PropertyPermission "org.apache.juli.ClassLoaderLogManager.debug", "read"; - permission java.util.PropertyPermission "catalina.base", "read"; - - // Note: To enable per context logging configuration, permit read access to - // the appropriate file. Be sure that the logging configuration is - // secure before enabling such access. - // E.g. for the examples web application (uncomment and unwrap - // the following to be on a single line): - // permission java.io.FilePermission "${catalina.base}${file.separator} - // webapps${file.separator}examples${file.separator}WEB-INF - // ${file.separator}classes${file.separator}logging.properties", "read"; -}; - -// These permissions apply to the server startup code -grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { - permission java.security.AllPermission; -}; - -// These permissions apply to the servlet API classes -// and those that are shared across all class loaders -// located in the "lib" directory -grant codeBase "file:${catalina.home}/lib/-" { - permission java.security.AllPermission; -}; - - -// If using a per instance lib directory, i.e. ${catalina.base}/lib, -// then the following permission will need to be uncommented -// grant codeBase "file:${catalina.base}/lib/-" { -// permission java.security.AllPermission; -// }; - - -// ========== WEB APPLICATION PERMISSIONS ===================================== - - -// These permissions are granted by default to all web applications -// In addition, a web application will be given a read FilePermission -// for all files and directories in its document root. -grant { - // Required for JNDI lookup of named JDBC DataSource's and - // javamail named MimePart DataSource used to send mail - permission java.util.PropertyPermission "java.home", "read"; - permission java.util.PropertyPermission "java.naming.*", "read"; - permission java.util.PropertyPermission "javax.sql.*", "read"; - - // OS Specific properties to allow read access - permission java.util.PropertyPermission "os.name", "read"; - permission java.util.PropertyPermission "os.version", "read"; - permission java.util.PropertyPermission "os.arch", "read"; - permission java.util.PropertyPermission "file.separator", "read"; - permission java.util.PropertyPermission "path.separator", "read"; - permission java.util.PropertyPermission "line.separator", "read"; - - // JVM properties to allow read access - permission java.util.PropertyPermission "java.version", "read"; - permission java.util.PropertyPermission "java.vendor", "read"; - permission java.util.PropertyPermission "java.vendor.url", "read"; - permission java.util.PropertyPermission "java.class.version", "read"; - permission java.util.PropertyPermission "java.specification.version", "read"; - permission java.util.PropertyPermission "java.specification.vendor", "read"; - permission java.util.PropertyPermission "java.specification.name", "read"; - - permission java.util.PropertyPermission "java.vm.specification.version", "read"; - permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; - permission java.util.PropertyPermission "java.vm.specification.name", "read"; - permission java.util.PropertyPermission "java.vm.version", "read"; - permission java.util.PropertyPermission "java.vm.vendor", "read"; - permission java.util.PropertyPermission "java.vm.name", "read"; - - // Required for OpenJMX - permission java.lang.RuntimePermission "getAttribute"; - - // Allow read of JAXP compliant XML parser debug - permission java.util.PropertyPermission "jaxp.debug", "read"; - - // All JSPs need to be able to read this package - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat"; - - // Precompiled JSPs need access to these packages. - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.el"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime"; - permission java.lang.RuntimePermission - "accessClassInPackage.org.apache.jasper.runtime.*"; - - // Applications using WebSocket need to be able to access these packages - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket.server"; -}; - - -// The Manager application needs access to the following packages to support the -// session display functionality. It also requires the custom Tomcat -// DeployXmlPermission to enable the use of META-INF/context.xml -// These settings support the following configurations: -// - default CATALINA_HOME == CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, per instance Manager in CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, shared Manager in CATALINA_HOME -grant codeBase "file:${catalina.base}/webapps/manager/-" { - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; - permission org.apache.catalina.security.DeployXmlPermission "manager"; -}; -grant codeBase "file:${catalina.home}/webapps/manager/-" { - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; - permission org.apache.catalina.security.DeployXmlPermission "manager"; -}; - -// The Host Manager application needs the custom Tomcat DeployXmlPermission to -// enable the use of META-INF/context.xml -// These settings support the following configurations: -// - default CATALINA_HOME == CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, per instance Host Manager in CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, shared Host Manager in CATALINA_HOME -grant codeBase "file:${catalina.base}/webapps/host-manager/-" { - permission org.apache.catalina.security.DeployXmlPermission "host-manager"; -}; -grant codeBase "file:${catalina.home}/webapps/host-manager/-" { - permission org.apache.catalina.security.DeployXmlPermission "host-manager"; -}; - - -// You can assign additional permissions to particular web applications by -// adding additional "grant" entries here, based on the code base for that -// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files. -// -// Different permissions can be granted to JSP pages, classes loaded from -// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/ -// directory, or even to individual jar files in the /WEB-INF/lib/ directory. -// -// For instance, assume that the standard "examples" application -// included a JDBC driver that needed to establish a network connection to the -// corresponding database and used the scrape taglib to get the weather from -// the NOAA web server. You might create a "grant" entries like this: -// -// The permissions granted to the context root directory apply to JSP pages. -// grant codeBase "file:${catalina.base}/webapps/examples/-" { -// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; -// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; -// }; -// -// The permissions granted to the context WEB-INF/classes directory -// grant codeBase "file:${catalina.base}/webapps/examples/WEB-INF/classes/-" { -// }; -// -// The permission granted to your JDBC driver -// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar!/-" { -// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; -// }; -// The permission granted to the scrape taglib -// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/scrape.jar!/-" { -// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; -// }; - -// To grant permissions for web applications using packed WAR files, use the -// Tomcat specific WAR url scheme. -// -// The permissions granted to the entire web application -// grant codeBase "war:file:${catalina.base}/webapps/examples.war*/-" { -// }; -// -// The permissions granted to a specific JAR -// grant codeBase "war:file:${catalina.base}/webapps/examples.war*/WEB-INF/lib/foo.jar" { -// }; diff --git a/Darby/Servers/Tomcat v9.0 Server at localhost-config/catalina.properties b/Darby/Servers/Tomcat v9.0 Server at localhost-config/catalina.properties deleted file mode 100644 index cff2aa2..0000000 --- a/Darby/Servers/Tomcat v9.0 Server at localhost-config/catalina.properties +++ /dev/null @@ -1,206 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.tomcat. -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. -# -# by default, no packages are restricted for definition, and none of -# the class loaders supplied with the JDK call checkPackageDefinition. -# -package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,\ -org.apache.jasper.,org.apache.naming.,org.apache.tomcat. - -# -# -# List of comma-separated paths defining the contents of the "common" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank,the JVM system loader will be used as Catalina's "common" -# loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -# -# Note: Values are enclosed in double quotes ("...") in case either the -# ${catalina.base} path or the ${catalina.home} path contains a comma. -# Because double quotes are used for quoting, the double quote character -# may not appear in a path. -common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar" - -# -# List of comma-separated paths defining the contents of the "server" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank, the "common" loader will be used as Catalina's "server" -# loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -# -# Note: Values may be enclosed in double quotes ("...") in case either the -# ${catalina.base} path or the ${catalina.home} path contains a comma. -# Because double quotes are used for quoting, the double quote character -# may not appear in a path. -server.loader= - -# -# List of comma-separated paths defining the contents of the "shared" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_BASE path or absolute. If left as blank, -# the "common" loader will be used as Catalina's "shared" loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -# Please note that for single jars, e.g. bar.jar, you need the URL form -# starting with file:. -# -# Note: Values may be enclosed in double quotes ("...") in case either the -# ${catalina.base} path or the ${catalina.home} path contains a comma. -# Because double quotes are used for quoting, the double quote character -# may not appear in a path. -shared.loader= - -# Default list of JAR files that should not be scanned using the JarScanner -# functionality. This is typically used to scan JARs for configuration -# information. JARs that do not contain such information may be excluded from -# the scan to speed up the scanning process. This is the default list. JARs on -# this list are excluded from all scans. The list must be a comma separated list -# of JAR file names. -# The list of JARs to skip may be over-ridden at a Context level for individual -# scan types by configuring a JarScanner with a nested JarScanFilter. -# The JARs listed below include: -# - Tomcat Bootstrap JARs -# - Tomcat API JARs -# - Catalina JARs -# - Jasper JARs -# - Tomcat JARs -# - Common non-Tomcat JARs -# - Test JARs (JUnit, Cobertura and dependencies) -tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\ -annotations-api.jar,\ -ant-junit*.jar,\ -ant-launcher.jar,\ -ant.jar,\ -asm-*.jar,\ -aspectj*.jar,\ -bootstrap.jar,\ -catalina-ant.jar,\ -catalina-ha.jar,\ -catalina-ssi.jar,\ -catalina-storeconfig.jar,\ -catalina-tribes.jar,\ -catalina.jar,\ -cglib-*.jar,\ -cobertura-*.jar,\ -commons-beanutils*.jar,\ -commons-codec*.jar,\ -commons-collections*.jar,\ -commons-daemon.jar,\ -commons-dbcp*.jar,\ -commons-digester*.jar,\ -commons-fileupload*.jar,\ -commons-httpclient*.jar,\ -commons-io*.jar,\ -commons-lang*.jar,\ -commons-logging*.jar,\ -commons-math*.jar,\ -commons-pool*.jar,\ -dom4j-*.jar,\ -easymock-*.jar,\ -ecj-*.jar,\ -el-api.jar,\ -geronimo-spec-jaxrpc*.jar,\ -h2*.jar,\ -hamcrest-*.jar,\ -hibernate*.jar,\ -httpclient*.jar,\ -icu4j-*.jar,\ -jasper-el.jar,\ -jasper.jar,\ -jaspic-api.jar,\ -jaxb-*.jar,\ -jaxen-*.jar,\ -jdom-*.jar,\ -jetty-*.jar,\ -jmx-tools.jar,\ -jmx.jar,\ -jsp-api.jar,\ -jstl.jar,\ -jta*.jar,\ -junit-*.jar,\ -junit.jar,\ -log4j*.jar,\ -mail*.jar,\ -objenesis-*.jar,\ -oraclepki.jar,\ -oro-*.jar,\ -servlet-api-*.jar,\ -servlet-api.jar,\ -slf4j*.jar,\ -taglibs-standard-spec-*.jar,\ -tagsoup-*.jar,\ -tomcat-api.jar,\ -tomcat-coyote.jar,\ -tomcat-dbcp.jar,\ -tomcat-i18n-*.jar,\ -tomcat-jdbc.jar,\ -tomcat-jni.jar,\ -tomcat-juli-adapters.jar,\ -tomcat-juli.jar,\ -tomcat-util-scan.jar,\ -tomcat-util.jar,\ -tomcat-websocket.jar,\ -tools.jar,\ -websocket-api.jar,\ -wsdl4j*.jar,\ -xercesImpl.jar,\ -xml-apis.jar,\ -xmlParserAPIs-*.jar,\ -xmlParserAPIs.jar,\ -xom-*.jar - -# Default list of JAR files that should be scanned that overrides the default -# jarsToSkip list above. This is typically used to include a specific JAR that -# has been excluded by a broad file name pattern in the jarsToSkip list. -# The list of JARs to scan may be over-ridden at a Context level for individual -# scan types by configuring a JarScanner with a nested JarScanFilter. -tomcat.util.scan.StandardJarScanFilter.jarsToScan=\ -log4j-taglib*.jar,\ -log4j-web*.jar,\ -log4javascript*.jar,\ -slf4j-taglib*.jar - -# String cache configuration. -tomcat.util.buf.StringCache.byte.enabled=true -#tomcat.util.buf.StringCache.char.enabled=true -#tomcat.util.buf.StringCache.trainThreshold=500000 -#tomcat.util.buf.StringCache.cacheSize=5000 diff --git a/Darby/Servers/Tomcat v9.0 Server at localhost-config/context.xml b/Darby/Servers/Tomcat v9.0 Server at localhost-config/context.xml deleted file mode 100644 index befa0c2..0000000 --- a/Darby/Servers/Tomcat v9.0 Server at localhost-config/context.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - WEB-INF/web.xml - WEB-INF/tomcat-web.xml - ${catalina.base}/conf/web.xml - - - - \ No newline at end of file diff --git a/Darby/Servers/Tomcat v9.0 Server at localhost-config/server.xml b/Darby/Servers/Tomcat v9.0 Server at localhost-config/server.xml deleted file mode 100644 index 2c57937..0000000 --- a/Darby/Servers/Tomcat v9.0 Server at localhost-config/server.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Darby/Servers/Tomcat v9.0 Server at localhost-config/tomcat-users.xml b/Darby/Servers/Tomcat v9.0 Server at localhost-config/tomcat-users.xml deleted file mode 100644 index 7233d41..0000000 --- a/Darby/Servers/Tomcat v9.0 Server at localhost-config/tomcat-users.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Darby/Servers/Tomcat v9.0 Server at localhost-config/web.xml b/Darby/Servers/Tomcat v9.0 Server at localhost-config/web.xml deleted file mode 100644 index d3bfbe3..0000000 --- a/Darby/Servers/Tomcat v9.0 Server at localhost-config/web.xml +++ /dev/null @@ -1,4728 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - default - org.apache.catalina.servlets.DefaultServlet - - debug - 0 - - - listings - false - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jsp - org.apache.jasper.servlet.JspServlet - - fork - false - - - xpoweredBy - false - - 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - default - / - - - - - jsp - *.jsp - *.jspx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 30 - - - - - - - - - - - - - 123 - application/vnd.lotus-1-2-3 - - - 3dml - text/vnd.in3d.3dml - - - 3ds - image/x-3ds - - - 3g2 - video/3gpp2 - - - 3gp - video/3gpp - - - 7z - application/x-7z-compressed - - - aab - application/x-authorware-bin - - - aac - audio/x-aac - - - aam - application/x-authorware-map - - - aas - application/x-authorware-seg - - - abs - audio/x-mpeg - - - abw - application/x-abiword - - - ac - application/pkix-attr-cert - - - acc - application/vnd.americandynamics.acc - - - ace - application/x-ace-compressed - - - acu - application/vnd.acucobol - - - acutc - application/vnd.acucorp - - - adp - audio/adpcm - - - aep - application/vnd.audiograph - - - afm - application/x-font-type1 - - - afp - application/vnd.ibm.modcap - - - ahead - application/vnd.ahead.space - - - ai - application/postscript - - - aif - audio/x-aiff - - - aifc - audio/x-aiff - - - aiff - audio/x-aiff - - - aim - application/x-aim - - - air - application/vnd.adobe.air-application-installer-package+zip - - - ait - application/vnd.dvb.ait - - - ami - application/vnd.amiga.ami - - - anx - application/annodex - - - apk - application/vnd.android.package-archive - - - appcache - text/cache-manifest - - - application - application/x-ms-application - - - apr - application/vnd.lotus-approach - - - arc - application/x-freearc - - - art - image/x-jg - - - asc - application/pgp-signature - - - asf - video/x-ms-asf - - - asm - text/x-asm - - - aso - application/vnd.accpac.simply.aso - - - asx - video/x-ms-asf - - - atc - application/vnd.acucorp - - - atom - application/atom+xml - - - atomcat - application/atomcat+xml - - - atomsvc - application/atomsvc+xml - - - atx - application/vnd.antix.game-component - - - au - audio/basic - - - avi - video/x-msvideo - - - avx - video/x-rad-screenplay - - - aw - application/applixware - - - axa - audio/annodex - - - axv - video/annodex - - - azf - application/vnd.airzip.filesecure.azf - - - azs - application/vnd.airzip.filesecure.azs - - - azw - application/vnd.amazon.ebook - - - bat - application/x-msdownload - - - bcpio - application/x-bcpio - - - bdf - application/x-font-bdf - - - bdm - application/vnd.syncml.dm+wbxml - - - bed - application/vnd.realvnc.bed - - - bh2 - application/vnd.fujitsu.oasysprs - - - bin - application/octet-stream - - - blb - application/x-blorb - - - blorb - application/x-blorb - - - bmi - application/vnd.bmi - - - bmp - image/bmp - - - body - text/html - - - book - application/vnd.framemaker - - - box - application/vnd.previewsystems.box - - - boz - application/x-bzip2 - - - bpk - application/octet-stream - - - btif - image/prs.btif - - - bz - application/x-bzip - - - bz2 - application/x-bzip2 - - - c - text/x-c - - - c11amc - application/vnd.cluetrust.cartomobile-config - - - c11amz - application/vnd.cluetrust.cartomobile-config-pkg - - - c4d - application/vnd.clonk.c4group - - - c4f - application/vnd.clonk.c4group - - - c4g - application/vnd.clonk.c4group - - - c4p - application/vnd.clonk.c4group - - - c4u - application/vnd.clonk.c4group - - - cab - application/vnd.ms-cab-compressed - - - caf - audio/x-caf - - - cap - application/vnd.tcpdump.pcap - - - car - application/vnd.curl.car - - - cat - application/vnd.ms-pki.seccat - - - cb7 - application/x-cbr - - - cba - application/x-cbr - - - cbr - application/x-cbr - - - cbt - application/x-cbr - - - cbz - application/x-cbr - - - cc - text/x-c - - - cct - application/x-director - - - ccxml - application/ccxml+xml - - - cdbcmsg - application/vnd.contact.cmsg - - - cdf - application/x-cdf - - - cdkey - application/vnd.mediastation.cdkey - - - cdmia - application/cdmi-capability - - - cdmic - application/cdmi-container - - - cdmid - application/cdmi-domain - - - cdmio - application/cdmi-object - - - cdmiq - application/cdmi-queue - - - cdx - chemical/x-cdx - - - cdxml - application/vnd.chemdraw+xml - - - cdy - application/vnd.cinderella - - - cer - application/pkix-cert - - - cfs - application/x-cfs-compressed - - - cgm - image/cgm - - - chat - application/x-chat - - - chm - application/vnd.ms-htmlhelp - - - chrt - application/vnd.kde.kchart - - - cif - chemical/x-cif - - - cii - application/vnd.anser-web-certificate-issue-initiation - - - cil - application/vnd.ms-artgalry - - - cla - application/vnd.claymore - - - class - application/java - - - clkk - application/vnd.crick.clicker.keyboard - - - clkp - application/vnd.crick.clicker.palette - - - clkt - application/vnd.crick.clicker.template - - - clkw - application/vnd.crick.clicker.wordbank - - - clkx - application/vnd.crick.clicker - - - clp - application/x-msclip - - - cmc - application/vnd.cosmocaller - - - cmdf - chemical/x-cmdf - - - cml - chemical/x-cml - - - cmp - application/vnd.yellowriver-custom-menu - - - cmx - image/x-cmx - - - cod - application/vnd.rim.cod - - - com - application/x-msdownload - - - conf - text/plain - - - cpio - application/x-cpio - - - cpp - text/x-c - - - cpt - application/mac-compactpro - - - crd - application/x-mscardfile - - - crl - application/pkix-crl - - - crt - application/x-x509-ca-cert - - - cryptonote - application/vnd.rig.cryptonote - - - csh - application/x-csh - - - csml - chemical/x-csml - - - csp - application/vnd.commonspace - - - css - text/css - - - cst - application/x-director - - - csv - text/csv - - - cu - application/cu-seeme - - - curl - text/vnd.curl - - - cww - application/prs.cww - - - cxt - application/x-director - - - cxx - text/x-c - - - dae - model/vnd.collada+xml - - - daf - application/vnd.mobius.daf - - - dart - application/vnd.dart - - - dataless - application/vnd.fdsn.seed - - - davmount - application/davmount+xml - - - dbk - application/docbook+xml - - - dcr - application/x-director - - - dcurl - text/vnd.curl.dcurl - - - dd2 - application/vnd.oma.dd2+xml - - - ddd - application/vnd.fujixerox.ddd - - - deb - application/x-debian-package - - - def - text/plain - - - deploy - application/octet-stream - - - der - application/x-x509-ca-cert - - - dfac - application/vnd.dreamfactory - - - dgc - application/x-dgc-compressed - - - dib - image/bmp - - - dic - text/x-c - - - dir - application/x-director - - - dis - application/vnd.mobius.dis - - - dist - application/octet-stream - - - distz - application/octet-stream - - - djv - image/vnd.djvu - - - djvu - image/vnd.djvu - - - dll - application/x-msdownload - - - dmg - application/x-apple-diskimage - - - dmp - application/vnd.tcpdump.pcap - - - dms - application/octet-stream - - - dna - application/vnd.dna - - - doc - application/msword - - - docm - application/vnd.ms-word.document.macroenabled.12 - - - docx - application/vnd.openxmlformats-officedocument.wordprocessingml.document - - - dot - application/msword - - - dotm - application/vnd.ms-word.template.macroenabled.12 - - - dotx - application/vnd.openxmlformats-officedocument.wordprocessingml.template - - - dp - application/vnd.osgi.dp - - - dpg - application/vnd.dpgraph - - - dra - audio/vnd.dra - - - dsc - text/prs.lines.tag - - - dssc - application/dssc+der - - - dtb - application/x-dtbook+xml - - - dtd - application/xml-dtd - - - dts - audio/vnd.dts - - - dtshd - audio/vnd.dts.hd - - - dump - application/octet-stream - - - dv - video/x-dv - - - dvb - video/vnd.dvb.file - - - dvi - application/x-dvi - - - dwf - model/vnd.dwf - - - dwg - image/vnd.dwg - - - dxf - image/vnd.dxf - - - dxp - application/vnd.spotfire.dxp - - - dxr - application/x-director - - - ecelp4800 - audio/vnd.nuera.ecelp4800 - - - ecelp7470 - audio/vnd.nuera.ecelp7470 - - - ecelp9600 - audio/vnd.nuera.ecelp9600 - - - ecma - application/ecmascript - - - edm - application/vnd.novadigm.edm - - - edx - application/vnd.novadigm.edx - - - efif - application/vnd.picsel - - - ei6 - application/vnd.pg.osasli - - - elc - application/octet-stream - - - emf - application/x-msmetafile - - - eml - message/rfc822 - - - emma - application/emma+xml - - - emz - application/x-msmetafile - - - eol - audio/vnd.digital-winds - - - eot - application/vnd.ms-fontobject - - - eps - application/postscript - - - epub - application/epub+zip - - - es3 - application/vnd.eszigno3+xml - - - esa - application/vnd.osgi.subsystem - - - esf - application/vnd.epson.esf - - - et3 - application/vnd.eszigno3+xml - - - etx - text/x-setext - - - eva - application/x-eva - - - evy - application/x-envoy - - - exe - application/octet-stream - - - exi - application/exi - - - ext - application/vnd.novadigm.ext - - - ez - application/andrew-inset - - - ez2 - application/vnd.ezpix-album - - - ez3 - application/vnd.ezpix-package - - - f - text/x-fortran - - - f4v - video/x-f4v - - - f77 - text/x-fortran - - - f90 - text/x-fortran - - - fbs - image/vnd.fastbidsheet - - - fcdt - application/vnd.adobe.formscentral.fcdt - - - fcs - application/vnd.isac.fcs - - - fdf - application/vnd.fdf - - - fe_launch - application/vnd.denovo.fcselayout-link - - - fg5 - application/vnd.fujitsu.oasysgp - - - fgd - application/x-director - - - fh - image/x-freehand - - - fh4 - image/x-freehand - - - fh5 - image/x-freehand - - - fh7 - image/x-freehand - - - fhc - image/x-freehand - - - fig - application/x-xfig - - - flac - audio/flac - - - fli - video/x-fli - - - flo - application/vnd.micrografx.flo - - - flv - video/x-flv - - - flw - application/vnd.kde.kivio - - - flx - text/vnd.fmi.flexstor - - - fly - text/vnd.fly - - - fm - application/vnd.framemaker - - - fnc - application/vnd.frogans.fnc - - - for - text/x-fortran - - - fpx - image/vnd.fpx - - - frame - application/vnd.framemaker - - - fsc - application/vnd.fsc.weblaunch - - - fst - image/vnd.fst - - - ftc - application/vnd.fluxtime.clip - - - fti - application/vnd.anser-web-funds-transfer-initiation - - - fvt - video/vnd.fvt - - - fxp - application/vnd.adobe.fxp - - - fxpl - application/vnd.adobe.fxp - - - fzs - application/vnd.fuzzysheet - - - g2w - application/vnd.geoplan - - - g3 - image/g3fax - - - g3w - application/vnd.geospace - - - gac - application/vnd.groove-account - - - gam - application/x-tads - - - gbr - application/rpki-ghostbusters - - - gca - application/x-gca-compressed - - - gdl - model/vnd.gdl - - - geo - application/vnd.dynageo - - - gex - application/vnd.geometry-explorer - - - ggb - application/vnd.geogebra.file - - - ggt - application/vnd.geogebra.tool - - - ghf - application/vnd.groove-help - - - gif - image/gif - - - gim - application/vnd.groove-identity-message - - - gml - application/gml+xml - - - gmx - application/vnd.gmx - - - gnumeric - application/x-gnumeric - - - gph - application/vnd.flographit - - - gpx - application/gpx+xml - - - gqf - application/vnd.grafeq - - - gqs - application/vnd.grafeq - - - gram - application/srgs - - - gramps - application/x-gramps-xml - - - gre - application/vnd.geometry-explorer - - - grv - application/vnd.groove-injector - - - grxml - application/srgs+xml - - - gsf - application/x-font-ghostscript - - - gtar - application/x-gtar - - - gtm - application/vnd.groove-tool-message - - - gtw - model/vnd.gtw - - - gv - text/vnd.graphviz - - - gxf - application/gxf - - - gxt - application/vnd.geonext - - - gz - application/x-gzip - - - h - text/x-c - - - h261 - video/h261 - - - h263 - video/h263 - - - h264 - video/h264 - - - hal - application/vnd.hal+xml - - - hbci - application/vnd.hbci - - - hdf - application/x-hdf - - - hh - text/x-c - - - hlp - application/winhlp - - - hpgl - application/vnd.hp-hpgl - - - hpid - application/vnd.hp-hpid - - - hps - application/vnd.hp-hps - - - hqx - application/mac-binhex40 - - - htc - text/x-component - - - htke - application/vnd.kenameaapp - - - htm - text/html - - - html - text/html - - - hvd - application/vnd.yamaha.hv-dic - - - hvp - application/vnd.yamaha.hv-voice - - - hvs - application/vnd.yamaha.hv-script - - - i2g - application/vnd.intergeo - - - icc - application/vnd.iccprofile - - - ice - x-conference/x-cooltalk - - - icm - application/vnd.iccprofile - - - ico - image/x-icon - - - ics - text/calendar - - - ief - image/ief - - - ifb - text/calendar - - - ifm - application/vnd.shana.informed.formdata - - - iges - model/iges - - - igl - application/vnd.igloader - - - igm - application/vnd.insors.igm - - - igs - model/iges - - - igx - application/vnd.micrografx.igx - - - iif - application/vnd.shana.informed.interchange - - - imp - application/vnd.accpac.simply.imp - - - ims - application/vnd.ms-ims - - - in - text/plain - - - ink - application/inkml+xml - - - inkml - application/inkml+xml - - - install - application/x-install-instructions - - - iota - application/vnd.astraea-software.iota - - - ipfix - application/ipfix - - - ipk - application/vnd.shana.informed.package - - - irm - application/vnd.ibm.rights-management - - - irp - application/vnd.irepository.package+xml - - - iso - application/x-iso9660-image - - - itp - application/vnd.shana.informed.formtemplate - - - ivp - application/vnd.immervision-ivp - - - ivu - application/vnd.immervision-ivu - - - jad - text/vnd.sun.j2me.app-descriptor - - - jam - application/vnd.jam - - - jar - application/java-archive - - - java - text/x-java-source - - - jisp - application/vnd.jisp - - - jlt - application/vnd.hp-jlyt - - - jnlp - application/x-java-jnlp-file - - - joda - application/vnd.joost.joda-archive - - - jpe - image/jpeg - - - jpeg - image/jpeg - - - jpg - image/jpeg - - - jpgm - video/jpm - - - jpgv - video/jpeg - - - jpm - video/jpm - - - js - application/javascript - - - jsf - text/plain - - - json - application/json - - - jsonml - application/jsonml+json - - - jspf - text/plain - - - kar - audio/midi - - - karbon - application/vnd.kde.karbon - - - kfo - application/vnd.kde.kformula - - - kia - application/vnd.kidspiration - - - kml - application/vnd.google-earth.kml+xml - - - kmz - application/vnd.google-earth.kmz - - - kne - application/vnd.kinar - - - knp - application/vnd.kinar - - - kon - application/vnd.kde.kontour - - - kpr - application/vnd.kde.kpresenter - - - kpt - application/vnd.kde.kpresenter - - - kpxx - application/vnd.ds-keypoint - - - ksp - application/vnd.kde.kspread - - - ktr - application/vnd.kahootz - - - ktx - image/ktx - - - ktz - application/vnd.kahootz - - - kwd - application/vnd.kde.kword - - - kwt - application/vnd.kde.kword - - - lasxml - application/vnd.las.las+xml - - - latex - application/x-latex - - - lbd - application/vnd.llamagraphics.life-balance.desktop - - - lbe - application/vnd.llamagraphics.life-balance.exchange+xml - - - les - application/vnd.hhe.lesson-player - - - lha - application/x-lzh-compressed - - - link66 - application/vnd.route66.link66+xml - - - list - text/plain - - - list3820 - application/vnd.ibm.modcap - - - listafp - application/vnd.ibm.modcap - - - lnk - application/x-ms-shortcut - - - log - text/plain - - - lostxml - application/lost+xml - - - lrf - application/octet-stream - - - lrm - application/vnd.ms-lrm - - - ltf - application/vnd.frogans.ltf - - - lvp - audio/vnd.lucent.voice - - - lwp - application/vnd.lotus-wordpro - - - lzh - application/x-lzh-compressed - - - m13 - application/x-msmediaview - - - m14 - application/x-msmediaview - - - m1v - video/mpeg - - - m21 - application/mp21 - - - m2a - audio/mpeg - - - m2v - video/mpeg - - - m3a - audio/mpeg - - - m3u - audio/x-mpegurl - - - m3u8 - application/vnd.apple.mpegurl - - - m4a - audio/mp4 - - - m4b - audio/mp4 - - - m4r - audio/mp4 - - - m4u - video/vnd.mpegurl - - - m4v - video/mp4 - - - ma - application/mathematica - - - mac - image/x-macpaint - - - mads - application/mads+xml - - - mag - application/vnd.ecowin.chart - - - maker - application/vnd.framemaker - - - man - text/troff - - - mar - application/octet-stream - - - mathml - application/mathml+xml - - - mb - application/mathematica - - - mbk - application/vnd.mobius.mbk - - - mbox - application/mbox - - - mc1 - application/vnd.medcalcdata - - - mcd - application/vnd.mcd - - - mcurl - text/vnd.curl.mcurl - - - mdb - application/x-msaccess - - - mdi - image/vnd.ms-modi - - - me - text/troff - - - mesh - model/mesh - - - meta4 - application/metalink4+xml - - - metalink - application/metalink+xml - - - mets - application/mets+xml - - - mfm - application/vnd.mfmp - - - mft - application/rpki-manifest - - - mgp - application/vnd.osgeo.mapguide.package - - - mgz - application/vnd.proteus.magazine - - - mid - audio/midi - - - midi - audio/midi - - - mie - application/x-mie - - - mif - application/x-mif - - - mime - message/rfc822 - - - mj2 - video/mj2 - - - mjp2 - video/mj2 - - - mk3d - video/x-matroska - - - mka - audio/x-matroska - - - mks - video/x-matroska - - - mkv - video/x-matroska - - - mlp - application/vnd.dolby.mlp - - - mmd - application/vnd.chipnuts.karaoke-mmd - - - mmf - application/vnd.smaf - - - mmr - image/vnd.fujixerox.edmics-mmr - - - mng - video/x-mng - - - mny - application/x-msmoney - - - mobi - application/x-mobipocket-ebook - - - mods - application/mods+xml - - - mov - video/quicktime - - - movie - video/x-sgi-movie - - - mp1 - audio/mpeg - - - mp2 - audio/mpeg - - - mp21 - application/mp21 - - - mp2a - audio/mpeg - - - mp3 - audio/mpeg - - - mp4 - video/mp4 - - - mp4a - audio/mp4 - - - mp4s - application/mp4 - - - mp4v - video/mp4 - - - mpa - audio/mpeg - - - mpc - application/vnd.mophun.certificate - - - mpe - video/mpeg - - - mpeg - video/mpeg - - - mpega - audio/x-mpeg - - - mpg - video/mpeg - - - mpg4 - video/mp4 - - - mpga - audio/mpeg - - - mpkg - application/vnd.apple.installer+xml - - - mpm - application/vnd.blueice.multipass - - - mpn - application/vnd.mophun.application - - - mpp - application/vnd.ms-project - - - mpt - application/vnd.ms-project - - - mpv2 - video/mpeg2 - - - mpy - application/vnd.ibm.minipay - - - mqy - application/vnd.mobius.mqy - - - mrc - application/marc - - - mrcx - application/marcxml+xml - - - ms - text/troff - - - mscml - application/mediaservercontrol+xml - - - mseed - application/vnd.fdsn.mseed - - - mseq - application/vnd.mseq - - - msf - application/vnd.epson.msf - - - msh - model/mesh - - - msi - application/x-msdownload - - - msl - application/vnd.mobius.msl - - - msty - application/vnd.muvee.style - - - mts - model/vnd.mts - - - mus - application/vnd.musician - - - musicxml - application/vnd.recordare.musicxml+xml - - - mvb - application/x-msmediaview - - - mwf - application/vnd.mfer - - - mxf - application/mxf - - - mxl - application/vnd.recordare.musicxml - - - mxml - application/xv+xml - - - mxs - application/vnd.triscape.mxs - - - mxu - video/vnd.mpegurl - - - n-gage - application/vnd.nokia.n-gage.symbian.install - - - n3 - text/n3 - - - nb - application/mathematica - - - nbp - application/vnd.wolfram.player - - - nc - application/x-netcdf - - - ncx - application/x-dtbncx+xml - - - nfo - text/x-nfo - - - ngdat - application/vnd.nokia.n-gage.data - - - nitf - application/vnd.nitf - - - nlu - application/vnd.neurolanguage.nlu - - - nml - application/vnd.enliven - - - nnd - application/vnd.noblenet-directory - - - nns - application/vnd.noblenet-sealer - - - nnw - application/vnd.noblenet-web - - - npx - image/vnd.net-fpx - - - nsc - application/x-conference - - - nsf - application/vnd.lotus-notes - - - ntf - application/vnd.nitf - - - nzb - application/x-nzb - - - oa2 - application/vnd.fujitsu.oasys2 - - - oa3 - application/vnd.fujitsu.oasys3 - - - oas - application/vnd.fujitsu.oasys - - - obd - application/x-msbinder - - - obj - application/x-tgif - - - oda - application/oda - - - - odb - application/vnd.oasis.opendocument.database - - - - odc - application/vnd.oasis.opendocument.chart - - - - odf - application/vnd.oasis.opendocument.formula - - - odft - application/vnd.oasis.opendocument.formula-template - - - - odg - application/vnd.oasis.opendocument.graphics - - - - odi - application/vnd.oasis.opendocument.image - - - - odm - application/vnd.oasis.opendocument.text-master - - - - odp - application/vnd.oasis.opendocument.presentation - - - - ods - application/vnd.oasis.opendocument.spreadsheet - - - - odt - application/vnd.oasis.opendocument.text - - - oga - audio/ogg - - - ogg - audio/ogg - - - ogv - video/ogg - - - - ogx - application/ogg - - - omdoc - application/omdoc+xml - - - onepkg - application/onenote - - - onetmp - application/onenote - - - onetoc - application/onenote - - - onetoc2 - application/onenote - - - opf - application/oebps-package+xml - - - opml - text/x-opml - - - oprc - application/vnd.palm - - - org - application/vnd.lotus-organizer - - - osf - application/vnd.yamaha.openscoreformat - - - osfpvg - application/vnd.yamaha.openscoreformat.osfpvg+xml - - - otc - application/vnd.oasis.opendocument.chart-template - - - otf - font/otf - - - - otg - application/vnd.oasis.opendocument.graphics-template - - - - oth - application/vnd.oasis.opendocument.text-web - - - oti - application/vnd.oasis.opendocument.image-template - - - - otp - application/vnd.oasis.opendocument.presentation-template - - - - ots - application/vnd.oasis.opendocument.spreadsheet-template - - - - ott - application/vnd.oasis.opendocument.text-template - - - oxps - application/oxps - - - oxt - application/vnd.openofficeorg.extension - - - p - text/x-pascal - - - p10 - application/pkcs10 - - - p12 - application/x-pkcs12 - - - p7b - application/x-pkcs7-certificates - - - p7c - application/pkcs7-mime - - - p7m - application/pkcs7-mime - - - p7r - application/x-pkcs7-certreqresp - - - p7s - application/pkcs7-signature - - - p8 - application/pkcs8 - - - pas - text/x-pascal - - - paw - application/vnd.pawaafile - - - pbd - application/vnd.powerbuilder6 - - - pbm - image/x-portable-bitmap - - - pcap - application/vnd.tcpdump.pcap - - - pcf - application/x-font-pcf - - - pcl - application/vnd.hp-pcl - - - pclxl - application/vnd.hp-pclxl - - - pct - image/pict - - - pcurl - application/vnd.curl.pcurl - - - pcx - image/x-pcx - - - pdb - application/vnd.palm - - - pdf - application/pdf - - - pfa - application/x-font-type1 - - - pfb - application/x-font-type1 - - - pfm - application/x-font-type1 - - - pfr - application/font-tdpfr - - - pfx - application/x-pkcs12 - - - pgm - image/x-portable-graymap - - - pgn - application/x-chess-pgn - - - pgp - application/pgp-encrypted - - - pic - image/pict - - - pict - image/pict - - - pkg - application/octet-stream - - - pki - application/pkixcmp - - - pkipath - application/pkix-pkipath - - - plb - application/vnd.3gpp.pic-bw-large - - - plc - application/vnd.mobius.plc - - - plf - application/vnd.pocketlearn - - - pls - audio/x-scpls - - - pml - application/vnd.ctc-posml - - - png - image/png - - - pnm - image/x-portable-anymap - - - pnt - image/x-macpaint - - - portpkg - application/vnd.macports.portpkg - - - pot - application/vnd.ms-powerpoint - - - potm - application/vnd.ms-powerpoint.template.macroenabled.12 - - - potx - application/vnd.openxmlformats-officedocument.presentationml.template - - - ppam - application/vnd.ms-powerpoint.addin.macroenabled.12 - - - ppd - application/vnd.cups-ppd - - - ppm - image/x-portable-pixmap - - - pps - application/vnd.ms-powerpoint - - - ppsm - application/vnd.ms-powerpoint.slideshow.macroenabled.12 - - - ppsx - application/vnd.openxmlformats-officedocument.presentationml.slideshow - - - ppt - application/vnd.ms-powerpoint - - - pptm - application/vnd.ms-powerpoint.presentation.macroenabled.12 - - - pptx - application/vnd.openxmlformats-officedocument.presentationml.presentation - - - pqa - application/vnd.palm - - - prc - application/x-mobipocket-ebook - - - pre - application/vnd.lotus-freelance - - - prf - application/pics-rules - - - ps - application/postscript - - - psb - application/vnd.3gpp.pic-bw-small - - - psd - image/vnd.adobe.photoshop - - - psf - application/x-font-linux-psf - - - pskcxml - application/pskc+xml - - - ptid - application/vnd.pvi.ptid1 - - - pub - application/x-mspublisher - - - pvb - application/vnd.3gpp.pic-bw-var - - - pwn - application/vnd.3m.post-it-notes - - - pya - audio/vnd.ms-playready.media.pya - - - pyv - video/vnd.ms-playready.media.pyv - - - qam - application/vnd.epson.quickanime - - - qbo - application/vnd.intu.qbo - - - qfx - application/vnd.intu.qfx - - - qps - application/vnd.publishare-delta-tree - - - qt - video/quicktime - - - qti - image/x-quicktime - - - qtif - image/x-quicktime - - - qwd - application/vnd.quark.quarkxpress - - - qwt - application/vnd.quark.quarkxpress - - - qxb - application/vnd.quark.quarkxpress - - - qxd - application/vnd.quark.quarkxpress - - - qxl - application/vnd.quark.quarkxpress - - - qxt - application/vnd.quark.quarkxpress - - - ra - audio/x-pn-realaudio - - - ram - audio/x-pn-realaudio - - - rar - application/x-rar-compressed - - - ras - image/x-cmu-raster - - - rcprofile - application/vnd.ipunplugged.rcprofile - - - rdf - application/rdf+xml - - - rdz - application/vnd.data-vision.rdz - - - rep - application/vnd.businessobjects - - - res - application/x-dtbresource+xml - - - rgb - image/x-rgb - - - rif - application/reginfo+xml - - - rip - audio/vnd.rip - - - ris - application/x-research-info-systems - - - rl - application/resource-lists+xml - - - rlc - image/vnd.fujixerox.edmics-rlc - - - rld - application/resource-lists-diff+xml - - - rm - application/vnd.rn-realmedia - - - rmi - audio/midi - - - rmp - audio/x-pn-realaudio-plugin - - - rms - application/vnd.jcp.javame.midlet-rms - - - rmvb - application/vnd.rn-realmedia-vbr - - - rnc - application/relax-ng-compact-syntax - - - roa - application/rpki-roa - - - roff - text/troff - - - rp9 - application/vnd.cloanto.rp9 - - - rpss - application/vnd.nokia.radio-presets - - - rpst - application/vnd.nokia.radio-preset - - - rq - application/sparql-query - - - rs - application/rls-services+xml - - - rsd - application/rsd+xml - - - rss - application/rss+xml - - - rtf - application/rtf - - - rtx - text/richtext - - - s - text/x-asm - - - s3m - audio/s3m - - - saf - application/vnd.yamaha.smaf-audio - - - sbml - application/sbml+xml - - - sc - application/vnd.ibm.secure-container - - - scd - application/x-msschedule - - - scm - application/vnd.lotus-screencam - - - scq - application/scvp-cv-request - - - scs - application/scvp-cv-response - - - scurl - text/vnd.curl.scurl - - - sda - application/vnd.stardivision.draw - - - sdc - application/vnd.stardivision.calc - - - sdd - application/vnd.stardivision.impress - - - sdkd - application/vnd.solent.sdkm+xml - - - sdkm - application/vnd.solent.sdkm+xml - - - sdp - application/sdp - - - sdw - application/vnd.stardivision.writer - - - see - application/vnd.seemail - - - seed - application/vnd.fdsn.seed - - - sema - application/vnd.sema - - - semd - application/vnd.semd - - - semf - application/vnd.semf - - - ser - application/java-serialized-object - - - setpay - application/set-payment-initiation - - - setreg - application/set-registration-initiation - - - sfd-hdstx - application/vnd.hydrostatix.sof-data - - - sfs - application/vnd.spotfire.sfs - - - sfv - text/x-sfv - - - sgi - image/sgi - - - sgl - application/vnd.stardivision.writer-global - - - sgm - text/sgml - - - sgml - text/sgml - - - sh - application/x-sh - - - shar - application/x-shar - - - shf - application/shf+xml - - - - sid - image/x-mrsid-image - - - sig - application/pgp-signature - - - sil - audio/silk - - - silo - model/mesh - - - sis - application/vnd.symbian.install - - - sisx - application/vnd.symbian.install - - - sit - application/x-stuffit - - - sitx - application/x-stuffitx - - - skd - application/vnd.koan - - - skm - application/vnd.koan - - - skp - application/vnd.koan - - - skt - application/vnd.koan - - - sldm - application/vnd.ms-powerpoint.slide.macroenabled.12 - - - sldx - application/vnd.openxmlformats-officedocument.presentationml.slide - - - slt - application/vnd.epson.salt - - - sm - application/vnd.stepmania.stepchart - - - smf - application/vnd.stardivision.math - - - smi - application/smil+xml - - - smil - application/smil+xml - - - smv - video/x-smv - - - smzip - application/vnd.stepmania.package - - - snd - audio/basic - - - snf - application/x-font-snf - - - so - application/octet-stream - - - spc - application/x-pkcs7-certificates - - - spf - application/vnd.yamaha.smaf-phrase - - - spl - application/x-futuresplash - - - spot - text/vnd.in3d.spot - - - spp - application/scvp-vp-response - - - spq - application/scvp-vp-request - - - spx - audio/ogg - - - sql - application/x-sql - - - src - application/x-wais-source - - - srt - application/x-subrip - - - sru - application/sru+xml - - - srx - application/sparql-results+xml - - - ssdl - application/ssdl+xml - - - sse - application/vnd.kodak-descriptor - - - ssf - application/vnd.epson.ssf - - - ssml - application/ssml+xml - - - st - application/vnd.sailingtracker.track - - - stc - application/vnd.sun.xml.calc.template - - - std - application/vnd.sun.xml.draw.template - - - stf - application/vnd.wt.stf - - - sti - application/vnd.sun.xml.impress.template - - - stk - application/hyperstudio - - - stl - application/vnd.ms-pki.stl - - - str - application/vnd.pg.format - - - stw - application/vnd.sun.xml.writer.template - - - sub - text/vnd.dvb.subtitle - - - sus - application/vnd.sus-calendar - - - susp - application/vnd.sus-calendar - - - sv4cpio - application/x-sv4cpio - - - sv4crc - application/x-sv4crc - - - svc - application/vnd.dvb.service - - - svd - application/vnd.svd - - - svg - image/svg+xml - - - svgz - image/svg+xml - - - swa - application/x-director - - - swf - application/x-shockwave-flash - - - swi - application/vnd.aristanetworks.swi - - - sxc - application/vnd.sun.xml.calc - - - sxd - application/vnd.sun.xml.draw - - - sxg - application/vnd.sun.xml.writer.global - - - sxi - application/vnd.sun.xml.impress - - - sxm - application/vnd.sun.xml.math - - - sxw - application/vnd.sun.xml.writer - - - t - text/troff - - - t3 - application/x-t3vm-image - - - taglet - application/vnd.mynfc - - - tao - application/vnd.tao.intent-module-archive - - - tar - application/x-tar - - - tcap - application/vnd.3gpp2.tcap - - - tcl - application/x-tcl - - - teacher - application/vnd.smart.teacher - - - tei - application/tei+xml - - - teicorpus - application/tei+xml - - - tex - application/x-tex - - - texi - application/x-texinfo - - - texinfo - application/x-texinfo - - - text - text/plain - - - tfi - application/thraud+xml - - - tfm - application/x-tex-tfm - - - tga - image/x-tga - - - thmx - application/vnd.ms-officetheme - - - tif - image/tiff - - - tiff - image/tiff - - - tmo - application/vnd.tmobile-livetv - - - torrent - application/x-bittorrent - - - tpl - application/vnd.groove-tool-template - - - tpt - application/vnd.trid.tpt - - - tr - text/troff - - - tra - application/vnd.trueapp - - - trm - application/x-msterminal - - - tsd - application/timestamped-data - - - tsv - text/tab-separated-values - - - ttc - font/collection - - - ttf - font/ttf - - - ttl - text/turtle - - - twd - application/vnd.simtech-mindmapper - - - twds - application/vnd.simtech-mindmapper - - - txd - application/vnd.genomatix.tuxedo - - - txf - application/vnd.mobius.txf - - - txt - text/plain - - - u32 - application/x-authorware-bin - - - udeb - application/x-debian-package - - - ufd - application/vnd.ufdl - - - ufdl - application/vnd.ufdl - - - ulw - audio/basic - - - ulx - application/x-glulx - - - umj - application/vnd.umajin - - - unityweb - application/vnd.unity - - - uoml - application/vnd.uoml+xml - - - uri - text/uri-list - - - uris - text/uri-list - - - urls - text/uri-list - - - ustar - application/x-ustar - - - utz - application/vnd.uiq.theme - - - uu - text/x-uuencode - - - uva - audio/vnd.dece.audio - - - uvd - application/vnd.dece.data - - - uvf - application/vnd.dece.data - - - uvg - image/vnd.dece.graphic - - - uvh - video/vnd.dece.hd - - - uvi - image/vnd.dece.graphic - - - uvm - video/vnd.dece.mobile - - - uvp - video/vnd.dece.pd - - - uvs - video/vnd.dece.sd - - - uvt - application/vnd.dece.ttml+xml - - - uvu - video/vnd.uvvu.mp4 - - - uvv - video/vnd.dece.video - - - uvva - audio/vnd.dece.audio - - - uvvd - application/vnd.dece.data - - - uvvf - application/vnd.dece.data - - - uvvg - image/vnd.dece.graphic - - - uvvh - video/vnd.dece.hd - - - uvvi - image/vnd.dece.graphic - - - uvvm - video/vnd.dece.mobile - - - uvvp - video/vnd.dece.pd - - - uvvs - video/vnd.dece.sd - - - uvvt - application/vnd.dece.ttml+xml - - - uvvu - video/vnd.uvvu.mp4 - - - uvvv - video/vnd.dece.video - - - uvvx - application/vnd.dece.unspecified - - - uvvz - application/vnd.dece.zip - - - uvx - application/vnd.dece.unspecified - - - uvz - application/vnd.dece.zip - - - vcard - text/vcard - - - vcd - application/x-cdlink - - - vcf - text/x-vcard - - - vcg - application/vnd.groove-vcard - - - vcs - text/x-vcalendar - - - vcx - application/vnd.vcx - - - vis - application/vnd.visionary - - - viv - video/vnd.vivo - - - vob - video/x-ms-vob - - - vor - application/vnd.stardivision.writer - - - vox - application/x-authorware-bin - - - vrml - model/vrml - - - vsd - application/vnd.visio - - - vsf - application/vnd.vsf - - - vss - application/vnd.visio - - - vst - application/vnd.visio - - - vsw - application/vnd.visio - - - vtu - model/vnd.vtu - - - vxml - application/voicexml+xml - - - w3d - application/x-director - - - wad - application/x-doom - - - wav - audio/x-wav - - - wax - audio/x-ms-wax - - - - wbmp - image/vnd.wap.wbmp - - - wbs - application/vnd.criticaltools.wbs+xml - - - wbxml - application/vnd.wap.wbxml - - - wcm - application/vnd.ms-works - - - wdb - application/vnd.ms-works - - - wdp - image/vnd.ms-photo - - - weba - audio/webm - - - webm - video/webm - - - webp - image/webp - - - wg - application/vnd.pmi.widget - - - wgt - application/widget - - - wks - application/vnd.ms-works - - - wm - video/x-ms-wm - - - wma - audio/x-ms-wma - - - wmd - application/x-ms-wmd - - - wmf - application/x-msmetafile - - - - wml - text/vnd.wap.wml - - - - wmlc - application/vnd.wap.wmlc - - - - wmls - text/vnd.wap.wmlscript - - - - wmlsc - application/vnd.wap.wmlscriptc - - - wmv - video/x-ms-wmv - - - wmx - video/x-ms-wmx - - - wmz - application/x-msmetafile - - - woff - font/woff - - - woff2 - font/woff2 - - - wpd - application/vnd.wordperfect - - - wpl - application/vnd.ms-wpl - - - wps - application/vnd.ms-works - - - wqd - application/vnd.wqd - - - wri - application/x-mswrite - - - wrl - model/vrml - - - wsdl - application/wsdl+xml - - - wspolicy - application/wspolicy+xml - - - wtb - application/vnd.webturbo - - - wvx - video/x-ms-wvx - - - x32 - application/x-authorware-bin - - - x3d - model/x3d+xml - - - x3db - model/x3d+binary - - - x3dbz - model/x3d+binary - - - x3dv - model/x3d+vrml - - - x3dvz - model/x3d+vrml - - - x3dz - model/x3d+xml - - - xaml - application/xaml+xml - - - xap - application/x-silverlight-app - - - xar - application/vnd.xara - - - xbap - application/x-ms-xbap - - - xbd - application/vnd.fujixerox.docuworks.binder - - - xbm - image/x-xbitmap - - - xdf - application/xcap-diff+xml - - - xdm - application/vnd.syncml.dm+xml - - - xdp - application/vnd.adobe.xdp+xml - - - xdssc - application/dssc+xml - - - xdw - application/vnd.fujixerox.docuworks - - - xenc - application/xenc+xml - - - xer - application/patch-ops-error+xml - - - xfdf - application/vnd.adobe.xfdf - - - xfdl - application/vnd.xfdl - - - xht - application/xhtml+xml - - - xhtml - application/xhtml+xml - - - xhvml - application/xv+xml - - - xif - image/vnd.xiff - - - xla - application/vnd.ms-excel - - - xlam - application/vnd.ms-excel.addin.macroenabled.12 - - - xlc - application/vnd.ms-excel - - - xlf - application/x-xliff+xml - - - xlm - application/vnd.ms-excel - - - xls - application/vnd.ms-excel - - - xlsb - application/vnd.ms-excel.sheet.binary.macroenabled.12 - - - xlsm - application/vnd.ms-excel.sheet.macroenabled.12 - - - xlsx - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - - - xlt - application/vnd.ms-excel - - - xltm - application/vnd.ms-excel.template.macroenabled.12 - - - xltx - application/vnd.openxmlformats-officedocument.spreadsheetml.template - - - xlw - application/vnd.ms-excel - - - xm - audio/xm - - - xml - application/xml - - - xo - application/vnd.olpc-sugar - - - xop - application/xop+xml - - - xpi - application/x-xpinstall - - - xpl - application/xproc+xml - - - xpm - image/x-xpixmap - - - xpr - application/vnd.is-xpr - - - xps - application/vnd.ms-xpsdocument - - - xpw - application/vnd.intercon.formnet - - - xpx - application/vnd.intercon.formnet - - - xsl - application/xml - - - xslt - application/xslt+xml - - - xsm - application/vnd.syncml+xml - - - xspf - application/xspf+xml - - - xul - application/vnd.mozilla.xul+xml - - - xvm - application/xv+xml - - - xvml - application/xv+xml - - - xwd - image/x-xwindowdump - - - xyz - chemical/x-xyz - - - xz - application/x-xz - - - yang - application/yang - - - yin - application/yin+xml - - - z - application/x-compress - - - z1 - application/x-zmachine - - - z2 - application/x-zmachine - - - z3 - application/x-zmachine - - - z4 - application/x-zmachine - - - z5 - application/x-zmachine - - - z6 - application/x-zmachine - - - z7 - application/x-zmachine - - - z8 - application/x-zmachine - - - zaz - application/vnd.zzazz.deck+xml - - - zip - application/zip - - - zir - application/vnd.zul - - - zirz - application/vnd.zul - - - zmm - application/vnd.handheld-entertainment+xml - - - - - - - - - - - - - - - - - - index.html - index.htm - index.jsp - - - \ No newline at end of file diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/BaseballCoach.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/BaseballCoach.java deleted file mode 100644 index 91a060e..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/BaseballCoach.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.luv2code.springdemo; - -public class BaseballCoach implements Coach { - - // define a private field for the dependency - private FortuneService fortuneService; - - // define a constructor for dependency injection - public BaseballCoach(FortuneService theFortuneService) { - fortuneService = theFortuneService; - } - - - - - @Override - public String getDailyWorkout() { - return "Spend 30 minutes on batting practice"; - } - - @Override - public String getDailyFortune() { - - // user my fortuneService to get a fortune - return fortuneService.getFortune(); - } - -} - - - - - - - - diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/Coach.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/Coach.java deleted file mode 100644 index 7c2e2ef..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/Coach.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.luv2code.springdemo; - -public interface Coach { - - public String getDailyWorkout(); - - public String getDailyFortune(); - - - -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/CricketCoach.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/CricketCoach.java deleted file mode 100644 index 8ed9474..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/CricketCoach.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.luv2code.springdemo; - -public class CricketCoach implements Coach { - - private FortuneService fortuneService; - - // add new fields for emailAddress and team - private String emailAddress; - private String team; - - // create a no-arg constructor - public CricketCoach() { - System.out.println("CricketCoach: inside no-arg constructor"); - } - - // our setter method - public void setFortuneService(FortuneService fortuneService) { - System.out.println("CricketCoach: inside setter method - setFortuneService"); - this.fortuneService = fortuneService; - } - - - // get daily workout - @Override - public String getDailyWorkout() { - return "Practice fast bowling for 15 minutes"; - } - - - // getter fortuneService - @Override - public String getDailyFortune() { - return fortuneService.getFortune(); - } - - // getter for emailAddress - public String getEmailAddress() { - return emailAddress; - } - - // setter for emailAddress - public void setEmailAddress(String emailAddress) { - System.out.println("CricketCoach: inside setter method - setEmailAddress"); - this.emailAddress = emailAddress; - } - - // getter for team - public String getTeam() { - return team; - } - - // setter for team - public void setTeam(String team) { - System.out.println("CricketCoach: inside setter method - setTeam"); - this.team = team; - } - -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/FortuneService.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/FortuneService.java deleted file mode 100644 index 1296b41..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/FortuneService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.luv2code.springdemo; - -public interface FortuneService { - - public String getFortune(); - - -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/GolfCoach.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/GolfCoach.java deleted file mode 100644 index a18877a..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/GolfCoach.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.luv2code.springdemo; - -public class GolfCoach implements Coach { - - private FortuneService fortuneService; - - public GolfCoach(FortuneService theFortuneService) { - fortuneService = theFortuneService; - } - - @Override - public String getDailyWorkout() { - return "Practice your putting skills for 2 hours today"; - } - - @Override - public String getDailyFortune() { - return fortuneService.getFortune(); - } - -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/HappyFortuneService.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/HappyFortuneService.java deleted file mode 100644 index 797a907..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/HappyFortuneService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.luv2code.springdemo; - -public class HappyFortuneService implements FortuneService { - - @Override - public String getFortune() { - // TODO Auto-generated method stub - return "Today is your lucky day!"; - } - -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/HelloSpringApp.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/HelloSpringApp.java deleted file mode 100644 index c670009..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/HelloSpringApp.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.luv2code.springdemo; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class HelloSpringApp { - - public static void main(String[] args) { - - - // load the spring configuration file - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext("applicationContext.xml"); - - // retrieve bean from spring container - Coach theCoach = context.getBean("myCoach", Coach.class); - - // call methods on the bean - System.out.println(theCoach.getDailyWorkout()); - - // let's call our new method for fortunes - System.out.println(theCoach.getDailyFortune()); - - // close the context - context.close(); - - } -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/MyApp.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/MyApp.java deleted file mode 100644 index c6e9ffc..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/MyApp.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.luv2code.springdemo; - -public class MyApp { - - public static void main(String[] args) { - - // create the object - // Coach theCoach = new TrackCoach(null); - - // use the object - // System.out.println(theCoach.getDailyWorkout()); - } - -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/MyLoggerConfig.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/MyLoggerConfig.java deleted file mode 100644 index 9ff55f4..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/MyLoggerConfig.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.luv2code.springdemo; - -import java.util.logging.ConsoleHandler; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.logging.SimpleFormatter; - -import org.springframework.context.annotation.AnnotationConfigApplicationContext; - -public class MyLoggerConfig { - - private String rootLoggerLevel; - private String printedLoggerLevel; - - public void setRootLoggerLevel(String rootLoggerLevel) { - this.rootLoggerLevel = rootLoggerLevel; - } - - public void setPrintedLoggerLevel(String printedLoggerLevel) { - this.printedLoggerLevel = printedLoggerLevel; - } - - public void initLogger() { - - // parse levels - Level rootLevel = Level.parse(rootLoggerLevel); - Level printedLevel = Level.parse(printedLoggerLevel); - - // get logger for app context - Logger applicationContextLogger = Logger.getLogger(AnnotationConfigApplicationContext.class.getName()); - - // get parent logger - Logger loggerParent = applicationContextLogger.getParent(); - - // set root logging level - loggerParent.setLevel(rootLevel); - - // set up console handler - ConsoleHandler consoleHandler = new ConsoleHandler(); - consoleHandler.setLevel(printedLevel); - consoleHandler.setFormatter(new SimpleFormatter()); - - // add handler to the logger - loggerParent.addHandler(consoleHandler); - } - -} \ No newline at end of file diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/SetterDemoApp.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/SetterDemoApp.java deleted file mode 100644 index 36a12dd..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/SetterDemoApp.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.luv2code.springdemo; - -import org.springframework.context.support.ClassPathXmlApplicationContext; - -public class SetterDemoApp { - - public static void main(String[] args) { - - // load the spring config file - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext("applicationContext.xml"); - - - // retrieve the bean from spring container - CricketCoach theCoach = context.getBean("myCricketCoach", CricketCoach.class); - - // call methods on the bean - // ... let's come back to this ... - System.out.println(theCoach.getDailyWorkout()); - System.out.println(theCoach.getDailyFortune()); - - // call our getLiterals - System.out.println(theCoach.getEmailAddress()); - System.out.println(theCoach.getTeam()); - - // close the context - context.close(); - - } - - -} diff --git a/Darby/spring-demo-one/src/com/luv2code/springdemo/TrackCoach.java b/Darby/spring-demo-one/src/com/luv2code/springdemo/TrackCoach.java deleted file mode 100644 index 7d6fa5d..0000000 --- a/Darby/spring-demo-one/src/com/luv2code/springdemo/TrackCoach.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.luv2code.springdemo; - -public class TrackCoach implements Coach { - - private FortuneService fortuneService; - - public TrackCoach(FortuneService fortuneService) { - this.fortuneService = fortuneService; - } - - @Override - public String getDailyWorkout() { - return "Run a hard 5k"; - } - - @Override - public String getDailyFortune() { - return "Just Do It: " + fortuneService.getFortune(); - } - -} - - - - - - - - - - diff --git a/Darby/spring-demo-one/src/sport.properties b/Darby/spring-demo-one/src/sport.properties deleted file mode 100644 index 37c5221..0000000 --- a/Darby/spring-demo-one/src/sport.properties +++ /dev/null @@ -1,2 +0,0 @@ -foo.email=silly@luv2code.com -foo.team=Royal Pallindromes Chennai diff --git a/Fedin/.gitignore b/Fedin/.gitignore new file mode 100644 index 0000000..e10e727 --- /dev/null +++ b/Fedin/.gitignore @@ -0,0 +1 @@ +/.metadata/ diff --git a/Fedin/DesignStrategies/.classpath b/Fedin/DesignStrategies/.classpath new file mode 100644 index 0000000..51a8bba --- /dev/null +++ b/Fedin/DesignStrategies/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Fedin/DesignStrategies/.gitignore b/Fedin/DesignStrategies/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Fedin/DesignStrategies/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Fedin/DesignStrategies/.project b/Fedin/DesignStrategies/.project new file mode 100644 index 0000000..acbab4c --- /dev/null +++ b/Fedin/DesignStrategies/.project @@ -0,0 +1,17 @@ + + + DesignStrategies + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Fedin/DesignStrategies/.settings/org.eclipse.jdt.core.prefs b/Fedin/DesignStrategies/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/Fedin/DesignStrategies/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Fedin/DesignStrategies/src/.classpath b/Fedin/DesignStrategies/src/.classpath new file mode 100644 index 0000000..3f3893a --- /dev/null +++ b/Fedin/DesignStrategies/src/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Fedin/DesignStrategies/src/.gitignore b/Fedin/DesignStrategies/src/.gitignore new file mode 100644 index 0000000..fb842cd --- /dev/null +++ b/Fedin/DesignStrategies/src/.gitignore @@ -0,0 +1 @@ +/hhh.class diff --git a/Fedin/DesignStrategies/src/.project b/Fedin/DesignStrategies/src/.project new file mode 100644 index 0000000..0f6f6a7 --- /dev/null +++ b/Fedin/DesignStrategies/src/.project @@ -0,0 +1,17 @@ + + + src + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Fedin/DesignStrategies/src/DelegationExample/.gitignore b/Fedin/DesignStrategies/src/DelegationExample/.gitignore new file mode 100644 index 0000000..cab6c99 --- /dev/null +++ b/Fedin/DesignStrategies/src/DelegationExample/.gitignore @@ -0,0 +1,3 @@ +/Printer.class +/RealPrinter.class +/Tester.class diff --git a/Fedin/DesignStrategies/src/DelegationExample/Tester.java b/Fedin/DesignStrategies/src/DelegationExample/Tester.java new file mode 100644 index 0000000..fa7a41f --- /dev/null +++ b/Fedin/DesignStrategies/src/DelegationExample/Tester.java @@ -0,0 +1,27 @@ +package DelegationExample; + +class RealPrinter { + + // the "delegate" + void print() { + System.out.println("The Delegate"); + } +} + +class Printer { + // the "delegator" + RealPrinter p = new RealPrinter(); + + // create the delegate + void print() { + p.print(); // delegation + } +} + +class Tester { + // to the outside world it looks like Printer actually prints + public static void main(String[] args) { + Printer printer = new Printer(); + printer.print(); + } +} \ No newline at end of file diff --git a/Fedin/DesignStrategies/src/LiskovSubstitution/Vehicle.java b/Fedin/DesignStrategies/src/LiskovSubstitution/Vehicle.java new file mode 100644 index 0000000..e007929 --- /dev/null +++ b/Fedin/DesignStrategies/src/LiskovSubstitution/Vehicle.java @@ -0,0 +1,30 @@ +package LiskovSubstitution; + +public class Vehicle { + abstract int getSpeed(); + abstract int getCubicCapacity(); +} + +public class Car extends Vehicle { + int getSPeed() { } + int getCubicCapacity() {} + boolean sHatchBack() {} +} + +public class Bus extend Vehicle +{ + int getSpeed() { + inte getCubicCapacity() {} + String getEmergencyExitLoc() {} + } +} + +public static void main (String [] args) { + + Vehicle vehicle = new Bus(); + vehicle.getSpeed(); + vehicle = new Car(); + vehicle.getCubicCapacity(); +} + + diff --git a/Fedin/DesignStrategies/src/OpenClosedPrinciple/Shape.java b/Fedin/DesignStrategies/src/OpenClosedPrinciple/Shape.java new file mode 100644 index 0000000..4d63425 --- /dev/null +++ b/Fedin/DesignStrategies/src/OpenClosedPrinciple/Shape.java @@ -0,0 +1,32 @@ +package OpenClosedPrinciple; + +public interface Shape { + public double calculateArea(); + // open for extension +} + +class Rectangle implements Shape { + public double length; + public double width; + + public double calculateArea() { + return length * length; + } +} + +class Circle implements Shape { + public double radius; + + public double calculateArea() { + return (22/7) * radius * radius; + } +} + +class AreaCalculator { + public double calculateRectangleArea(Shape shape) + { + return shape.calculateArea(); + // implement calcArea w. method specific to that class + // closed for modification + } +} \ No newline at end of file diff --git a/Fedin/DesignStrategies/src/ProgrammingToAnInterface/.gitignore b/Fedin/DesignStrategies/src/ProgrammingToAnInterface/.gitignore new file mode 100644 index 0000000..947e231 --- /dev/null +++ b/Fedin/DesignStrategies/src/ProgrammingToAnInterface/.gitignore @@ -0,0 +1,4 @@ +/Computer.class +/Monitor.class +/Projector.class +/displayModule.class diff --git a/Fedin/DesignStrategies/src/ProgrammingToAnInterface/Computer.java b/Fedin/DesignStrategies/src/ProgrammingToAnInterface/Computer.java new file mode 100644 index 0000000..ee0227a --- /dev/null +++ b/Fedin/DesignStrategies/src/ProgrammingToAnInterface/Computer.java @@ -0,0 +1,42 @@ +package ProgrammingToAnInterface; + + +interface displayModule { + public void display(); +} + + +class Monitor implements displayModule { + public void display() { + System.out.println("Display through Monitor"); + } +} + +class Projector implements displayModule { + public void display() { + System.out.println("Display through projector"); + } +} + +public class Computer { + displayModule dm; + + public void setDisplayModule(displayModule dm) { + this.dm = dm; + } + + public void display() { + dm.display(); + } + + public static void main(String args[]) { + Computer cm = new Computer(); + displayModule dm = new Monitor(); + displayModule dm1 = new Projector(); + + cm.setDisplayModule(dm); + cm.display(); + cm.setDisplayModule(dm1); + cm.display(); + } +} \ No newline at end of file diff --git a/Fedin/DesignStrategies/src/SinglerResponsibility/Employee.java b/Fedin/DesignStrategies/src/SinglerResponsibility/Employee.java new file mode 100644 index 0000000..1511a98 --- /dev/null +++ b/Fedin/DesignStrategies/src/SinglerResponsibility/Employee.java @@ -0,0 +1,22 @@ +package SinglerResponsibility; + +import java.util.Date; + +public class Employee { + private String employeeId; + private String name; + private String address; + private Date dateOfJoining; + + // extracted to external classes +// public boolean isPromotionDueThisYear() { +// //promotion logic +// } +// +// public double calcIncomeTaxForCurrentYear() { +// // income tax logic +// } + + // getters / setters for all member variables +} + diff --git a/Fedin/DesignStrategies/src/SinglerResponsibility/Finance.java b/Fedin/DesignStrategies/src/SinglerResponsibility/Finance.java new file mode 100644 index 0000000..7c42bdd --- /dev/null +++ b/Fedin/DesignStrategies/src/SinglerResponsibility/Finance.java @@ -0,0 +1,7 @@ +package SinglerResponsibility; + +public class Finance { + public double calcIncomeTaxForCurrentYear(Employee imp) { + return 0; + } +} diff --git a/Fedin/DesignStrategies/src/SinglerResponsibility/HRPromotions.java b/Fedin/DesignStrategies/src/SinglerResponsibility/HRPromotions.java new file mode 100644 index 0000000..64f53c1 --- /dev/null +++ b/Fedin/DesignStrategies/src/SinglerResponsibility/HRPromotions.java @@ -0,0 +1,9 @@ +package SinglerResponsibility; + +public class HRPromotions { + + public boolean isPromotionDueThisYear(Employee emp) { + return false; + // promotion logic implementation is using the employee information passed in + } +} diff --git a/Short/Short_JavaProjects/src/utilities/.gitignore b/Short/Short_JavaProjects/src/utilities/.gitignore new file mode 100644 index 0000000..e5b7768 --- /dev/null +++ b/Short/Short_JavaProjects/src/utilities/.gitignore @@ -0,0 +1 @@ +/CSV.class