class Cal
attr_reader :v1, :v2
attr_writer :v1
def initialize(v1,v2)
@v1 = v1
@v2 = v2
end
def add()
return @v1+@v2
end
def subtract()
return @v1-@v2
end
def setV1(v)
if v.is_a?(Integer)
@v1 = v
end
end
def getV1()
return @v1
end
end
class CalMultiply < Cal
def multiply()
return @v1*@v2
end
end
class CalDivide < CalMultiply
def divide()
return @v1/@v2
end
end
c1 = CalMultiply.new(10,10)
p c1.add()
p c1.multiply()
c2 = CalDivide.new(20, 10)
p c2, c2.add()
p c2, c2.multiply()
p c2, c2.divide()
Y2xhc3MgQ2FsCiAgYXR0cl9yZWFkZXIgOnYxLCA6djIKICBhdHRyX3dyaXRlciA6djEKICBkZWYgaW5pdGlhbGl6ZSh2MSx2MikKICAgIEB2MSA9IHYxCiAgICBAdjIgPSB2MgogIGVuZAogIGRlZiBhZGQoKQogICAgcmV0dXJuIEB2MStAdjIKICBlbmQKICBkZWYgc3VidHJhY3QoKQogICAgcmV0dXJuIEB2MS1AdjIKICBlbmQKICBkZWYgc2V0VjEodikKICAgIGlmIHYuaXNfYT8oSW50ZWdlcikKICAgICAgQHYxID0gdgogICAgZW5kCiAgZW5kCiAgZGVmIGdldFYxKCkKICAgIHJldHVybiBAdjEKICBlbmQKZW5kCmNsYXNzIENhbE11bHRpcGx5IDwgQ2FsCiAgZGVmIG11bHRpcGx5KCkKICAgIHJldHVybiBAdjEqQHYyCiAgZW5kCmVuZApjbGFzcyBDYWxEaXZpZGUgPCBDYWxNdWx0aXBseQogIGRlZiBkaXZpZGUoKQogICAgcmV0dXJuIEB2MS9AdjIKICBlbmQKZW5kCmMxID0gQ2FsTXVsdGlwbHkubmV3KDEwLDEwKQpwIGMxLmFkZCgpCnAgYzEubXVsdGlwbHkoKQpjMiA9IENhbERpdmlkZS5uZXcoMjAsIDEwKQpwIGMyLCBjMi5hZGQoKQpwIGMyLCBjMi5tdWx0aXBseSgpCnAgYzIsIGMyLmRpdmlkZSgpCg==