Quadratic Upgrade 3  •  Java Showcase  •  10/07/2026
TNT | JavaQuadraticSaga — Upgrade 3

Quadratic Upgrade 3

The crown jewel: a roots-first constructor that builds a quadratic from either two real roots or a complex conjugate pair — with full defensive validation and Vieta’s Formulas under the hood.

⬆ Upgrade from Upgrade 2

What’s New in Upgrade 3

QuadraticDriver changes:

  • Removed final from the three shared constants — a regression from Upgrade 2, and a good reminder that it should be restored
  • Two new constructor tests: one from real roots, one from a complex conjugate pair
  • T-table output added through printOrderedPairsIn()
  • DWR: xmin, xmax, and xinc are reused correctly without being re-declared

Class changes:

  • Quadratic: new roots constructor Quadratic(OrderedPair r1, OrderedPair r2)
  • Quadratic: printOrderedPairsIn() adds a reusable t-table generator
  • Quadratic: isEffectivelyZero() promoted to public
  • ComplexOrderedPair: add() and multiply() support conjugate-root arithmetic
  • OrderedPair: unchanged from Upgrade 2

QuadraticDriver.java — The T-Table Challenge

Upgrade 3 turns the driver into a two-part showcase: first a quadratic built from two real roots, then one built from a complex conjugate pair. The driver also demonstrates the new t-table printer and includes a DWR about reusing local variables instead of re-declaring them.

Key Changes from Upgrade 2

  • Two new quadratic tests centered on the roots constructor: one real, one complex
  • printOrderedPairsIn() demo prints around the vertex in two output formats
  • DWR note calls out proper variable reuse for xmin, xmax, xinc
  • final was removed from the constants — a regression worth discussing on the analysis page
QuadraticDriver.java Java · File 1 of 4

    OrderedPair.java — Still the Foundation Unchanged from Upgrade 2

    No structural changes here. That matters: Upgrade 3 gets its new power by combining the existing OrderedPair foundation with smarter constructors and smarter complex arithmetic elsewhere.

    No Changes from Upgrade 2

    • OrderedPair still provides the shared real/imaginary storage model used by the subclass
    • Included here so the four-file project remains complete and runnable as-is
    OrderedPair.java Java · File 2 of 4

      ComplexOrderedPair.java — Complex Arithmetic Arrives

      This is the enabling upgrade. Without add() and multiply(), the quadratic roots constructor could not compute real coefficients from a complex conjugate pair. Upgrade 3 makes the subclass do the math that belongs to complex numbers.

      Key Changes from Upgrade 2

      • add() added for component-wise complex addition
      • multiply() added using FOIL and the identity i² = -1
      • Comments walk through the algebra explicitly at APCS level
      • The copy constructor still models the correct use of getters for private superclass fields
      ComplexOrderedPair.java Java · File 3 of 4

        Quadratic.java — The Roots Constructor

        Upgrade 3 flips the usual workflow inside out. Instead of starting with a, b, and c and solving for roots, the new constructor starts with roots and reconstructs the quadratic. That demanded Vieta’s Formulas, a defensive programming gate, a t-table generator, and one excellent DWR about cast operator precedence.

        Key Changes from Upgrade 2

        • New roots constructor handles both real roots and complex conjugate roots
        • Defensive validation checks the inputs before any coefficient computation happens
        • printOrderedPairsIn() generates a t-table over a caller-chosen interval
        • isEffectivelyZero() is now public so outside inputs can be validated cleanly
        • DWR comment documents the cast trap around subclass-only method calls
        DWR! CAST OPERATOR PRECEDENCE TRAP
        (ComplexOrderedPair)r1.multiply(...) tries to call multiply() on an OrderedPair reference. Java parses it as: cast the result, not the receiver.
        Fix: store the downcast first — ComplexOrderedPair z1 = (ComplexOrderedPair) r1;
        Quadratic.java Java · File 4 of 4 · roots-first design