Hi,
I am working through abstract classes within java, and have the below abstract classes and sub classes:
So if you take a look at the abstract class Sequence, what I am doing is calling validate initially on every Sequence, to check that it is a valid one.
When I come to DNA Sequence, I am trying to create the method revComp() which reverses the DNA sequence and then finds the complimentary letters. This is all ok, but I am slightly confused about throwing the InvalidSequence in the revComp() method. It obviously throws the InvalidException when, in the main of the DNASequence, I create a new DNA Sequence, as this extends the Abstract class Sequence, and validate() is called. So when throwing the InvalidException in the revComp() it makes no difference what parameters I use. This is of course wrong, so how do I get it to throw the exception correctly?
Any help appreciated!
I am working through abstract classes within java, and have the below abstract classes and sub classes:
So if you take a look at the abstract class Sequence, what I am doing is calling validate initially on every Sequence, to check that it is a valid one.
When I come to DNA Sequence, I am trying to create the method revComp() which reverses the DNA sequence and then finds the complimentary letters. This is all ok, but I am slightly confused about throwing the InvalidSequence in the revComp() method. It obviously throws the InvalidException when, in the main of the DNASequence, I create a new DNA Sequence, as this extends the Abstract class Sequence, and validate() is called. So when throwing the InvalidException in the revComp() it makes no difference what parameters I use. This is of course wrong, so how do I get it to throw the exception correctly?
Any help appreciated!