Skip to content

Ports - Shamira#40

Open
MiraMarshall wants to merge 2 commits intoAda-C11:masterfrom
MiraMarshall:master
Open

Ports - Shamira#40
MiraMarshall wants to merge 2 commits intoAda-C11:masterfrom
MiraMarshall:master

Conversation

@MiraMarshall
Copy link

@MiraMarshall MiraMarshall commented Feb 19, 2019

ride share

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What did your data structure look like at first? Did this structure evolve over time? Why? First I had an outside hash, then an array, and then an array of hashes.
What was your strategy for going through the data structure and gathering information? Since all the info was structured the same for each driver I was able to iterate through the info using .each.
What was an example of something that was necessary to store in a variable? Why was it necessary, useful, or helpful? I put formulas throughout the program, like the total amount of money in its own variable so I could call it later, if needed.
What kinds of iteration did you use? Did you use .map? If so, when? If not, why, or when would be a good opportunity to use it? I used .map to create a separate array to store the computed info I got by using .sum and other computations to find the average.
Were some calculations easier than others? Why? Finding the sum, average, and max were easier because there are enumerables for those calculations built in ruby.

@CheezItMan
Copy link

Ride Share

What We're Looking For

Feature Feedback
Answers the comprehension questions Some of the formulas are not stored in variables, instead they are stored in methods.
Readable code with consistent indentation and reasonable code style Check
Outputs the correct number of rides each driver has given Check
Outputs the total amount of money each driver has made Check
Outputs the average rating for each driver Check
Outputs which driver made the most money Check
Outputs which driver has the highest average rating You have the method to calculate this, but didn't call it.

Summary | I would suggest writing methods to do the calculations, breaking up your code into modules, but what you have is fine. You made good use of ennumerables. Well done.

info = [
{
driver: ["DR0001"],
rider: ["RD0003", "RD0015", "RD0003"],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, by making each element's hash containing a series of parallel arrays, your code becomes a bit more fragile and harder to read. That's because it depends on the order of the rider id and date and cost and rating to stay aligned for this to work. It does here, but could make the code harder to maintain.

},
]
# Iterated through the info i need to answer the specific questions in the prompt. Used .map to create a new array with the computed info to answer the ?s.
computed_infos = info.each_with_index.map do |driver_info, i|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever setting up a hash with the calculated info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants