diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..12f2f4d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..453f32a --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/lab-java-interfaces-and-abstract-classes.iml b/.idea/lab-java-interfaces-and-abstract-classes.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/lab-java-interfaces-and-abstract-classes.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..abd5e3f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ff55171 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ 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/Systems/pom.xml b/Systems/pom.xml new file mode 100644 index 0000000..4fe0108 --- /dev/null +++ b/Systems/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + com.ironhack + Systems + 1.0-SNAPSHOT + + + 25 + 25 + UTF-8 + + + \ No newline at end of file diff --git a/Systems/src/main/java/Decimal/DecimalOperations.java b/Systems/src/main/java/Decimal/DecimalOperations.java new file mode 100644 index 0000000..8bb819d --- /dev/null +++ b/Systems/src/main/java/Decimal/DecimalOperations.java @@ -0,0 +1,22 @@ +package Decimal; + +import java.math.BigDecimal; +import java.math.RoundingMode; + + + +class DecimalOperations { + void main() { + System.out.println(rounding(new BigDecimal("55.55"))); + System.out.println(negate(new BigDecimal("66.33"))); + + } + + public double rounding(BigDecimal value) { + return value.setScale(2 , RoundingMode.UP).doubleValue(); + } + + public BigDecimal negate(BigDecimal value) { + return value.negate().setScale(1 , RoundingMode.UP); + } +} diff --git a/Systems/src/main/java/InList/InList.java b/Systems/src/main/java/InList/InList.java new file mode 100644 index 0000000..5634fbf --- /dev/null +++ b/Systems/src/main/java/InList/InList.java @@ -0,0 +1,7 @@ +package InList; + +public interface InList { + + void add(int number); + int get(int id); +} diff --git a/Systems/src/main/java/InList/IntListArray.java b/Systems/src/main/java/InList/IntListArray.java new file mode 100644 index 0000000..6a69473 --- /dev/null +++ b/Systems/src/main/java/InList/IntListArray.java @@ -0,0 +1,53 @@ +package InList; + +import java.lang.reflect.Array; + +public class IntListArray implements InList{ + private int[] data; + private int size; + + public IntListArray() { + this.data = new int[10]; + this.size = 0; + } + + @Override + public void add(int number) { + if (size == data.length) { + // grow by 50% (e.g., 10 -> 15) + int newCapacity = data.length + (data.length / 2); + if (newCapacity == data.length) { + // defensive: if length were 1, length/2 would be 0 + newCapacity = data.length + 1; + } + + int[] newData = new int[newCapacity]; + for (int i = 0; i < data.length; i++) { + newData[i] = data[i]; + } + data = newData; + } + + data[size] = number; + size++; + } + + @Override + public int get(int id) { + if (id < 0 || id >= size) { + throw new IndexOutOfBoundsException( + "id=" + id + " out of bounds (size=" + size + ")" + ); + } + return data[id]; + } + + public int size() { + return size; + } + + public int capacity() { + return data.length; + } +} + diff --git a/Systems/src/main/java/InList/IntVector.java b/Systems/src/main/java/InList/IntVector.java new file mode 100644 index 0000000..9003c49 --- /dev/null +++ b/Systems/src/main/java/InList/IntVector.java @@ -0,0 +1,49 @@ +package InList; + +import InList.InList; + +public class IntVector implements InList { + + private int[] data; + private int size; + + public IntVector() { + this.data = new int[20]; + this.size = 0; + } + + @Override + public void add(int number) { + if (size == data.length) { + // double capacity (e.g., 20 -> 40) + int newCapacity = data.length * 2; + + int[] newData = new int[newCapacity]; + for (int i = 0; i < data.length; i++) { + newData[i] = data[i]; + } + data = newData; + } + + data[size] = number; + size++; + } + + @Override + public int get(int id) { + if (id < 0 || id >= size) { + throw new IndexOutOfBoundsException( + "id=" + id + " out of bounds (size=" + size + ")" + ); + } + return data[id]; + } + + public int size() { + return size; + } + + public int capacity() { + return data.length; + } +} \ No newline at end of file diff --git a/Systems/src/main/java/VideoStreaming/Movie.java b/Systems/src/main/java/VideoStreaming/Movie.java new file mode 100644 index 0000000..4cd13ad --- /dev/null +++ b/Systems/src/main/java/VideoStreaming/Movie.java @@ -0,0 +1,24 @@ +package VideoStreaming; + +public class Movie extends Video { + private double ratings; + + public Movie(int duration, String title, double ratings) { + super(duration, title); + this.ratings = ratings; + } + + @Override + public String getInfo(){ + String info = "Our video's title is "+ getTitle() + " duration equals to " + getDuration() + "rating is " + ratings; + return info; + } + + public double getRatings() { + return ratings; + } + + public void setRatings(double ratings) { + this.ratings = ratings; + } +} diff --git a/Systems/src/main/java/VideoStreaming/TVSeries.java b/Systems/src/main/java/VideoStreaming/TVSeries.java new file mode 100644 index 0000000..9295845 --- /dev/null +++ b/Systems/src/main/java/VideoStreaming/TVSeries.java @@ -0,0 +1,24 @@ +package VideoStreaming; + +public class TVSeries extends Video{ + private int episodes; + + public TVSeries(int duration, String title, int episodes) { + super(duration, title); + this.episodes = episodes; + } + + @Override + public String getInfo(){ + String info = "Our video's title is "+ getTitle() + " duration equals to " + getDuration() + "episdoes amount is " + episodes; + return info; + } + + public int getEpisodes() { + return episodes; + } + + public void setEpisodes(int episodes) { + this.episodes = episodes; + } +} diff --git a/Systems/src/main/java/VideoStreaming/Video.java b/Systems/src/main/java/VideoStreaming/Video.java new file mode 100644 index 0000000..8c95617 --- /dev/null +++ b/Systems/src/main/java/VideoStreaming/Video.java @@ -0,0 +1,35 @@ +package VideoStreaming; + +public abstract class Video { + private String title; + private int duration; + + + public Video(int duration, String title) { + this.duration = duration; + this.title = title; + } + + public String getInfo(){ + String info = "Our video's title is "+ title + " duration equals to " + duration; + return info; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/Systems/src/main/java/VideoStreaming/VideoDemo.java b/Systems/src/main/java/VideoStreaming/VideoDemo.java new file mode 100644 index 0000000..4a66369 --- /dev/null +++ b/Systems/src/main/java/VideoStreaming/VideoDemo.java @@ -0,0 +1,11 @@ +package VideoStreaming; + +public class VideoDemo { + static void main() { + Video series = new TVSeries(120 , "Big Brother" , 22); + Video movie = new Movie(122, "Titanic ", 7.7); + + System.out.println("Series general info is : " + series.getInfo()); + System.out.println("Movies general info is : " + movie.getInfo()); + } +} diff --git a/Systems/src/main/java/com/ironhack/Main.java b/Systems/src/main/java/com/ironhack/Main.java new file mode 100644 index 0000000..9860728 --- /dev/null +++ b/Systems/src/main/java/com/ironhack/Main.java @@ -0,0 +1,17 @@ +package com.ironhack; + +//TIP To Run code, press or +// click the icon in the gutter. +public class Main { + static void main() { + //TIP Press with your caret at the highlighted text + // to see how IntelliJ IDEA suggests fixing it. + IO.println(String.format("Hello and welcome!")); + + for (int i = 1; i <= 5; i++) { + //TIP Press to start debugging your code. We have set one breakpoint + // for you, but you can always add more by pressing . + IO.println("i = " + i); + } + } +} diff --git a/Systems/src/main/java/com/ironhack/inventory/Car.java b/Systems/src/main/java/com/ironhack/inventory/Car.java new file mode 100644 index 0000000..d0eed07 --- /dev/null +++ b/Systems/src/main/java/com/ironhack/inventory/Car.java @@ -0,0 +1,24 @@ +package com.ironhack.inventory; + +public abstract class Car { + + String vinNumber; + String make; + String model; + int milleage; + + public Car(String make, int milleage, String model, String vinNumber) { + this.make = make; + this.milleage = milleage; + this.model = model; + this.vinNumber = vinNumber; + } + + public String getInfo(){ + String info = "This car's vinnumber is: " + this.vinNumber + " make is : " + this.make + + " mode is : " + this.model + " millage equals to + " + this.milleage; + return info; + + } + +} diff --git a/Systems/src/main/java/com/ironhack/inventory/CarDemo.java b/Systems/src/main/java/com/ironhack/inventory/CarDemo.java new file mode 100644 index 0000000..fdf9021 --- /dev/null +++ b/Systems/src/main/java/com/ironhack/inventory/CarDemo.java @@ -0,0 +1,13 @@ +package com.ironhack.inventory; + +public class CarDemo { + static void main() { + Car sedan = new Sedan("Kia" , 100 , " forte " , "BHH482KKW"); + Car truck = new Truck("Truck " , 200 , "ATEGO","DLSF324SD" , 200.00); + Car moto = new UtilityVehicle("Moto" , 150 , "RAW" , "SDFD32SQ" , false ); + + System.out.println("Sedans general info is : " + sedan.getInfo()); + System.out.println("Truck's general indo is : "+ truck.getInfo()); + System.out.println("Moto's general info is : " + moto.getInfo()); + } +} diff --git a/Systems/src/main/java/com/ironhack/inventory/Sedan.java b/Systems/src/main/java/com/ironhack/inventory/Sedan.java new file mode 100644 index 0000000..a11d4c5 --- /dev/null +++ b/Systems/src/main/java/com/ironhack/inventory/Sedan.java @@ -0,0 +1,8 @@ +package com.ironhack.inventory; + +public class Sedan extends Car{ + + public Sedan(String make, int milleage, String model, String vinNumber) { + super(make, milleage, model, vinNumber); + } +} diff --git a/Systems/src/main/java/com/ironhack/inventory/Truck.java b/Systems/src/main/java/com/ironhack/inventory/Truck.java new file mode 100644 index 0000000..ecfbdc2 --- /dev/null +++ b/Systems/src/main/java/com/ironhack/inventory/Truck.java @@ -0,0 +1,18 @@ +package com.ironhack.inventory; + +public class Truck extends Car{ + double towingCapacity; + + public Truck(String make, int milleage, String model, String vinNumber, double towingCapacity) { + super(make, milleage, model, vinNumber); + this.towingCapacity = towingCapacity; + } + + @Override + public String getInfo(){ + String info = "This car's vinnumber is: " + this.vinNumber + " make is : " + this.make + + " mode is : " + this.model + " millage equals to + " + this.milleage + + " what is its capacity ? : " + this.towingCapacity; + return info; + } +} diff --git a/Systems/src/main/java/com/ironhack/inventory/UtilityVehicle.java b/Systems/src/main/java/com/ironhack/inventory/UtilityVehicle.java new file mode 100644 index 0000000..03b45b3 --- /dev/null +++ b/Systems/src/main/java/com/ironhack/inventory/UtilityVehicle.java @@ -0,0 +1,18 @@ +package com.ironhack.inventory; + +public class UtilityVehicle extends Car{ + boolean fourWheelDrive ; + + public UtilityVehicle(String make, int milleage, String model, String vinNumber, boolean fourWheelDrive) { + super(make, milleage, model, vinNumber); + this.fourWheelDrive = fourWheelDrive; + } + + @Override + public String getInfo(){ + String info = "This car's vinnumber is: " + this.vinNumber + " make is : " + this.make + + " mode is : " + this.model + " millage equals to + " + this.milleage + + " is it fourwheel drive ? " + this.fourWheelDrive; + return info; + } +} diff --git a/Systems/target/classes/Decimal/DecimalOperations.class b/Systems/target/classes/Decimal/DecimalOperations.class new file mode 100644 index 0000000..ef5b55f Binary files /dev/null and b/Systems/target/classes/Decimal/DecimalOperations.class differ diff --git a/Systems/target/classes/InList/InList.class b/Systems/target/classes/InList/InList.class new file mode 100644 index 0000000..f8156dd Binary files /dev/null and b/Systems/target/classes/InList/InList.class differ diff --git a/Systems/target/classes/InList/IntListArray.class b/Systems/target/classes/InList/IntListArray.class new file mode 100644 index 0000000..fefee4c Binary files /dev/null and b/Systems/target/classes/InList/IntListArray.class differ diff --git a/Systems/target/classes/InList/IntVector.class b/Systems/target/classes/InList/IntVector.class new file mode 100644 index 0000000..89c134b Binary files /dev/null and b/Systems/target/classes/InList/IntVector.class differ diff --git a/Systems/target/classes/VideoStreaming/Movie.class b/Systems/target/classes/VideoStreaming/Movie.class new file mode 100644 index 0000000..dc691cf Binary files /dev/null and b/Systems/target/classes/VideoStreaming/Movie.class differ diff --git a/Systems/target/classes/VideoStreaming/TVSeries.class b/Systems/target/classes/VideoStreaming/TVSeries.class new file mode 100644 index 0000000..396dbcc Binary files /dev/null and b/Systems/target/classes/VideoStreaming/TVSeries.class differ diff --git a/Systems/target/classes/VideoStreaming/Video.class b/Systems/target/classes/VideoStreaming/Video.class new file mode 100644 index 0000000..128e483 Binary files /dev/null and b/Systems/target/classes/VideoStreaming/Video.class differ diff --git a/Systems/target/classes/VideoStreaming/VideoDemo.class b/Systems/target/classes/VideoStreaming/VideoDemo.class new file mode 100644 index 0000000..53f4d58 Binary files /dev/null and b/Systems/target/classes/VideoStreaming/VideoDemo.class differ diff --git a/Systems/target/classes/com/ironhack/Main.class b/Systems/target/classes/com/ironhack/Main.class new file mode 100644 index 0000000..3c322b8 Binary files /dev/null and b/Systems/target/classes/com/ironhack/Main.class differ diff --git a/Systems/target/classes/com/ironhack/inventory/Car.class b/Systems/target/classes/com/ironhack/inventory/Car.class new file mode 100644 index 0000000..2fb3da6 Binary files /dev/null and b/Systems/target/classes/com/ironhack/inventory/Car.class differ diff --git a/Systems/target/classes/com/ironhack/inventory/CarDemo.class b/Systems/target/classes/com/ironhack/inventory/CarDemo.class new file mode 100644 index 0000000..da9ff0e Binary files /dev/null and b/Systems/target/classes/com/ironhack/inventory/CarDemo.class differ diff --git a/Systems/target/classes/com/ironhack/inventory/Sedan.class b/Systems/target/classes/com/ironhack/inventory/Sedan.class new file mode 100644 index 0000000..b7fa6f4 Binary files /dev/null and b/Systems/target/classes/com/ironhack/inventory/Sedan.class differ diff --git a/Systems/target/classes/com/ironhack/inventory/Truck.class b/Systems/target/classes/com/ironhack/inventory/Truck.class new file mode 100644 index 0000000..63a68f4 Binary files /dev/null and b/Systems/target/classes/com/ironhack/inventory/Truck.class differ diff --git a/Systems/target/classes/com/ironhack/inventory/UtilityVehicle.class b/Systems/target/classes/com/ironhack/inventory/UtilityVehicle.class new file mode 100644 index 0000000..4e32a9f Binary files /dev/null and b/Systems/target/classes/com/ironhack/inventory/UtilityVehicle.class differ