diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e84736 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e95028 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ + +# Local history +.history + +# Wollok Log +*.log diff --git a/README.md b/README.md new file mode 100644 index 0000000..76b305e --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ + + +## example + +TODO + diff --git a/assets/cuadradoliso.jpg b/assets/cuadradoliso.jpg new file mode 100644 index 0000000..22db5c3 Binary files /dev/null and b/assets/cuadradoliso.jpg differ diff --git a/assets/fondoClaro.jpg b/assets/fondoClaro.jpg new file mode 100644 index 0000000..e73730e Binary files /dev/null and b/assets/fondoClaro.jpg differ diff --git a/assets/haskell.png b/assets/haskell.png new file mode 100644 index 0000000..639b519 Binary files /dev/null and b/assets/haskell.png differ diff --git a/assets/number-0.png b/assets/number-0.png new file mode 100644 index 0000000..0bb4ba4 Binary files /dev/null and b/assets/number-0.png differ diff --git a/assets/number-1.png b/assets/number-1.png new file mode 100644 index 0000000..a665cf9 Binary files /dev/null and b/assets/number-1.png differ diff --git a/assets/number-10.png b/assets/number-10.png new file mode 100644 index 0000000..5cc964e Binary files /dev/null and b/assets/number-10.png differ diff --git a/assets/number-2.png b/assets/number-2.png new file mode 100644 index 0000000..bb07e91 Binary files /dev/null and b/assets/number-2.png differ diff --git a/assets/number-3.png b/assets/number-3.png new file mode 100644 index 0000000..c7b8b8d Binary files /dev/null and b/assets/number-3.png differ diff --git a/assets/number-4.png b/assets/number-4.png new file mode 100644 index 0000000..5bfdef9 Binary files /dev/null and b/assets/number-4.png differ diff --git a/assets/number-5.png b/assets/number-5.png new file mode 100644 index 0000000..786d9aa Binary files /dev/null and b/assets/number-5.png differ diff --git a/assets/number-6.png b/assets/number-6.png new file mode 100644 index 0000000..7afa415 Binary files /dev/null and b/assets/number-6.png differ diff --git a/assets/number-7.png b/assets/number-7.png new file mode 100644 index 0000000..9db312e Binary files /dev/null and b/assets/number-7.png differ diff --git a/assets/number-8.png b/assets/number-8.png new file mode 100644 index 0000000..fad6799 Binary files /dev/null and b/assets/number-8.png differ diff --git a/assets/number-9.png b/assets/number-9.png new file mode 100644 index 0000000..1ce2955 Binary files /dev/null and b/assets/number-9.png differ diff --git a/assets/prolog.png b/assets/prolog.png new file mode 100644 index 0000000..30fc5f5 Binary files /dev/null and b/assets/prolog.png differ diff --git a/assets/wollok.png b/assets/wollok.png new file mode 100644 index 0000000..e46c636 Binary files /dev/null and b/assets/wollok.png differ diff --git a/encuesta.wpgm b/encuesta.wpgm new file mode 100644 index 0000000..1390790 --- /dev/null +++ b/encuesta.wpgm @@ -0,0 +1,19 @@ +import grafico.* +import grupo1.* +import grupo2.* +import opiniones.* + +program graficadorEncuestas { + const encuesta = new Encuesta() + encuesta.opiniones().add(grupo1) + encuesta.opiniones().add(grupo2) + + game.boardGround("fondoClaro.jpg") + game.height(14) + game.width(16) new GraficoBarrasIconos( + valores = encuesta.resultados(), + etiquetas = encuesta.descripciones(), + position = game.at(3, 3) + ).dibujar() + game.start() +} \ No newline at end of file diff --git a/grafico.wlk b/grafico.wlk new file mode 100644 index 0000000..d844a3f --- /dev/null +++ b/grafico.wlk @@ -0,0 +1,101 @@ +import wollok.game.* + +class BarraVertical { + const valor + var position + + method dibujar() { + if (valor > 0) valor.times( + { i => + new Item(position = position).dibujar() + position = position.up(1) + } + ) + } +} + +class GraficoBarras { + const valores + const etiquetas + const maximo = 10 + var property position + + method dibujar() { + self.dibujarBarras() + self.dibujarEtiquetasHorizontales() + self.dibujarEtiquetasVerticales() + } + + method dibujarBarras() { + var pos = position + + valores.forEach( + { valor => + new BarraVertical(valor = valor, position = pos).dibujar() + pos = pos.right(2) + } + ) + } + + method dibujarEtiquetasHorizontales() { + var pos = position.down(2) + etiquetas.forEach( + { etiqueta => + self.nuevaEtiquetaHorizontal(etiqueta, pos).dibujar() + pos = pos.right(2) + } + ) + } + + method dibujarEtiquetasVerticales() { + var pos = position.left(2) + maximo.times( + { nro => + self.nuevaEtiquetaVertical(nro.toString(), pos).dibujar() + pos = pos.up(1) + } + ) + } + + method nuevaEtiquetaHorizontal(etiqueta, pos) = new Etiqueta( + text = etiqueta, + position = pos + ) + + method nuevaEtiquetaVertical(etiqueta, pos) = self.nuevaEtiquetaHorizontal( + etiqueta, + pos + ) +} + +class GraficoBarrasIconos inherits GraficoBarras { + override method nuevaEtiquetaHorizontal(etiqueta, pos) = new Icono( + image = etiqueta, + position = pos + ) + + override method nuevaEtiquetaVertical(etiqueta, pos) = new Icono( + image = ("number-" + etiqueta) + ".png", + position = pos + ) +} + +class Visual { + const property position + + method dibujar() { + game.addVisual(self) + } +} + +class Icono inherits Visual { + const property image +} + +class Etiqueta inherits Visual { + const property text +} + +class Item inherits Visual { + method image() = "cuadradoliso.jpg" +} diff --git a/grupo1.wlk b/grupo1.wlk new file mode 100644 index 0000000..d6db5fd --- /dev/null +++ b/grupo1.wlk @@ -0,0 +1,7 @@ +import opiniones.* + +const grupo1 = new Opinion( + objetos = 9, + funcional = 7, + logico = 3 +) diff --git a/grupo2.wlk b/grupo2.wlk new file mode 100644 index 0000000..0d43d02 --- /dev/null +++ b/grupo2.wlk @@ -0,0 +1,7 @@ +import opiniones.* + +const grupo2 = new Opinion( + objetos = 6, + funcional = 10, + logico = 4 +) \ No newline at end of file diff --git a/opiniones.wlk b/opiniones.wlk new file mode 100644 index 0000000..749775b --- /dev/null +++ b/opiniones.wlk @@ -0,0 +1,18 @@ +class Opinion { + + var property objetos + + var property funcional + + var property logico + +} + + +class Encuesta { + const property opiniones = [] + const property descripciones = ["wollok.png", "haskell.png", "prolog.png"] + const property criterios = [{o=>o.objetos()},{o=>o.funcional()},{o=>o.logico()} ] + + method resultados() = criterios.map({c=>opiniones.sum(c)/opiniones.size()}) +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..c47f60e --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "encuesta", + "version": "1.0.0", + "wollokVersion": "4.0.0", + "author": "lucas", + "license": "ISC" +} diff --git a/testExample.wtest b/testExample.wtest new file mode 100644 index 0000000..01bc252 --- /dev/null +++ b/testExample.wtest @@ -0,0 +1,9 @@ +import grafico.* + +describe "group of tests for grafico" { + + test "valoracion promedio" { + //assert.equals(100, pepita.energy()) + } + +} \ No newline at end of file