# ordered_pair_main.py — Cross Training: Classes & OOP
# Run with OrderedPair.py in the same directory.
# In OnlineGDB: create a second file named OrderedPair.py, paste the class there,
# then run this file.  Link: https://www.onlinegdb.com/online_python_compiler
#
# This file mirrors OrderedPairDriver.java: same constructor sequence,
# same method calls, same output intent.
#
# OOP vocabulary exercised here:
#   OrderedPair()                     — default constructor (x=0.0, y=0.0 → origin)
#   OrderedPair(x, y)                 — two-parameter constructor
#   OrderedPair.from_ordered_pair(p)  — copy constructor via @classmethod
#   obj.set_label(lbl)                — setter: controlled mutation
#   obj.get_abs_val()                 — getter: read-only access to private field
#   obj.transpose()                   — utility: mutates the object in place
#   print(obj)                        — calls __str__ automatically
#   f-strings: f"f({x}) = {y}"        — Python's concise string interpolation

from OrderedPair import OrderedPair

# Return function — mirrors Java's static double f(double x)
def f(x):
    print("...f...")
    m = 3.0
    b = 2.0
    return m * x + b
#end f

def main():
    print("=== Ordered Pair Main ===\n")

    x = 2.0
    y = f(x)   # y = 8.0 — captured
    print(f"f({x}) = {y}")

    print("\n--- Creating the Origin ---")
    origin = OrderedPair()
    print("origin =", origin)

    print("\n--- Creating a Point ---")
    ptA = OrderedPair(x, y)
    print("ptA =", ptA)
    ptA.set_label("A")
    print("ptA =", ptA)
    #print("AbsVal ptA =", ptA._abs_val)   # accessible but breaks encapsulation
    print("AbsVal ptA =", ptA.get_abs_val())

    print("\n--- Creating a Transposed Point ---")
    ptA_t = OrderedPair.from_ordered_pair(ptA)
    ptA_t.transpose()
    print("ptA_transpose =", ptA_t)
    print("AbsVal", ptA_t.get_label(), "=", ptA_t.get_abs_val())

    print("\n--- Thanks for using our program! ---")

#end main

if __name__ == "__main__":
    main()
