From a2b35b4f9ac3a9b7545e865cb0fb9a0e156b42f9 Mon Sep 17 00:00:00 2001 From: maestro1997 <37818078+maestro1997@users.noreply.github.com> Date: Mon, 2 Sep 2019 19:50:33 +0300 Subject: [PATCH 1/7] Update README.md --- courses/ruby/ex03-wallet/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/courses/ruby/ex03-wallet/README.md b/courses/ruby/ex03-wallet/README.md index d2c0b467..f93fff87 100644 --- a/courses/ruby/ex03-wallet/README.md +++ b/courses/ruby/ex03-wallet/README.md @@ -1,3 +1,3 @@ -# TODO: Structure and finalize me please ! +The goal of these exercises is to help you understand classes and methods, both how they work and how they can improve you code readability and flexability instead using just functions. -Use ex01 README.md as a template. +#Exercise structure From b6368ee2b59d60a30242526b0f4a17759c1ca51f Mon Sep 17 00:00:00 2001 From: maestro1997 <37818078+maestro1997@users.noreply.github.com> Date: Mon, 2 Sep 2019 19:53:17 +0300 Subject: [PATCH 2/7] Update README.md --- courses/ruby/ex03-wallet/README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/courses/ruby/ex03-wallet/README.md b/courses/ruby/ex03-wallet/README.md index f93fff87..7a83ac83 100644 --- a/courses/ruby/ex03-wallet/README.md +++ b/courses/ruby/ex03-wallet/README.md @@ -1,3 +1,22 @@ The goal of these exercises is to help you understand classes and methods, both how they work and how they can improve you code readability and flexability instead using just functions. -#Exercise structure +# Exercise structure + +``` +class WalletTest < Minitest::Test + def test_wallet_starts_at_zero + #skip + wallet = Wallet.new + assert_equal 0, wallet.cents + assert_equal 0, wallet.dollars + end + + def test_wallet_starts_at_non_zero + #skip + wallet = Wallet.new(:penny, :nickel) + assert_equal 6, wallet.cents + assert_equal 0.06, wallet.dollars + end +end + +``` From 7854b93cac7a4a6331e38baabc2ce9079f4799ad Mon Sep 17 00:00:00 2001 From: maestro1997 <37818078+maestro1997@users.noreply.github.com> Date: Mon, 2 Sep 2019 20:17:27 +0300 Subject: [PATCH 3/7] Update README.md --- courses/ruby/ex03-wallet/README.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/courses/ruby/ex03-wallet/README.md b/courses/ruby/ex03-wallet/README.md index 7a83ac83..3bfd0b08 100644 --- a/courses/ruby/ex03-wallet/README.md +++ b/courses/ruby/ex03-wallet/README.md @@ -2,7 +2,7 @@ The goal of these exercises is to help you understand classes and methods, both # Exercise structure -``` +```ruby class WalletTest < Minitest::Test def test_wallet_starts_at_zero #skip @@ -18,5 +18,30 @@ class WalletTest < Minitest::Test assert_equal 0.06, wallet.dollars end end +``` +You should implement a simple wallet Class, which may contain 5 types of currency: penny, nickel, dime, quarter, dollar. +Your wallet should store two fields: counts of cents and dollars. This fields must be readable. +Also you should create next methods: +1)Initializing new wallet with specified nominals (for one for each type) or just empty wallet if no arguments passed +2) Adding any coin or dollar to wallet ( "<<" method - takes one argument - name of currency ) +3) Getting one coin or one dollar from wallet if respective nominal exists in wallet. ( "take" method - takes some number of currencies) +# Running the test files +Unit tests are implemented with Minitest. If you did not check doc yet it's time to do it now. + +# Running test suite: +```console +ruby wallet_test.rb ``` +Expected output: +```console +Run options: --seed 8431 + +# Running: + +.......... + +Finished in 0.000935s, 10699.5929 runs/s, 34238.6972 assertions/s. +10 runs, 32 assertions, 0 failures, 0 errors, 0 skips + + From 0a72e1956ecad88fd06124ed3779531a8fbd16be Mon Sep 17 00:00:00 2001 From: maestro1997 <37818078+maestro1997@users.noreply.github.com> Date: Mon, 2 Sep 2019 20:19:12 +0300 Subject: [PATCH 4/7] Update README.md --- courses/ruby/ex03-wallet/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/courses/ruby/ex03-wallet/README.md b/courses/ruby/ex03-wallet/README.md index 3bfd0b08..5ba3ec3c 100644 --- a/courses/ruby/ex03-wallet/README.md +++ b/courses/ruby/ex03-wallet/README.md @@ -43,5 +43,22 @@ Run options: --seed 8431 Finished in 0.000935s, 10699.5929 runs/s, 34238.6972 assertions/s. 10 runs, 32 assertions, 0 failures, 0 errors, 0 skips +``` + +# Running rubocop: +```console +rubocop wallet_test.rb +``` + +Expected output: +```console +Inspecting 1 file +. + +1 file inspected, no offenses detected +``` + +# Bonus +Fix all rubocop offences and submit patch without solution. If there is something to improve in .rubocop.yml you are welcome! From c461f73083ee2a96f59705047c393951f51f4e2d Mon Sep 17 00:00:00 2001 From: maestro1997 <37818078+maestro1997@users.noreply.github.com> Date: Mon, 2 Sep 2019 20:21:06 +0300 Subject: [PATCH 5/7] Update README.md --- courses/ruby/ex03-wallet/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/courses/ruby/ex03-wallet/README.md b/courses/ruby/ex03-wallet/README.md index 5ba3ec3c..e446b530 100644 --- a/courses/ruby/ex03-wallet/README.md +++ b/courses/ruby/ex03-wallet/README.md @@ -22,9 +22,9 @@ end You should implement a simple wallet Class, which may contain 5 types of currency: penny, nickel, dime, quarter, dollar. Your wallet should store two fields: counts of cents and dollars. This fields must be readable. Also you should create next methods: -1)Initializing new wallet with specified nominals (for one for each type) or just empty wallet if no arguments passed -2) Adding any coin or dollar to wallet ( "<<" method - takes one argument - name of currency ) -3) Getting one coin or one dollar from wallet if respective nominal exists in wallet. ( "take" method - takes some number of currencies) +1)Initializing new wallet with specified nominals (for one for each type) or just empty wallet if no arguments passed \ +2) Adding any coin or dollar to wallet ( "<<" method - takes one argument - name of currency ) \ +3) Getting one coin or one dollar from wallet if respective nominal exists in wallet. ( "take" method - takes some number of currencies) \ # Running the test files Unit tests are implemented with Minitest. If you did not check doc yet it's time to do it now. From 5da9c0eeedbc9904e385fcfac3e0b04145cada67 Mon Sep 17 00:00:00 2001 From: maestro1997 <37818078+maestro1997@users.noreply.github.com> Date: Mon, 2 Sep 2019 20:23:03 +0300 Subject: [PATCH 6/7] Update README.md --- courses/ruby/ex03-wallet/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/ruby/ex03-wallet/README.md b/courses/ruby/ex03-wallet/README.md index e446b530..5f264155 100644 --- a/courses/ruby/ex03-wallet/README.md +++ b/courses/ruby/ex03-wallet/README.md @@ -1,7 +1,7 @@ The goal of these exercises is to help you understand classes and methods, both how they work and how they can improve you code readability and flexability instead using just functions. # Exercise structure - +Unit test example: ```ruby class WalletTest < Minitest::Test def test_wallet_starts_at_zero From 69c833f47a6397a4565733d75c98af27ca7942a9 Mon Sep 17 00:00:00 2001 From: maestro1997 <37818078+maestro1997@users.noreply.github.com> Date: Mon, 2 Sep 2019 20:23:43 +0300 Subject: [PATCH 7/7] Update README.md --- courses/ruby/ex03-wallet/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/ruby/ex03-wallet/README.md b/courses/ruby/ex03-wallet/README.md index 5f264155..7435759c 100644 --- a/courses/ruby/ex03-wallet/README.md +++ b/courses/ruby/ex03-wallet/README.md @@ -24,7 +24,7 @@ Your wallet should store two fields: counts of cents and dollars. This fields mu Also you should create next methods: 1)Initializing new wallet with specified nominals (for one for each type) or just empty wallet if no arguments passed \ 2) Adding any coin or dollar to wallet ( "<<" method - takes one argument - name of currency ) \ -3) Getting one coin or one dollar from wallet if respective nominal exists in wallet. ( "take" method - takes some number of currencies) \ +3) Getting one coin or one dollar from wallet if respective nominal exists in wallet. ( "take" method - takes some number of currencies) # Running the test files Unit tests are implemented with Minitest. If you did not check doc yet it's time to do it now.