0 Members and 1 Guest are viewing this topic.
while 1puts 'Type whatever you want here!'text = gets.chompputs textif text == 'Quit' abortendend
guess = 10000puts 'Guess a number from 0 to 50!'number = rand(50)while guess > 0 guess = gets.to_i if guess == number puts 'Great job! You guessed the number!' abort elsif guess > number puts 'That is not the right number.' puts 'Try again, with a LOWER number' elsif guess < number puts 'That is not the right number.' puts 'Try again, with a HIGHER number' endend
--snip--Also, a guessing game If you have ruby installed, run the attached file.Else, install it Code: [Select]guess = 10000puts 'Guess a number from 0 to 50!'number = rand(50)while guess > 0 guess = gets.to_i if guess == number puts 'Great job! You guessed the number!' abort elsif guess > number puts 'That is not the right number.' puts 'Try again, with a LOWER number' elsif guess < number puts 'That is not the right number.' puts 'Try again, with a HIGHER number' endend
Yeah, I like how much it is like a basic language. Another good thing, is that there are a few ruby dev environments in the cloud, like cloud9
Good idea! But be reminded, this wasn't on calc.
You could sell designs to TI or HP or Casio
Quote from: Unicorn on July 19, 2015, 02:24:04 amGood idea! But be reminded, this wasn't on calc. It would be great if there were ARM powered calculators that ran a *nix OS (probably BSD. That seems like a good fit for a calculator!) so you could use any language you wanted without having to do much work porting, as well as use many programs targeted at desktop devices.now I know what I should do with a future computer science degree
Quote from: Strontium on July 19, 2015, 03:43:52 amQuote from: Unicorn on July 19, 2015, 02:24:04 amGood idea! But be reminded, this wasn't on calc. It would be great if there were ARM powered calculators that ran a *nix OS (probably BSD. That seems like a good fit for a calculator!) so you could use any language you wanted without having to do much work porting, as well as use many programs targeted at desktop devices.now I know what I should do with a future computer science degree * Juju points to Nspire Linux >.>
require 'green_shoes'guess = 0ans = rand(1...50)Shoes.app(title: "RubyGuess") do while 1guess = ask("Guess a Numer from 1 - 50")guess = guess.to_i if guess == ans alert "Great Job! You guessed the number!" if confirm("Quit?") exit end endif guess != ans if guess > ans quit = confirm(" You did not guess the number. Try a lower number.") end if guess < ans quit = confirm(" You did not guess the number. Try a higher number") end if quit == false exit end end end end