7 public function get_rows()
12 public function get_cols()
17 protected function mk_matrix()
21 for ($i = 0; $i < $this->rows
; $i++
)
22 for ($j = 0; $j < $this->cols
; $j++
)
28 public function check_values($mat2, $value)
30 if (($this->rows
!= $mat2->rows
) ||
31 ($this->cols
!= $mat2->cols
))
32 throw new Exception("Matrizes sao diferentes");
34 for ($i = 0; $i < $this->rows
; $i++
) {
35 for ($j = 0; $j < $this->cols
; $j++
) {
36 if ($this->matrix
[$i][$j] == $value &&
37 $mat2->matrix
[$i][$j] == $value)
38 throw new Exception("Matrizes com o mesmo valor");
43 public function __construct($r, $c)
45 if ($r <= 0 ||
$c <= 0)
46 throw new Exception("Colunas ou Linhas invalidas");
50 $this->matrix
= $this->mk_matrix($r, $c);
54 class disciplina
extends matrix
{
57 private function dia_to_row($d)
59 $dias = array("seg" => 0, "ter" => 1, "qua" => 2,
60 "qui" => 3, "sex" => 4);
62 if (!array_key_exists($d, $dias))
63 throw new Exception("Dia invalido");
68 public function get_nome()
73 public function set_nome($n)
78 private function change_horario($d, $h, $value)
82 if ($h < 0 ||
$h > $this->cols
)
83 throw new Exception("Hora invalida");
85 if ($value != true && $value != false)
86 throw new Exception("value tem que ser booleano");
88 $cur = &$this->matrix
[$this->dia_to_row($d)][$h];
90 throw new Exception("Valor ja alterado");
95 public function has_horario($dia, $hora)
98 return $this->matrix
[$this->dia_to_row($dia)][$hora];
101 public function set_horario($d, $h)
103 if ($this->has_horario($d, $h))
104 throw new Exception("Dia e hora ja existem " .
107 $this->change_horario($d, $h, true);
110 public function unset_horario($d, $h)
112 $this->change_horario($d, $h, false);
115 public function __construct($n)
119 parent
::__construct($rows, $cols);