/OOP-in-python-module

This module is designed to help explorers determine if there is an impenetrable obstruction when digging to the core of the earth. It calculates the expected time for a machine to travel a certain distance and checks if the actual time exceeds the expected time by a specified threshold.

Primary LanguagePython

OOP Concept Test

This module is designed to help explorers determine if there is an impenetrable obstruction when digging to the core of the earth. It calculates the expected time for a machine to travel a certain distance and checks if the actual time exceeds the expected time by a specified threshold. If the actual time exceeds the expected time by the specified threshold, then there is an impenetrable obstruction. Otherwise, there is no impenetrable obstruction.

The Object-Oriented Programming (OOP) concept used in this module is encapsulation.

Encapsulation is one of the fundamental principles of OOP that involves bundling data (attributes) and methods (functions) that operate on that data into a single unit, known as a class. The class acts as a blueprint for creating objects that can store and manipulate data in a controlled manner.

In the code snippet:

def is_impenetrable(expected_time, actual_time):
    # ...

Here, the code defines a function (is_impenetrable) that encapsulates (hide) the logic for determining whether there's an impenetrable obstruction based on the given parameters.

Usage

Installation:

No installation is required for this module as it consists of a single Python file.
No external APIs, No libraries, no frameworks, pure OOP concept.

Usage:

  • Import is_impenetrable function from the obstruction_class module into your Python script.
  • from obstruction_class import is_impenetrable

    Provide the following parameters:

  • expected_time: Expected time in minutes
  • actual_time: Actual time in minutes
  • if is_impenetrable(expected_time, actual_time): <br />
        print("There is an impenetrable obstruction!.")
    else:
        print("There is no impenetrable obstruction.!")

    Explanation:

  • function calculates the expected time it will take to get from point a to point b by adding 60 minutes to expected_time_to_reach.
  • It also calculates the maximum allowed time based on the speed and distance.
  • If the actual_time exceeds both the threshold time and the maximum allowed time, it indicates an impenetrable obstruction.
  • Examples

    Here's an example of how to use the module:

    from obstruction_class import is_impenetrable
    
    speed = 10  # Speed in miles per hour
    distance = 15  # Distance in miles
    location_b = distance / speed * 60  # Expected time in minutes
    
    location_a = 78  # Actual time in minutes
    
    if is_impenetrable(location_b, location_a):
        print("There is an impenetrable obstruction!")
    else:
        print("There is no impenetrable obstruction!")

    Run the main.py script:

    Run the following command to run the main.py script:

    python main.py

    if you are using ubuntu, run the following command:

    python3 main.py

    Note

    This module is designed for learning purposes and may require further enhancements for production use.

    Author

    Isah Jacob