Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to create a C++ class called Sudoku. This class should be implemented in the Sudoku.h and Sudoku.cpp files. The public interface of this

You are to create a C++ class called Sudoku. This class should be implemented in the Sudoku.h and Sudoku.cpp files. The public interface of this class is as follows:

Sudoku(): Default constructor. Should initialize the object with an empty puzzle (81 zeroes).

void loadFromFile(std::string filename): Reinitializes the object with a new puzzle from the specified file. The passed string will be the relative path of the text file (e.g., "../txt/sudoku1-test.txt"). You may assume the input file has the specified format of nine rows of nine digits separated by a space, and the numbers represent a valid Sudoku puzzle. Note: It is recommended that you use the extraction operator to read in the values, as it will automatically skip all white spaces (blanks, newlines) for you.

bool solve(): The entry point for your solver. Returns true if a solution was found, otherwise returns false. If no solution was found, you may leave the puzzle in either (1) its initial state, or (2) the state when you determined no solution was possible.

bool equals(const Sudoku& other) const: Determines if two puzzles are equal. Two puzzles are equal if the values in each corresponding cell are the same.

std::ostream& operator<<(std::ostream& out, const Sudoku& sudoku): A friend function that prints to the output stream out the current puzzle contents in a nicely formatted manner as seen in the example above. Instead of printing to std::cout, print to the passed output stream out and return it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

10-9 How have social technologies changed e-commerce?

Answered: 1 week ago