diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..fe1b073
Binary files /dev/null and b/.DS_Store differ
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/lab-java-interfaces-and-abstract-classes-es.iml b/.idea/lab-java-interfaces-and-abstract-classes-es.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/lab-java-interfaces-and-abstract-classes-es.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..47478b9
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..10ef36b
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/untitled/Car.class b/out/production/untitled/Car.class
new file mode 100644
index 0000000..cb7cd96
Binary files /dev/null and b/out/production/untitled/Car.class differ
diff --git a/out/production/untitled/InList.class b/out/production/untitled/InList.class
new file mode 100644
index 0000000..71abb95
Binary files /dev/null and b/out/production/untitled/InList.class differ
diff --git a/out/production/untitled/IndexOutOfBoundsException.class b/out/production/untitled/IndexOutOfBoundsException.class
new file mode 100644
index 0000000..6e75a81
Binary files /dev/null and b/out/production/untitled/IndexOutOfBoundsException.class differ
diff --git a/out/production/untitled/IntArrayList.class b/out/production/untitled/IntArrayList.class
new file mode 100644
index 0000000..c966366
Binary files /dev/null and b/out/production/untitled/IntArrayList.class differ
diff --git a/out/production/untitled/IntVector.class b/out/production/untitled/IntVector.class
new file mode 100644
index 0000000..f1ea21c
Binary files /dev/null and b/out/production/untitled/IntVector.class differ
diff --git a/out/production/untitled/Main.class b/out/production/untitled/Main.class
new file mode 100644
index 0000000..269ab7e
Binary files /dev/null and b/out/production/untitled/Main.class differ
diff --git a/out/production/untitled/Movie.class b/out/production/untitled/Movie.class
new file mode 100644
index 0000000..c69dac1
Binary files /dev/null and b/out/production/untitled/Movie.class differ
diff --git a/out/production/untitled/Sedan.class b/out/production/untitled/Sedan.class
new file mode 100644
index 0000000..02b07b8
Binary files /dev/null and b/out/production/untitled/Sedan.class differ
diff --git a/out/production/untitled/Truck.class b/out/production/untitled/Truck.class
new file mode 100644
index 0000000..a65f7fd
Binary files /dev/null and b/out/production/untitled/Truck.class differ
diff --git a/out/production/untitled/TvSeries.class b/out/production/untitled/TvSeries.class
new file mode 100644
index 0000000..4f38aa4
Binary files /dev/null and b/out/production/untitled/TvSeries.class differ
diff --git a/out/production/untitled/UtilityVehicle.class b/out/production/untitled/UtilityVehicle.class
new file mode 100644
index 0000000..1006e02
Binary files /dev/null and b/out/production/untitled/UtilityVehicle.class differ
diff --git a/out/production/untitled/Video.class b/out/production/untitled/Video.class
new file mode 100644
index 0000000..3bff430
Binary files /dev/null and b/out/production/untitled/Video.class differ
diff --git a/untitled/.DS_Store b/untitled/.DS_Store
new file mode 100644
index 0000000..9a874b5
Binary files /dev/null and b/untitled/.DS_Store differ
diff --git a/untitled/src/Car.java b/untitled/src/Car.java
new file mode 100644
index 0000000..9bcd7fb
--- /dev/null
+++ b/untitled/src/Car.java
@@ -0,0 +1,48 @@
+public abstract class Car {
+ private String vinNumber;
+ private String make;
+ private String model;
+ private int mileage;
+
+
+ public Car(String vinNumber, String make, String model, int mileage){
+ this.vinNumber = vinNumber;
+ this.make = make;
+ this.model = model;
+ this.mileage = mileage;
+ }
+
+ public String getVinNumber() {
+ return vinNumber;
+ }
+
+ public void setVinNumber(String vinNumber) {
+ this.vinNumber = vinNumber;
+ }
+
+ 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 int getMileage() {
+ return mileage;
+ }
+
+ public void setMileage(int mileage) {
+ this.mileage = mileage;
+ }
+
+ public abstract String getInfo();
+}
diff --git a/untitled/src/InList.java b/untitled/src/InList.java
new file mode 100644
index 0000000..ed7e2ae
--- /dev/null
+++ b/untitled/src/InList.java
@@ -0,0 +1,4 @@
+public interface InList {
+ void add(int number);
+ int get(int id);
+}
diff --git a/untitled/src/IndexOutOfBoundsException.java b/untitled/src/IndexOutOfBoundsException.java
new file mode 100644
index 0000000..76f2b07
--- /dev/null
+++ b/untitled/src/IndexOutOfBoundsException.java
@@ -0,0 +1,5 @@
+public class IndexOutOfBoundsException extends RuntimeException {
+ public IndexOutOfBoundsException(String message) {
+ super(message);
+ }
+}
diff --git a/untitled/src/IntArrayList.java b/untitled/src/IntArrayList.java
new file mode 100644
index 0000000..c1bb1d0
--- /dev/null
+++ b/untitled/src/IntArrayList.java
@@ -0,0 +1,38 @@
+public class IntArrayList implements InList {
+ private int[] array;
+ private int size;
+
+ public IntArrayList() {
+ array = new int[10];
+ size = 0;
+ }
+
+ private void resizeArray() {
+ int newSize = array.length + (array.length / 2); // Increase the 50%
+ int[] newArray = new int[newSize];
+ System.arraycopy(array, 0, newArray, 0, array.length);
+ array = newArray;
+ System.out.println("IntArrayList resized! New array size: " + newSize);
+
+ }
+
+ @Override
+ public void add(int number) {
+ if (size == array.length) {
+ resizeArray();
+ }
+ array[size++] = number;
+ }
+
+ @Override
+ public int get(int id) {
+ if (id >= 0 && id < size) {
+ return array[id];
+ } else { //as we need to return an int, we need exception
+ throw new IndexOutOfBoundsException("Index out of range");
+ }
+
+ }
+
+}
+
diff --git a/untitled/src/IntVector.java b/untitled/src/IntVector.java
new file mode 100644
index 0000000..efbddef
--- /dev/null
+++ b/untitled/src/IntVector.java
@@ -0,0 +1,37 @@
+public class IntVector implements InList{
+ private int[] array;
+ private int size;
+
+ public IntVector() {
+ array = new int[20];
+ size = 0;
+ }
+
+ private void resizeArray() {
+ int newSize = array.length * 2; // Double the size
+ int[] newArray = new int[newSize];
+ System.arraycopy(array, 0, newArray, 0, array.length);
+ array = newArray;
+ System.out.println("InVector resized! New array size: " + newSize);
+ }
+
+ @Override
+ public void add(int number) {
+ if (size == array.length) {
+ resizeArray();
+ }
+ array[size++] = number;
+ }
+
+ @Override
+ public int get(int id) {
+ if (id >= 0 && id < size) {
+ return array[id];
+ } else { //as we need to return an int, we need excpetion
+ throw new IndexOutOfBoundsException("Index out of range");
+ }
+
+ }
+
+
+}
diff --git a/untitled/src/Main.java b/untitled/src/Main.java
new file mode 100644
index 0000000..dc12ba0
--- /dev/null
+++ b/untitled/src/Main.java
@@ -0,0 +1,73 @@
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+public class Main {
+ public static double roundTwo(BigDecimal number) {
+ BigDecimal rounded = number.setScale(2, RoundingMode.HALF_UP);
+ return rounded.doubleValue();
+ }
+public static double invert(BigDecimal number){
+ BigDecimal inverted = number.negate();
+ BigDecimal rounded = inverted.setScale(1, RoundingMode.HALF_UP);
+ return rounded.doubleValue();
+}
+ public static void main(String[] args) {
+
+ System.out.println("ERCERCICE 1 ---------- BIG DECIMAL");
+ BigDecimal num1 = new BigDecimal("4.2565");
+ BigDecimal num2 = new BigDecimal("-9.548");
+
+ System.out.println(roundTwo(num1));
+ System.out.println(invert(num1));
+ System.out.println(roundTwo(num2));
+ System.out.println(invert(num2));
+
+ System.out.println("\nEXERCICIE 2 ----------");
+ Car Sedan = new Sedan("891223","Cheverolet","Aveo",15000);
+ Car UtilityVehicle = new UtilityVehicle("654321", "Jeep", "Cherokee", 20000, true);
+ Car Truck = new Truck("789012", "Ford", "F-150", 25000,4.6);
+
+
+ System.out.println(Sedan.getInfo());
+ System.out.println(UtilityVehicle.getInfo());
+ System.out.println(Truck.getInfo());
+
+ System.out.println("\nEXERCICE 3---------");
+ Video movie = new Movie("Harry Potter",120,9.5);
+ Video tvserie = new TvSeries("El cor de la ciutat",30,500);
+
+ System.out.println(movie.getInfo());
+ System.out.println(tvserie.getInfo());
+
+ System.out.println("\nEXERCICE 4---------");
+
+ InList arrayList = new IntArrayList();
+ System.out.println("\nTesting IntArrayList:");
+ for (int i = 0; i < 17; i++) {
+ arrayList.add(i * 2);
+ }
+ for (int i = 0; i < 17; i++) {
+ System.out.println("Element at index " + i + ": " + arrayList.get(i));
+ }
+
+
+ InList vector = new IntVector();
+ System.out.println("\nTesting IntVector:");
+ for (int i = 0; i < 25; i++) {
+ vector.add(i * 3);
+ }
+ for (int i = 0; i < 25; i++) {
+ System.out.println("Element at index " + i + ": " + vector.get(i));
+ }
+
+
+
+ }
+
+}
+
+
+
+
+
+
diff --git a/untitled/src/Movie.java b/untitled/src/Movie.java
new file mode 100644
index 0000000..069fe81
--- /dev/null
+++ b/untitled/src/Movie.java
@@ -0,0 +1,13 @@
+public class Movie extends Video {
+ private double rating;
+
+ public Movie (String title, int duration,double rating){
+ super(title, duration);
+ this.rating = rating;
+ }
+
+ @Override
+ public String getInfo(){
+ return "The " + getTitle() + " movie has a duration of " + getDuration() + " minutes and is rated as " + rating;
+ }
+}
diff --git a/untitled/src/Sedan.java b/untitled/src/Sedan.java
new file mode 100644
index 0000000..3cad435
--- /dev/null
+++ b/untitled/src/Sedan.java
@@ -0,0 +1,13 @@
+public class Sedan extends Car{
+
+ public Sedan(String vinNumber, String make, String model, int mileage) {
+ super(vinNumber, make, model, mileage);
+ }
+
+ @Override
+ public String getInfo() {
+ return "Sedan [VIN: " + getVinNumber() + ", Make: " + getMake() + ", Model: " + getModel() + ", Mileage: " + getMileage() + "]";
+ }
+}
+
+
diff --git a/untitled/src/Truck.java b/untitled/src/Truck.java
new file mode 100644
index 0000000..8893080
--- /dev/null
+++ b/untitled/src/Truck.java
@@ -0,0 +1,14 @@
+public class Truck extends Car{
+ private final double towingCapacity;
+
+
+ public Truck(String vinNumber, String make, String model, int mileage, double towingCapacity) {
+ super(vinNumber, make, model, mileage);
+ this.towingCapacity = towingCapacity;
+ }
+
+ @Override
+ public String getInfo() {
+ return "Truck [VIN: " + getVinNumber() + ", Make: " + getMake() + ", Model: " + getModel() + ", Mileage: " + getMileage() + " Towing capacity: "+ towingCapacity + "]";
+ }
+}
diff --git a/untitled/src/TvSeries.java b/untitled/src/TvSeries.java
new file mode 100644
index 0000000..74cb21d
--- /dev/null
+++ b/untitled/src/TvSeries.java
@@ -0,0 +1,21 @@
+public class TvSeries extends Video{
+ private int episodes;
+
+ public TvSeries (String title, int duration, int episodes){
+ super(title,duration);
+ this.episodes = episodes;
+ }
+
+ public int getEpisodes() {
+ return episodes;
+ }
+
+ public void setEpisodes(int episodes) {
+ this.episodes = episodes;
+ }
+
+ @Override
+ public String getInfo(){
+ return "The " + getTitle() + " has a duration of " + getDuration() + " minutes and have " + episodes + " episodes";
+ }
+}
diff --git a/untitled/src/UtilityVehicle.java b/untitled/src/UtilityVehicle.java
new file mode 100644
index 0000000..37efa14
--- /dev/null
+++ b/untitled/src/UtilityVehicle.java
@@ -0,0 +1,13 @@
+
+public class UtilityVehicle extends Car {
+ private final boolean fourWheelDrive;
+
+ public UtilityVehicle(String vinNumber, String make, String model,int mileage, boolean fourWheelDrive){
+ super(vinNumber,make,model,mileage);
+ this.fourWheelDrive = fourWheelDrive;
+ }
+ @Override
+ public String getInfo() {
+ return "UtilityVehicle [VIN: " + getVinNumber() + ", Make: " + getMake() + ", Model: " + getModel() + ", Mileage: " + getMileage() + ", Four-Wheel Drive: " + fourWheelDrive + "]";
+ }
+}
diff --git a/untitled/src/Video.java b/untitled/src/Video.java
new file mode 100644
index 0000000..cfa96cf
--- /dev/null
+++ b/untitled/src/Video.java
@@ -0,0 +1,31 @@
+public abstract class Video {
+ private String title;
+ private int duration;
+
+ public Video(String title, int duration) {
+ this.title = title;
+ this.duration = duration;
+ }
+
+ public String getInfo (String title, int duration){
+ return "The " + getTitle() + " has a duration of " + getDuration();
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getDuration() {
+ return duration;
+ }
+
+ public void setDuration(int duration) {
+ this.duration = duration;
+ }
+
+ public abstract String getInfo();
+}
diff --git a/untitled/untitled.iml b/untitled/untitled.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/untitled/untitled.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file