Course of Raku / Objects, I/O, and exceptions / Classes and objects / Attributes / Exercises

A point class

Problem

Define a class Point with two attributes, x and y. Create two points — one at (3, 4) and one at the origin (0, 0) — and print the distance between the two points.

Example

The program prints:

5

Solution

See the solution

Course navigation

Quiz — Attributes   |   Solution: A point class