/*
entwickelt von:
Christian Vogt
*/


import javax.swing.*;

public class _muenzwurf
{

	public static int werfkopf(int anzahl)
	{
		int kopf = 0;

		for(int i = 0; i < anzahl; i++)
    	{
			if(Math.random() < 0.5)
	         {
				kopf++;
			}	// end if
	     }	// end for
	   	return kopf;
	}	// end method


	public static JTextField[] einlesen()
    {
         JTextField[] feld = {new JTextField()};
		Object[] msg = {"Eingabe", feld[0]};
		(new JOptionPane(msg)).createDialog(null, "Zahlenraten").setVisible(true);

         int eingabe = Integer.parseInt(feld[0].getText());

         return eingabe;
    }

	public static void anzeigen(int kopf, int zahl)
	{
		String ausgabe = "";
		char zeichen = '#';
    	int balkenlaenge;
		int skala = 100;

    	// Balken für Kopf
		ausgabe += "Kopf: ";
		balkenlaenge = skala * kopf /(kopf + zahl);

    	for(int i = 0; i < balkenlaenge; i++)
		{
			ausgabe += zeichen;
		}

    	ausgabe +="\n\n";

    	// Balken für Zahl
		ausgabe += "Zahl: ";
	   	balkenlaenge = skala * zahl /(kopf + zahl);

    	for(int i = 0; i < balkenlaenge; i++)
	    	{
			ausgabe += zeichen;
	    	}

		JOptionPane.showMessageDialog(null, ausgabe, "Die Ausgabe", JOptionPane.PLAIN_MESSAGE);
	}	// end method
}	// end class