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..9317e2f --- /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..14f4eba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ 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..0487b94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ 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/Lab/pom.xml b/Lab/pom.xml new file mode 100644 index 0000000..79178b7 --- /dev/null +++ b/Lab/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + org.example + Lab + 1.0-SNAPSHOT + + + 25 + 25 + UTF-8 + + + \ No newline at end of file diff --git a/Lab/src/main/java/org/example/CarInventorySystem/Car.java b/Lab/src/main/java/org/example/CarInventorySystem/Car.java new file mode 100644 index 0000000..6253a4a --- /dev/null +++ b/Lab/src/main/java/org/example/CarInventorySystem/Car.java @@ -0,0 +1,54 @@ +package org.example.CarInventorySystem; + +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 String getInfo() { + return "VIN number: "+getVinNumber() + + "\nmake: " + getMake() + + "\nmodel: " + getModel() + + "\nmileage: " + getMileage(); + } +} diff --git a/Lab/src/main/java/org/example/CarInventorySystem/Sedan.java b/Lab/src/main/java/org/example/CarInventorySystem/Sedan.java new file mode 100644 index 0000000..31258e6 --- /dev/null +++ b/Lab/src/main/java/org/example/CarInventorySystem/Sedan.java @@ -0,0 +1,8 @@ +package org.example.CarInventorySystem; + +public class Sedan extends Car{ + + public Sedan(String vinNumber, String make, String model, int mileage) { + super(vinNumber, make, model, mileage); + } +} diff --git a/Lab/src/main/java/org/example/CarInventorySystem/Truck.java b/Lab/src/main/java/org/example/CarInventorySystem/Truck.java new file mode 100644 index 0000000..0dfeed7 --- /dev/null +++ b/Lab/src/main/java/org/example/CarInventorySystem/Truck.java @@ -0,0 +1,22 @@ +package org.example.CarInventorySystem; + +public class Truck extends Car{ + private 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 super.getInfo()+"\n towing capacity : "+towingCapacity; + } + + public double getTowingCapacity() { + return towingCapacity; + } + + public void setTowingCapacity(double towingCapacity) { + this.towingCapacity = towingCapacity; + } +} diff --git a/Lab/src/main/java/org/example/CarInventorySystem/UtilityVehicle.java b/Lab/src/main/java/org/example/CarInventorySystem/UtilityVehicle.java new file mode 100644 index 0000000..dbcd55e --- /dev/null +++ b/Lab/src/main/java/org/example/CarInventorySystem/UtilityVehicle.java @@ -0,0 +1,23 @@ +package org.example.CarInventorySystem; + +public class UtilityVehicle extends Car{ + private 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 super.getInfo()+"\n four wheel drive : "+(fourWheelDrive?"Yes":"No"); + } + + public boolean isFourWheelDrive() { + return fourWheelDrive; + } + + public void setFourWheelDrive(boolean fourWheelDrive) { + this.fourWheelDrive = fourWheelDrive; + } +} diff --git a/Lab/src/main/java/org/example/IntListInterface/IntArrayList.java b/Lab/src/main/java/org/example/IntListInterface/IntArrayList.java new file mode 100644 index 0000000..5a93520 --- /dev/null +++ b/Lab/src/main/java/org/example/IntListInterface/IntArrayList.java @@ -0,0 +1,31 @@ +package org.example.IntListInterface; + +import org.example.VideoStreamingService.Movie; + +import java.util.Arrays; + +public class IntArrayList implements IntList{ + private int size=0; + private int maxSize=10; + private int[] numbers=new int[maxSize]; + @Override + public void add(int number) { + if(size=0&&idRun code, press or +// click the icon in the gutter. +public class Main { + static void main() { + System.out.println(roundToHundredth(BigDecimal.valueOf(4.25255))); + System.out.println(roundToTenth(BigDecimal.valueOf(4.25255))); + } + public static double roundToHundredth(BigDecimal number){ + return number.setScale(2, RoundingMode.HALF_UP).doubleValue(); + } + public static BigDecimal roundToTenth(BigDecimal number){ + return number.setScale(1, RoundingMode.HALF_UP).negate(); + } +} diff --git a/Lab/src/main/java/org/example/VideoStreamingService/Movie.java b/Lab/src/main/java/org/example/VideoStreamingService/Movie.java new file mode 100644 index 0000000..742f035 --- /dev/null +++ b/Lab/src/main/java/org/example/VideoStreamingService/Movie.java @@ -0,0 +1,22 @@ +package org.example.VideoStreamingService; + +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 super.getInfo()+"\nRating: "+rating; + } + + public double getRating() { + return rating; + } + + public void setRating(double rating) { + this.rating = rating; + } +} diff --git a/Lab/src/main/java/org/example/VideoStreamingService/TvSeries.java b/Lab/src/main/java/org/example/VideoStreamingService/TvSeries.java new file mode 100644 index 0000000..4177113 --- /dev/null +++ b/Lab/src/main/java/org/example/VideoStreamingService/TvSeries.java @@ -0,0 +1,20 @@ +package org.example.VideoStreamingService; + +public class TvSeries extends Video{ + private int episodes; + public TvSeries(String title, int duration, int episodes) { + super(title, duration); + this.episodes = episodes; + } + @Override + public String getInfo() { + return super.getInfo()+"\nEpisodes: "+episodes; + } + public int getEpisodes() { + return episodes; + } + + public void setEpisodes(int episodes) { + this.episodes = episodes; + } +} diff --git a/Lab/src/main/java/org/example/VideoStreamingService/Video.java b/Lab/src/main/java/org/example/VideoStreamingService/Video.java new file mode 100644 index 0000000..4417be3 --- /dev/null +++ b/Lab/src/main/java/org/example/VideoStreamingService/Video.java @@ -0,0 +1,31 @@ +package org.example.VideoStreamingService; + +public abstract class Video { + private String title; + private int duration; + + public Video(String title, int duration) { + this.title = title; + this.duration = duration; + } + + 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 String getInfo() { + return "Title: "+title + +"\nDuration: "+duration; + } +} diff --git a/Lab/target/classes/org/example/CarInventorySystem/Car.class b/Lab/target/classes/org/example/CarInventorySystem/Car.class new file mode 100644 index 0000000..aa7d635 Binary files /dev/null and b/Lab/target/classes/org/example/CarInventorySystem/Car.class differ diff --git a/Lab/target/classes/org/example/CarInventorySystem/Sedan.class b/Lab/target/classes/org/example/CarInventorySystem/Sedan.class new file mode 100644 index 0000000..9068a73 Binary files /dev/null and b/Lab/target/classes/org/example/CarInventorySystem/Sedan.class differ diff --git a/Lab/target/classes/org/example/CarInventorySystem/Truck.class b/Lab/target/classes/org/example/CarInventorySystem/Truck.class new file mode 100644 index 0000000..43c20ac Binary files /dev/null and b/Lab/target/classes/org/example/CarInventorySystem/Truck.class differ diff --git a/Lab/target/classes/org/example/CarInventorySystem/UtilityVehicle.class b/Lab/target/classes/org/example/CarInventorySystem/UtilityVehicle.class new file mode 100644 index 0000000..a48811e Binary files /dev/null and b/Lab/target/classes/org/example/CarInventorySystem/UtilityVehicle.class differ diff --git a/Lab/target/classes/org/example/IntListInterface/IntArrayList.class b/Lab/target/classes/org/example/IntListInterface/IntArrayList.class new file mode 100644 index 0000000..9fe5368 Binary files /dev/null and b/Lab/target/classes/org/example/IntListInterface/IntArrayList.class differ diff --git a/Lab/target/classes/org/example/IntListInterface/IntList.class b/Lab/target/classes/org/example/IntListInterface/IntList.class new file mode 100644 index 0000000..3479b41 Binary files /dev/null and b/Lab/target/classes/org/example/IntListInterface/IntList.class differ diff --git a/Lab/target/classes/org/example/IntListInterface/IntVector.class b/Lab/target/classes/org/example/IntListInterface/IntVector.class new file mode 100644 index 0000000..eee3789 Binary files /dev/null and b/Lab/target/classes/org/example/IntListInterface/IntVector.class differ diff --git a/Lab/target/classes/org/example/Main.class b/Lab/target/classes/org/example/Main.class new file mode 100644 index 0000000..30f2d86 Binary files /dev/null and b/Lab/target/classes/org/example/Main.class differ diff --git a/Lab/target/classes/org/example/VideoStreamingService/Movie.class b/Lab/target/classes/org/example/VideoStreamingService/Movie.class new file mode 100644 index 0000000..93051e3 Binary files /dev/null and b/Lab/target/classes/org/example/VideoStreamingService/Movie.class differ diff --git a/Lab/target/classes/org/example/VideoStreamingService/TvSeries.class b/Lab/target/classes/org/example/VideoStreamingService/TvSeries.class new file mode 100644 index 0000000..377bdbe Binary files /dev/null and b/Lab/target/classes/org/example/VideoStreamingService/TvSeries.class differ diff --git a/Lab/target/classes/org/example/VideoStreamingService/Video.class b/Lab/target/classes/org/example/VideoStreamingService/Video.class new file mode 100644 index 0000000..01364a8 Binary files /dev/null and b/Lab/target/classes/org/example/VideoStreamingService/Video.class differ diff --git a/README.md b/README.md index ce069b6..9b13102 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Once you finish the assignment, submit a URL link to your repository or your pul 3. `IntArrayList` should store numbers in an array with a length of 10 by default. When the `add` method is called, you must first determine if the array is full. If it is, create a new array that is 50% larger, move all elements over to the new array and add the new element. (For example, an array of length 10 would be increased to 15.) 4. `IntVector` should store numbers in an array with a length of 20 by default. When the `add` method is called, you must first determine if the array is full. If it is, create a new array that is double the size of the current array, move all elements over to the new array and add the new element. (For example, an array of length 10 would be increased to 20.) 5. In your `README.md`, include an example of when `IntArrayList` would be more efficient and when `IntVector` would be more efficient. +Example: When working with big data, it is more efficient to use intVector; otherwise, intArrayList.