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 theCrossclass that takes a 2D listgridas a parameter. It creates a new instance of theCrossclass by assigning thegridparameter to thegridproperty of the new instance. This allows you to create aCrossobject from an existing 2D list.
Properties
-
colors
↔ Map<
int, Styles> -
The code
Map<int, Styles> colors = <int, Styles>{...};is creating a map calledcolorsthat maps integers toStylesobjects. The keys of the map are integers, and the values areStylesobjects. Each integer represents a color code, and the correspondingStylesobject 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 thegetGridgetter method from theBasicShapeinterface. It returns thegridproperty, which is a 2D list representing the cross. This allows other classes that implement theBasicShapeinterface to access thegridproperty of theCrossclass.read-onlyoverride -
grid
↔ List<
List< int> > -
The
@override late final List<List<int>> grid;is declaring a late final variablegridof typeList<List<int>>. The@overrideannotation indicates that this variable is overriding a property from a superclass or implementing an interface. In this case, it is overriding thegridproperty from theBasicShapeinterface. Thelatekeyword indicates that the variable will be initialized at a later point before it is accessed. Thefinalkeyword 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 thehashCodegetter method from theObjectclass.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