/
UKRegNosHandler
UKRegNosHandler
package com.celestial.tdd.ukcar.regnos;
import java.text.DecimalFormat;
/**
*
* @author Selvyn
*/
public class UKRegNosHandler
{
public String nextRegCode(String initValue) throws BadYearException
{
String result = "";
int regNo = Integer.parseInt(initValue);
if (regNo > 50)
{
regNo -= 49;
result = formatResult( regNo );
} else
{
if (regNo == 50)
{
throw new BadYearException("2050 is an invalid year");
} else
{
regNo += 50;
result = formatResult(regNo);
}
}
return result;
}
private String formatResult( int value )
{
java.text.DecimalFormat nft = new DecimalFormat("#00.##");
nft.setDecimalSeparatorAlwaysShown(false);
return nft.format(value);
}
}
, multiple selections available,
Related content
UKRegNosHandlerTest
UKRegNosHandlerTest
More like this
QL-2) TDD kata (optional, but great TDD practice).
QL-2) TDD kata (optional, but great TDD practice).
More like this
fitnesse script
fitnesse script
More like this
05 - Introduction to Java - Exercise 3
05 - Introduction to Java - Exercise 3
More like this
02 - OOP Intro - Exercise 2
02 - OOP Intro - Exercise 2
More like this
Prime Number Answer
Prime Number Answer
More like this