Skip to content

Instantly share code, notes, and snippets.

Created August 14, 2008 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save anonymous/5405 to your computer and use it in GitHub Desktop.
Save anonymous/5405 to your computer and use it in GitHub Desktop.
$KCODE = "UTF-8"
class BmiRechner
def initialize
self.get_name
puts "WIr werden jetzt herausfinden ob sie\n-zu dick\n-zu duenn\n-oder genau richtig sind."
end
def get_wert(frage)
puts(frage)
gets.chomp
end
def get_name
@name = self.get_wert("Hallo wie ist ihr Name?")
end
def get_gewicht
@gewicht = self.get_wert("Geben sie bitte ihr Gewicht ein.")
end
def get_groese
@groese = self.get_wert("Geben sie bitte ihre Groese in >>METERN<<(z.B 1.65) ein.")
end
def get_bestaetigung
self.get_wert("#{@name}, sie sind #{@groese} Groß und wiegen #{@gewicht}.\n Ist das richtig?\nBitte geben sie J oder N ein.")
end
def bmi_calculator
@bmi = @gewicht.to_i / (@groese.to_f ** 2)
end
def hallo
self.get_gewicht()
self.get_groese()
self.bmi_calculator
bestaetigung = self.get_bestaetigung()
if self.get_bestaetigung == "J"
self.output_results
else
puts "Dan nochmal"
hallo()
end
end
def output_results
puts "Gut. Ihr Bodymasindex betraegt #{@bmi}"
if @bmi < 19
puts "o.0 Schnell zu Mc Donalds^^"
elsif @bmi < 25
puts "PERFEKT"
elsif @bmi < 30
puts "SCHNELL INS FITNESSTUDIO"
end
end
end
lol = BmiRechner.new
lol.hallo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment