diff --git a/Lab2.02/.gitignore b/Lab2.02/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/Lab2.02/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/Lab2.02/.idea/.gitignore b/Lab2.02/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/Lab2.02/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/Lab2.02/.idea/encodings.xml b/Lab2.02/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/Lab2.02/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Lab2.02/.idea/misc.xml b/Lab2.02/.idea/misc.xml
new file mode 100644
index 0000000..df00c07
--- /dev/null
+++ b/Lab2.02/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Lab2.02/.idea/vcs.xml b/Lab2.02/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/Lab2.02/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Lab2.02/pom.xml b/Lab2.02/pom.xml
new file mode 100644
index 0000000..1dc9a96
--- /dev/null
+++ b/Lab2.02/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+ Ironhack.schl
+ Lab2.02
+ 1.0-SNAPSHOT
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.10.2
+ test
+
+
+
+
\ No newline at end of file
diff --git a/Lab2.02/src/main/java/Ironhack/schl/ConcretePlayer.java b/Lab2.02/src/main/java/Ironhack/schl/ConcretePlayer.java
new file mode 100644
index 0000000..f59be41
--- /dev/null
+++ b/Lab2.02/src/main/java/Ironhack/schl/ConcretePlayer.java
@@ -0,0 +1,10 @@
+package Ironhack.schl;
+
+public class ConcretePlayer extends Player {
+
+ public ConcretePlayer(int health, int attackPower, int lives) {
+ super(health, attackPower, lives);
+ }
+
+ // Implement any abstract methods from the Player class here
+}
\ No newline at end of file
diff --git a/Lab2.02/src/main/java/Ironhack/schl/Elf.java b/Lab2.02/src/main/java/Ironhack/schl/Elf.java
new file mode 100644
index 0000000..e1a7604
--- /dev/null
+++ b/Lab2.02/src/main/java/Ironhack/schl/Elf.java
@@ -0,0 +1,19 @@
+package Ironhack.schl;
+
+public class Elf extends Player{
+ private int speed;
+
+ public Elf(int health, int strength, int lives, int speed) {
+ super(health, strength, lives);
+ this.speed = speed;
+ }
+
+ public int getSpeed() {
+ return speed;
+ }
+
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
+
+}
diff --git a/Lab2.02/src/main/java/Ironhack/schl/JavaKeywordsChecker.java b/Lab2.02/src/main/java/Ironhack/schl/JavaKeywordsChecker.java
new file mode 100644
index 0000000..9e4a7ea
--- /dev/null
+++ b/Lab2.02/src/main/java/Ironhack/schl/JavaKeywordsChecker.java
@@ -0,0 +1,25 @@
+package Ironhack.schl;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class JavaKeywordsChecker {
+
+ private static final List JAVA_KEYWORDS = Arrays.asList(
+ "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const",
+ "continue", "default", "do", "double", "else", "enum", "extends", "final", "finally", "float",
+ "for", "goto", "if", "implements", "import", "instanceof", "int", "interface", "long", "native",
+ "new", "package", "private", "protected", "public", "return", "short", "static", "strictfp", "super",
+ "switch", "synchronized", "this", "throw", "throws", "transient", "try", "void", "volatile", "while"
+ );
+
+ public boolean containsJavaKeywords(String input) {
+ String[] words = input.split("\\s+");
+ for (String word : words) {
+ if (JAVA_KEYWORDS.contains(word)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/Lab2.02/src/main/java/Ironhack/schl/OddIntegers.java b/Lab2.02/src/main/java/Ironhack/schl/OddIntegers.java
new file mode 100644
index 0000000..b515ed4
--- /dev/null
+++ b/Lab2.02/src/main/java/Ironhack/schl/OddIntegers.java
@@ -0,0 +1,18 @@
+package Ironhack.schl;
+public class OddIntegers {
+
+ public int[] getOddIntegers(int n) {
+ if (n < 0) {
+ return new int[0];
+ }
+
+ int count = n / 2 + (n % 2 == 1 ? 1 : 0);
+ int[] oddIntegers = new int[count];
+
+ for (int i = 0; i < count; i++) {
+ oddIntegers[i] = 2 * i + 1;
+ }
+
+ return oddIntegers;
+ }
+}
diff --git a/Lab2.02/src/main/java/Ironhack/schl/Player.java b/Lab2.02/src/main/java/Ironhack/schl/Player.java
new file mode 100644
index 0000000..5f96c39
--- /dev/null
+++ b/Lab2.02/src/main/java/Ironhack/schl/Player.java
@@ -0,0 +1,67 @@
+package Ironhack.schl;
+
+public abstract class Player {
+ private int health;
+ private int strength;
+ private int lives;
+
+ //Constructor
+
+ public Player(int health, int strength, int lives) {
+ this.health = health;
+ this.strength = strength;
+ this.lives = lives;
+ }
+
+ // Getters and setters
+
+ public int getHealth() {
+ return health;
+ }
+
+ public int getStrength() {
+ return strength;
+ }
+
+ public int getLives() {
+ return lives;
+ }
+
+ public void setStrength(int strength) {
+ this.strength = strength;
+ }
+
+ public void setHealth(int health) {
+ this.health = health;
+ }
+
+ public void setLives(int lives) {
+ this.lives = lives;
+ }
+
+ public void decrementLive() {
+ lives--;
+ if (lives > 0) {
+ restoreHealth();
+ System.out.println("You have " + lives + " lives left");
+ } else {
+ System.out.println("This character died.");
+ }
+ }
+
+ public void checkHealth() {
+ if (health <= 0) {
+ decrementLive();
+ }
+ }
+
+ public void restoreHealth() {
+ this.health = 100;
+
+ }
+
+ public void attack(Player playerToAttack) {
+ playerToAttack.setHealth(playerToAttack.getHealth() - strength);
+ }
+
+}
\ No newline at end of file
diff --git a/Lab2.02/src/main/java/Ironhack/schl/Warrior.java b/Lab2.02/src/main/java/Ironhack/schl/Warrior.java
new file mode 100644
index 0000000..d1f3757
--- /dev/null
+++ b/Lab2.02/src/main/java/Ironhack/schl/Warrior.java
@@ -0,0 +1,23 @@
+package Ironhack.schl;
+
+public class Warrior extends Player {
+ private int force;
+
+ public Warrior(int health, int strength, int lives, int force) {
+ super(health, strength, lives);
+ this.force = force;
+ }
+
+ public int getForce() {
+ return force;
+ }
+
+ public void setForce(int force) {
+ this.force = force;
+ }
+
+ public Elf convertToElf() {
+
+ return new Elf(getHealth(), getStrength(), getLives(), 10);
+ }
+}
diff --git a/Lab2.02/src/main/java/Ironhack/schl/Wizard.java b/Lab2.02/src/main/java/Ironhack/schl/Wizard.java
new file mode 100644
index 0000000..6f56581
--- /dev/null
+++ b/Lab2.02/src/main/java/Ironhack/schl/Wizard.java
@@ -0,0 +1,24 @@
+package Ironhack.schl;
+
+public class Wizard extends Player{
+ private String spell;
+
+ public Wizard(int health, int strength, int lives, String spell) {
+ super(health, strength, lives);
+ this.spell = spell;
+ }
+
+ public void setSpell(String spell) {
+ this.spell = spell;
+
+ }
+
+ public String getSpell() {
+ return spell;
+ }
+
+ public Elf convertToElf() {
+
+ return new Elf(getHealth(), getStrength(), getLives(), 10);
+ }
+}
diff --git a/Lab2.02/src/test/java/ElfTest.java b/Lab2.02/src/test/java/ElfTest.java
new file mode 100644
index 0000000..225303a
--- /dev/null
+++ b/Lab2.02/src/test/java/ElfTest.java
@@ -0,0 +1,6 @@
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class ElfTest {
+ // No tests to address
+}
diff --git a/Lab2.02/src/test/java/OddIntegersTest.java b/Lab2.02/src/test/java/OddIntegersTest.java
new file mode 100644
index 0000000..7c7dc0f
--- /dev/null
+++ b/Lab2.02/src/test/java/OddIntegersTest.java
@@ -0,0 +1,29 @@
+
+import Ironhack.schl.OddIntegers;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class OddIntegersTest {
+
+ @Test
+ public void testOddIntegers_nIs10() {
+ OddIntegers oddIntegers = new OddIntegers();
+ int[] expected = {1, 3, 5, 7, 9};
+ assertArrayEquals(expected, oddIntegers.getOddIntegers(10));
+ }
+
+ @Test
+ public void testOddIntegers_nIs0() {
+ OddIntegers oddIntegers = new OddIntegers();
+ int[] expected = {};
+ assertArrayEquals(expected, oddIntegers.getOddIntegers(0));
+ }
+
+ @Test
+ public void testOddIntegers_nIsNegative() {
+ OddIntegers oddIntegers = new OddIntegers();
+ int[] expected = {};
+ assertArrayEquals(expected, oddIntegers.getOddIntegers(-5));
+ }
+
+}
\ No newline at end of file
diff --git a/Lab2.02/src/test/java/PlayerTest.java b/Lab2.02/src/test/java/PlayerTest.java
new file mode 100644
index 0000000..f7ce30d
--- /dev/null
+++ b/Lab2.02/src/test/java/PlayerTest.java
@@ -0,0 +1,40 @@
+import Ironhack.schl.ConcretePlayer;
+import Ironhack.schl.Player;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class PlayerTest {
+
+ @Test
+ public void testDecrementLive() {
+ Player player = new ConcretePlayer(100, 20, 3);
+ player.decrementLive();
+ assertEquals(2, player.getLives());
+ assertEquals(100, player.getHealth());
+
+ player.decrementLive();
+ assertEquals(1, player.getLives());
+ assertEquals(100, player.getHealth());
+
+ player.decrementLive();
+ assertEquals(0, player.getLives());
+ System.out.println("This character died.");
+ }
+
+ @Test
+ public void testAttack() {
+ ConcretePlayer player1 = new ConcretePlayer(100, 20, 3);
+ ConcretePlayer player2 = new ConcretePlayer(80, 15, 2);
+
+ player1.attack(player2);
+ assertEquals(60, player2.getHealth());
+ }
+
+ @Test
+ public void testCheckHealth() {
+ ConcretePlayer player = new ConcretePlayer(0, 20, 3);
+ player.checkHealth();
+ assertEquals(2, player.getLives());
+ assertEquals(100, player.getHealth());
+ }
+}
\ No newline at end of file
diff --git a/Lab2.02/src/test/java/WarriorTest.java b/Lab2.02/src/test/java/WarriorTest.java
new file mode 100644
index 0000000..a696bfa
--- /dev/null
+++ b/Lab2.02/src/test/java/WarriorTest.java
@@ -0,0 +1,16 @@
+import Ironhack.schl.Elf;
+import Ironhack.schl.Warrior;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+public class WarriorTest {
+
+ @Test
+ public void testConvertToElf() {
+ Warrior warrior = new Warrior(100, 20, 3, 50);
+ Elf elf = warrior.convertToElf();
+ assertEquals(100, elf.getHealth());
+ assertEquals(20, elf.getStrength());
+ assertEquals(3, elf.getLives());
+ assertEquals(10, elf.getSpeed());
+ }
+}
\ No newline at end of file
diff --git a/Lab2.02/src/test/java/WizardTest.java b/Lab2.02/src/test/java/WizardTest.java
new file mode 100644
index 0000000..01ac4fc
--- /dev/null
+++ b/Lab2.02/src/test/java/WizardTest.java
@@ -0,0 +1,17 @@
+import Ironhack.schl.Elf;
+import Ironhack.schl.Wizard;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class WizardTest {
+
+ @Test
+ public void testConvertToElf() {
+ Wizard wizard = new Wizard(100, 20, 3, "Fireball");
+ Elf elf = wizard.convertToElf();
+ assertEquals(100, elf.getHealth());
+ assertEquals(20, elf.getStrength());
+ assertEquals(3, elf.getLives());
+ assertEquals(10, elf.getSpeed());
+ }
+}
\ No newline at end of file