<?php

#    (gH)   -_-  statobj1.php  ;  TimeStamp (unix) : 18 Juin 2007 vers 12:13
#
#    Objets statistiques en php, implémentation simple
#

#######################################################

class VS {

#######################################################

  var    $nomCourt = "" ;
  var    $nomLong  = "" ;
  var    $tabVal   = array() ;

  function VS($nom="",$lstVal="",$nomdetail="") {
    $this->nomCourt = $nom ;
    $this->nomLong  = $nomdetail ;
    if (strlen(trim($lstVal))>0) { $this->tabVal = preg_split("/ +/ ",$lstVal) ; } ;
  } # fin de fonction VS

  function nature() {
    return("non sue") ;
  } # fin de fonction nature

  function get_nomCourt() {
    return( $this->nomCourt ) ;
  } # fin de fonction get_nomCourt

  function set_nomCourt($nom) {
    $this->nomCourt  = $nom ;
  } # fin de fonction set_nomCourt

  function get_nomLong() {
    return( $this->nomLong ) ;
  } # fin de fonction get_nomLong

  function set_nomLong($nomdetail) {
    $this->nomLong  = $nomdetail ;
  } # fin de fonction set_nomLong

  function taille() {
    return( count($this->tabVal) ) ;
  } # fin de fonction taille

  function decritVS() {
    echo "Variable  : ".$this->get_nomCourt()."\n" ;
    echo "detail    : ".$this->get_nomLong()."\n" ;
    echo "nature    : ".$this->nature()."\n" ;
    echo "taille    : ".$this->taille()."\n" ;
  } # fin de fonction decritVS

} # fin de classe variable statistique

#######################################################

class QT extends VS {

#######################################################

  var $unite = "???" ;

  function QT($nom="",$lstVal="",$unit="???",$nomdetail="") {
    parent::VS($nom,$lstVal,$nomdetail) ;
    $this->unite = $unit ;
  } # fin de fonction QT

  function nature() {
    return("QT") ;
  } # fin de fonction nature

  function get_unite() {
    return( $this->unite ) ;
  } # fin de fonction get_unite

  function set_nomLong($unit) {
    $this->unite  = $unit ;
  } # fin de fonction set_unite

  function decritQT() {
    parent::decritVS() ;
    echo "unité     : ".$this->get_unite()."\n" ;
  } # fin de fonction decritQT

} # fin de classe variable statistique quantitative

#######################################################

class QL extends VS {

#######################################################

  var $tabModa = array() ;

  function QL($nom="",$lstVal="",$tmoda=array(),$nomdetail="") {
    parent::VS($nom,$lstVal,$nomdetail) ;
    $this->tabModa = $tmoda ;
  } # fin de fonction QL

  function nature() {
    return("QL") ;
  } # fin de fonction nature

  function get_modalites() {
    ksort($this->tabModa) ;
    $ret = "" ;
    $nbc = 0 ;
    $nbm = count($this->tabModa) ;
    foreach ($this->tabModa as $cle => $valeur) {
      $ret .= "$cle = $valeur" ;
      $nbc++ ;
      if ($nbc<$nbm) { $ret .= " ; " ; }
    } ; # fin de pour chaque modalité
    return( $ret ) ;
  } # fin de fonction get_modalites

  function decritQL() {
    parent::decritVS() ;
    echo "modalités : ".$this->get_modalites()."\n" ;
  } # fin de fonction decritQT

} # fin de classe variable statistique quantitative

#######################################################
#######################################################

?>