Solution: Age of Teacher and Students
Understand how to implement object-oriented programming concepts in Ruby by calculating ages using class inheritance. Learn to extract and average teacher and student ages with methods like collect and inject. Discover practical ways to manage data within Ruby classes and enhance problem-solving skills.
We'll cover the following...
We'll cover the following...
Solution
Explanation
Lines 11–21: The
agemethod calculates age by finding the difference among the year, month, and day of the instance variable ...