Skip to content

Commit

Permalink
ejemplo con dos opiniones
Browse files Browse the repository at this point in the history
  • Loading branch information
lspigariol committed Nov 27, 2024
0 parents commit 6a1affb
Show file tree
Hide file tree
Showing 26 changed files with 194 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

Binary file added assets/cuadradoliso.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/fondoClaro.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/haskell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/number-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/prolog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wollok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions encuesta.wpgm
Original file line number Diff line number Diff line change
@@ -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()
}
101 changes: 101 additions & 0 deletions grafico.wlk
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions grupo1.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import opiniones.*

const grupo1 = new Opinion(
objetos = 9,
funcional = 7,
logico = 3
)
7 changes: 7 additions & 0 deletions grupo2.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import opiniones.*

const grupo2 = new Opinion(
objetos = 6,
funcional = 10,
logico = 4
)
18 changes: 18 additions & 0 deletions opiniones.wlk
Original file line number Diff line number Diff line change
@@ -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()})
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "encuesta",
"version": "1.0.0",
"wollokVersion": "4.0.0",
"author": "lucas",
"license": "ISC"
}
9 changes: 9 additions & 0 deletions testExample.wtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import grafico.*

describe "group of tests for grafico" {

test "valoracion promedio" {
//assert.equals(100, pepita.energy())
}

}

0 comments on commit 6a1affb

Please sign in to comment.