DotPuzzle
public struct DotPuzzle
A DotPuzzle ADT represents a connect-the-dots puzzle that is in the middle of being solved. To that end, the abstract state of this ADT is two properties:
- conected: a list of dots that have already been connected, in the order that they were connected.
- unconnected: a list of dots that have yet to be connected, in the order that the should be connected.
Both sequences can be represented as arrays of Dots.
-
The points that have been connected.
Declaration
Swift
public let connected: [Dot]
-
The points that have not been connected.
Declaration
Swift
public let unconnected: [Dot]
-
Create a new puzzle from an array of points, ordered in the way they should be numbered (labelled…) and connected.
Declaration
Swift
public init(_ points: [CGPoint])
Parameters
points
All points in the Puzzle.
-
Create a new DotPuzzle that has the same dots as self, but with the first unconnected dot now being the last connected dot.
Requires:
unconnected
is not emptyDeclaration
Swift
public func connectOneMoreDot() -> DotPuzzle
Return Value
a new
DotPuzzle
reflecting that change.