Skip to content

Commit

Permalink
Merge pull request #838 from tdou25/sudoku
Browse files Browse the repository at this point in the history
Sudoku
  • Loading branch information
tdou25 authored Jul 12, 2024
2 parents fa57cf7 + 55b8345 commit 04a219b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
34 changes: 34 additions & 0 deletions src/main/java/edu/rpi/legup/puzzle/sudoku/SudokuCell.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package edu.rpi.legup.puzzle.sudoku;

import edu.rpi.legup.model.elements.Element;
import edu.rpi.legup.model.gameboard.GridCell;
import java.awt.*;
import java.util.HashSet;
import java.util.Set;
import java.awt.event.MouseEvent;


public class SudokuCell extends GridCell<Integer> {
private int groupIndex;
private Set<Integer> annotations;
private int max;
//private int data;

/**
* SudokuCell Constructor - creates a new Sudoku cell to hold the puzzleElement
Expand Down Expand Up @@ -59,4 +63,34 @@ public SudokuCell copy() {
copy.setGiven(isGiven);
return copy;
}

@Override
public void setType(Element e, MouseEvent m) {
System.out.println("Attempting to change tile");
if(e.getElementName().equals("Number Tile")){
if (e.getElementName().equals("Number Tile")) {
if (m.getButton() == MouseEvent.BUTTON1) {
if (this.data <= 0 || this.data > 8) {
this.data = 1;
}
else {
this.data = this.data + 1;
}
}
else {
if (m.getButton() == MouseEvent.BUTTON3) {
if (this.data > 1) {
this.data = this.data - 1;
}
else {
this.data = 9;
}
}
}
}
}
else{
this.data = 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SudokuCellController extends ElementController {
@Override
public void changeCell(MouseEvent e, PuzzleElement data) {
SudokuCell cell = (SudokuCell) data;
System.out.print(111);
//System.out.print(111);
if (e.getButton() == MouseEvent.BUTTON1) {
if (e.isControlDown()) {
this.boardView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package edu.rpi.legup.puzzle.sudoku.elements;

import edu.rpi.legup.model.elements.PlaceableElement;
import edu.rpi.legup.model.elements.NonPlaceableElement;

public class NumberTile extends PlaceableElement {
public class NumberTile extends NonPlaceableElement {
private int object_num;

public NumberTile() {
super("SUDO-PLAC-0001", "Number Tile", "A numbered tile", null);
super("SUDO-PLAC-0001", "Number Tile", "A numbered tile", "edu/rpi/legup/images/sudoku/tiles/NumberTile.png");
object_num = 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package edu.rpi.legup.puzzle.sudoku.elements;

import edu.rpi.legup.model.elements.PlaceableElement;

public class UnknownTile extends PlaceableElement {
public UnknownTile() {
super(
"SUDO-UNPL-0001",
"Unknown Tile",
"A blank tile",
"edu/rpi/legup/images/sudoku/tiles/UnknownTile.png");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUDO-PLAC-0001 : NumberTile
NURI-UNPL-0001 : UnknownTile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 04a219b

Please sign in to comment.