Skip to content

Commit

Permalink
Fixed conflicts in fluid flow >> flow rate 1
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmjr committed Jun 3, 2023
2 parents 05dc5e8 + 27f29ae commit 5221bfc
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mjr.twaire.code.physic;

public abstract class Calculations {
public abstract double getResult();
public abstract String getSteps();
public abstract String getFormula();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// A = Q / v
final class Area {
import com.mjr.twaire.code.physic.Calculations;

final class Area extends Calculations {
private static Area instance;

private double flowRate;
Expand Down Expand Up @@ -32,10 +33,12 @@ private void calculateWithoutCustomUnit () {
step1 = flowRate / velocity;
}

@Override
public double getResult () {
return step1;
}

@Override
public String getSteps () {
if (hasCustomUnits)
return null;
Expand Down Expand Up @@ -87,6 +90,11 @@ private Area setUnitOfResult (int unitOfResult) {
public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "A = Q / v";
}

protected static Area getInstance (double flowRate, double velocity) {
if (!(instance instanceof Area))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// Q = V / ∆t
final class FlowRate1 {
import com.mjr.twaire.code.physic.Calculations;

final class FlowRate1 extends Calculations {
private static FlowRate1 instance;

private double volume;
Expand Down Expand Up @@ -31,11 +32,13 @@ private void calculateWithCustomUnit () {
private void calculateWithoutCustomUnit () {
step1 = volume / deltaTime;
}


@Override
public Double getResult () {
return step1;
}

@Override
public String getSteps () {
if (hasCustomUnit)
return null;
Expand Down Expand Up @@ -89,6 +92,11 @@ private FlowRate1 setUnitOfResult (int unitOfResult) {
public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "Q = V / ∆t";
}

protected static FlowRate1 getInstance (double volume, double time) {
if (!(instance instanceof FlowRate1))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// Q = A * v
final class FlowRate2 {
import com.mjr.twaire.code.physic.Calculations;

final class FlowRate2 extends Calculations {
private static FlowRate2 instance;

private double area;
Expand Down Expand Up @@ -31,10 +32,12 @@ private void calculateWithoutCustomUnit () {
step1 = area * velocity;
}

@Override
public double getResult () {
return step1;
}

@Override
public String getSteps () {
if (hasCustomUnits)
return null;
Expand Down Expand Up @@ -88,6 +91,11 @@ private FlowRate2 setUnitOfResult (int unitOfResult) {
public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "Q = A * v";
}

protected static FlowRate2 getInstance (double area, double velocity) {
if (!(instance instanceof FlowRate2))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// Q = π * r² * v
final class FlowRate3 {
import com.mjr.twaire.code.physic.Calculations;

final class FlowRate3 extends Calculations {
private static FlowRate3 instance;

private double ray;
Expand Down Expand Up @@ -36,10 +37,12 @@ private void calculateWithoutCustomUnit () {
step3 = step2 * velocity;
}

@Override
public double getResult () {
return step3;
}

@Override
public String getSteps () {
if (hasCustomUnits)
return null;
Expand Down Expand Up @@ -90,6 +93,11 @@ private FlowRate3 setUnitOfResult (int unitOfResult) {
public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "Q = π × r² * v";
}

protected static FlowRate3 getInstance (double ray,
double velocity) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// r = √[Q / (π * v)]
final class Ray {
import com.mjr.twaire.code.physic.Calculations;

final class Ray extends Calculations {
private static Ray instance;

private double flowRate;
Expand Down Expand Up @@ -36,10 +37,12 @@ private void calculateWithoutCustomUnits () {
step3 = Math.sqrt(step2);
}

@Override
public double getResult () {
return step3;
}

@Override
public String getSteps () {
if (hasCustomUnits)
return null;
Expand Down Expand Up @@ -95,6 +98,11 @@ public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "r = √[Q / (π × v)]";
}

protected static Ray getInstance (double flowRate, double velocity) {
if (!(instance instanceof Ray))
instance = new Ray();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// v = Q / A
final class Speed1 {
import com.mjr.twaire.code.physic.Calculations;

final class Speed1 extends Calculations {
private static Speed1 instance;

private double flowRate;
Expand Down Expand Up @@ -32,10 +33,12 @@ private void calculateWithoutCustomUnit () {
step1 = flowRate / area;
}

@Override
public double getResult () {
return step1;
}

@Override
public String getSteps () {
if (hasCustomUnits)
return null;
Expand Down Expand Up @@ -88,6 +91,11 @@ public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "v = Q / A";
}

protected static Speed1 getInstance (double flowRate, double area) {
if (!(instance instanceof Speed1))
instance = new Speed1();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// v = Q / [π * (ray)²]
final class Speed2 {
import com.mjr.twaire.code.physic.Calculations;

final class Speed2 extends Calculations {
private static Speed2 instance;

private double flowRate;
Expand Down Expand Up @@ -35,10 +36,12 @@ private void calculateWithoutCustomUnit () {
step3 = flowRate / step2;
}

@Override
public double getResult () {
return step3;
}

@Override
public String getSteps () {
if (hasCustomUnits)
return null;
Expand Down Expand Up @@ -92,6 +95,11 @@ private Speed2 setUnitOfRest (int unitOfResult) {
public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "v = Q / [π × (r)²]";
}

protected static Speed2 getInstance (double flowRate, double ray) {
if (!(instance instanceof Speed2))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// ∆t = V/ Q
final class Time {
private static Time instance;
import com.mjr.twaire.code.physic.Calculations;

final class Time extends Calculations {
private static Time instance;

private double volume;
private double flowRate;

Expand Down Expand Up @@ -31,10 +32,12 @@ private void calculateWithoutCustomUnit () {
step1 = volume / flowRate;
}

@Override
public double getResult () {
return step1;
}

@Override
public String getSteps () {
return "∆t = " + volume + "m³ ÷ " + flowRate + "m³/s"
+ "\n∆t = " + step1 + "s";
Expand Down Expand Up @@ -84,6 +87,11 @@ private Time setUnitOfResult (int unitOfResult) {
public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "∆t = V/ Q";
}

protected static Time getInstance (double volume, double flowRate) {
if (!(instance instanceof Time))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.mjr.twaire.code.physic.hydrodynamics.fluidflow;

// V = ∆t * Q
final class Volume {
import com.mjr.twaire.code.physic.Calculations;

final class Volume extends Calculations {
private static Volume instance;

private double deltaTime;
Expand Down Expand Up @@ -32,10 +33,12 @@ private void calculateWithoutCustomUnit () {
step1 = deltaTime * flowRate;
}

@Override
public double getResult () {
return step1;
}

@Override
public String getSteps () {
if (hasCustomUnit)
return null;
Expand Down Expand Up @@ -87,6 +90,11 @@ private Volume setUnitOfResult (int unitOfResult) {
public int getUnitOfResult () {
return unitOfResult;
}

@Override
public String getFormula() {
return "V = ∆t × Q";
}

protected static Volume getInstance (double deltaTime, double flowRate) {
if (!(instance instanceof Volume))
Expand Down

0 comments on commit 5221bfc

Please sign in to comment.