Cross class

Basic cross for the CAT interpreter

Implemented types

Constructors

Cross()
It creates a 6x6 matrix of zeros
Cross.fromList(List<List<int>> grid)
Construct cross from an existing 6x6 matrix. Cross.fromList(this.grid); is a constructor in the Cross class that takes a 2D list grid as a parameter. It creates a new instance of the Cross class by assigning the grid parameter to the grid property of the new instance. This allows you to create a Cross object from an existing 2D list.

Properties

colors Map<int, Styles>
The code Map<int, Styles> colors = <int, Styles>{...}; is creating a map called colors that maps integers to Styles objects. The keys of the map are integers, and the values are Styles objects. Each integer represents a color code, and the corresponding Styles object represents the color associated with that code.
read / write
getGrid List<List<int>>
The @override List<List<int>> get getGrid => grid; is a getter method that overrides the getGrid getter method from the BasicShape interface. It returns the grid property, which is a 2D list representing the cross. This allows other classes that implement the BasicShape interface to access the grid property of the Cross class.
read-onlyoverride
grid List<List<int>>
The @override late final List<List<int>> grid; is declaring a late final variable grid of type List<List<int>>. The @override annotation indicates that this variable is overriding a property from a superclass or implementing an interface. In this case, it is overriding the grid property from the BasicShape interface. The late keyword indicates that the variable will be initialized at a later point before it is accessed. The final keyword indicates that the variable cannot be reassigned once it is initialized.
latefinaloverride
hashCode int
The @override int get hashCode => Object.hash(grid, colors); is overriding the hashCode getter method from the Object class.
read-onlyoverride
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

copy() Cross
Copy the cross by mapping each row to a new list containing the same elements.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
It prints the cross
override
validatePosition(int row, int column) bool
The function validates if a given position is within a specific range.
override

Operators

operator ==(Object other) bool
Overriding the == operator.
override