-
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 Functionality of comparing value and conversion between differe…
…nt volume units
- Loading branch information
Showing
15 changed files
with
372 additions
and
81 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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.
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.volume; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class Cup extends Volume{ | ||
|
||
public Cup(double volume) { | ||
super(volume*48); | ||
} | ||
|
||
@Override | ||
public double getVolumeValue() { | ||
return super.getVolume(); | ||
} | ||
|
||
public static double convert(Volume volume) { | ||
return volume.getVolumeValue()/48; | ||
} | ||
} |
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.volume; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class Ounce extends Volume{ | ||
|
||
public Ounce(double volume) { | ||
super(volume*6); | ||
} | ||
|
||
@Override | ||
public double getVolumeValue() { | ||
return super.getVolume(); | ||
} | ||
|
||
public static double convert(Volume volume) { | ||
return volume.getVolumeValue()/6; | ||
} | ||
} |
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.volume; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class TableSpoon extends Volume{ | ||
|
||
public TableSpoon(double volume) { | ||
super(volume*3); | ||
} | ||
|
||
@Override | ||
public double getVolumeValue() { | ||
return super.getVolume(); | ||
} | ||
|
||
public static double convert(Volume volume) { | ||
return volume.getVolumeValue()/3; | ||
} | ||
} |
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,21 @@ | ||
package domain.volume; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class TeaSpoon extends Volume{ | ||
|
||
public TeaSpoon(double volume) { | ||
super(volume); | ||
} | ||
|
||
@Override | ||
public double getVolumeValue() { | ||
return super.getVolume(); | ||
} | ||
|
||
public static double convert(Volume volume) { | ||
return volume.getVolumeValue(); | ||
} | ||
|
||
} |
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,32 @@ | ||
package tests; | ||
|
||
import domain.volume.Cup; | ||
import domain.volume.Ounce; | ||
import domain.volume.TableSpoon; | ||
import domain.volume.TeaSpoon; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by aakash on 7/30/2015. | ||
*/ | ||
public class VolumeTest { | ||
|
||
@Test | ||
public void checkComparisonBetweenTbspAndCup() { | ||
|
||
assertTrue(new TableSpoon(16).equals(new Cup(1))); | ||
} | ||
|
||
@Test | ||
public void checkConversionFromOunceToTeaspoon() { | ||
Ounce onz = new Ounce(2); | ||
double tsp = TeaSpoon.convert(onz); | ||
|
||
TeaSpoon teaSpoon = new TeaSpoon(tsp); | ||
|
||
assertEquals(12,tsp,0.00001); | ||
assertTrue(teaSpoon.equals(onz)); | ||
} | ||
} |