Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Thing
- def initialize( aName, aDescription )
- @name = aName
- @description = aDescription
- puts ("Thing.initialize: #{self.inspect}\n\n")
- end
- def aMethod( aNewName )
- @name = aNewName
- puts ("Thing.aMethod: #{self.inspect}\n\n")
- end
- end
- class Thing2 < Thing
- def initialize( aName, aDescription)
- super
- @fulldescription = "this is #{@name}, which is #{@description}"
- puts ("Thing2.initialize: #{self.inspect}\n\n")
- end
- def aMethod( aNewName, aNewDescription )
- super( aNewName )
- puts ("Thing2.aMethod: #{self.inspect}\n\n")
- end
- end
- class Thing3 < Thing2
- def initialize( aName, aDescription, aValue )
- super( aName, aDescription )
- @value = aValue
- puts ("Thing3.initialize: #{self.inspect}\n\n")
- end
- def aMethod( aNewName, aNewDescription, aNewValue )
- super( aNewName, aNewDescription )
- @value = aNewValue
- puts ("Thing3.aMethod: #{self.inspect}\n\n")
- end
- end
- class Thing4 < Thing3
- def aMethod
- puts ("Thing4.aMethod: #{self.inspect}\n\n")
- end
- end
- class Thing5 < Thing4
- end
- t = Thing.new("a thing ", "a lovely full of thinginess")
- t.aMethod("a new thing")
- t2 = Thing2.new("a thing2", "a thing2 thing of great beauty")
- t2.aMethod("a new thing2", "a new thing2 description")
- t3 = Thing3.new("a thing3", "a thing3 full of thing and thing2iness",500)
- t3.aMethod("a new thing3", "and a new thing3 description",1000)
- t4 = Thing4.new("a thing4", "the nicest thing4 you will ever see",10)
- t4.aMethod
- t5 = Thing5.new("a thing5", "a very simple thing5",40)
- t5.aMethod
Add Comment
Please, Sign In to add comment