Skip to content

Commit

Permalink
Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
msatmod committed Aug 30, 2022
1 parent dff2e4a commit 5af06ef
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Day 9/Modules.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Program for Modules

module Trig

PI = 3.14159265359

def Trig.sinfunc(x)
puts Math.sin(x)
end
def Trig.cosfunc(x)
puts Math.cos(x)
end
end

module Moral

Very_bad = 0
Bad = 1

def Moral.sinfunc(badnesslevel)
if (badnesslevel == 0)
puts "THE MEGA is very bad"
else
puts "Amey is little bad"
end
end
end

puts Trig::PI

Trig.sinfunc(0)

Moral.sinfunc(Moral::Bad)
15 changes: 15 additions & 0 deletions Day 9/Modules_with_Class.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Program for MODULES

module Mymodule2
class TestClass
def initialize
puts "TestClass Object Created"
end
def mymethod
puts "It is a user defined method."
end
end
end

myobject = Mymodule2::TestClass.new
myobject.mymethod

0 comments on commit 5af06ef

Please sign in to comment.