Skip to content

Commit

Permalink
created the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammed-Azab committed Dec 1, 2024
1 parent e4a3d45 commit 1d138ee
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.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.

73 changes: 64 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,72 @@
<?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>org.example</groupId>
<artifactId>untitled</artifactId>
<groupId>com.example</groupId>
<artifactId>steam-tables</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>

</project>

<dependencies>
<!-- Apache POI for Excel manipulation -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>

<!-- XML Parser (optional, needed for reading XLSX) -->
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>5.0.3</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>

<!-- JUnit for Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.3</version> <!-- Use this stable version -->
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.example;

public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
Expand Down
168 changes: 168 additions & 0 deletions src/main/java/steamTables/Controller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package steamTables;


public class Controller {

private static DataBase db ;


public Controller() {
db = new DataBase();
}

// Find Steam Using Temperature and Pressure
public Steam findTheSteamUsingTP(double T, double P) {
Steam steam = new Steam();
steam.setT(T);
steam.setP(P);
return steam;
}

// Find Steam Using Temperature and Volume
public Steam findTheSteamUsingTV(double T, double v) {
Steam steam = new Steam();
steam.setT(T);
steam.setV(v);

return steam;
}

// Find Steam Using Temperature and Internal Energy
public Steam findTheSteamUsingTU(double T, double u) {
Steam steam = new Steam();
steam.setT(T);
steam.setU(u);
return steam;
}

// Find Steam Using Temperature and Enthalpy
public Steam findTheSteamUsingTH(double T, double h) {
Steam steam = new Steam();
steam.setT(T);
steam.setH(h);

return steam;
}

// Find Steam Using Temperature and Quality
public Steam findTheSteamUsingTX(double T, double X) {
Steam steam = new Steam();
steam.setT(T);
steam.setX(X);
setPhase(steam, X);

return steam;
}

// Find Steam Using Temperature and Entropy
public Steam findTheSteamUsingTS(double T, double s) {
Steam steam = new Steam();
steam.setT(T);
return steam;
}

// Find Steam Using Pressure and Volume
public Steam findTheSteamUsingPV(double P, double v) {
Steam steam = new Steam();
steam.setP(P);

return steam;
}

// Find Steam Using Pressure and Internal Energy
public Steam findTheSteamUsingPU(double P, double u) {
Steam steam = new Steam();
steam.setP(P);
steam.setU(u);
return steam;
}

// Find Steam Using Pressure and Enthalpy
public Steam findTheSteamUsingPH(double P, double h) {
Steam steam = new Steam();
steam.setP(P);
steam.setH(h);


return steam;
}

// Find Steam Using Pressure and Quality
public Steam findTheSteamUsingPX(double P, double X) {
Steam steam = new Steam();
steam.setP(P);
steam.setX(X);
setPhase(steam, X);

return steam;
}

// Find Steam Using Pressure and Entropy
public Steam findTheSteamUsingPS(double P, double s) {
Steam steam = new Steam();
steam.setP(P);
steam.setS(s);

return steam;
}

public Steam findTheSteamUsingUV(double u, double v) {
Steam steam = new Steam();
steam.setV(v);
steam.setU(u);
return steam;
}

public Steam findTheSteamUsingUX(double u, double X) {
Steam steam = new Steam();
steam.setX(X);
steam.setU(u);
setPhase(steam, X);
return steam;
}

private void setPhase(Steam steam, double X) {
if (X ==1) {
steam.setSteamPhase(SteamPhase.SaturatedLiquid);
}
else if (X ==0) {
steam.setSteamPhase(SteamPhase.SaturatedVapour);
}
else if ( X > 1 || X < 0 ) {
throw new IllegalArgumentException("X must be between 0 and 1");
}
else {
steam.setSteamPhase(SteamPhase.saturatedMixture);
}
}

public Steam findTheSteamUsingTState(double T, SteamPhase phase) {
Steam steam = new Steam();
steam.setT(T);
steam.setSteamPhase(phase);
steam.setX(phase.getX());
return steam;

}

public Steam findTheSteamUsingPState(double P, SteamPhase phase) {
Steam steam = new Steam();
steam.setP(P);
steam.setSteamPhase(phase);
steam.setX(phase.getX());
return steam;

}

public Steam findTheSteamUsingHState(double H, SteamPhase phase) {
Steam steam = new Steam();
steam.setH(H);
steam.setSteamPhase(phase);
steam.setX(phase.getX());
return steam;

}



}
File renamed without changes.
File renamed without changes.

0 comments on commit 1d138ee

Please sign in to comment.