Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Gambas class file
- ' WeatherDato: Datos Meteorológicos
- Inherits Subject
- Private ListaObservadores As Variant[] ' variant[] tiene metodos especiales de busqueda, añadir, etc ya programados
- Private tem As Single
- Private hum As Single
- Private pre As Single
- Private EstTiempo As String 'estaod del tiempo
- Public Sub _new()
- ListaObservadores = New Variant[]
- End
- Public Sub RegistrarObservador(o As Observador)
- ListaObservadores.Add(o)
- End
- Public Sub BorrarObservador(o As Observador)
- Dim i As Integer
- i = ListaObservadores.Find(o)
- If i >= 0 Then ListaObservadores.Delete(i)
- End
- Public Sub NotificarObservadores()
- Dim i As Integer
- Dim obs As Observador
- For i = 0 To ListaObservadores.Count - 1
- obs = New Observador
- obs = ListaObservadores[i]
- obs.update(tem, hum, pre, EstTiempo)
- Next
- End
- Public Sub cambioDeMediciones()
- NotificarObservadores()
- End
- Public Sub setMediciones(temperatura As Single, humedad As Single, presion As Single, EstadoTiempo As String)
- tem = temperatura
- hum = humedad
- pre = presion
- EstTiempo = EstadoTiempo
- cambioDeMediciones() 'notificar a todos los observadores el cambio...
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement