What Was Added
QuadraticDriver upgrades:
finaladded to all three constants — compiler enforces immutabilityq4.printSummary()replacesSystem.out.println(q4.summary())— demonstrates utility-calling-utility pattern- Copy constructor test enhanced:
getMemoryAddress()comparison proves distinct objects - New Alias Trap section:
q7 = q2(nonew!) shares the same address;q7.setC(666)silently mutates q2 - Degenerate test promoted to
q8to freeq7for the alias demonstration
Quadratic class upgrades:
extends Objectexplicit — makes the implicit Java parent visible in codeaxisOfSymmetrynew String ivar — computed incomputeVertex(), reported insummary()memoryAddressnew String ivar — set in every constructor viaobtainMemoryAddress()obtainMemoryAddress()new utility — callssuper.toString()to capture the JVM address stringprintSummary()new utility — wrapssummary()so the caller only needs one linegetAxisOfSymmetry(),getMemoryAddress()new getters
OrderedPair & ComplexOrderedPair:
- Unchanged from Upgrade 1 — all additions are in the driver and
Quadratic.java
QuadraticDriver.java — The Command Center
Two major additions: final on every constant, and the aliasing
trap demonstration. The copy constructor test now compares memory addresses to prove objects are distinct.
The alias test uses q7 = q2 (no new!) to show that both variables reference
the same object — and that mutating one silently changes the other.
Key Changes from Upgrade 1
finalkeyword onSHOULD_SHOW_BREADCRUMBS,DF,EPSILON— prevents accidental reassignmentq4.printSummary()— the commented-outprintln(q4.summary())shows the old approach side-by-side- Copy constructor section uses
getMemoryAddress().equals(...)to verify distinct identity - Alias section:
q7 = q2→ same address proven →q7.setC(666)→ q2 is silently corrupted
Quadratic q7 = q2; does NOT create a new object.
It copies the reference (memory address), not the data. Both q7 and q2
now point to the same spot in memory. Changing one changes both.
Use new Quadratic(q2) when you need an independent copy.
OrderedPair.java — The Foundation Unchanged from Upgrade 1
No structural changes from Upgrade 1. Included here for completeness so the
four-file project is self-contained. DF.format() in toString() and
breadcrumbs throughout remain as they were.
No Changes from Upgrade 1
- All additions in this upgrade are confined to
QuadraticDriver.javaandQuadratic.java - This file is included so the four-file set is complete and runnable as-is in JDoodle
ComplexOrderedPair.java — The Subclass Unchanged from Upgrade 1
No changes. extends OrderedPair, overridden toString()
for a + bi notation, conjugate() and modulus()
remain exactly as in Upgrade 1.
No Changes from Upgrade 1
- Polymorphic
toString()dispatch still drivesgetRootsDescription()— no changes needed - Included here for the complete four-file project
Quadratic.java — The Full PCNICOTGSU Blueprint
The main additions are here. extends Object is now explicit.
Two new String ivars — axisOfSymmetry and memoryAddress — make
the object more self-aware. obtainMemoryAddress() uses super.toString()
to capture the JVM’s identity string, which the driver then uses to prove whether two variables
point to the same object or not. See the
analysis page
for a deep dive into every decision.
Key Changes from Upgrade 1
extends Objectexplicit declaration — pedagogical bridge tosuper.toString()axisOfSymmetrynew private String ivar — set insidecomputeVertex()as"x = " + DF.format(h)memoryAddressnew private String ivar — set in every constructor viaobtainMemoryAddress()obtainMemoryAddress()new utility — returnssuper.toString()which producesQuadratic@1a2b3c4dprintSummary()new public utility — callssummary()and prints result; utility calling a utilitysummary()expanded to include axis of symmetry and memory address outputgetAxisOfSymmetry()andgetMemoryAddress()new getters