This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NewRental | |
| def identifier | |
| 'a latest movie' | |
| end | |
| def price(days_rented) | |
| NewRentalPrice.new(days_rented).amount | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ClassicRentalPrice | |
| attr_reader :days_rented | |
| def initialize(days_rented) | |
| @days_rented = days_rented | |
| end | |
| def amount | |
| 2 * days_rented | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Rental | |
| attr_reader :price, :statement, :days_rented, :movie_type | |
| def initialize(days_rented, movie_type) | |
| @days_rented = days_rented | |
| @movie_type = movie_type | |
| @price = calculate_price | |
| @statement = calculate_statement | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Rental | |
| attr_reader :days_rented, :movie_type | |
| def initialize(days_rented, movie_type) | |
| @days_rented = days_rented | |
| @movie_type = movie_type | |
| end | |
| def price_per_day | |
| case movie_type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var matrix = [ | |
| [1, 1, 1, 2, 2, 3], | |
| [2, 3, 3, 4, 4, 6], | |
| [3, 5, 6, 6, 7, 7], | |
| [4, 5, 6, 6, 8, 8], | |
| [5, 7, 7, 8, 8, 9] | |
| ]; | |
| var target = 6; // We’re going to try find the position of 6 in the array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function combineChars (chars) { | |
| var permutations = [], words = [], firstChar; | |
| if (chars.length === 1) { // base case | |
| permutations.push(chars); | |
| return permutations; | |
| } | |
| firstChar = chars[0]; | |
| chars = chars.substring(1,chars.length); | |
| words = combineChars(chars); | |
| for (var i = 0; i < words.length; i++) { |
NewerOlder