Skip to content

Commit

Permalink
solucion
Browse files Browse the repository at this point in the history
  • Loading branch information
lspigariol committed Nov 13, 2024
0 parents commit 9085bb8
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: build

on: [push, pull_request]
jobs:
wollok-ts:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: |
wget -O wollok-ts-cli https://github.com/uqbar-project/wollok-ts-cli/releases/latest/download/wollok-ts-cli-linux-x64
chmod a+x ./wollok-ts-cli
./wollok-ts-cli test --skipValidations -p ./
shell: bash
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# Local history
.history

# Wollok Log
*.log
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


## example

TODO

96 changes: 96 additions & 0 deletions intensa.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
object intensamente {
var property intensidadLimite = 10
const personas = []
method agregar(p){
personas.add(p)
}

method cantidadPorExplotar() = personas.count{p=>p.porExplotar()}

method todosViven(evento) {
personas.forEach{p=>p.vivir(evento)}
}
}

class Persona {
var property edad
const emociones = []

method esAdolescente() = edad.between(12,19)

method tenerEmocion(nueva){
emociones.add(nueva)
}

method porExplotar() =
emociones.all{e=>e.puedeLiberarse()}

method vivir(evento){
emociones.forEach{e=>e.intentarLiberarse(evento)}
}
}


class Emocion{
var cantidadEventos = 0
var property intensidad
method puedeLiberarse() =
intensidad > intensamente.intensidadLimite() and
self.condicionAdicional()

method condicionAdicional()

method intentarLiberarse(evento) {
if(self.puedeLiberarse())
self.liberarse(evento)
cantidadEventos +=1
}
method liberarse(evento){
self.intensidad( intensidad - evento.impacto())
}
}
class Ansiedad inherits Furia{
override method liberarse(evento) { }
}

class Furia inherits Emocion(intensidad=100){
const palabrotas = []
override method condicionAdicional() =
palabrotas.any{p=>p.size() >= 7}
override method liberarse(evento){
super(evento)
palabrotas.remove(palabrotas.first())
}
method aprender(pal){
palabrotas.add(pal)
}
}

class Alegria inherits Emocion{
override method condicionAdicional() =
cantidadEventos.even()

override method intensidad(valor){
intensidad = valor.abs()
}
}

class Tristeza inherits Emocion {
var property causa = "melancolia"
override method condicionAdicional() =
causa != "melancolia"
override method liberarse(evento){
super(evento)
causa= evento.descripcion()
}
}

class OtraEmocion inherits Emocion {
override method condicionAdicional() =
cantidadEventos > intensidad
}

class Evento{
var property impacto
var property descripcion
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "intensamente",
"version": "1.0.0",
"wollokVersion": "4.0.0",
"author": "lucas",
"license": "ISC"
}
52 changes: 52 additions & 0 deletions test.wtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import intensa.*

describe "group of tests " {
const riley = new Persona(edad = 12)
const alegriaR = new Alegria(intensidad=20)
const tristezaR = new Tristeza(intensidad = 70)

const padre = new Persona(edad = 40)
const alegriaP = new Alegria(intensidad=50)
const otraP = new OtraEmocion(intensidad = 20)
const furiaP = new Furia()

const partido = new Evento(impacto=10, descripcion="hockey")
test "un adolescente " {

assert.that( riley.esAdolescente())
}

test "por explotar emocionalmente con tristeza por no melancolia" {
tristezaR.causa("escuela")
riley.tenerEmocion(alegriaR)
riley.tenerEmocion(tristezaR)
assert.that(riley.porExplotar())
}

test "no esta por explotar emocionalmente con tristeza por melancolia" {
riley.tenerEmocion(alegriaR)
riley.tenerEmocion(tristezaR)
assert.notThat(riley.porExplotar())
}

test "un evento es alterador"{
var cantidad
intensamente.agregar(riley)
riley.tenerEmocion(alegriaR)
riley.tenerEmocion(tristezaR)
tristezaR.causa("escuela")

intensamente.agregar(padre)
padre.tenerEmocion(alegriaP)
padre.tenerEmocion(furiaP)
padre.tenerEmocion(otraP)
furiaP.aprender("xxxxxxxxxx")

cantidad = intensamente.cantidadPorExplotar()

intensamente.todosViven(partido)

assert.notEquals (cantidad, intensamente.cantidadPorExplotar())

}
}

0 comments on commit 9085bb8

Please sign in to comment.