From 2ae574472d54e704293d6881f8a61ec725def3a1 Mon Sep 17 00:00:00 2001 From: meatball Date: Sat, 17 Aug 2024 16:01:14 +0200 Subject: [PATCH] Changes based on feedback --- concepts/getters-setters/.meta/config.json | 4 ++-- concepts/getters-setters/about.md | 4 ++-- concepts/getters-setters/introduction.md | 4 ++-- exercises/concept/task-handler/.docs/test.cr | 5 ----- exercises/concept/weighing-machine/.docs/hints.md | 4 ++-- exercises/concept/weighing-machine/.docs/instructions.md | 9 +++++---- exercises/concept/weighing-machine/.docs/introduction.md | 4 ++-- exercises/concept/weighing-machine/.meta/config.json | 1 + .../weighing-machine/spec/weighing_machine_spec.cr | 4 ++-- 9 files changed, 18 insertions(+), 21 deletions(-) delete mode 100644 exercises/concept/task-handler/.docs/test.cr diff --git a/concepts/getters-setters/.meta/config.json b/concepts/getters-setters/.meta/config.json index 1bc4bc97..b5cf3f2b 100644 --- a/concepts/getters-setters/.meta/config.json +++ b/concepts/getters-setters/.meta/config.json @@ -1,5 +1,5 @@ { - "blurb": "Crystal has macros for defining getters and setters. Which is used to access and modify the instance variables of a class.", + "blurb": "Crystal has macros for defining getters and setters. These are used to access and modify the instance variables of a class.", "authors": ["meatball133"], - "contributors": [] + "contributors": ["ryanplusplus"] } diff --git a/concepts/getters-setters/about.md b/concepts/getters-setters/about.md index 969091ae..1bbdec87 100644 --- a/concepts/getters-setters/about.md +++ b/concepts/getters-setters/about.md @@ -12,7 +12,7 @@ Crystal has defined these as `getter`, `setter` and `property` macros. Getter is a macro that defines a method that returns the value of an instance variable. This means that you no longer have to write `@` in front of the instance variable when you want to access it (in methods, excluding initialize); instead, you can call the method that the getter macro has defined. -The getter macro can accept multiple instance variables by separating them with a comma. +The getter macro can accept multiple instance variables by separating them with commas. ```crystal # This: @@ -44,7 +44,7 @@ Symbols will be covered later in the symbol concept. ## Setters -Setters is a macro that defines a method that sets the value of an instance variable. +Setter is a macro that defines a method that sets the value of an instance variable. This macro isn't that often found and is commonly the `property` macro used instead. The methods that will be created will look like `name_of_method=`; the `=` is what makes it so the property can be set. diff --git a/concepts/getters-setters/introduction.md b/concepts/getters-setters/introduction.md index 01a5024b..adc75f71 100644 --- a/concepts/getters-setters/introduction.md +++ b/concepts/getters-setters/introduction.md @@ -12,7 +12,7 @@ Crystal has defined these as `getter`, `setter` and `property` macros. Getter is a macro that defines a method that returns the value of an instance variable. This means that you no longer have to write `@` in front of the instance variable when you want to access it (in methods, excluding initialize); instead, you can call the method that the getter macro has defined. -The getter macro can accept multiple instance variables by separating them with a comma. +The getter macro can accept multiple instance variables by separating them with commas. ```crystal # This: @@ -44,7 +44,7 @@ Symbols will be covered later in the symbol concept. ## Setters -Setters is a macro that defines a method that sets the value of an instance variable. +Setter is a macro that defines a method that sets the value of an instance variable. This macro isn't that often found and is commonly the `property` macro used instead. The methods that will be created will look like `name_of_method=`; the `=` is what makes it so the property can be set. diff --git a/exercises/concept/task-handler/.docs/test.cr b/exercises/concept/task-handler/.docs/test.cr deleted file mode 100644 index 5862b662..00000000 --- a/exercises/concept/task-handler/.docs/test.cr +++ /dev/null @@ -1,5 +0,0 @@ -def my_method(&block : Int32, Int32 -> Int32) - 1 + yield(2, 3) - end - -p my_method { |x, y| x * y } \ No newline at end of file diff --git a/exercises/concept/weighing-machine/.docs/hints.md b/exercises/concept/weighing-machine/.docs/hints.md index 5ff25eae..ee3362cc 100644 --- a/exercises/concept/weighing-machine/.docs/hints.md +++ b/exercises/concept/weighing-machine/.docs/hints.md @@ -2,12 +2,12 @@ ## General -- To creat the getter and setter methods you should use the `getter`, `setter` and `property` macros. +- To create the getter and setter methods you should use the `getter`, `setter` and `property` macros. ## 1. Create an initial state for the weighing machine - To initialize the weighing machine you should use the `initialize` method. -- The method should take two arguments, `precision` and `metric` which should be a `Int32` and `Bool` respectively. +- The method should take two arguments, `precision` and `metric`, which should be an `Int32` and `Bool`, respectively. These should be used to set the instance variables `@precision` and `@metric`. - The instance variable `@weight` should be set to `0.0`. diff --git a/exercises/concept/weighing-machine/.docs/instructions.md b/exercises/concept/weighing-machine/.docs/instructions.md index e50885a6..49626ab7 100644 --- a/exercises/concept/weighing-machine/.docs/instructions.md +++ b/exercises/concept/weighing-machine/.docs/instructions.md @@ -1,15 +1,15 @@ # Instructions -In this exercise you'll be modelling a weighing machine. +In this exercise you'll be modeling a weighing machine. ## 1. Create an initial state for the weighing machine -The weighing machine when initalized should refer to its factory settings which is different for where the machine is sold. +When initialized, the weighing machine should refer to its factory settings which is different for where the machine is sold. Thereby the machine should be able to be initialized with a precision and if it is metric or imperial. Implement the `WeighingMachine#initialize` method which takes two arguments, `precision` which is an `Int32` and `metric` which is a `Bool`. The `metric` argument when `true` means that the machine should use the metric system, otherwise it should use the imperial system. -The initizalized set should also set an instance variable, `@weight` to `0.0`. +The initialize method set should also set the instance variable `@weight` to `0.0`. ```crystal precision = 3 @@ -49,7 +49,8 @@ wm.weigh ## 4. Allow the machine to be switch between metric and imperial units -Implement the `WeighingMachine#metric=` property to allow the unit to be set, it should accept a boolean value. +Implement the `WeighingMachine#metric=` property to allow the unit to be set. +It should accept a boolean value. ```crystal precision = 3 diff --git a/exercises/concept/weighing-machine/.docs/introduction.md b/exercises/concept/weighing-machine/.docs/introduction.md index 01a5024b..adc75f71 100644 --- a/exercises/concept/weighing-machine/.docs/introduction.md +++ b/exercises/concept/weighing-machine/.docs/introduction.md @@ -12,7 +12,7 @@ Crystal has defined these as `getter`, `setter` and `property` macros. Getter is a macro that defines a method that returns the value of an instance variable. This means that you no longer have to write `@` in front of the instance variable when you want to access it (in methods, excluding initialize); instead, you can call the method that the getter macro has defined. -The getter macro can accept multiple instance variables by separating them with a comma. +The getter macro can accept multiple instance variables by separating them with commas. ```crystal # This: @@ -44,7 +44,7 @@ Symbols will be covered later in the symbol concept. ## Setters -Setters is a macro that defines a method that sets the value of an instance variable. +Setter is a macro that defines a method that sets the value of an instance variable. This macro isn't that often found and is commonly the `property` macro used instead. The methods that will be created will look like `name_of_method=`; the `=` is what makes it so the property can be set. diff --git a/exercises/concept/weighing-machine/.meta/config.json b/exercises/concept/weighing-machine/.meta/config.json index 738cfb17..edb2b14f 100644 --- a/exercises/concept/weighing-machine/.meta/config.json +++ b/exercises/concept/weighing-machine/.meta/config.json @@ -1,5 +1,6 @@ { "authors": ["meatball133"], + "contributors": "ryanplusplus", "files": { "solution": [ "src/weighing_machine.cr" diff --git a/exercises/concept/weighing-machine/spec/weighing_machine_spec.cr b/exercises/concept/weighing-machine/spec/weighing_machine_spec.cr index 2c88e10e..c4b602c8 100644 --- a/exercises/concept/weighing-machine/spec/weighing_machine_spec.cr +++ b/exercises/concept/weighing-machine/spec/weighing_machine_spec.cr @@ -41,7 +41,7 @@ describe WeighingMachine do weighing_machine.precision.should eq(5) end - it "should not allowed to be modify" do + it "should not allow modification" do {% if WeighingMachine.has_method? "precision=" %} raise "Error: precision should not have a setter" {% end %} @@ -87,7 +87,7 @@ describe WeighingMachine do weighing_machine.weigh.should eq("11.023") end - it "should not allowed to be get" do + it "should not allow getting" do {% if WeighingMachine.has_method? "metric" %} raise "Error: metric should not have a getter" {% end %}