diff --git a/lab3/.vscode/settings.json b/lab3/.vscode/settings.json new file mode 100644 index 0000000..e112a70 --- /dev/null +++ b/lab3/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/lab3/README.md b/lab3/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/lab3/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/lab3/bin/BigDecimal_Operations/Main.class b/lab3/bin/BigDecimal_Operations/Main.class new file mode 100644 index 0000000..fd283f1 Binary files /dev/null and b/lab3/bin/BigDecimal_Operations/Main.class differ diff --git a/lab3/bin/Car_Inventory_System/Car.class b/lab3/bin/Car_Inventory_System/Car.class new file mode 100644 index 0000000..829db8a Binary files /dev/null and b/lab3/bin/Car_Inventory_System/Car.class differ diff --git a/lab3/bin/Car_Inventory_System/Sedan.class b/lab3/bin/Car_Inventory_System/Sedan.class new file mode 100644 index 0000000..cf5a723 Binary files /dev/null and b/lab3/bin/Car_Inventory_System/Sedan.class differ diff --git a/lab3/bin/Car_Inventory_System/Truck.class b/lab3/bin/Car_Inventory_System/Truck.class new file mode 100644 index 0000000..252abf8 Binary files /dev/null and b/lab3/bin/Car_Inventory_System/Truck.class differ diff --git a/lab3/bin/Car_Inventory_System/UtilityVehicle.class b/lab3/bin/Car_Inventory_System/UtilityVehicle.class new file mode 100644 index 0000000..c776e16 Binary files /dev/null and b/lab3/bin/Car_Inventory_System/UtilityVehicle.class differ diff --git a/lab3/bin/IntList_Interface/IntArrayList.class b/lab3/bin/IntList_Interface/IntArrayList.class new file mode 100644 index 0000000..0a2396a Binary files /dev/null and b/lab3/bin/IntList_Interface/IntArrayList.class differ diff --git a/lab3/bin/IntList_Interface/IntList.class b/lab3/bin/IntList_Interface/IntList.class new file mode 100644 index 0000000..abcba00 Binary files /dev/null and b/lab3/bin/IntList_Interface/IntList.class differ diff --git a/lab3/bin/IntList_Interface/IntVector.class b/lab3/bin/IntList_Interface/IntVector.class new file mode 100644 index 0000000..c720dea Binary files /dev/null and b/lab3/bin/IntList_Interface/IntVector.class differ diff --git a/lab3/bin/IntList_Interface/README.md b/lab3/bin/IntList_Interface/README.md new file mode 100644 index 0000000..ca6721b --- /dev/null +++ b/lab3/bin/IntList_Interface/README.md @@ -0,0 +1,12 @@ +IntArrayList: + +-- using this class is good when you are adding not many elements to the list. because it creates less free slots that will not take much memory + +IntVector: + +-- this class is good when you need to add more items. it makes less copies and give more slots. + + +note: +-- if use IntArrayList when you need more slots, then copying of the prev. arrays will fill memory. + diff --git a/lab3/bin/Video_Streaming_Service/Movie.class b/lab3/bin/Video_Streaming_Service/Movie.class new file mode 100644 index 0000000..0ca8669 Binary files /dev/null and b/lab3/bin/Video_Streaming_Service/Movie.class differ diff --git a/lab3/bin/Video_Streaming_Service/TvSeries.class b/lab3/bin/Video_Streaming_Service/TvSeries.class new file mode 100644 index 0000000..1aba67b Binary files /dev/null and b/lab3/bin/Video_Streaming_Service/TvSeries.class differ diff --git a/lab3/bin/Video_Streaming_Service/Video.class b/lab3/bin/Video_Streaming_Service/Video.class new file mode 100644 index 0000000..7782c24 Binary files /dev/null and b/lab3/bin/Video_Streaming_Service/Video.class differ diff --git a/lab3/src/BigDecimal_Operations/Main.java b/lab3/src/BigDecimal_Operations/Main.java new file mode 100644 index 0000000..b7a8dcd --- /dev/null +++ b/lab3/src/BigDecimal_Operations/Main.java @@ -0,0 +1,26 @@ +package BigDecimal_Operations; +import java.math.BigDecimal; +import java.math.RoundingMode; + +public class Main { + public static void main(String[] args) throws Exception { + + + + } + +//BigDecimal Operations +//1 + public double task1Method(BigDecimal bigD){ + + return bigD.setScale(2, RoundingMode.HALF_UP).doubleValue(); + + } + + //2 signum() checks if biginteger positive negative or 0 + public BigDecimal task2Method(BigDecimal bigD){ + BigDecimal result = bigD.setScale(1, RoundingMode.HALF_UP); + + return result.negate(); + } +} diff --git a/lab3/src/Car_Inventory_System/Car.java b/lab3/src/Car_Inventory_System/Car.java new file mode 100644 index 0000000..714a26a --- /dev/null +++ b/lab3/src/Car_Inventory_System/Car.java @@ -0,0 +1,50 @@ +package Car_Inventory_System; + +public abstract class Car { + + private String vinNumber; + private String make; + private String model; + private int mileage; + + public String getInfo(){ + + return "vinNumber is " + this.vinNumber + "\nmake is "+ make + +"\nmodel is " + model+ "\nmileage is "+ 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; + } + + +} diff --git a/lab3/src/Car_Inventory_System/Sedan.java b/lab3/src/Car_Inventory_System/Sedan.java new file mode 100644 index 0000000..d899dce --- /dev/null +++ b/lab3/src/Car_Inventory_System/Sedan.java @@ -0,0 +1,5 @@ +package Car_Inventory_System; + +public class Sedan extends Car{ + +} diff --git a/lab3/src/Car_Inventory_System/Truck.java b/lab3/src/Car_Inventory_System/Truck.java new file mode 100644 index 0000000..3d28d66 --- /dev/null +++ b/lab3/src/Car_Inventory_System/Truck.java @@ -0,0 +1,16 @@ +package Car_Inventory_System; + +public class Truck extends Car{ + + private double towingCapacity; + + public double getTowingCapacity() { + return towingCapacity; + } + + public void setTowingCapacity(double towingCapacity) { + this.towingCapacity = towingCapacity; + } + + +} diff --git a/lab3/src/Car_Inventory_System/UtilityVehicle.java b/lab3/src/Car_Inventory_System/UtilityVehicle.java new file mode 100644 index 0000000..22384f5 --- /dev/null +++ b/lab3/src/Car_Inventory_System/UtilityVehicle.java @@ -0,0 +1,15 @@ +package Car_Inventory_System; + +public class UtilityVehicle extends Car{ + + private boolean fourWheelDrive; + + public boolean isFourWheelDrive() { + return fourWheelDrive; + } + + public void setFourWheelDrive(boolean fourWheelDrive) { + this.fourWheelDrive = fourWheelDrive; + } + +} diff --git a/lab3/src/IntList_Interface/IntArrayList.java b/lab3/src/IntList_Interface/IntArrayList.java new file mode 100644 index 0000000..b2588dc --- /dev/null +++ b/lab3/src/IntList_Interface/IntArrayList.java @@ -0,0 +1,43 @@ +package IntList_Interface; +//readme.md is in package itself + +public class IntArrayList implements IntList { + + private int currentIndex = 0; + + private int[] array = new int[10]; + + + @Override + public void add(int eded) { + + // + if (currentIndex == array.length) { + + int[] newarr = new int[(int) (array.length * 1.5)]; + + for (int i = 0; i < array.length; i++) { + newarr[i] = array[i]; + + } + + array = newarr; + } + + array[currentIndex] = eded; + currentIndex++; + + } + + @Override + public int get(int id) { + + if (id >= 0 && id < array.length) { + return array[id]; + } + else { + return -1; + } + } + +} diff --git a/lab3/src/IntList_Interface/IntList.java b/lab3/src/IntList_Interface/IntList.java new file mode 100644 index 0000000..0d3e964 --- /dev/null +++ b/lab3/src/IntList_Interface/IntList.java @@ -0,0 +1,12 @@ +package IntList_Interface; + +public interface IntList { + + + void add(int number); + + int get(int id); + + + +} diff --git a/lab3/src/IntList_Interface/IntVector.java b/lab3/src/IntList_Interface/IntVector.java new file mode 100644 index 0000000..d5676c1 --- /dev/null +++ b/lab3/src/IntList_Interface/IntVector.java @@ -0,0 +1,43 @@ +package IntList_Interface; + +public class IntVector implements IntList { + +private int currentIndex = 0; + + private int[] array = new int[10]; + + + @Override + public void add(int eded) { + + + if (currentIndex == array.length) { + + int[] newarr = new int[array.length * 2]; + + for (int i = 0; i < array.length; i++) { + newarr[i] = array[i]; + + } + + array = newarr; + } + + array[currentIndex] = eded; + currentIndex++; + + } + + @Override + public int get(int id) { + + if (id >= 0 && id < array.length) { + return array[id]; + } + else { + return -1; + // + } + } + +} diff --git a/lab3/src/IntList_Interface/README.md b/lab3/src/IntList_Interface/README.md new file mode 100644 index 0000000..ca6721b --- /dev/null +++ b/lab3/src/IntList_Interface/README.md @@ -0,0 +1,12 @@ +IntArrayList: + +-- using this class is good when you are adding not many elements to the list. because it creates less free slots that will not take much memory + +IntVector: + +-- this class is good when you need to add more items. it makes less copies and give more slots. + + +note: +-- if use IntArrayList when you need more slots, then copying of the prev. arrays will fill memory. + diff --git a/lab3/src/Video_Streaming_Service/Movie.java b/lab3/src/Video_Streaming_Service/Movie.java new file mode 100644 index 0000000..20645d1 --- /dev/null +++ b/lab3/src/Video_Streaming_Service/Movie.java @@ -0,0 +1,15 @@ +package Video_Streaming_Service; + +public class Movie extends Video{ + + private double rating; + + public double getRating() { + return rating; + } + + public void setRating(double rating) { + this.rating = rating; + } + +} diff --git a/lab3/src/Video_Streaming_Service/TvSeries.java b/lab3/src/Video_Streaming_Service/TvSeries.java new file mode 100644 index 0000000..c50daf8 --- /dev/null +++ b/lab3/src/Video_Streaming_Service/TvSeries.java @@ -0,0 +1,15 @@ +package Video_Streaming_Service; + +public class TvSeries extends Video{ + + private int episodes; + + public int getEpisodes() { + return episodes; + } + + public void setEpisodes(int episodes) { + this.episodes = episodes; + } + +} diff --git a/lab3/src/Video_Streaming_Service/Video.java b/lab3/src/Video_Streaming_Service/Video.java new file mode 100644 index 0000000..bf6210b --- /dev/null +++ b/lab3/src/Video_Streaming_Service/Video.java @@ -0,0 +1,13 @@ +package Video_Streaming_Service; + +public abstract class Video { + + private String title; + private int duration; + + public String getInfo(){ + + return "title is " + this.title + "\nduration"+ duration; + + } +}