-
Notifications
You must be signed in to change notification settings - Fork 0
Hometask 1 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Hometask 1 #1
Changes from 9 commits
8b0efe6
5ba59b4
af4e2ea
ba36235
f357222
79b4cbd
b1c77a4
6e991d8
41b4ce0
b00fe25
bd5820f
4a920da
83bf4cd
77e09e4
f874e4d
83cc4d4
3ec2140
d08083a
401450a
2e2f0b4
6bf7c85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| array1 = ["apple", "onion", "orange"] | ||
| array2 = ["apple", "onion", "orange", "Sugar"] | ||
| array1 & array2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| numbers = [45, 3123, 2141, 387, 15463, 6] | ||
| numbers.sort! {|x, y| y <=> x} | ||
| puts numbers |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| class Home | ||
| def initialize(color) | ||
| @color = color | ||
| end | ||
| end | ||
| p Home.new(1).method(:initialize).source_location | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| class Numbers | ||
| def sum(number, other) | ||
| number + other | ||
| end | ||
|
|
||
| def difference(number, other) | ||
| number - other | ||
| end | ||
|
|
||
| def multiplication(number, other) | ||
| number * other | ||
| end | ||
|
|
||
| def division(number, other) | ||
| number / other | ||
| end | ||
| end | ||
| calculator = Numbers.new | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In example to task 6 you can see next |
||
| puts calculator.sum(5, 10) | ||
| puts calculator.difference(5, 10) | ||
| puts calculator.multiplication(5, 10) | ||
| puts calculator.division(5, 10) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,8 @@ class New | |
| def task | ||
| myArray = ["stuff", "widget", "ruby", "goodies", "java", "emerald", "etc" ] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this script must take arguments from outside ( |
||
| item = myArray[rand(myArray.length)] | ||
| puts item | ||
| end | ||
| end | ||
| a = New.new | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should create instance outside of class body |
||
| a.task | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong realization of task. The script should take the NAME OF TEXT FILE and the LINE.