package Variable; sub new{ my ($class) = @_; my $self = {value => 0}; bless $self,$class; return $self; } sub setValueAdderVar{ my ($self,$val) = @_; $self->{old} = $self->{value}; $self->{value} = $val * $val; $self->{Adder}->refresh($self->{old},$self->{value}); } sub connectAdder{ my ($self,$var) = @_; $self->{Adder} = $var; } sub connectSqrt{ my ($self,$var) = @_; $self->{Sqrt} = $var; } sub setValueSqrtVar{ my ($self,$val) = @_; $self->setValue($val); $self->{Sqrt}->refresh($self->getValue()); } sub setValue{ my ($self,$val) = @_; $self->{value} = $val; } sub getValue{ my ($self) = @_; return $self->{value}; } 1;