Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 2 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions example.wlk

This file was deleted.

101 changes: 101 additions & 0 deletions intensamente.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
class Persona {
const edad

const emociones = []

// 1
method esAdolecente() = edad.between(12, 19)

// 2
method agregarEmocion(emocion) = emociones.add(emocion)

//3
method puedeExplotar() = emociones.all({e => e.puedeLiberarse()})

//4
method hacerEvento(evento) {
emociones.forEach({ e => e.liberar(evento) })
}}

//6
class Grupo{
const integrantes=[]
method vivirEvento(evento)= integrantes.forEach{p=>p.hacerEvento(evento)}
}
class Emocion {

var property intensidad=500
var property cantidadEventos = 0
var property criterioIntensidad = 5

// Método para determinar si una emoción puede liberarse
method puedeLiberarse() = true

//5
method cambiarCriterioIntensidad(nuevoCriterio) {
criterioIntensidad = nuevoCriterio
}

method intensidad()=intensidad

method liberar(evento) {
cantidadEventos += 1
if(self.puedeLiberarse()){
intensidad -= evento.impacto()
}
}

method intensidadElevada() = intensidad>criterioIntensidad
}

class Furia inherits Emocion(){
const palabrotas=[]

override method puedeLiberarse() = self.tienePalabrota7() and self.intensidadElevada()
method tienePalabrota7() = palabrotas.any{p=>p.size()>7}

}

class Alegria inherits Emocion{

override method initialize() {
intensidad = intensidad.abs()
}
override method puedeLiberarse() = self.intensidadElevada() && self.eventosPar()
method eventosPar() = cantidadEventos%2 == 0

}

class Tristeza inherits Emocion{
var property causa = "melancolia"
override method puedeLiberarse() = causa != "melancolia" && self.intensidadElevada()
override method liberar(evento){
super(evento)
causa = evento.descripcion()
}
}

class DesagradoYtemor inherits Emocion{
override method puedeLiberarse() = cantidadEventos > intensidad && self.intensidadElevada()
}

//Se libera si el impacto de la última emocion fue mayor al criterio de intensidad
class Especial inherits Emocion{
var property recuerdo = 10
method intesidad() = 100
override method puedeLiberarse() = recuerdo > criterioIntensidad
override method liberar(evento){
super(evento)
recuerdo = evento.impacto()
}
}

class Evento{
const property impacto
const descripcion

method descripcion() = descripcion
}

const tristeza = new Alegria(intensidad=-100)
const evento1 = new Evento(impacto=2,descripcion="")
1,429 changes: 1,429 additions & 0 deletions log/wollok.log

Large diffs are not rendered by default.

519 changes: 519 additions & 0 deletions log/wollok1.log

Large diffs are not rendered by default.

1,056 changes: 1,056 additions & 0 deletions log/wollok2.log

Large diffs are not rendered by default.

563 changes: 563 additions & 0 deletions log/wollok3.log

Large diffs are not rendered by default.

718 changes: 718 additions & 0 deletions log/wollok4.log

Large diffs are not rendered by default.

967 changes: 967 additions & 0 deletions log/wollok5.log

Large diffs are not rendered by default.

161 changes: 161 additions & 0 deletions log/wollok6.log

Large diffs are not rendered by default.

1,574 changes: 1,574 additions & 0 deletions log/wollok7.log

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions testExample.wtest
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import example.pepita

import intensamente.*
describe "group of tests for pepita" {

test "pepita has initial energy" {
assert.equals(100, pepita.energy())

test "6" {
const evento = new Evento(impacto=10, descripcion="hola")
const emocion1 = new Furia(palabrotas=["AAAAAAAAAAAA"])
const emocion2 = new Furia(palabrotas=["B"])
const emocion3 = new Furia(palabrotas=["EWFFFFFFEFWEWFWE"])
const eitan = new Persona(edad=10, emociones=[emocion1,emocion2])
const ramiro = new Persona(edad=1, emociones=[emocion1])
const grupo = new Grupo(integrantes=[eitan,ramiro])
grupo.vivirEvento(evento)

//la emocion 1 se vivio dos veces una por ramiro y otra por eitan mientras q la emocion 2 1 sola vez
assert.equals(2, emocion1.cantidadEventos())
assert.equals(480, emocion1.intensidad())
assert.equals(500, emocion2.intensidad())
assert.equals(1, emocion2.cantidadEventos())
}


}