web/DuneRealmsGUI/src/main/java/com/dunerealms/gui/ExchangePrice.java

6 lines
455 B
Java

package com.dunerealms.gui;
import java.math.BigDecimal;
final class ExchangePrice {
static long parse(String text){if(text==null||!text.matches("[0-9]{1,7}(?:\\.[0-9]{1,2})?"))throw new IllegalArgumentException("Enter a price such as 1.00 DM.");long n=new BigDecimal(text).movePointRight(2).longValueExact();if(n<1||n>100000000)throw new IllegalArgumentException("Choose a price between 0.01 and 1000000.00 DM.");return n;}
private ExchangePrice(){}
}