-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b44590f
Showing
7 changed files
with
3,523 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
|
||
## example | ||
|
||
TODO | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
class Comida { | ||
var property cocinero | ||
method calorias() = 100 + 3 * self.grasas() | ||
method grasas() | ||
} | ||
|
||
class Entrada inherits Comida{ | ||
override method grasas() = 0 | ||
method bonito() = true | ||
} | ||
|
||
class Principal inherits Comida{ | ||
var property bonito = true | ||
const property grasas | ||
override method grasas() = grasas | ||
} | ||
class Postre inherits Comida{ | ||
const colores | ||
override method grasas() = 120 | ||
method bonito() = colores > 3 | ||
} | ||
class Cocinero { | ||
var especialidad = sousChef | ||
|
||
method calificar(plato) = especialidad.calificar(plato) | ||
method cocinar() = especialidad.cocinar(self) | ||
// method cocinar() = especialidad.cocinar() | ||
|
||
method especialidad(nueva){ | ||
especialidad = nueva | ||
} | ||
} | ||
|
||
class Pastelero { | ||
const nivelDeseado | ||
method calificar(plato) = (5 * plato.grasas() / nivelDeseado ).min(10) | ||
method cocinar(cocinero) = new Postre(colores = nivelDeseado/50,cocinero =cocinero) | ||
// method cocinar() = new Postre(colores = nivelDeseado/50) | ||
} | ||
class Chef { | ||
const calorias | ||
method calificar(plato) = if (plato.bonito()and plato.calorias() <= calorias ) 10 else 0 | ||
method cocinar(cocinero) = new Principal(grasas = calorias, cocinero = cocinero) | ||
// method cocinar() = new Principal(grasas = calorias) | ||
} | ||
|
||
object sousChef { | ||
// Implementacioń inventada. Siempre es un numero entre 1 y 10. No califica con 0 | ||
method calificar(plato) = plato.calorias()%10 + 1 | ||
method cocinar(cocinero) = new Entrada(cocinero = cocinero) | ||
// method cocinar() = new Entrada() | ||
} | ||
object concurso { | ||
|
||
const cocineros = [] | ||
const platosPresentados = [] | ||
method inscribirse(cocinero){ | ||
cocineros.add(cocinero) | ||
platosPresentados.add(cocinero.cocinar()) | ||
} | ||
method calificacion(plato) = cocineros.sum{cocinero=>cocinero.calificar(plato)} | ||
method ganador() = platosPresentados.max{plato => self.calificacion(plato)}.cocinero() | ||
|
||
// Variante, si en vez de cocinar el plato en el momento de inscribirse, lo hace al momento de obtener el ganador | ||
// En este caso, el plato no necesita conocer al cocinero que lo hizo la momento de cocinarse | ||
// method ganador() = cocineros.max{cocinero => self.calificacion(cocinero.cocinar())} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "masterchef", | ||
"version": "1.0.0", | ||
"wollokVersion": "4.0.0", | ||
"author": "lucas", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import cocina.* | ||
|
||
describe "tests de cocineros" { | ||
|
||
const donato = new Cocinero(especialidad = new Chef(calorias = 150)) | ||
const otroCocinero = new Cocinero(especialidad = new Chef(calorias = 1)) | ||
const damian = new Cocinero(especialidad = new Pastelero(nivelDeseado = 200)) | ||
const otroPastelero = new Cocinero(especialidad = new Pastelero(nivelDeseado = 50)) | ||
const german = new Cocinero(especialidad = sousChef) | ||
|
||
const entrada = german.cocinar() | ||
const platoPrincipal = donato.cocinar() | ||
const otroPlatoPrincipal = otroCocinero.cocinar() | ||
const postre = damian.cocinar() | ||
|
||
method inscripcionConcurso(){ | ||
concurso.inscribirse(donato) | ||
concurso.inscribirse(damian) | ||
concurso.inscribirse(german) | ||
} | ||
test "Un pastelero con nivelDeseado alto crea un postre bonito" { | ||
assert.that(damian.cocinar().bonito()) | ||
} | ||
test "Un pastelero con nivelDeseado bajo crea un postre que no es bonito" { | ||
assert.notThat(otroPastelero.cocinar().bonito()) | ||
} | ||
test "Un souschef crea una entrada" { | ||
assert.equals(0, german.cocinar().grasas()) | ||
} | ||
test "Un chef crea un plato principal con tanta grasa como sus calorias" { | ||
assert.equals(150, donato.cocinar().grasas()) | ||
} | ||
|
||
test "Un pastelero califica una entrada con 0" { | ||
assert.equals(0,damian.calificar(entrada)) | ||
} | ||
test "Un chef califica una entrada con 10" { | ||
assert.equals(10,donato.calificar(entrada)) | ||
} | ||
test "Un souschef califica una entrada con 1" { | ||
assert.equals(1,german.calificar(entrada)) | ||
} | ||
|
||
test "Un pastelero con nivelDeseado alto califica un plato principal" { | ||
assert.equals(3.75,damian.calificar(platoPrincipal)) | ||
} | ||
test "Un pastelero con nivelDeseado bajo califica un plato principal" { | ||
assert.equals(10,otroPastelero.calificar(platoPrincipal)) | ||
} | ||
test "Un chef califica plato principal " { | ||
assert.equals(0,donato.calificar(platoPrincipal)) | ||
} | ||
|
||
test "Un chef califica plato principal pocas calorias" { | ||
assert.equals(10,donato.calificar(otroPlatoPrincipal)) | ||
} | ||
|
||
test "Un souschef califica plato principal" { | ||
assert.equals(4,german.calificar(otroPlatoPrincipal)) | ||
} | ||
|
||
test "Un pastelero califica postre" { | ||
assert.equals(3,damian.calificar(postre)) | ||
} | ||
test "Un chef califica postre " { | ||
assert.equals(0,donato.calificar(postre)) | ||
} | ||
|
||
test "Un souschef califica postre" { | ||
assert.equals(1,german.calificar(postre)) | ||
} | ||
|
||
test "calificacion total de una entrada por todo el jurado"{ | ||
self.inscripcionConcurso() | ||
assert.equals(11,concurso.calificacion(entrada)) | ||
} | ||
test "calificacion total de un platoPrincipal por todo el jurado"{ | ||
self.inscripcionConcurso() | ||
assert.equals(4.75,concurso.calificacion(platoPrincipal)) | ||
} | ||
test "calificacion total de un postre por todo el jurado"{ | ||
self.inscripcionConcurso() | ||
assert.equals(4,concurso.calificacion(postre)) | ||
} | ||
test "el ganador del concurso" { | ||
self.inscripcionConcurso() | ||
assert.equals(german,concurso.ganador()) | ||
} | ||
|
||
} |