Sha256: 14cc2a65e4d419d111d0633ed40ccb9309cd17e7e8b34943810ecfb53e5a6a51

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 Bytes

Contents

class Pat
	attr_accessor :a, :b

	def initialize(a, b)
		self.a = a
		self.b = b
	end

	def sum_alg
		a+b
	end

	def mult_alg
		a*b
	end

	def minus_alg
		a-b
	end

	def alg
		sum_alg+mult_alg+minus_alg
	end
end

class PatInhetit1 < Pat
	def sum_alg
		a+b+2
	end
end

class PatInhetit2 < Pat
	def mult_alg
		a*b*3
	end
end

pat = Pat.new(4, 2)
pat1 = PatInhetit1.new(4, 2)
pat2 = PatInhetit2.new(4, 2)

puts(pat.alg)
puts(pat1.alg)
puts(pat2.alg)

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mc_gem-0.0.1 Lab2/examples/pattern_pattern.rb
mvcStudentXD-1.2.1 Lab2/examples/pattern_pattern.rb