-
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 25eed02
Showing
5 changed files
with
184 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 @@ | ||
|
||
# Local history | ||
.history | ||
|
||
# Wollok Log | ||
*.log |
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,151 @@ | ||
object mundo{ | ||
const personas = [] | ||
|
||
method transcurrirUnMes(){ | ||
calendario.pasarMes() | ||
personas.forEach{persona => persona.cobrarSalario()} | ||
} | ||
|
||
method personaConMasCosas() = personas.max({persona => persona.cantidadCosas()}) | ||
} | ||
|
||
object calendario { | ||
var property mes = 1 | ||
method pasarMes() { | ||
mes = mes + 1 | ||
} | ||
} | ||
|
||
class Persona{ | ||
const efectivo = new PagoInmediato() | ||
const formasPago = [efectivo] | ||
const cosas = [] | ||
const cuotas = [] | ||
var formaPreferida | ||
|
||
var property salario | ||
var montoParaPagarCuotas | ||
|
||
// compras | ||
method modificarForma(){ | ||
formaPreferida = formasPago.anyOne() | ||
} | ||
|
||
method comprar(cosa){ | ||
if(self.puedeComprar(cosa)){ | ||
self.pagar(cosa) | ||
cosas.add(cosa) | ||
} | ||
} | ||
|
||
method puedeComprar(cosa) = formaPreferida.puedePagar(cosa) | ||
|
||
method pagar(cosa){ | ||
formaPreferida.pagar(cosa,self) | ||
} | ||
|
||
method agregarCuota(cuota){ | ||
cuotas.add(cuota) | ||
} | ||
|
||
// sueldo | ||
|
||
method cobrarSalario(){ | ||
montoParaPagarCuotas = salario | ||
self.pagarCuotas() | ||
efectivo.aumentar(montoParaPagarCuotas) | ||
} | ||
|
||
method pagarCuotas(){ | ||
self.cuotasVencidas().forEach({cuota => self.pagarCuota(cuota)}) | ||
} | ||
|
||
method cuotasVencidas() = cuotas.filter({cuota => cuota.estaVencida()}) | ||
|
||
method pagarCuota(cuota){ | ||
if (montoParaPagarCuotas > cuota.importe() ){ | ||
montoParaPagarCuotas -= cuota.importe() | ||
cuota.pagar() | ||
} | ||
} | ||
|
||
method totalDeuda() = self.cuotasVencidas().sum{cuota => cuota.importe()} | ||
|
||
method cantidadCosas() = cosas.size() | ||
} | ||
|
||
class Cosa{ | ||
var property precio | ||
method precioFinanciado() = precio * (1 + bancoCentral.tasaInteres()) | ||
} | ||
|
||
class FormaPago { | ||
method puedePagar(cosa) = cosa.precio() <= self.disponible() | ||
method disponible() | ||
} | ||
class PagoInmediato inherits FormaPago{ // Para debito y efectivo | ||
var property disponible = 0 | ||
|
||
method aumentar(importe) { | ||
disponible = disponible + importe | ||
} | ||
|
||
method pagar(cosa,persona){ | ||
self.aumentar( -cosa.precio() ) | ||
} | ||
} | ||
|
||
class PagoCredito inherits FormaPago { | ||
const banco | ||
var cantidadCuotas | ||
|
||
override method disponible() = banco.maximoPermitido() | ||
|
||
method pagar(cosa,persona){ | ||
cantidadCuotas.times{ numero => | ||
persona.agregarCuota( | ||
new Cuota(mes = calendario.mes() + numero, importe = cosa.precioFinanciado()) | ||
) | ||
} | ||
} | ||
} | ||
|
||
class Cuota{ | ||
const mes | ||
const property importe | ||
var property pagada = false | ||
|
||
method pagar(){ | ||
pagada = true | ||
} | ||
|
||
method vencida() = mes <= calendario.mes() && not pagada | ||
} | ||
|
||
|
||
object bancoCentral{ | ||
var property tasaInteres = 0.1 | ||
} | ||
|
||
class Banco { | ||
var property montoMaximo | ||
} | ||
|
||
// Segunda parte | ||
|
||
class CompradorCompulsivo inherits Persona{ | ||
override method puedeComprar(cosa) = formasPago.any({formaPago => formaPago.puedePagar(cosa)}) | ||
|
||
override method pagar(cosa){ | ||
formasPago.find{formaPago => formaPago.puedePagar(cosa)}.pagar(cosa,self) | ||
} | ||
} | ||
|
||
class PagadorCompulsivo inherits Persona{ | ||
override method pagarCuotas(){ | ||
super() | ||
montoParaPagarCuotas += efectivo.disponible() | ||
efectivo.disponible(0) | ||
super() | ||
} | ||
} |
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": "compradores", | ||
"version": "1.0.0", | ||
"wollokVersion": "4.0.0", | ||
"author": "lucas", | ||
"license": "ISC" | ||
} |