Skip to content

Gdzagaa1/cs108-sudoku-database

Repository files navigation

Object Oriented Programming coursework from Stanford's CS108 curriculum.

This was completed as part of my university coursework at Free University of Tbilisi, following the CS108 curriculum originally developed at Stanford.

See the assignment PDF for detailed explanation and implementation requirements.

CS108 Sudoku & Metropolises Database

This project implements the two parts:

  • Part A - Sudoku solver & GUI that applies recursive backtracking with spot-order heuristics and exposes both a programmatic API and a Swing front end.
  • Part B - Metropolises database explorer that lets a user add/query a MySQL table via a JTable powered by a custom AbstractTableModel.

Repository layout

  • sudoku_A/ – core solver (Sudoku), Swing UI (SudokuFrame) and unit tests.
  • database_B/ – database model (Metropolis), DAO layer, table model, Swing UI (MetropolisFrame), DAO tests and starter SQL.

Technologies used

  • Java 8+ for all application logic, unit tests and Swing GUIs.
  • Swing (javax.swing, java.awt) for both desktop interfaces.
  • MySQL as the relational datastore for the metropolises client.
  • JDBC + MySQL Connector/J for database connectivity.
  • Apache Commons DBCP2/Pool2 and Commons Logging for connection pooling and logging.
  • JUnit 3 (junit.framework.TestCase) for automated tests.

Part A – Sudoku solver

Key classes

  • Sudoku: encapsulates a puzzle grid, exposes constructors from int[][] or text and implements solve(), getSolutionText(), getElapsed() and toString().
  • Sudoku.Spot: inner class that models each empty cell, computes legal values on demand and enables the “most constrained first” heuristic by exposing numPossibleValues().
  • SudokuFrame: small Swing app with dual text areas (puzzle + solution), a Check button and an “Auto Check” toggle wired through a DocumentListener.

Part B – Metropolises database client

Data model & persistence

  • Metropolis: simple POJO used by both the DAO and the table model.
  • MetropolisesDAO: wraps a BasicDataSource to issue parameterized INSERT/SELECT statements based on UI criteria (population comparison + exact/partial matches).
  • MetropolisesTable: custom AbstractTableModel that owns the DAO, exposes search(...) and add(...) and notifies the JTable via fireTableDataChanged().

Tests

  • sudoku_A/SudokuTest.java uses JUnit to cover solving, elapsed time tracking and grid parsing.
  • database_B/MetropolisesTest.java spins up a dedicated MySQL schema (metropolises_test) to verify DAO add/search logic under several scenarios.

About

Sudoku solver with GUI and MySQL metropolis database application. Built with Java Swing and JDBC.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages