(15 points)
The germ's genome is a String object. Germs reproduce only by mating. The child gets the genome of one of its parents as such. The likelihood is the same for each parent's genome. The choice of genome can be made with the expression if (Math.random()<0.5) ...
Example: (this is exactly how to output: the object's order number belongs to the output, the third output can, of course, be eiter "(3): Mary" tai "(3): Mark")
Germ daddy = new Germ("Mark"); Germ mommy = new Germ("Mary"); Germ child = daddy.mate(mommy); System.out.println(daddy); // output: (1): Mark System.out.println(mommy); // output: (2): Mary System.out.println(child); // output: (3): Mary DoubleGerm geezer = new DoubleGerm("Charlie"); // number 4 DoubleGerm biddy = new DoubleGerm("Carrie"); // numero 5 DoubleGerm cub = biddy.mate(geezer); System.out.println(cub); // output: (6): CarrieCharlie (14 points)
a) public abstract class Innards { public void doThisandThat(); } b) public interface Innards { public void doThisandThat(); } (10 points)
With the help of an Integerfilter object, the integers in a text file can be read so that all other signs are ignored, they are just passed by. (Any unbroken character string is seen as an integer, all the signs ignored.)
The numbers in the file are read with the accessor public int readNextNumber(), that returns the following integer in the file. When there are no more integers in the file, the method returns -1.
Exceptions are handled in the class Integerfilter so that the user of its instances is not bothered with them; if the creation of the object Inputfile fails, the method readNextNumber() returns -1 from the start. If the execution of the method readRow() leads to an exception, the method readNextNumber() returns -1. For a user of the object Integerfilter, a broken or missing file looks like file with no integers. A file that is broken in the process just looks like it ends.
NB! The Integerfilter only has to handle the exceptions caused by Inputfile on the most general level, as an Exception.
NB! If you know how, use the method Integer.parseInt(String m).
asdf10 asd4 ö2xcv?+das-9asd,for example, the program outputs the average 6.25.
NB! You can use the class Inputfile, for heaven's sake, do not start programming it now!
(14 points)