Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions New folder/homework
Submodule homework added at b3f818
1 change: 1 addition & 0 deletions gitFromAtom/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testing
1 change: 0 additions & 1 deletion homework
Submodule homework deleted from 4fcd00
1 change: 1 addition & 0 deletions onlineRepo/aymanthefirst.github.io
Submodule aymanthefirst.github.io added at a1fc01
74 changes: 74 additions & 0 deletions ruby1/giraffe.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# puts "Hello world"
# anArray = ['1','2','3','4','5']
# puts anArray
# puts anArray.max
#
# i = 0
# while i < anArray.length
# item = anArray[i]
# puts "current item: #{item}"
# i+=1
# end

# x = 5
# if x > 2
# puts "x is greater than 2"
# elsif x <= 2 and x !=0
# puts "x is 1"
# else
# puts "i can't guess the number"
# end
#.....................................................................
# largest 2
#
#
# maxNum = 0
# secondMax = 0
# anArray = [7,1,8,3,4]
# i =0;
#
# while i < anArray.length
# if anArray[i] > maxNum
# maxNum = anArray[i]
# end
# i+=1
# end
#
# i =0;
# while i < anArray.length
# if anArray[i] > secondMax && anArray[i] != maxNum
# secondMax = anArray[i]
# end
# i+=1
# end
#
# puts maxNum
# puts secondMax
#
#//................................................................
smallest 2


smallestNum = 100
second = 100
anArray = [7,1,8,3,4]

i =0;
while i < anArray.length
if anArray[i] < smallestNum
smallestNum = anArray[i]
end
i+=1
end

i =0;
while i < anArray.length
if anArray[i] < second && anArray[i] != smallestNum
second = anArray[i]
end
i+=1
end


puts smallestNum
puts second
28 changes: 28 additions & 0 deletions ruby2/challenge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# # test whether string is palindrome
def check aString
if aString == aString.reverse
return "this string is a palindrome"

else
return "this string is not a palindrome"
end
end
$stdout.puts "please provide the string"
$stdout.flush
aString = $stdin.gets.chomp

testing = check aString
puts testing

# write a program that prints a multiplication table for numbers up to 12
def calc num1
for i in 0..12
puts "#{i} * #{num1} = #{i*num1}"
end
end

$stdout.puts "Please provide the number"
$stdout.flush
number = $stdin.gets.chomp.to_i

calc number
22 changes: 22 additions & 0 deletions ruby2/challenge2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# // add one number to another
# def summarise var1,var2=10
# var1+var2
# end
#
# sum = summarise 3,5
# puts sum

# def greet var1="hi ",var2="name"
# var1+var2
# end
#
# puts greet

# *******
# def say what, *words, ends
# for i in words
# puts "#{what} #{i} #{ends}"
# end
# end
#
# say "hello", "bob", "luke", "whatsup"
20 changes: 20 additions & 0 deletions ruby2/newClass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Create a class furniture that have width, height and length and method that calculates the area of the any instance of the class.
class Furniture
def initialize(w,h)
@width, @height = w, h
end

def getArea
@width * @height
end
end

# Create a derived class table which can also check if the table lower then 1 meter.
class Table < Furniture
def small
self.getArea < 1
end
end

aTable = Table.new(0.5,0.5)
puts aTable.small()
232 changes: 232 additions & 0 deletions ruby2/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# # puts "hello world"
# my_name = "ayman"
# puts "hello #{my_name}"
# first_num = 5.7
# second_num =3
# puts first_num + second_num
# puts "division #{first_num.to_f/second_num}" # to float
# # to string .to_s
# # to intiger .to_i
# puts first_num.ceil
# # puts first_num.methods
# # question mark means true or false
#
# puts "foo".is_a? String
# puts "foo".length
# puts "foo".downcase
# # puts "foo".uppercase
# puts "foo".reverse
# puts "foo".taint
# my_label = :text # static or symbol in ruby
# puts my_label
#
#
# ar = [1,4,5,6,:my_label]
# puts ar.last
# puts ar.pop
# puts ar.shift # oposite to pop
# puts ar.class
# puts my_name.class
#
#
# # map with key value
# person = {
# :name=> "Halil",
# :age=> 55
# }
# puts person[:name]
# # don't for got to use [:name] needs the : or there will be an eror
#
# puts "person is #{person[:name]} and age is #{person[:age]} "
#
# person2 = {
# name: "dan",
# age: 33
# }
#
# puts "person is #{person2[:name]} and age is #{person2[:age]} "
#
# 100 car
#
# number = 100
# item = ""
# if number > 1000000
# item = "house"
# end
# if number < 1000000 && number > 5000000
# item = "boat"
# end
# if number < 200000 && number > 200000
# iem = "car"
# end
# if number < 200000 && number > 300000
# item = "bank"
# end
# if number < 300000
# item = "life"
# end
#
# puts item
# name = gets
# # puts greeting.chars.sort.join
# # if name starts with a or ends with n say hello, if not say hi
# if name[0] == "a" || name[0] == "A" || name[name.length-2] == "l" || name[name.length-2] == "L"
# puts "hello #{name.capitalize}"
# else
# puts "hey #{name.capitalize}"
# end

# x = "3000"
# case x
# case 1000000..(Float::INFINITY)
# puts "house"
# when 500000..100000
# puts "boat"
# when 200000..500000
# puts "car"
# when 200000..300000
# puts "bank"
# when -(Floar::INFINITY)..30000
# puts "life"
# else
# puts "ERROR ERROR"
# i=0
# loop do
# puts "Smth"
# i+=1
# if i>5
# break
# end
# end
# ar = [1,2,3,4,5,6,7,8,9,10]
# i=0
# while i<10 do
# # puts ar[i]
# puts "#{ar[i]}"
# i+=1
# end

# find sum of elements
ar = [1,2,3,4,5]
# i = 0;
# sum = 0
# begin
# sum = sum+ar[i]
# i+=1
# end while i<ar.length
# puts sum
# mean = sum/2
# puts mean
#
#print elements on odd positions
# inverse loop
# i = 0
# until i>ar.length do
# if i%2 == 0
# puts ar[i]
#
# end
# i+=1
# end
# begin
# puts ar[i]
# i+=2
# end until i>ar.length

# for i in 0..ar.length
# puts ar[i]
# end
# for i in "a".."z"
# puts i
# end
# (3..7).each do |i|
# puts i
# end

# ar.each_with_index do |value, index|
# puts value
# puts index
# end

# ar2 = ["halil","ayman","three"]
# reverse = ar2.map do |word|
# puts word.reverse
# end

# ar = [1,2,3,4,5,6,7,8]
# sum = ar.reduce (0,:+)
# puts sum

# sum = ar.reduce 1 do |total, number|
# total*number
# end
# puts sum
# s= sum 3,5
#
# def sum num1,num2
# num1+num2
# end
#
# su = sum 3,5
# puts su

# weight = 100
# height = 1.50
# weight = weight*0.45
# height = height*0.025
# height = height*height
# bmi = weight/height.to_f
# puts "height: #{height} weight: #{weight} bmi: #{bmi}"
#
# distance = 6
# fuelEf = 3
# costPG = 5
# speed = 67
# if speed > 60
# for i in 60..speed
# fuelEf -=2
# i+=1
# end
# end
# time = speed/distance.to_f
# price = costPG/fuelEf.to_f
#
# puts "You're trip will take #{time.to_f.round(2)} hours and cost #{price.to_f.round(2)}"
# require "natural_time.rb"
# require 'rainbow'

# puts NaturalTime.to_sentence(65)


# puts Rainbow("this is red").red + " and " + Rainbow("this on yellow bg").bg(:yellow) + " and " + Rainbow("even bright underlined!").underline.bright
#
# "this string".red
# # => \e[31mthis string\e[0m
# "my string".blue
# # => \e[34mmy string\e[0m
# # etc...
#
# require 'colorize'
#
# String.colors # return array of all possible colors names
# String.modes # return array of all possible modes
# String.color_samples # displays color samples in all combinations
# String.disable_colorization # check if colorization is disabled
# String.disable_colorization = false # enable colorization
# String.disable_colorization false # enable colorization
# String.disable_colorization = true # disable colorization
# String.disable_colorization true # disable colorization
#
# puts "This is blue".colorize(:blue)
# puts "This is light blue".colorize(:light_blue)
# puts "This is also blue".colorize(:color => :blue)
# puts "This is light blue with red background".colorize(:color => :light_blue, :background => :red)
# puts "This is light blue with red background".colorize(:light_blue ).colorize( :background => :red)
# puts "This is blue text on red".blue.on_red
# puts "This is red on blue".colorize(:red).on_blue
# puts "This is red on blue and underline".colorize(:red).on_blue.underline
# puts "This is blue text on red".blue.on_red.blink
# puts "This is uncolorized".blue.on_red.uncolorize
#
rspec ./spec/person_spec.rb:11 # Person name should be a string
"ayman"./spec/person_spec.rb:11
1 change: 1 addition & 0 deletions ruby3/rubyyClass
Submodule rubyyClass added at 282907
Loading