Guest User

Untitled

a guest
Jun 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.53 KB | None | 0 0
  1. class Thing
  2.   def initialize( aName, aDescription )
  3.     @name = aName
  4.     @description = aDescription
  5.     puts ("Thing.initialize: #{self.inspect}\n\n")
  6.   end
  7.  
  8.   def aMethod( aNewName )
  9.     @name = aNewName
  10.     puts ("Thing.aMethod: #{self.inspect}\n\n")
  11.   end
  12. end
  13.  
  14. class Thing2 < Thing
  15.   def initialize( aName, aDescription)
  16.     super
  17.     @fulldescription = "this is #{@name}, which is #{@description}"
  18.     puts ("Thing2.initialize: #{self.inspect}\n\n")
  19.   end
  20.  
  21.   def aMethod( aNewName, aNewDescription )
  22.     super( aNewName )
  23.     puts ("Thing2.aMethod: #{self.inspect}\n\n")
  24.   end
  25. end
  26.  
  27. class Thing3 < Thing2
  28.   def initialize( aName, aDescription, aValue )
  29.     super( aName, aDescription )
  30.     @value = aValue
  31.     puts ("Thing3.initialize: #{self.inspect}\n\n")
  32.   end
  33.  
  34.   def aMethod( aNewName, aNewDescription, aNewValue )
  35.     super( aNewName, aNewDescription )
  36.     @value = aNewValue
  37.     puts ("Thing3.aMethod: #{self.inspect}\n\n")
  38.   end
  39. end
  40.  
  41. class Thing4 < Thing3
  42.   def aMethod
  43.     puts ("Thing4.aMethod: #{self.inspect}\n\n")
  44.   end
  45. end
  46.  
  47. class Thing5 < Thing4
  48. end
  49.  
  50. t = Thing.new("a thing ", "a lovely full of thinginess")
  51. t.aMethod("a new thing")
  52.  
  53. t2 = Thing2.new("a thing2", "a thing2 thing of great beauty")
  54. t2.aMethod("a new thing2", "a new thing2 description")
  55.  
  56. t3 = Thing3.new("a thing3", "a thing3 full of thing and thing2iness",500)
  57. t3.aMethod("a new thing3", "and a new thing3 description",1000)
  58.  
  59. t4 = Thing4.new("a thing4", "the nicest thing4 you will ever see",10)
  60. t4.aMethod
  61.  
  62. t5 = Thing5.new("a thing5", "a very simple thing5",40)
  63. t5.aMethod
Add Comment
Please, Sign In to add comment