Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object lobo {
- var caloria = 1000
- method saberCaloria(){
- return caloria
- }
- method comer(algo){
- caloria=(algo.calculaPeso() + caloria)
- }
- method estaGordo(){
- return caloria > 21
- }
- method estaSaludable(){
- return caloria >= 20 and caloria <= 150
- }
- method caloriaCorrer(tiempo){
- caloria=caloria-tiempo*2
- }
- method correr(lugar){
- self.caloriaCorrer(lugar.calculaTiempo())
- }
- method soplarCasa(casa){
- caloria = caloria - (casa.calcularResistencia() + casa.pesoHabitante())
- }
- }
- object narrador {
- method secuencia(){
- lobo.correr(bosque)
- lobo.comer(chancho1)
- lobo.correr(casaAbuela)
- lobo.comer(abuela)
- lobo.comer(caperucita)
- if(lobo.estaSaludable()){
- console.println('Esta saludable')
- }
- if(lobo.estaGordo()){
- console.println('Esta Gordo')
- }
- }
- }
- object casaAbuela{
- var distancia = 50
- method calculaTiempo(){
- return (distancia*2)
- }
- }
- object bosque{
- var distancia = 100
- method calculaTiempo(){
- return (distancia*2)
- }
- }
- object chancho1{
- var peso = 100
- method calculaPeso(){
- return (peso/10)}
- method kilos(){
- return peso
- }
- }
- object chancho2{
- var peso = 200
- method kilos(){
- return peso
- }
- }
- object chancho3{
- var peso = 300
- method kilos(){
- return peso
- }
- }
- object caperucita{
- var calorias= 200
- method calculaPeso(){
- calorias = calorias + canastita.manzana()
- return calorias
- }
- }
- object canastita{
- var manzanas=20
- var calorias
- method manzana(){
- calorias = manzanas*2
- return calorias
- }
- }
- object abuela {
- var calorias=0
- method calculaPeso(){
- return calorias
- }
- }
- object casaPaja{
- var resistencia = 0
- var habitante = chancho1
- method calcularResistencia(){
- return resistencia
- }
- method pesoHabitante(){
- return chancho1.kilos()
- }
- }
- object casaMadera{
- var resistencia =5
- var habitante= chancho2
- method calcularResistencia(){
- return resistencia
- }
- method pesoHabitante(){
- return chancho2.kilos()
- }
- }
- object casaLadrillos{
- var habitante= chancho3
- var ladrillos = 10
- method calcularResistencia(){
- return ladrillos*2
- }
- method pesoHabitante(){
- return chancho3.kilos()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement