From 73b18120d59dd1ccfb06a74e6309b650ee3add01 Mon Sep 17 00:00:00 2001 From: zoroksana Date: Mon, 12 Jun 2017 10:04:11 +0300 Subject: [PATCH 1/3] Add files via upload --- Svyryda_Homework2.patch | 105 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Svyryda_Homework2.patch diff --git a/Svyryda_Homework2.patch b/Svyryda_Homework2.patch new file mode 100644 index 0000000..7f6a355 --- /dev/null +++ b/Svyryda_Homework2.patch @@ -0,0 +1,105 @@ +Index: lib/topics/state_and_behaviour.rb +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- lib/topics/state_and_behaviour.rb (date 1497217375000) ++++ lib/topics/state_and_behaviour.rb (revision ) +@@ -1,40 +1,29 @@ + # frozen_string_literal: true + + # exercise state and behaviour +-class Newspaper +- def every_day +- "Actual newspaper is publised every day" ++module StateAndBehaviour ++ +- end ++end ++class Car ++ attr_accessor :year,:color,:model,:current_speed ++ ++ ++def initialize (car_attributes) ++ @year=car_attributes[:year] || 2015 ++ @color=car_attributes[:color] || 'purple' ++ @model=car_attributes[:model] || 'skyline' ++ @current_speed = car_attributes[:current_speed] = 8 +-end ++ end +-class Magazine +- def every_week +- "Fresh magazine is published every week" ++ ++def speed_up (speed_is_raising) ++ @current_speed+=speed_is_raising +- end ++end ++ ++def push_break (speed_decrease) ++ @current_speed-=speed_decrease + end +-class Book +- def writer_under_inspiration +- "Readers are waiting for bestseller" +- end +-end + +-module StateAndBehaviour +- class Print_Edition +- attr_reader :periodicity +- def initialize (periodicity) +- @periodicity =periodicity ++def self.default_car ++ Car.new(default_car) +- end ++end +- def periodicity +- case periodicity +- when Newspaper +- periodicity.every_day +- when Magazine +- periodicity.every_week +- when Book +- periodicity.writer_under_inspiration +- end ++end +- c = Print_Edition.new(Book.new) +- c.periodicity +- end +- end +-end +- +Index: lib/topics/object_model.rb +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +--- lib/topics/object_model.rb (date 1497217375000) ++++ lib/topics/object_model.rb (revision ) +@@ -2,5 +2,24 @@ + + # exercise object model + module ObjectModel ++ module Linux_Friendly ++ def fork_process ++ super ++ end ++ ++ end ++ ++ class Desktop ++ def fork_process ++ "Parent: allocate memory" ++ end ++ def mine_bitcoins ++ inspect ++ end ++ end ++ ++ class Laptop < Desktop ++ prepend Linux_Friendly ++ end +- ++ + end From 76bbe398397695a5d8ecf1ddbabeec4cb6f360f0 Mon Sep 17 00:00:00 2001 From: zoroksana Date: Mon, 12 Jun 2017 10:06:12 +0300 Subject: [PATCH 2/3] Create object_model.rb Svyryda.Homework.Object_Model --- lib/topics/object_model.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/topics/object_model.rb b/lib/topics/object_model.rb index 6c55a4f..0ae656a 100644 --- a/lib/topics/object_model.rb +++ b/lib/topics/object_model.rb @@ -2,4 +2,24 @@ # exercise object model module ObjectModel + module Linux_Friendly + def fork_process + super + end + + end + + class Desktop + def fork_process + "Parent: allocate memory" + end + def mine_bitcoins + inspect + end + end + + class Laptop < Desktop + prepend Linux_Friendly + end + end From e78a430733bb58e95ead362477c5264b8fa87fb1 Mon Sep 17 00:00:00 2001 From: zoroksana Date: Mon, 12 Jun 2017 10:07:52 +0300 Subject: [PATCH 3/3] Create state_and_behaviour.rb Svyryda.Homework2.State_and_behavior --- lib/topics/state_and_behaviour.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/topics/state_and_behaviour.rb b/lib/topics/state_and_behaviour.rb index d7b35a0..773052d 100644 --- a/lib/topics/state_and_behaviour.rb +++ b/lib/topics/state_and_behaviour.rb @@ -2,4 +2,28 @@ # exercise state and behaviour module StateAndBehaviour + +end +class Car + attr_accessor :year,:color,:model,:current_speed + + +def initialize (car_attributes) + @year=car_attributes[:year] || 2015 + @color=car_attributes[:color] || 'purple' + @model=car_attributes[:model] || 'skyline' + @current_speed = car_attributes[:current_speed] = 8 + end + +def speed_up (speed_is_raising) + @current_speed+=speed_is_raising +end + +def push_break (speed_decrease) + @current_speed-=speed_decrease +end + +def self.default_car + Car.new(default_car) +end end