Skip to content

Commit

Permalink
94: Translate Hurricane Demo
Browse files Browse the repository at this point in the history
Task-Url: #94
  • Loading branch information
keilw committed Jul 25, 2020
1 parent e831a9a commit 9206f38
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,19 @@ public static void main(String[] args) {
scale = STD;
}

if (scale !=null) {
if (scale != null) {
// If the wind scale has a maximum we take that assuming the worst case, otherwise the minimum
final Quantity<Speed> metricSpeed = scale.hasMaximum() ?
scale.getMaximum().to(KILOMETRE_PER_HOUR) :
scale.getMinimum().to(KILOMETRE_PER_HOUR);

System.out.print(metricSpeed);
System.out.println(" (" + Messages.getString("SaffirSimpsonHurricaneWindScale." + scale.getCategory(), true)
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Quantity<Length> l = Quantities.getQuantity(500, KILO(METRE));
System.out.println(String.format(Messages.getString("ThePerfectStorm.1"), l)); //$NON-NLS-1$
final Quantity<Length> distance = Quantities.getQuantity(500, KILO(METRE));
System.out.println(String.format(Messages.getString("ThePerfectStorm.1"), distance)); //$NON-NLS-1$

Quantity<Time> timeToEvacuate = l.divide(metricSpeed).asType(Time.class);
final Quantity<Time> timeToEvacuate = distance.divide(metricSpeed).asType(Time.class);
//Quantity<?> timeToEvacuate = l.divide(metricSpeed); //if you don't want to cast ;-)
SimpleUnitFormat.getInstance().label(timeToEvacuate.getUnit(), Messages.getString("ThePerfectStorm.2")); //$NON-NLS-1$
System.out.println(String.format(Messages.getString("ThePerfectStorm.3"), timeToEvacuate)); //$NON-NLS-1$
Expand Down

0 comments on commit 9206f38

Please sign in to comment.