# -*- encoding: utf-8 -*-
#股票1
class Stock1
def buy
puts ‘股票1买入’
end
def sell
puts ‘股票1卖出’
end
end
#股票2
class Stock2
def buy
puts ‘股票2买入’
end
def sell
puts ‘股票2卖出’
end
end
#股票3
class Stock3
def buy
puts ‘股票3买入’
end
def sell
puts ‘股票3卖出’
end
end
#国债1
class NationalDebt1
def buy
puts ‘国债1买入’
end
def sell
puts ‘国债1卖出’
end
end
#房地产1
class Realty1
def buy
puts ‘房地产1买入’
end
def sell
puts ‘房地产1卖出’
end
end
#基金类
class Fund
attr_accessor s1, s2, s3, n1, r1
def initialize
s1=Stock1.new
s2=Stock2.new
s3=Stock3.new
n1=NationalDebt1.new
r1=Realty1.new
end
def buy
s1.buy
s2.buy
s3.buy
n1.buy
r1.buy
end
def sell
s1.sell
s2.sell
s3.sell
n1.sell
r1.sell
end
end
f1=Fund.new
f1.buy
f1.sell