-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |