UML DIAGRAM FOR AND DISCUSSION FOR InvalidDNAStrandException
UML DIAGRAM FOR AND DISCUSSION FOR InvalidDNAStrandException
InvalidDNAStrandException extends RuntimeException
<<constructor>> InvalidDNAStrandException( )
<<constructor>> InvalidDNAStrandException(molecule : char)
There will be two reasons that cause a DNA strand to be invalid. If the strand is longer than 15 characters (this is due to size limitation of an int) and if there are characters in the strand other than ‘A’, ‘C’, ‘G’, or ‘T’. There are two constructors, one for each problem, giving a different String message for the Exception to reflect the problem.
Methods:
InvalidDNAStrandException( ) – Class constructor. Calls upon super class constructor with the String “Strand too long”
InvalidDNAStrandException(molecule : char) – Class constructor. Calls upon super class constructor with the String, “Invalid molecule: “, followed by the character that is passed.
| InvalidDNAStrandException extends RuntimeException |
| <<constructor>> InvalidDNAStrandException( ) <<constructor>> InvalidDNAStrandException(molecule : char) |
Solution
InvalidDNAStrandException()
{
super(\"Strand too long \");
}
InvalidDNAStrandException(char molecule)
{
super(\"Invalid molecule : \"+molecule);
}
