-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Temperaure Domain with comparison and conversion functionality
- Loading branch information
Showing
31 changed files
with
426 additions
and
272 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+167 Bytes
(120%)
out/production/CheckConversion/domain/length/Centimetres.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+169 Bytes
(120%)
out/production/CheckConversion/domain/length/Metres.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+776 Bytes
out/production/CheckConversion/domain/temperature/Temperature.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+245 Bytes
(140%)
out/production/CheckConversion/domain/volume/TableSpoon.class
Binary file not shown.
Binary file modified
BIN
+249 Bytes
(150%)
out/production/CheckConversion/domain/volume/TeaSpoon.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package domain.temperature; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class Celsius extends Temperature{ | ||
|
||
public Celsius(double temperature) { | ||
super(temperature); | ||
} | ||
|
||
@Override | ||
public double tempBaseValue(double temperature) { | ||
return temperature; | ||
} | ||
|
||
public static Celsius convert(Temperature t) { | ||
return new Celsius(t.getTemperature()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package domain.temperature; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class Fahrenheit extends Temperature{ | ||
|
||
public Fahrenheit(double temperature) { | ||
super(temperature); | ||
} | ||
|
||
@Override | ||
public double tempBaseValue(double temperature) { | ||
return (((temperature-32)*5)/9); | ||
} | ||
|
||
public static Fahrenheit convert(Temperature t) { | ||
return new Fahrenheit(((t.getTemperature()*9)/5)+32); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package domain.temperature; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public abstract class Temperature { | ||
|
||
private double temperature; | ||
|
||
public Temperature(double temperature) { | ||
this.temperature = tempBaseValue(temperature); | ||
} | ||
|
||
public double getTemperature() { | ||
return temperature; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if(!(o instanceof Temperature)) | ||
return false; | ||
|
||
Temperature that = (Temperature) o; | ||
|
||
return Double.compare(that.temperature, temperature) == 0; | ||
} | ||
|
||
public abstract double tempBaseValue(double temperature); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package tests; | ||
|
||
import domain.temperature.Celsius; | ||
import domain.temperature.Fahrenheit; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class TemperatureTest { | ||
|
||
@Test | ||
public void checkComparisonBetweenCelsiusAndFahrenheit(){ | ||
assertTrue(new Celsius(40).equals(new Fahrenheit(104))); | ||
} | ||
|
||
@Test | ||
public void checkConversionFromFahrenheitToCelsius() { | ||
|
||
assertEquals(40,Celsius.convert(new Fahrenheit(104)).getTemperature(),0.00001); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters