From c25d77c9aa8c0b5e81d0303b36d1d1128d051360 Mon Sep 17 00:00:00 2001 From: "nshizirungudieumerci@gmail.com" Date: Mon, 10 Aug 2026 15:44:51 -0400 Subject: [PATCH] added a parsons problem to the inheritance section --- source/ch6_definingclasses.ptx | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/source/ch6_definingclasses.ptx b/source/ch6_definingclasses.ptx index 4adb2ff..4375608 100644 --- a/source/ch6_definingclasses.ptx +++ b/source/ch6_definingclasses.ptx @@ -961,6 +961,38 @@ public void test(Number a, Number b) { You will still get this error even if all your code that calls this test method passes two Fractions as parameters (remember that Fraction does implement add).

+ + + +

+ Construct the toString method for the Fraction class so that printing a + fraction shows it in the form numerator/denominator. Drag the blocks into the correct order on the right. +

+
+ + + + public String toString() { + + + public void toString() { + + + + + + return numerator.toString() + "/" + denominator.toString(); + + + numerator.toString() + "/" + denominator.toString(); + + + + + } + + +