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.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

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

9 changes: 9 additions & 0 deletions .idea/encodings.xml

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

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

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.

20 changes: 20 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.

17 changes: 17 additions & 0 deletions Systems/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.ironhack</groupId>
<artifactId>Systems</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
22 changes: 22 additions & 0 deletions Systems/src/main/java/Decimal/DecimalOperations.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
7 changes: 7 additions & 0 deletions Systems/src/main/java/InList/InList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package InList;

public interface InList {

void add(int number);
int get(int id);
}
53 changes: 53 additions & 0 deletions Systems/src/main/java/InList/IntListArray.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

49 changes: 49 additions & 0 deletions Systems/src/main/java/InList/IntVector.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
24 changes: 24 additions & 0 deletions Systems/src/main/java/VideoStreaming/Movie.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
24 changes: 24 additions & 0 deletions Systems/src/main/java/VideoStreaming/TVSeries.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
35 changes: 35 additions & 0 deletions Systems/src/main/java/VideoStreaming/Video.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
11 changes: 11 additions & 0 deletions Systems/src/main/java/VideoStreaming/VideoDemo.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
17 changes: 17 additions & 0 deletions Systems/src/main/java/com/ironhack/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.ironhack;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
static void main() {
//TIP Press <shortcut actionId="ShowIntentionActions"/> 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 <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
IO.println("i = " + i);
}
}
}
Loading