// Gerry Brönnimann, ib03
// Pruefung 4.19

// Aufgabe 4)

public class Bieter
{


	public static void main(String [] args)
	{
		int max = 100000;
		Spiel spiel;
		int truempfe1 = 0;
		int truempfe2 = 0;
		int truempfe3 = 0;



		for (int i = 0; i<max; i++)
		{
			spiel = new Spiel();
			truempfe1 += spiel.truempfe[0];
			truempfe2 += spiel.truempfe[1];
			truempfe3 += spiel.truempfe[2];
		}

		int truempfe = max*9;
		float anteil1 = (float)truempfe1/(float)truempfe;
		float anteil2 = (float)truempfe2/(float)truempfe;
		float anteil3 = (float)truempfe3/(float)truempfe;
		System.out.println("Runden: " + max);
		System.out.println("Total Truempfe (9*Runden): " + truempfe);
		System.out.println("1) Truempfe:  " + truempfe1 + "; Anteil: " + anteil1 );
		System.out.println("2) Truempfe:  " + truempfe2 + "; Anteil: " + anteil2 );
		System.out.println("3) Truempfe:  " + truempfe3 + "; Anteil: " + anteil3 );
		System.out.println("Ant. 1+2+3:   " + (anteil1+anteil2+anteil3) );


	}

}

class Spiel
{
	int totalKarten = 36;
	int runden = totalKarten;
	int totalTruempfe = 9;  // Anz. Truempfe im Spiel
	int totalNormal = 27;	// Anz. normale Karten im Spiel

	int truempfe[] = new int[3]; // truempfe pro Spieler
	int normal[] = new int[3]; // truempfe pro Spieler

	int trumpf; // farbe 1, 2, 3 oder 4
	int farbe;
	int spielerNr = 0;

	public Spiel()
	{


		trumpf = (int) (Math.random() *4+ 1);


		for (int i = 0; i<runden; i++)
		{

			if (i==0)
			{
				truempfe[spielerNr]++;
				totalTruempfe--;
			}
			else
			{
				farbe = (int) (Math.random() * totalKarten + 1);
				// trumpf?
				if (farbe <= totalTruempfe && totalTruempfe > 0)
				{
					truempfe[spielerNr]++;
					totalTruempfe--;
				}
				else
				{
					normal[spielerNr]++;
					totalNormal--;
				}
			}

			if (spielerNr == 2) spielerNr = 0;
			else spielerNr++;

			totalKarten--;
		}
		/*
		System.out.println("1: truempfe: " + truempfe[0] + ", normal: " + normal[0] + ", Karten: " + (truempfe[0]+normal[0]) );
		System.out.println("2: truempfe: " + truempfe[1] + ", normal: " + normal[1] + ", Karten: " + (truempfe[1]+normal[1]) );
		System.out.println("3: truempfe: " + truempfe[2] + ", normal: " + normal[2] + ", Karten: " + (truempfe[2]+normal[2]) );
		System.out.println("total: truempfe: " + (truempfe[0]+truempfe[1]+truempfe[2]) + ", normal: " + (normal[0]+normal[1]+normal[2]) );
		*/
	}

}