/* TEMPLATE for the Rect class:
int distTo0() {
... this.nw ...
... this.nw.x ...
... this.nw.y ...
... this.width ...
... this.height ... } */
/* TEMPLATE for the Dot class:
int distTo0() {
... this.location ...
... this.location.x ...
... this.location.y ... } */
Again, we have three different methods, one for each class.
// PROGRAM for the class Circle:
int distTo0() {
return this.center.distTo0(); }
// PROGRAM for the class Rect:
int distTo0() {
return this.nw.distTo0(); }
// PROGRAM for the class Dot:
int distTo0() {
return this.location.distTo0(); }
c1.distTo0() == 30 c2.distTo0() == 60 r1.distTo0() == 30 r2.distTo0() == 60 d1.distTo0() == 30 d2.distTo0() == 60