diff --git a/.gitignore b/.gitignore index 1ee84da..e03d470 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.DS_Store *.sw* diff --git a/objects_class/actor.rb b/objects_class/actor.rb new file mode 100644 index 0000000..d831598 --- /dev/null +++ b/objects_class/actor.rb @@ -0,0 +1,26 @@ +class Actor + + attr_accessor :genre + + def initialize(show_name, actor_name, genre) + @show_name = show_name + @actor_name = actor_name + @genre = genre + end + + def altered_carbon_show + if @show_name == "Altered Carbon" + "I'm an actor of this show" + else + "I don't work here" + end + end + + def actor + @actor_name + end + + def show_name + @show_name + end +end \ No newline at end of file diff --git a/objects_class/actress.rb b/objects_class/actress.rb new file mode 100644 index 0000000..2a4200d --- /dev/null +++ b/objects_class/actress.rb @@ -0,0 +1,13 @@ +class Actress < Entertainment + def initialize(netflix_show, genre, schedule, price) + @netflix_show = netflix_show + @genre = genre + @schedule = schedule + @price = price + end + + #show en el que sale + def actress_shows + "Show 1" + end +end \ No newline at end of file diff --git a/objects_class/car.rb b/objects_class/car.rb new file mode 100644 index 0000000..ff07e29 --- /dev/null +++ b/objects_class/car.rb @@ -0,0 +1,36 @@ +class Car + + attr_accessor :location + + def initialize(gps, location, speed) + @gps = gps + @location = location + @speed = speed + end + + def self_driving + "Driving" + end + + def to_s + "My speed is #{@speed}" + end + + def speed_limit + if @speed.eql?40 + "You are driving OK" + else + "Slow down duuuude" + end + end + + def detect_accident + if @location.eql?("Bogotá") && @gps <= 30 + "There's an accident, you should change your route" + else + "I can't find anything" + end + end + +end + diff --git a/objects_class/chair.rb b/objects_class/chair.rb new file mode 100644 index 0000000..1b8ed84 --- /dev/null +++ b/objects_class/chair.rb @@ -0,0 +1,25 @@ +class Chair + def initialize(year, type) + @year = year + @type = type + end + + def group_car_chair + if @type == "car" + "This is a chair for a car" + else + "This is another type of chair" + end + end + + def maintenance_chair + if @year < 2000 + "You should check the state of your chair" + else + "It's functional" + end + end +end + +new_chair = Chair.new(2018, "car") +p new_chair.maintenance_chair \ No newline at end of file diff --git a/objects_class/entertaiment.rb b/objects_class/entertaiment.rb new file mode 100644 index 0000000..001a815 --- /dev/null +++ b/objects_class/entertaiment.rb @@ -0,0 +1,3 @@ +class Entertainment + #relacionar tv con actriz +end \ No newline at end of file diff --git a/objects_class/entertainment.rb b/objects_class/entertainment.rb new file mode 100644 index 0000000..79e797a --- /dev/null +++ b/objects_class/entertainment.rb @@ -0,0 +1,12 @@ +require './tv_new' + + +new_tv = TvNew.new("netflix", "scifi", "Comercial carros") +puts new_tv.inspect +puts new_tv.comercial +puts new_tv.new_actor("Mute", "Lina", "Drama") +puts new_tv.show_actor_shows +puts new_tv.show_actor_genre + +puts new_tv.new_car(100, "Cali", 60) +puts new_tv.go_to_comercial \ No newline at end of file diff --git a/objects_class/module.rb b/objects_class/module.rb new file mode 100644 index 0000000..84b1e9f --- /dev/null +++ b/objects_class/module.rb @@ -0,0 +1,6 @@ +require '.tv_new' +require '.actor' + +module ActorShow + +end \ No newline at end of file diff --git a/objects_class/tv.rb b/objects_class/tv.rb new file mode 100644 index 0000000..d2dedd0 --- /dev/null +++ b/objects_class/tv.rb @@ -0,0 +1,58 @@ +require './actress' + +class Tv + + def initialize(smart, screen, size, energy) + @smart = smart + @screen = screen + @size = size + @energy = energy + end + + #muestre el menu con las opciones + def show_menu + menu + @home = home + @channels = {"Sony channel" => 10, "Warner channel" => 20, "Fox channel" => 30} + @store = store + @netflix = netflix + end + + #cambie los canales + def change_channels + end + + #vaya a la app de netflix + def go_to_netflix_show(netflix_show) + #para relacionar al tv con la actriz + actress_show + end + + #vaya al store + def go_to_store + end + + #encender + def turn_on + "Welcome to this new experience" + end + + #apagar + def turn_off + "Bye" + end + + #menú + def menu + if @size >= 52 + puts "Home" + puts "Channels" + puts "Store" + else + turn_off + end + end +end + +new_tv = Tv.new("smart", "flat", 52, 260) +puts new_tv.show_menu \ No newline at end of file diff --git a/objects_class/tv_new.rb b/objects_class/tv_new.rb new file mode 100644 index 0000000..69e8873 --- /dev/null +++ b/objects_class/tv_new.rb @@ -0,0 +1,51 @@ +require './actor' +require './car' + +class TvNew + + attr_accessor :lina + attr_accessor :comercial + + def initialize(app, genre, comercial) + @app = app + @genre = genre + @comercial = comercial + end + + def go_to_netflix + if @app == "netflix" + "This is Netflix what you want to watch?" + else + "You're watching " + end + end + + def altered_carbon_show + if @app == "netflix" && @genre == "scifi" + "Altered Carbon -> Play" + else + "Choose another show" + end + end + + def new_actor(show_name, actor_name, genre) + @lina ||= Actor.new(show_name, actor_name, genre) + end + + def show_actor_shows + lina.show_name + end + + def show_actor_genre + lina.genre + end + + def new_car(gps, location, speed) + @car_new ||= Car.new(gps, location, speed) + end + + + def go_to_comercial + car_new.speed + end +end \ No newline at end of file diff --git a/objects_examples/tv.rb b/objects_examples/tv.rb index 7ce92ce..38cf2fa 100644 --- a/objects_examples/tv.rb +++ b/objects_examples/tv.rb @@ -25,12 +25,12 @@ def change_channel(new_channel) end end - def actor(actor_name) - Actor.new(actor_name) - end - # def actor(actor_name) -# @actor ||= Actor.new(actor_name) +# Actor.new(actor_name) # end -end + def actor(actor_name) + @actor ||= Actor.new(actor_name) + end + +end \ No newline at end of file diff --git a/ruby_1/challenges.rb b/ruby_1/challenges.rb index 282508c..7783848 100644 --- a/ruby_1/challenges.rb +++ b/ruby_1/challenges.rb @@ -11,7 +11,7 @@ 3. Add the body to the funciont max_number that outputs the higher number between two inputs -3. Add the body to the funciont is_in_my_range? that outputs if a number is between 0 and 100 +3. Add the body to the funciont is_in_my_range? that outputs if a number is between 0 and 100 =end