well first I started programing with vb6. I became good at it. but I wanted to start with something solid and little easy. so I went for Ruby(ruby in steel)
i did this thing on ruby for tax rate calculation using this code
according to the tutorial I'm taking i did an cat and dog objects making them bark and miaow using this code
and thanks.
i did this thing on ruby for tax rate calculation using this code
taxrate = 0.17
LBP = 1.5
print "Enter object price:"
s = gets
subtotal = s.to_f
if (subtotal <0.0) then
subtotal = 0.0
end
tax = subtotal * taxrate
puts "tax on object is 17% => Tax on $#{subtotal} is $#{tax}, so grand total is $#{subtotal+tax}"
tax = (subtotal+tax) * LBP
puts "it will cost #{tax} in LBP"
doing this on ruby is easier than VB6 but there is something that confused me that is doing objects on ruby.according to the tutorial I'm taking i did an cat and dog objects making them bark and miaow using this code
class Dog
def set_name( aName )
@myname = aName
end
def get_name
return @myname
end
def talk
return 'woof!'
end
end
class Cat
def set_name( aName )
@myname = aName
end
def get_name
return @myname
end
def talk
return 'miaow!'
end
end
mydog = Dog.new
yourdog = Dog.new
mycat = Cat.new
yourcat = Cat.new
someotherdog = Dog.new
mydog.set_name( 'Fido' )
yourdog.set_name( 'Bonzo' )
mycat.set_name( 'Tiddles' )
yourcat.set_name( 'Flossy' )
puts(mydog.get_name)
puts(yourdog.get_name)
puts(someotherdog.get_name)
puts(mycat.get_name)
puts(yourcat.get_name)
puts(mydog.talk)
puts(yourdog.talk)
puts(mycat.talk)
puts(yourcat.talk)
but all is given to me is text. i can get the same result if i just made them a text using puts or print, while in vb6 i can draw a dog and put the cat and make them bark or miaow by clicking on them or something. so i didn't really know what the purpose of using all this code to make object that gives me only writings. I mean where is the object? can someone explain or something? and thanks.