Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/lab-java-interfaces-and-abstract-classes.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/BigDecimalOperations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.math.BigDecimal;
import java.math.RoundingMode;

public class BigDecimalOperations {
static void main(String[] args){

BigDecimal a = new BigDecimal("4.2545");
double result = toRoundedDouble(a);

System.out.println(result);

BigDecimal b = new BigDecimal("1.2345");
BigDecimal bMinus = reverseSign(b);

System.out.println(bMinus);

BigDecimal c = new BigDecimal("-45.67");
BigDecimal cMinus = reverseSign(c);

System.out.println(cMinus);
}

private static double toRoundedDouble(BigDecimal a) {
return a.setScale(2, RoundingMode.HALF_UP).doubleValue();
}

private static BigDecimal reverseSign(BigDecimal b ){
return b.setScale(1, RoundingMode.HALF_UP).negate();
}


}
52 changes: 52 additions & 0 deletions src/CarInventorySystem/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package 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 void getInfo(){
System.out.println("The vehicle is a " + make + " " + model + " with VIN number: " + vinNumber + " and at " + mileage + "km.");
}

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;
}
}
15 changes: 15 additions & 0 deletions src/CarInventorySystem/CarApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package CarInventorySystem;

public class CarApplication {
public static void main(String[] args){

Car sedan = new Sedan ("WZZZADG30986DC45H", "Honda", "Civic", 150000);
Car truck = new Truck ("1FTFWET4EFA88453", "Ford", "F-150", 289648, 14000);
Car utility = new UtilityVehicle("J3T1AC12R8M1003HM76", "Toyota", "Rav4", 35699, true);


sedan.getInfo();
truck.getInfo();
utility.getInfo();
}
}
12 changes: 12 additions & 0 deletions src/CarInventorySystem/Sedan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package CarInventorySystem;

public class Sedan extends Car {


public Sedan(String vinNumber, String make, String model, int mileage) {
super(vinNumber, make, model, mileage);
}



}
24 changes: 24 additions & 0 deletions src/CarInventorySystem/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package 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 void getInfo(){
System.out.println("The vehicle is a " + getMake() + " " + getModel() + " with VIN number: " + getVinNumber() + " at " + getMileage() + "km " + "and with a towning capacity of " + towingCapacity);
}


public double getTowingCapacity() {
return towingCapacity;
}

public void setTowingCapacity(double towingCapacity) {
this.towingCapacity = towingCapacity;
}
}
23 changes: 23 additions & 0 deletions src/CarInventorySystem/UtilityVehicle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package 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;
}


public void getInfo() {
System.out.println("The vehicle is a " + getMake() + " " + getModel() + " with VIN number: " + getVinNumber() + " at " + getMileage() + "km " + "and has four wheel drive " + fourWheelDrive);
}

boolean isFourWheelDrive () {
return fourWheelDrive;
}

public void setFourWheelDrive ( boolean fourWheelDrive){
this.fourWheelDrive = fourWheelDrive;
}
}
30 changes: 30 additions & 0 deletions src/Interface/IntArrayList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package Interface;

import java.sql.Array;

public class IntArrayList implements IntList {




public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length){
int[] sourceArray = new int[] {1,2,3,4,5,6,7,8,9,10};
int[] destinationArray = new int[10];
System.arraycopy(sourceArray, 0, destinationArray, 4, sourceArray.length);

System.out.println(Array.toString(destinationArray));
}




@Override
public int add(int number) {
return 0;
}

@Override
public int get(int id) {
return 0;
}
}
13 changes: 13 additions & 0 deletions src/Interface/IntList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package Interface;

public interface IntList {

default int add(int number){
}




default int get(int id){
}
}
9 changes: 9 additions & 0 deletions src/Interface/IntListApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package Interface;

public class IntListApplication {
static void main (String[] args){



}
}
13 changes: 13 additions & 0 deletions src/Interface/IntVector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package Interface;

public class IntVector implements IntList{
@Override
public int add(int number) {
return 0;
}

@Override
public int get(int id) {
return 0;
}
}
24 changes: 24 additions & 0 deletions src/VideoStreamingService/Movie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package 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 void getInfo() {
System.out.println(getTitle() + " has a rating of " + rating + " over 10");
}

public double getRating() {
return rating;
}

public void setRating(double rating) {
this.rating = rating;
}
}
12 changes: 12 additions & 0 deletions src/VideoStreamingService/StreamingApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package VideoStreamingService;

public class StreamingApplication {
public static void main(String[] args) {
Video tvSerie = new TvSeries("Doctor Who", 1, 30);
Video movie = new Movie("Lord Of The Rings", 5, 8.5);

tvSerie.getInfo();
movie.getInfo();

}
}
25 changes: 25 additions & 0 deletions src/VideoStreamingService/TvSeries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package VideoStreamingService;

public class TvSeries extends Video {
private int episode;


public TvSeries(String title, int duration, int episode) {
super(title, duration);
this.episode = episode;
}


@Override
public void getInfo() {
System.out.println(getTitle() + " has " + episode + " episodes");
}

public int getEpisode() {
return episode;
}

public void setEpisode(int episode) {
this.episode = episode;
}
}
31 changes: 31 additions & 0 deletions src/VideoStreamingService/Video.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package VideoStreamingService;

public abstract class Video {
private String title;
private int duration;

public Video(String title, int duration) {
this.title = title;
this.duration = duration;
}

public void getInfo(){
System.out.println(title + " has a duration of " + duration + "h");
}

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;
}
}