|
Coding!
Sept 13, 2011 15:05:53 GMT -5
Post by ♫Moonbane♫ on Sept 13, 2011 15:05:53 GMT -5
Cool! That's lucky, I actually have seen WarGames! (I really don't see movies much) The code basically looks good. But you need to remember that when you use an "if" statement, there has to be something to compare the answer to. This: gets.chomp if = 'NO' ... Will not work, but this: if gets.chomp == 'NO' ... should work fine. Also remember to use a == instead of a = when comparing. Hopefully this makes sense (I've never been a good explainer). If not, I fixed this in the code, so this should work: puts 'PLEASE INPUT STARTUP CODE'
if gets.chomp == 'CPE 1704 TKS' puts 'Hello, Professor Falken.' puts 'Would you like to play a game? (YES | NO)' if gets.chomp == 'NO' puts 'Oh, well, too bad then. Shutting down...' else # if it is not 'NO'... puts 'Alright, then. Truth, or dare?' if gets.chomp == 'Truth' puts 'WHY WAS I CREATED?' # user input doesn't matter here -- it's always wrong :D gets else # meaning dare... puts 'I DARE YOU TO KILL YOURSELF.' end end end
Alternatively, you can use a "case" statement like I did in my game. This lets you compare user input options more easily. So: puts 'Truth or dare?'
case gets.chomp when 'Truth' puts 'WHY WAS I CREATED' when 'Dare' puts 'I DARE YOU TO KILL YOURSELF' when 'Toothless' puts 'WRONG MOVIE' end
Hope this helps! Hmm... It seems to work, except when I insert Truth. The line goes down, but the "puts" command doesn't come up. So I don't see his question, and it just ends. No warning message, even. Also, when I try to hit "no" to refuse the game, it goes to truth or dare.
|
|
|
Coding!
Sept 13, 2011 19:24:54 GMT -5
Post by IcelandicEel on Sept 13, 2011 19:24:54 GMT -5
Oh, well, are you making sure that the input is capitalized properly? In Ruby, 'no' is not the same thing as 'NO' or 'No'. The same issue might be the cause of the 'Truth' bug. If you don't want capitalization to matter, try: if gets.chomp.upcase == 'no'.upcase (or 'truth'.upcase, or whatever) toothless11: Have you installed Ruby?
|
|
|
Coding!
Sept 13, 2011 20:37:22 GMT -5
Post by toothless11 on Sept 13, 2011 20:37:22 GMT -5
Well I went to the page and it only had the Source download :/. But all the coding looks confusing XD.
|
|
|
Coding!
Sept 13, 2011 20:52:41 GMT -5
Post by IcelandicEel on Sept 13, 2011 20:52:41 GMT -5
Do you run Windows? If you do, try downloading this: rubyinstaller.org/Coding is confusing! It's basically like learning another language (though a little easier, in my opinion). It's also easier to read when it's indented. Because of this I can't even read my own Dragon program anymore.
|
|
|
Coding!
Sept 13, 2011 20:55:09 GMT -5
Post by toothless11 on Sept 13, 2011 20:55:09 GMT -5
Oh, lol XD. Well it looks hard . And I can't download the installer right now . I have like 30 MB left in my computers disk space .
|
|
|
Coding!
Sept 13, 2011 21:08:36 GMT -5
Post by IcelandicEel on Sept 13, 2011 21:08:36 GMT -5
No, that's not very good, is it? Generally, it's not a good thing to have more RAM than hard drive space... Then you'd need reverse virtual memory! (computer science joke, ignore By the way, with this post (#50) I have finally become a Viking! ;D
|
|
|
Coding!
Sept 13, 2011 21:10:14 GMT -5
Post by toothless11 on Sept 13, 2011 21:10:14 GMT -5
Lol my comp has like 600 MB of RAM. It SUCKS :/.
|
|
|
Coding!
Sept 13, 2011 21:13:02 GMT -5
Post by IcelandicEel on Sept 13, 2011 21:13:02 GMT -5
Ha, mine is 2 GB!
|
|
|
Coding!
Sept 13, 2011 21:14:36 GMT -5
Post by toothless11 on Sept 13, 2011 21:14:36 GMT -5
Lol lucky .
|
|
|
Coding!
Sept 13, 2011 21:18:59 GMT -5
Post by IcelandicEel on Sept 13, 2011 21:18:59 GMT -5
Although I don't really notice too much of a difference compared to computers with less RAM. I'm not a very heavy user of RAM.
|
|
|
Coding!
Sept 13, 2011 21:20:36 GMT -5
Post by toothless11 on Sept 13, 2011 21:20:36 GMT -5
Lol, the less the RAM, the slower the computer XD. My computer is so slow, that most of the times right clicking the desktop makes the thing that comes out take like a minute to appear .
|
|
|
Coding!
Sept 13, 2011 21:37:10 GMT -5
Post by IcelandicEel on Sept 13, 2011 21:37:10 GMT -5
I know what you mean! I just try to do that as infrequently as possible.
|
|
|
Coding!
Sept 13, 2011 22:23:40 GMT -5
Post by toothless11 on Sept 13, 2011 22:23:40 GMT -5
Haha lol XD. Well, about a few weeks ago my sister was gonna send us a laptop, but it's too expensive so she said that she was gonna wait like a month or so so she can raise money to send it.
|
|