class Cell

Gestion de cases dans une planche de Sudoku

Variables d'instance

Public Class Methods

creer(row, col, box) click to toggle source

Représentation d'une case

  • Arguments :

    • row -> Désignation de la ligne de la case

    • col -> Désignation de la colonne de la case

    • box -> Désignation de la “box”

  • Returns

# File class/cell_class.rb, line 38
def self.creer(row, col, box)
  new(row, col, box)
end

Public Instance Methods

==(other) click to toggle source

Méthode de comparaison entre différente instance de Cell

  • Arguments :

    • other -> autre Cell a compare

  • Returns

    • true/false

# File class/cell_class.rb, line 49
def ==(other)
  @value == other.value and @freeze == other.freeze?
end
freeze() click to toggle source

Met la case en read only

# File class/cell_class.rb, line 67
def freeze
  # instance_eval { undef :value= }
  @freeze = true
end
freeze?() click to toggle source

Connaitre si la cell est define lors de la generation

  • Returns

    • true/false

# File class/cell_class.rb, line 62
def freeze?
  @freeze
end
to_s() click to toggle source

Pour debugging

  • Exemple

    Value: 2, Row: 0, Col: 0, Box: 0
    Value: 4, Row: 0, Col: 1, Box: 0
    Value: 6, Row: 0, Col: 2, Box: 0
    Value: 1, Row: 0, Col: 3, Box: 1
    Value: 3, Row: 0, Col: 4, Box: 1
    Value: 5, Row: 0, Col: 5, Box: 1
    Value: 8, Row: 0, Col: 6, Box: 2
    Value: 7, Row: 0, Col: 7, Box: 2
# File class/cell_class.rb, line 82
def to_s
  return "Value: #{@value}, Row: #{@row}, Col: #{@col}, Box: #{@box}"
end
vide?() click to toggle source

Connaitre si une Cell n'est pas remplie

  • Returns

    • true/false

# File class/cell_class.rb, line 55
def vide?
  @value == 0
end