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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
349 changes: 349 additions & 0 deletions Enterprise-Java-Development-1.08_Ivan_Hernandez/README.md

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions Enterprise-Java-Development-1.08_Ivan_Hernandez/src/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
abstract class Car {
public String vinNumber;

public String make;
public String model;
public int mileage;

public String getInfo() {
return vinNumber + ", " + make + ", " + model + ", " + mileage + "\n";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class IntArrayList implements IntList {
private int[] array;
private int size;

public IntArrayList() {
this.array = new int[10];
this.size = 0;
}

public void add(int number) {
if (size == array.length) {
int[] newArray = new int[array.length + array.length / 2];
System.arraycopy(array, 0, newArray, 0, size);
array = newArray;
}
array[size++] = number;
}

public int get(int id) {
if (id < 0 || id >= size) {
throw new IndexOutOfBoundsException("Index out of bounds: " + id);
}
return array[id];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public interface IntList {
void add(int number);
int get(int id);
}

21 changes: 21 additions & 0 deletions Enterprise-Java-Development-1.08_Ivan_Hernandez/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
public static void main(String[] args) {
BigDecimal number = new BigDecimal(1.57268278278672647627647267);
System.out.println(roundToNearestHundredth(number));
System.out.println(invertAndRound(number));
}

public static double roundToNearestHundredth(BigDecimal number) {
return (number.setScale(2, RoundingMode.HALF_UP)).doubleValue();
}

public static BigDecimal invertAndRound(BigDecimal number) {
return (number.setScale(1, RoundingMode.HALF_UP)).negate();
}
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Movie extends Video{
private double rating;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public class Sedan extends Car {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class Truck extends Car{
private double towingCapacity;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class TvSeries extends Video{
private int episodes;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class UtilityVehicle extends Car{
private boolean fourWheelDrive;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
abstract class Video {
public String title;
public int duration;
public String getInfo(){
return title+", "+duration;
};

}
25 changes: 25 additions & 0 deletions Enterprise-Java-Development-1.08_Ivan_Hernandez/src/intVector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class intVector implements IntList {
private int[] array;
private int size;

public intVector() {
this.array = new int[20];
this.size = 0;
}

public void add(int number) {
if (size == array.length) {
int[] newArray = new int[array.length * 2];
System.arraycopy(array, 0, newArray, 0, size);
array = newArray;
}
array[size++] = number;
}

public int get(int id) {
if (id < 0 || id >= size) {
throw new IndexOutOfBoundsException("Index out of bounds: " + id);
}
return array[id];
}
}