Tärning | Visa källkod | Hangman | XHTML | CSS | How to become a hacker

Visa källkod

Nedanstående filer finns i denna katalogen. Klicka på en fil för att visa dess innehåll.

dice6/

CDice.php
CDiceSvg.php
CHistogram.php
FDice.php
FHistogram.php
common.php
dice.php
source.php
template.php

CDice.php
<?php
// ===========================================================================================
//
// CDice.php
//
// Description: A class for a dice
//
// Author: Mikael Roos
//


class CDice {  

    // -------------------------------------------------------------------------------------------
    //
    // Member variables
    //
    private $iLastThrows = Array();


    // -------------------------------------------------------------------------------------------
    //
    // Throw a dice, return the value.
    //
    public function Roll() {
        return rand(1,6);
    }


    // -------------------------------------------------------------------------------------------
    //
    // Throw a dice repeatedly, return the value(s).
    //
    public function RollRepeatedly($aNumber) {
        $this->iLastThrows = Array();
        for($i=1; $i<=$aNumber; $i++) {
            $this->iLastThrows[$i] = $this->Roll(); 
        }    
        return $this->iLastThrows;
    }

    
    // -------------------------------------------------------------------------------------------
    //
    // Return an array of the last throws.
    //
    public function GetLastThrows() {
        return $this->iLastThrows;
    }


} // End of class


?>
 .                        
..:    © Mikael Roos, 2009