Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Greed At Its Best
Message
 
À
04/09/2007 13:40:42
Information générale
Forum:
Politics
Catégorie:
Autre
Divers
Thread ID:
01251725
Message ID:
01252278
Vues:
20
Tamar, I completely agree with you. I expanded your code to make it runnable
local loCoin1, loCoin2, lnTosses, lnSuccess, lnToss

loCoin1				= Createobject('Coin')
loCoin2				= Createobject('Coin')

lnSuccess			= 0 && Two Heads
lnTosses			= 100

for lnToss = 1 to lnTosses
	loCoin1.Toss()
	loCoin2.Toss()
	if loCoin1.getFace() + loCoin2.getFace() = 'HH'
		lnSuccess			= lnSuccess + 1
	endif
next lnToss

? lnSuccess / lnTosses * 100

define class coin as Session
	protected face
	
	function getFace() as String
		return this.Face
	endfunc
	
	function init() as boolean
		Rand(-1)
		this.Toss()
	endfunc
	
	procedure toss() as VOID
		this.Face			= Iif(Rand() < 0.5, 'H', 'T')
	endproc
enddefine
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform