Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 863 Bytes

0f05.md

File metadata and controls

17 lines (13 loc) · 863 Bytes

Back to questions

Solution to 0f05: Coloured points

See code at solutions/code/tutorialquestions/question0f05

Inspect the sample solution carefully and check you understand it. Note that in the constructor of ColouredPoint, super(coordX, coordY, coordZ) is used to invoke the constructor of Point, after which this.colour = colour assigns to the additional colour field. This pattern of building subclass constructors is standard.

Look at the toString method in ColouredPoint. Observe that @Override has been used to indicate that this should override a superclass method. If we accidentally mis-spelled toString, thus not overriding the parent method, the use of @Override would generate a useful compiler error. Look at the way super.toString() is used in the body of toString().