View Single Post
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2006-01-25, 13:48

I'm gonna respond, but I've already passed the three minutes, so good night.

For reference, here's the original palindrome code (here's hoping vBulletin, unlike WordPress, doesn't mangle it). It strips uppercase, spaces and the last character of a line, so it works with a lot of things. But it's not object-oriented. And your two-class approach doesn't strike me as particularly object-oriented either. After all, my code is already pretty much split in two (a procedure that returns the results of the check, and a main block that handles the input).

Code:
#!/usr/bin/env ruby def isAPalindrome?(text) puts text if text.downcase.delete(" ").chop == text.downcase.delete(" ").chop.reverse then return true else return false end end input = gets if isAPalindrome?(input) then puts "\""+input.chop+"\" is a palindrome indeed!" else puts "But no, it is not." end

Last edited by chucker : 2006-01-25 at 13:54.
  quote