<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package cs2110.netid.assignment1;

import java.io.IOException;
import java.util.Collection;

import cs2110.assignment1.Gene;
import cs2110.assignment1.Species;
import cs2110.assignment1.SpeciesReader;

/**
 *   Simple main class to test species reading
 */
public class Main {

	/**
	 * Main method to test reading species files and parsing of DNA into genes
	 * 
	 * This assumes your SpeciesReader subclass is named MySpeciesReader. If not,
	 * you'll have to edit this file.
	 * 
	 * @param args .dat files to read
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
	
		SpeciesReader reader = new MySpeciesReader();
		
		for(String filename : args) {
			System.out.printf("Reading %s...\n", filename);
			
			Species species = reader.readSpecies(filename);
			
			printSpecies(species);
		}
	}

	/**
	 * Print diagnostic information about a species
	 * 
	 * @param species
	 */
	private static void printSpecies(Species species) {
		System.out.printf("    Name: %s\n", species.getName());
		System.out.printf("    LatinName: %s\n", species.getLatinName());
		System.out.printf("    ImageFilename: %s\n", species.getImageFilename());
		System.out.printf("    DNA length: %d characters\n", species.getDNA().length());
		printGenome(species.getGenome());
		System.out.println();
	}
	
	/**
	 * Print the genes in a genome
	 * 
	 * @param genome
	 */
	private static void printGenome(Collection&lt;Gene&gt; genome) {
		System.out.printf("    %d genes\n", genome.size());
		System.out.println("   --------------------------");
		int i = 0;
		
		for(Gene gene : genome) {
			System.out.printf("       %d: %s\n", i++, gene.getDNA());
		}
	}
}

</pre></body></html>