diff --git a/HYFBE-java-week-5.iml b/HYFBE-java-week-5.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/HYFBE-java-week-5.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/resources/cat.jpeg b/resources/cat.jpeg
deleted file mode 100644
index 50be1e0..0000000
Binary files a/resources/cat.jpeg and /dev/null differ
diff --git a/resources/data.txt b/resources/data.txt
new file mode 100644
index 0000000..e69de29
diff --git a/resources/introduction/ks_serotonine.txt b/resources/introduction/ks_serotonine.txt
new file mode 100644
index 0000000..09e706a
--- /dev/null
+++ b/resources/introduction/ks_serotonine.txt
@@ -0,0 +1,5 @@
+Once upon a time there was a little dinosaur.
+This little dinosaur was very sad. Its mom had disappeared for a long time now, and it felt so lonely and insecure!
+Our little dinosaur wandered all day through the huge trees and plants of the primary forest, yelling non-stop after its mom.
+Rexor the Tyrannosaurus had a very fine ear… and an acute nose. Danger was there!
+The sky got darker… the day was vanishing, and the forest filled with shadows.
diff --git a/resources/introduction/kwiketa_skwirk.txt b/resources/introduction/kwiketa_skwirk.txt
new file mode 100644
index 0000000..e69de29
diff --git a/resources/introduction/new.txt b/resources/introduction/new.txt
new file mode 100644
index 0000000..e69de29
diff --git a/resources/introduction/notes.txt b/resources/introduction/notes.txt
new file mode 100644
index 0000000..58c2f37
--- /dev/null
+++ b/resources/introduction/notes.txt
@@ -0,0 +1,2 @@
+Java I/O is powerful.
+Streams make reading and writing easier.
diff --git a/resources/introduction/smiling_pit.jpg b/resources/introduction/smiling_pit.jpg
new file mode 100644
index 0000000..d5a1aff
Binary files /dev/null and b/resources/introduction/smiling_pit.jpg differ
diff --git a/resources/introduction/smiling_pit_copy.jpg b/resources/introduction/smiling_pit_copy.jpg
new file mode 100644
index 0000000..d5a1aff
Binary files /dev/null and b/resources/introduction/smiling_pit_copy.jpg differ
diff --git a/resources/introduction/students.txt b/resources/introduction/students.txt
new file mode 100644
index 0000000..e69de29
diff --git a/resources/introduction/test.txt b/resources/introduction/test.txt
new file mode 100644
index 0000000..6cdd5fc
--- /dev/null
+++ b/resources/introduction/test.txt
@@ -0,0 +1 @@
+Once upon a time
\ No newline at end of file
diff --git a/resources/test/subtest/text.txt b/resources/test/subtest/text.txt
new file mode 100644
index 0000000..e925143
--- /dev/null
+++ b/resources/test/subtest/text.txt
@@ -0,0 +1 @@
+Une souris verte...
\ No newline at end of file
diff --git a/src/generics/exercises/Exercise2.java b/src/generics/exercises/Exercise2.java
index 9170a9d..eb27ce4 100644
--- a/src/generics/exercises/Exercise2.java
+++ b/src/generics/exercises/Exercise2.java
@@ -1,6 +1,7 @@
package generics.exercises;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
@@ -31,50 +32,126 @@
public class Exercise2 {
public static void main(String[] args) {
+ String[] words = {"Hello", "World", "Java", "Zia petit toutou"};
+ Integer[] numbers = {0,1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ Double[] doubles = {133.99, 24.50, 33.99, 4d, 575.98};
+ List numbersList = new ArrayList<>(List.of(numbers));
+ List doublesList = new ArrayList<>(List.of(doubles));
+
System.out.println("=== Task 1: Print Array ===\n");
-
- // TODO: Call printArray method
- String[] words = {"Hello", "World", "Java"};
- Integer[] numbers = {1, 2, 3, 4, 5};
-
-
+ printArray(words); printArray(numbers); printArray(doubles);
+
System.out.println("\n=== Task 2: Reverse Array ===\n");
-
- // TODO: Call reverse method
-
-
+ Integer[] reverseNumbers = reverse(numbers);
+ System.out.println(Arrays.toString(reverseNumbers));
+ Double[] reverseDoubles = reverse(doubles);
+ System.out.println(Arrays.toString(reverseDoubles));
+
System.out.println("\n=== Task 3: Find Minimum ===\n");
-
- // TODO: Call findMin method
- List integers = new ArrayList<>();
- integers.add(10);
- integers.add(5);
- integers.add(20);
- integers.add(3);
-
+ System.out.println("Min: " + findMin(numbersList));
+ System.out.println("Min: " + findMin(doublesList));
+
System.out.println("\n=== Task 4: Calculator ===\n");
-
- // TODO: Create and use Calculator instances
-
+ Calculator ci = new Calculator<>(numbers);
+ System.out.println("[ADD] " + ci.add());
+ System.out.println("[SUBSTRACT] " + ci.substract());
+ System.out.println("[MULTIPLY] " + ci.multiply());
+ Calculator cd = new Calculator<>(doubles);
+ System.out.println("[ADD] " + cd.add());
+ System.out.println("[SUBSTRACT] " + cd.substract());
+ System.out.printf("[MULTIPLY] %.2f %n",cd.multiply());
+
+
System.out.println("\n=== Task 5: Count Greater Than ===\n");
-
- // TODO: Call countGreaterThan method
-
+ System.out.printf("Greater elements: %d%n", countGreaterThan(words, "Vernaculaire"));
+ System.out.printf("Greater elements: %d%n", countGreaterThan(numbers, 5));
+ System.out.printf("Greater elements: %d%n", countGreaterThan(doubles, 100d));
+
}
- // TODO: Task 1 - Implement printArray method
-
-
- // TODO: Task 2 - Implement reverse method
-
-
- // TODO: Task 3 - Implement findMin method
+ // Task 1 - Implement printArray method
+ public static void printArray(T[] array){
+ if(array.length == 0){
+ System.out.println("Empty array.");
+ return;
+ }
+ for (T item:array){
+ System.out.print(item + " ");
+ }
+ System.out.println();
+ }
+
+ // Task 2 - Implement reverse method
+ public static T[] reverse(T[] array){
+
+ T [] reverse = array;
+ int lg = reverse.length -1;
+ for(int i = 0; i<= lg / 2; i++){
+ T temp = reverse[i];
+ reverse[i] = reverse[lg-i];
+ reverse[lg-i] = temp;
+ }
+ return reverse;
+ }
- // TODO: Task 5 - Implement countGreaterThan method
+ // Task 3 - Implement findMin method
+ public static double findMin(List extends Number> numbers){
+ double min = numbers.get(0).doubleValue();
+ for(Number item:numbers){
+ double i = item.doubleValue();
+ min = min < i ? min: i;
+ }
+ return min;
+ }
+
+
+ // Task 5 - Implement countGreaterThan method
+ public static > int countGreaterThan(T[] array, T element ){
+ int count = 0;
+ for(T item:array){
+ if( element.compareTo(item) < 0){
+ System.out.println(item + " is greater than " + element);
+ count++;
+ }
+ }
+ return count;
+ }
}
-// TODO: Task 4 - Create Calculator class here
+// Task 4 - Create Calculator class here
+class Calculator{
+ T[] array;
+ public Calculator(T[] array){
+ this.array = array;
+ }
+ protected double add(){
+ double count = this.array[0].doubleValue();
+ int lg = this.array.length;
+ for (int i = 1; i < lg; i++) {
+ count += this.array[i].doubleValue();
+ }
+ return count;
+ }
+ protected double substract(){
+ double count = this.array[0].doubleValue();
+ int lg = this.array.length;
+ for (int i = 1; i < lg; i++) {
+ count -= this.array[i].doubleValue();
+ }
+ return count;
+ }
+ protected double multiply(){
+ double count = this.array[0].doubleValue();
+ int lg = this.array.length ;
+ for (int i = 1; i < lg; i++) {
+ count *= this.array[i].doubleValue();
+ }
+ return count;
+ }
+
+}
+
diff --git a/src/generics/exercises/Exercise3.java b/src/generics/exercises/Exercise3.java
deleted file mode 100644
index c89e3de..0000000
--- a/src/generics/exercises/Exercise3.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package generics.exercises;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Exercise 3: Wildcards and PECS
- *
- * Tasks:
- * 1. Write a method printList(List> list) that prints any list
- * - Try with different types of lists
- *
- * 2. Write a method sumList(List extends Number> numbers) that calculates
- * the sum of all numbers
- * - Try with List, List, and mixed List
- *
- * 3. Write a method addThreeIntegers(List super Integer> list) that adds
- * the numbers 10, 20, 30 to the list
- * - Try with List, List, and List