/*
Trivial applet that displays a string - 4/96 PNL
*/
import java.awt.*;
import java.applet.Applet;
class Cross extends Start {
Start cross;
Fly One, Two;
static int x = 1, y = 25;
static int verticalDist = 150;
int width = 110;
int F_Red_Vest_Ebony, F_Red_Wing_Ebony, M_Red_Vest_Ebony, M_Red_Wing_Ebony,
F_Red_Vest_Albino, F_Sepia_Vest_Albino, M_Red_Vest_Albino, M_Sepia_Vest_Albino,
F_White_Wing_Albino, M_White_Wing_Albino, F_Red_Wing_Albino, F_Sepia_Wing_Albino,
M_Red_Wing_Albino, M_Sepia_Wing_Albino;
int population = 5;
int totalCount;
String theF1Cross[][] = new String[population][population];
String theF2Cross[][] = new String[population][population];
public Cross(Fly one, Fly two) {
One = one;
Two = two;
mate(One, Two, theF1Cross);
count(theF1Cross);
}
public void paint(Graphics g) {
if( F_Red_Wing_Albino > 0) {
g.drawImage(F_Red_Wing_AlbinoGif, x, y, this);
g.drawString("count " + F_Red_Wing_Albino, x, verticalDist);
adjust();
}
if( M_Red_Wing_Albino > 0) {
g.drawImage(M_Red_Wing_AlbinoGif, x, y, this);
g.drawString("count " + M_Red_Wing_Albino, x, verticalDist);
adjust();
}
if( F_Sepia_Wing_Albino > 0) {
g.drawImage(F_Sepia_Wing_AlbinoGif, x, y, this);
g.drawString("count " + F_Sepia_Wing_Albino, x, verticalDist);
adjust();
}
if( M_Sepia_Wing_Albino > 0) {
g.drawImage(M_Sepia_Wing_AlbinoGif, x, y, this);
g.drawString("count " + M_Sepia_Wing_Albino, x, verticalDist);
adjust();
}
if( F_Red_Vest_Albino > 0) {
g.drawImage(F_Red_Vest_AlbinoGif, x, y, this);
g.drawString("count " + F_Red_Vest_Albino, x, verticalDist);
adjust();
}
if( M_Red_Vest_Albino > 0) {
g.drawImage(M_Red_Vest_AlbinoGif, x, y, this);
g.drawString("count " + M_Red_Vest_Albino, x, verticalDist);
adjust();
}
if( F_Sepia_Vest_Albino > 0) {
g.drawImage(F_Sepia_Vest_AlbinoGif, x, y, this);
g.drawString("count " + F_Sepia_Vest_Albino, x, verticalDist);
adjust();
}
if( M_Sepia_Vest_Albino > 0) {
g.drawImage(M_Sepia_Vest_AlbinoGif, x, y, this);
g.drawString("count " + M_Sepia_Vest_Albino, x, verticalDist);
adjust();
}
if( F_Red_Wing_Ebony > 0) {
g.drawImage(F_Red_Wing_EbonyGif, x, y, this);
g.drawString("count " + F_Red_Wing_Ebony, x, verticalDist);
adjust();
}
if( M_Red_Wing_Ebony > 0) {
g.drawImage(M_Red_Wing_EbonyGif, x, y, this);
g.drawString("count " + M_Red_Wing_Ebony, x, verticalDist);
adjust();
}
if( F_Red_Vest_Ebony > 0) {
g.drawImage(F_Red_Vest_EbonyGif, x, y, this);
g.drawString("count " + F_Red_Vest_Ebony, x, verticalDist);
adjust();
}
if( M_Red_Vest_Ebony > 0) {
g.drawImage(M_Red_Vest_EbonyGif, x, y, this);
g.drawString("count " + M_Red_Vest_Ebony, x, verticalDist);
adjust();
}
if( F_White_Wing_Albino > 0) {
g.drawImage(F_White_Wing_AlbinoGif, x, y, this);
g.drawString("count " + F_White_Wing_Albino, x, verticalDist);
adjust();
}
if( M_White_Wing_Albino > 0) {
g.drawImage(M_White_Wing_AlbinoGif, x, y, this);
g.drawString("count " + M_White_Wing_Albino, x, verticalDist);
adjust();
}
validate();
repaint();
repaint();
}
public void adjust() {
if (x > 300) {
y+= 175;
x = 1;
verticalDist += 175;
}
else
x+= width;
}
public void mate(Fly one, Fly two, String theCross[][]) {
char sexTypeOneP1;
char T1A, T1B, T2A, T2B, T3A, T3B;
int sexTypeTwoP1,
eyeTypeOneP1, eyeTypeTwoP1,
wingTypeOneP1, wingTypeTwoP1,
bodyTypeOneP1, bodyTypeTwoP1;
char sex2 = 'o';
for (int row = 0; row < population; row++) {
for(int column = 0; column < population; column++) {
sexTypeOneP1 = 'X'; //must be X
sexTypeTwoP1 = (int)(Math.random() * 2);
//choose eye random
eyeTypeOneP1 = (int)(Math.random() * 2);
eyeTypeTwoP1 = (int)(Math.random() * 2);
wingTypeOneP1 = (int)(Math.random() * 2);
wingTypeTwoP1 = (int)(Math.random() * 2);
bodyTypeOneP1 = (int)(Math.random() * 2);
bodyTypeTwoP1 = (int)(Math.random() * 2);
if (sexTypeTwoP1 == 0)
sex2 = 'X';
else if(sexTypeTwoP1 == 1)
sex2 = 'Y';
//make sure that the Dominant allheles is first
if (one.allheles[1][eyeTypeOneP1] > two.allheles[1][eyeTypeTwoP1]) {
T1B = one.allheles[1][eyeTypeOneP1];
T1A = two.allheles[1][eyeTypeTwoP1];
}
else {
T1A = one.allheles[1][eyeTypeOneP1];
T1B = two.allheles[1][eyeTypeTwoP1];
}
if (one.allheles[2][wingTypeOneP1] > two.allheles[2][wingTypeTwoP1]) {
T2B = one.allheles[2][wingTypeOneP1];
T2A = two.allheles[2][wingTypeTwoP1];
}
else {
T2A = one.allheles[2][wingTypeOneP1];
T2B = two.allheles[2][wingTypeTwoP1];
}
if (one.allheles[3][bodyTypeOneP1] > two.allheles[3][bodyTypeTwoP1]) {
T3B = one.allheles[3][bodyTypeOneP1];
T3A = two.allheles[3][bodyTypeTwoP1];
}
else {
T3A = one.allheles[3][bodyTypeOneP1];
T3B = two.allheles[3][bodyTypeTwoP1];
}
theCross[row][column] = (""+ 'X' + sex2 + T1A + T1B
+ T2A + T2B
+ T3A + T3B);
}
}
}
public void count(String theCrossToCount[][]) {
for (int row = 0; row < population; row++) {
for(int column = 0; column < population; column++) {
//cross.showStatus("test");
if (theCrossToCount[row][column].equals("XXRRwwbb") | theCrossToCount[row][column].equals("XXRrwwbb"))
F_Red_Vest_Ebony++;
else if (theCrossToCount[row][column].equals("XXRRWWbb")| theCrossToCount[row][column].equals("XXRrWWbb")|
theCrossToCount[row][column].equals("XXRRWwbb")| theCrossToCount[row][column].equals("XXRrWwbb"))
F_Red_Wing_Ebony++;
else if (theCrossToCount[row][column].equals("XYRRwwbb")| theCrossToCount[row][column].equals("XYRrwwbb"))
M_Red_Vest_Ebony++;
else if (theCrossToCount[row][column].equals("XYRRWWbb")| theCrossToCount[row][column].equals("XYRrWWbb")|
theCrossToCount[row][column].equals("XYRRWwbb")| theCrossToCount[row][column].equals("XYRrWwbb"))
M_Red_Wing_Ebony++;
else if (theCrossToCount[row][column].equals("XXRRwwBB")| theCrossToCount[row][column].equals("XXRrwwBB")|
theCrossToCount[row][column].equals("XXRRwwBb")| theCrossToCount[row][column].equals("XXRrwwBb"))
F_Red_Vest_Albino++;
else if (theCrossToCount[row][column].equals("XXrrwwbb")| theCrossToCount[row][column].equals("XXrrwwBb"))
F_Sepia_Vest_Albino++;
else if (theCrossToCount[row][column].equals("XYRRwwBB")| theCrossToCount[row][column].equals("XYRrwwBB")|
theCrossToCount[row][column].equals("XYRRwwBb")| theCrossToCount[row][column].equals("XYRrwwBb"))
M_Red_Vest_Albino++;
else if (theCrossToCount[row][column].equals("XYrrwwBB")| theCrossToCount[row][column].equals("XYrrwwBb"))
M_Sepia_Vest_Albino++;
else if (theCrossToCount[row][column].equals("XXssWWBB")| theCrossToCount[row][column].equals("XXssWwBb"))
F_White_Wing_Albino++;
else if (theCrossToCount[row][column].equals("XYssWWBB")| theCrossToCount[row][column].equals("XYssWwBb"))
M_White_Wing_Albino++;
else if (theCrossToCount[row][column].equals("XXRRWWBB") | theCrossToCount[row][column].equals("XXRrWWBB") |
theCrossToCount[row][column].equals("XXRRWwBB")| theCrossToCount[row][column].equals("XXRrWwBB")|
theCrossToCount[row][column].equals("XXRRWWBb")| theCrossToCount[row][column].equals("XXRrWWBb")|
theCrossToCount[row][column].equals("XXRRWwBb")| theCrossToCount[row][column].equals("XXRrWwBb")|
theCrossToCount[row][column].equals("XXRsWWBB")| theCrossToCount[row][column].equals("XXRsWwBB")|
theCrossToCount[row][column].equals("XXRsWWBb")| theCrossToCount[row][column].equals("XXRsWwBb"))
F_Red_Wing_Albino++;
else if (theCrossToCount[row][column].equals("XXrrWWBB")| theCrossToCount[row][column].equals("XXrrWwBB")|
theCrossToCount[row][column].equals("XXrrWWBb")| theCrossToCount[row][column].equals("XXrrWwBb"))
F_Sepia_Wing_Albino++;
else if (theCrossToCount[row][column].equals("XYRRWWBB")| theCrossToCount[row][column].equals("XYRrWWBB") |
theCrossToCount[row][column].equals("XYRRWwBB")| theCrossToCount[row][column].equals("XYRrWwBB")|
theCrossToCount[row][column].equals("XYRRWWBb")| theCrossToCount[row][column].equals("XYRrWWBb")|
theCrossToCount[row][column].equals("XYRRWwBb")| theCrossToCount[row][column].equals("XYRrWwBb")|
theCrossToCount[row][column].equals("XYRsWWBB")| theCrossToCount[row][column].equals("XYRsWwBB")|
theCrossToCount[row][column].equals("XYRsWWBb")| theCrossToCount[row][column].equals("XYRsWwBb"))
M_Red_Wing_Albino++;
else if (theCrossToCount[row][column].equals("XYrrWWBB")| theCrossToCount[row][column].equals("XYrrWwBB")|
theCrossToCount[row][column].equals("XYrrWWBb")| theCrossToCount[row][column].equals("XYrrWwBb"))
M_Sepia_Wing_Albino++;
totalCount++;
}
}
}
}