------art_24199_22326389.1213474347298
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Sat, Jun 14, 2008 at 2:53 PM, Sebastian Hungerecker <
sepp2k / googlemail.com> wrote:

>
> You set index to 0 at every iteration of the loop.
>

Yes, but beyond that here's a critique of this code in the way of a
refactoring:

class Customer
  @@no_of_customers # I personally wouldn't use a class variable here,
but I'll let it go.

  def initialize(id, name, addr)
    @id
    @name
me
    @addrr
    # If we are really counting customers we should do it
    # when they each customer is created
    # not when they are displayed since
    # a customer just might get displayed more than once
    # or not at all.
    @@no_of_customers+  end

  def display_details()
    puts "Customer ID #@id"
    puts "Customer Name #@name"
    puts "Customer Address #@addr"
  end

  # I'd make this a class method since the number of customers
  # is a property of the class rather than each instance.
  def self.total_customers
    puts "total no. of customers are #@@no_of_customers"
  end
end

# This was just too C/Fortran like, let's treat the array like
# an object, not just a static array!
#
# Since we're collecting the customers here,
# we need to instantiate the array once, not everytime
# through the loop, and let's use a clearer name:

customers  ]

# Let's lose the magic variable $_! and make this a
# bit more understandable

more  y"
# note also that this was $_!  n" which is an assignment
# NOT a comparison

until(more "n")
  print "Enter user id "
  # We need to send chomp to the string we got, not self!
  id 
   「ナ   「
   
   「ナ   「
   
  」 フ          
   シシ テョィャャゥ
   「       ッ 「
     


」 チ          テッツッニュ コ
ョ  
   ョ゜ィゥ


ノ     ァ    ゜ ャ 
  ノ      

 テョ゜

ネ           テ 
   ャ   
           

 ョ



ュュ 
メ トホ

ヘ   メ
コッッョイョッ

ュュュュュュ゜イエアケケ゜イイウイカウクケョアイアウエキエウエキイケクュュ