CJCoding With Joseph
15free / daySign inCreate account

Thompson Rivers University

Abstract MyBMI Class

Assignment 1 BMI - SM 2025

What is an abstract class?

An abstract class is like a blueprint. You can’t create objects directly from it. Instead, it’s meant to be extended (inherited) by other classes. It can contain:

  • Regular methods (with code inside)

  • Abstract methods (just method headers, no code)

You use an abstract class when you want every subclass to follow the same structure, but let them implement certain details differently.

In our case, both ImperialUnit and MetricUnit will extend MyBMI, and they will each calculate BMI using different height units. So we’ll make sure they both inherit common data (like name and weight) and both are forced to implement their own way of calculating BMI.

Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 54 more lessons in Thompson Rivers University.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.