Cross class
Basic cross for the CAT interpreter
- Implemented types
Constructors
- Cross()
- It creates a 6x6 matrix of zeros
-
Cross.fromList(List<
List< grid)int> > -
Construct cross from an existing 6x6 matrix.
Cross.fromList(this.grid);
is a constructor in theCross
class that takes a 2D listgrid
as a parameter. It creates a new instance of theCross
class by assigning thegrid
parameter to thegrid
property of the new instance. This allows you to create aCross
object from an existing 2D list.
Properties
-
colors
↔ Map<
int, Styles> -
The code
Map<int, Styles> colors = <int, Styles>{...};
is creating a map calledcolors
that maps integers toStyles
objects. The keys of the map are integers, and the values areStyles
objects. Each integer represents a color code, and the correspondingStyles
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 thegetGrid
getter method from theBasicShape
interface. It returns thegrid
property, which is a 2D list representing the cross. This allows other classes that implement theBasicShape
interface to access thegrid
property of theCross
class.read-onlyoverride -
grid
↔ List<
List< int> > -
The
@override late final List<List<int>> grid;
is declaring a late final variablegrid
of typeList<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 thegrid
property from theBasicShape
interface. Thelate
keyword indicates that the variable will be initialized at a later point before it is accessed. Thefinal
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 thehashCode
getter method from theObject
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