Foreword: Yes, this is homework help.
The problem: “A health-care issue that has been in the news lately is the computerization of health records…In this exercise, you’ll design a “starter” HealthProfile class for a person. The class attributes should include the person’s first name, last name, gender, date of birth (consisting of separate attributes for the month, day and year of birth), height (in inches) and weight (in pounds). Your class should have a constructor that receives this data. For each attribute provide a property with set and get accessors. The class also should include methods that calculate and return the user’s age in years, maximum heart rate and target-heart-rate range, and body mass index (BMI). Write an app that prompts for the person’s information, instantiates an object of class HealthProfile for that person and displays the information from that object—including the person’s first name, last name, gender, date of birth, height and weight—then calculates and displays the person’s age in years, BMI, maximum heart rate and target-heart-rate range.”
My code for the problem is here.
As you can see, I’ve done most all of the problem right now and it’s set up in a way that I’m happy with. The code runs no errors (aside from the compiler errors in Fiddle, but that’s because it’s not using C#6 I imagine?) and I get no crashes or bugs when I run the code. The problem is that, in the output, the Age is constantly reporting zero (which is throwing off the methods that calculate off it, such as BMI and HeartRate). For whatever reason I can’t get it to register their age.
I’m pretty confident I’ve narrowed down the issue to being related to the “DOByear” variable and the Healthprofile class not pulling its value from the HealthprofileRun class. I know it’s not due to any of the return formulas because I can recreate this entire code as a single class and the code works perfect – but since my teacher’s requiring that I use two classes (because that’s what we’re learning in class), I’m stuck with trying to make this work.
Anyone have any ideas where I’m going wrong? Is it related to my get/set constructors for the Age method? Or…?