Skip to content

Commit

Permalink
ninios y adultos
Browse files Browse the repository at this point in the history
  • Loading branch information
juancuiule committed Oct 29, 2018
0 parents commit c88275c
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin
35 changes: 35 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jaloguin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.uqbar.project.wollok.wollokNature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
22 changes: 22 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: jaloguin
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: jaloguin; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: com.ibm.icu,
org.eclipse.xtext,
org.eclipse.xtext.generator,
org.eclipse.xtend,
org.eclipse.xtend.typesystem.emf,
org.eclipse.xpand,
de.itemis.xtext.antlr;resolution:=optional,
org.eclipse.emf.mwe2.launch;resolution:=optional,
org.uqbar.project.wollok,
org.uqbar.project.wollok.launch,
org.uqbar.project.wollok.lib,
org.eclipse.xtext.ui
Import-Package: org.apache.log4j,
org.apache.commons.logging
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
3 changes: 3 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source.. = src/
bin.includes = META-INF/,\
.
1 change: 1 addition & 0 deletions src/WOLLOK.ROOT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wollokRoot
49 changes: 49 additions & 0 deletions src/adulto.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import ninio.*

class Adulto {

var niniosQueIntentaronAsustarlo = 0

method tolerancia() {
return 10 * niniosQueIntentaronAsustarlo
}

method seAsustaCon(asustador) {
return self.tolerancia() < asustador.capacidadDeSusto()
}

method caramelosQueDa() {
return self.tolerancia() / 2
}

method darCaramelos(asustador) {
asustador.recibirCaramelos(self.caramelosQueDa())
}

method recibirSusto(asustador) {
if (self.seAsustaCon(asustador)) {
self.darCaramelos(asustador)
}
if (asustador.tieneMasDe(15)) {
niniosQueIntentaronAsustarlo += 1
}
}

}

class Abuelo inherits Adulto {

override method seAsustaCon(asustador) = true

override method caramelosQueDa() {
return super() / 2
}

}

class Necio inherits Adulto {

override method seAsustaCon(asustador) = false

}

10 changes: 10 additions & 0 deletions src/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
log4j.rootLogger=WARN, stdout

# WHOLE UQBAR
log4j.logger.org.uqbar=WARN
## DEBUGGER
org.uqbar.project.wollok.ui.debugger

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
30 changes: 30 additions & 0 deletions src/ninio.wlk
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Ninio {

var elementos
var actitud
var caramelos = 0

constructor(unaActitud, elementosIniciales) {
actitud = unaActitud
elementos = elementosIniciales
}

method capacidadDeSusto() {
return elementos.sum({ elemento => elemento.capacidadDeSusto() }) * actitud
}

method asustar(alguien) {
alguien.recibirSusto(self)
}

method recibirCaramelos(cantidad) {
caramelos += cantidad
}

method tieneMasDe(cantidad) {
return caramelos > cantidad
}

method caramelos() = caramelos
}

24 changes: 24 additions & 0 deletions src/tests/ninios.wtest
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ninio.*
import adulto.*

describe "tests para ninos" {

var hijitus
var oaky
var abuelito
fixture {
hijitus = new Ninio(5, #{})
oaky = new Ninio(10, #{})
abuelito = new Abuelo()
}

test "hijitus no tiene elementos entonces su capacidad de susto es 0" {
assert.equals(0, hijitus.capacidadDeSusto())
}

// test "oaky asusta a un abuelo y recibe caramelos" {
// abuelito.recibirSusto(oaky)
// assert.equals(2.5, oaky.caramelos())
// }
}

0 comments on commit c88275c

Please sign in to comment.