Created
September 21, 2014 00:14
-
-
Save pumpkincouture/50615b1b5df0fc40211b to your computer and use it in GitHub Desktop.
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 FlightBuilder | |
attr_reader :origin, :destination | |
attr_accessor :flight_duration | |
def initialize(array) | |
@origin = array[0].origin | |
@destination = array[-1].destination | |
end | |
def calculate_total_duration(array) | |
array.total_duration = 0 | |
array.each {|flight| array.total_duration += flight.duration} | |
end | |
def calculate_total_price(array) | |
array.total_price = 0 | |
array.each {|flight| array.total_price += flight.price} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment