Skip to content

Commit

Permalink
parte 1 y 2, test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarSiscovich committed Nov 7, 2024
1 parent dd7d36c commit 37c9a80
Show file tree
Hide file tree
Showing 9 changed files with 2,327 additions and 28 deletions.
73 changes: 45 additions & 28 deletions golosinas.wlk
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ object oblea {

method recibeMordisco() {
if (_peso > 70){
_peso = _peso / 2
_peso /= 2
} else {
_peso = _peso * 0.75
_peso *= 0.75
}
}
}
object chocolatin {
var property _precio = _pesoI / 2
method _precio() = _pesoI / 2
var property _sabor = "chocolate"
var property _peso = 0
var property _pesoI = 0
Expand All @@ -71,50 +71,47 @@ object chocolatin {
}

method recibeMordisco() {
_peso -= - 2
_peso -= 2
}
}

object golBaniada {
method _precio() = golosinaBase._precio() + 2
method _sabor() = golosinaBase._sabor()
method _peso() = golosinaBase._peso() + 4
method peso() = golosinaBase._peso() + banioChocolate
var property golosinaBase = null

method _gluten() = golosinaBase._gluten()
var property golosinaBase = null
var property banioChocolate = 4

method golosinaBase(golosina){
method golosinaBase(golosina,pesoInicial){
if (pesoInicial != null) {
chocolatin.peso(pesoInicial)
}
golosinaBase = golosina
return golosinaBase
}

method recibeMordisco(){
golosinaBase.recibeMordisco()
if (banioChocolate == 4){
self._peso() - 2
banioChocolate = 2
} else if (banioChocolate == 2){
self._peso() - 2
banioChocolate = 0
if (banioChocolate > 0 ){
banioChocolate -= 2
}
}
}

object tuti{
var property _precio = 0
var property _gluten = null
var property _sabor = naranja
var property _peso = 5
var property _gluten = null

method precio() {
if (_gluten == 1){
_precio = 7
}else if (_gluten == 0){
_precio = 10
method _precio() {
if (_gluten){
return 7
}else{
return 10
}
}
method gluten(valor){
_gluten = valor
}

method recibeMordisco() {
_sabor = _sabor.siguiente()
Expand All @@ -136,6 +133,9 @@ object frutilla {
object mariano {
var property golosina = []
var property precioCuidado = []
var property conjuntoSabores = #{}
var property sumaPeso = 0
var property golosinasDeseadas = [caramelo,"mentita",alfajor,"oreo"]
method comprar(unaGolosina){
golosina.add(unaGolosina)
}
Expand All @@ -147,12 +147,29 @@ object mariano {
method probar() {
golosina.forEach({golosina => golosina.recibeMordisco()})
}

method sinTACC() {
golosina.any({golosina => golosina._gluten()})
return golosina.any({golosina => golosina._gluten()})
}
method preciosCuidados(){
golosina.all({golosina => golosina._precio() <= 10})
return precioCuidado.add(golosina)
golosina.map({golosina => precioCuidado.add(golosina._precio() <= 10)})
return precioCuidado
}
}
method golosinaDeSabor(unSabor) {
golosina.all({golosina => golosina._sabor() == unSabor})
return golosina.first()
}
method golosinasDeSabor(unSabor) {
golosina.all({golosina => golosina._sabor() == unSabor})
return golosina
}
method sabores(){
golosina.map({golosina => conjuntoSabores.add(golosina._sabor())})
return conjuntoSabores
}
method golosinaMasCara() = golosina.max({golosina => golosina._precio()})
method pesoGolosinas() = golosina.sum({golosina => golosina._peso()})

method golosinasFaltantes(gDeseadas) = golosinasDeseadas.filter({ golosina => !golosina.contains(golosina)})


}
4 changes: 4 additions & 0 deletions log/wollok10.log

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions log/wollok11.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"level":"error","message":"✘ Completions for node failed: Error: [Send]{e18833} at golosinas.wlk:154 exhausted all cases without a match [Send]{e18833} at golosinas.wlk:154 exhausted all cases without a match","stack":"Error: [Send]{e18833} at golosinas.wlk:154 exhausted all cases without a match\n at c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:38:6067\n at yh (c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:2291:42)\n at kh (c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:2291:1004)\n at Y5n (c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:2291:1160)\n at c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:38:6056\n at yh (c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:2291:42)\n at c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:2291:2700\n at c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:2298:3774\n at c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:37:74872\n at Fe (c:\\Users\\Urano\\.vscode\\extensions\\uqbar.wollok-lsp-ide-0.3.6\\out\\server\\src\\server.js:7:8527)","timestamp":"2024-11-07T00:27:49.964Z"}
{"level":"info","message":"onRequest - completionItem/resolve","timestamp":"2024-11-07T00:27:50.092Z"}
588 changes: 588 additions & 0 deletions log/wollok5.log

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

645 changes: 645 additions & 0 deletions log/wollok7.log

Large diffs are not rendered by default.

729 changes: 729 additions & 0 deletions log/wollok8.log

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions log/wollok9.log

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions testBombon.wtest
Original file line number Diff line number Diff line change
@@ -1 +1,132 @@
import golosinas.*

describe "parte 1 golosinas" {
test "bombon" {
assert.equals(15, bombon._peso())
assert.equals(5, bombon._precio())
assert.equals("frutilla", bombon._sabor())
assert.notThat(bombon._gluten())
}
test "alfajor" {
assert.equals(300, alfajor._peso())
assert.equals(12, alfajor._precio())
assert.equals("chocolate", alfajor._sabor())
assert.notThat(alfajor._gluten())
}
test "caramelo" {
assert.equals(5, caramelo._peso())
assert.equals(1, caramelo._precio())
assert.equals("frutilla", caramelo._sabor())
assert.that(caramelo._gluten())
}
test "chupetin" {
assert.equals(7, chupetin._peso())
assert.equals(2, chupetin._precio())
assert.equals("naranja", chupetin._sabor())
assert.that(chupetin._gluten())
}
test "oblea" {
assert.equals(250, oblea._peso())
assert.equals(5, oblea._precio())
assert.equals("vainilla", oblea._sabor())
assert.notThat(oblea._gluten())
}
test "chocolatin 40" {
chocolatin.peso(40)
assert.equals(40, chocolatin._peso())
assert.equals(20, chocolatin._precio())
assert.equals("chocolate", chocolatin._sabor())
assert.notThat(chocolatin._gluten())
}
test "chocolatin 100" {
chocolatin.peso(100)
assert.equals(100, chocolatin._peso())
assert.equals(50, chocolatin._precio())
assert.equals("chocolate", chocolatin._sabor())
assert.notThat(chocolatin._gluten())
}
test "tutti gluten si"{
tuti._gluten(true)
assert.equals(7, tuti._precio())
}
test "tutti gluten no"{
tuti._gluten(false)
assert.equals(10, tuti._precio())
}

test "chocolatin 2 mordiscos" {
chocolatin.peso(100)
chocolatin.recibeMordisco()
chocolatin.recibeMordisco()
assert.equals(96, chocolatin._peso())
assert.equals(50, chocolatin._precio())
}
test "tutti-frutti 2 mordiscos" {
tuti.recibeMordisco()
tuti.recibeMordisco()
assert.equals(chocolate, tuti._sabor())
}
test "oblea 3 mordiscos" {
oblea.recibeMordisco()
oblea.recibeMordisco()
oblea.recibeMordisco()
assert.equals(46.875, oblea._peso())
}

test "tuti bañada"{
golBaniada.golosinaBase(tuti,null)
tuti._gluten(true)
assert.equals(9, golBaniada.peso())
assert.equals(9, golBaniada._precio())
assert.equals(naranja, golBaniada._sabor())
assert.that(golBaniada._gluten())
}
test "chocolatin bañado"{
golBaniada.golosinaBase(chocolatin,100)
assert.equals(104, golBaniada.peso())
assert.equals(52, golBaniada._precio())
assert.equals("chocolate", golBaniada._sabor())
assert.notThat(golBaniada._gluten())
}
}
test "chupetin bañado"{
golBaniada.golosinaBase(chupetin,null)
assert.equals(11, golBaniada.peso())
assert.equals(4, golBaniada._precio())
assert.equals("naranja", golBaniada._sabor())
assert.that(golBaniada._gluten())
}


describe "parte 2 mariano" {
test "comprar" {
mariano.comprar(chupetin)
assert.equals([chupetin],mariano.golosina())
}
test "desechar" {
mariano.comprar(chupetin)
mariano.comprar(alfajor)
mariano.desechar(chupetin)
assert.equals([alfajor],mariano.golosina())
}
test "sin TACC" {
mariano.comprar(chupetin)
mariano.comprar(alfajor)
mariano.comprar(chocolatin)
assert.that(mariano.sinTACC())
}
test "precios cuidados" {
mariano.comprar(chupetin)
mariano.comprar(alfajor)
mariano.comprar(caramelo)
mariano.preciosCuidados()
assert.equals([chupetin, caramelo], mariano.precioCuidado())
}
test "comprar" {
mariano.comprar(chupetin)
assert.equals([chupetin],mariano.golosina())
}


}

0 comments on commit 37c9a80

Please sign in to comment.