This is a Guided Pairing Session challenge for Unit 2. Please do not look at the challenge until your guided pairing session.
- Identify and explain what code is doing
- Identify and rewrite repetitive code
- Use if/else statements, string methods, while/until loops, Enumerable#each methods
Your future career will require you to deal with a lot of "legacy code," i.e. code that works as intended, but is difficult to modify. Sometimes you will be given the option to start over or modify the original code. Other times you will be forced to work with legacy code due to time or budget constraints. In this challenge, you have the option to completely trash the code and start over or work with the code that's here, but make sure that it works the same way. The driver code should still print "true" without being modified.
Whenever you get a set of code, you want to run it to make sure it works. Run the code in your terminal before making any changes.
Based on the test code at the bottom, what is the code doing (in general)? Identify the inputs and outputs? What do the tests output and why?
Read through the code indenting as you go. After each block, write a comment to explain what the code is doing.
When you get to code that is difficult to read, seems redundant, or stupidly executed, pause and refactor it. Make sure your changes don't break any of the tests! Refactor with future expandability in mind, you may decide to add some features later!
When the session is over, reflect on your learning.
Submit Feedback on Feedbackinator
Sync your changes (push your solution) to Github! Remember to include your pair's name!
(In case you didn't get enough of the delicious horrible-code)
Expand the program for the customer based on their requests. Use the methodology you've been practicing! (Write Driver Test Code, Pseudocode, Write your initial solution, Refactor, Reflect)
Hi! I am a small bakery owner who has a ruby program that calculates the number of items I need to bake for a customer with a favorite food. I love the program as it is, but I want to add a couple of features:
- The owner wants to have options to include a mix of all items, rather than favorite foods.
- The owner wants to add the following items to the menu: pudding (feeds two people), bunt cake (feeds 4 people), and mega-cupcakes (feeds 3 people)
NOTE: Write your own tests based on your expansion. The original tests should still pass.