Quadratic Upgrade  •  Java Showcase  •  09/14/2026
TNT | JavaQuadraticSaga — Concept #8 Expanded

Quadratic Upgrade

The Concept #8 Quadratic class, taken further.
Roots stored as OrderedPair and ComplexOrderedPair objects — composition, inheritance, and polymorphism working together in twelve downloadable files.

⬆ Upgrade from Concept #8

What Was Added

QuadraticDriver upgrades:

  • SHOULD_SHOW_BREADCRUMBS static boolean — toggle all debug output with one line
  • DF DecimalFormat static field — shared across all classes for consistent numeric display
  • EPSILON = 1E-9 constant — safe double equality tests (avoids == 0.0)
  • decimalFormatManager(n) utility factory method
  • Driver tests expanded: setter chain, copy constructor, degenerate case (a=0)

Quadratic class upgrades:

  • yIntercept stored as OrderedPair(0, c) — geometric consistency
  • roots[] array of OrderedPair — pre-computed at every state change
  • computeRoots() new utility: real roots as OrderedPair(r, 0), complex as ComplexOrderedPair(rp, ip)
  • summary() method for rich multi-line output
  • All setters trigger full recompute chain (including roots)
  • Epsilon-safe double comparisons throughout

OrderedPair & ComplexOrderedPair upgrades:

  • toString() now uses QuadraticDriver.DF.format() for clean numeric display (no trailing .0000000001 noise)
  • Breadcrumbs added throughout — toggled by the driver's SHOULD_SHOW_BREADCRUMBS flag

QuadraticDriver.java — The Command Center

The driver now doubles as a configuration hub. Three static constants (SHOULD_SHOW_BREADCRUMBS, DF, EPSILON) are shared by all four files, keeping formatting and debugging decisions in one place.

Key Changes from Concept #8

  • Three static class-level constants replace inline magic values
  • decimalFormatManager() creates the shared DecimalFormat — callable and reusable
  • q5.setB(-4); q5.setC(9); tests that chaining setters keeps all computed values in sync
  • Degenerate test (a=0) demonstrates the exception-handling path
  • summary() replaces raw toString() calls for richer driver output
QuadraticDriver.java Java · File 1 of 4

    OrderedPair.java — The Foundation

    Unchanged in structure from Concept #6 — only two additions that make the upgrade possible: DF.format() in toString() for cleaner output, and breadcrumbs throughout for optional debug tracing.

    Key Changes from Concept #8

    • toString() wraps coordinates in QuadraticDriver.DF.format(x) — no more (3.0000000001, 0.0) noise
    • Breadcrumb pattern added: all methods optionally print their name when SHOULD_SHOW_BREADCRUMBS is true
    • getX() and getY() were already present from Concept #8 (needed for subclass access to private fields)
    OrderedPair.java Java · File 2 of 4

      ComplexOrderedPair.java — The Subclass

      ComplexOrderedPair extends OrderedPair, inheriting its fields and methods, overriding toString() to produce a + bi notation, and adding conjugate() and modulus(). This is the class that makes complex roots displayable without any special-case code in the caller.

      Key Changes from Concept #8

      • toString() uses QuadraticDriver.DF.format() for all numeric values — consistent with OrderedPair
      • Breadcrumb added to constructors (follows the driver's debug toggle)
      • Core structure unchanged — the extends keyword, super() calls, and method overrides are identical to Concept #8
      ComplexOrderedPair.java Java · File 3 of 4

        Quadratic.java — The Full PCNICOTGSU Blueprint

        The main upgrade lives here. The computeRoots() method stores all roots as OrderedPair or ComplexOrderedPair objects. Every setter triggers the full recompute chain. Read the analysis page for a detailed walk-through of why each design decision was made.

        Key Changes from Concept #8

        • yIntercept new ivar — OrderedPair(0, c), stored as a geometric point not just a number
        • roots[] new ivar — OrderedPair[] that holds real or complex roots (polymorphism!)
        • computeYIntercept() new private utility — called in all constructors and setC
        • computeRoots() new private utility — real roots as OrderedPair(r, 0); complex as ComplexOrderedPair(rp, ip)
        • summary() new public method — shows vertex, discriminant, y-intercept, and roots in one call
        • getYIntercept() new getter — returns the y-intercept ordered pair
        • All a == 0 checks use Math.abs(a - 0.0) < EPSILON (safe double comparison)
        • + 0.0 applied to vertex h to prevent the -0.0 display artifact
        Quadratic.java Java · File 4 of 4 · PCNICOTGSU annotated