Join Carlos Rivas for an in-depth discussion in this video Print the solutions, part of Code Clinic: Java.
- [Instructor] Before proceeding,…be sure to go to the Exercise Files,…Starter Projects, Chapter 3,…and open the eightqueens folder in your favorite Java IDE.…We're using Visual Studio Code here,…so let's go there now.…Let's add the code to our PrintBoard function.…First thing,…we need to expand our small eight-digit…representation of the board…into a full-size chessboard with eight rows…and eight columns.…Let's do it now.…
To do so,…we're going to start with a loop of rows…followed by a loop of columns…going from zero to the length of the board,…and an inside loop also for the columns,…also to the end of the board.…So the board is square.…First thing we need to do is check…whether there is a value in the current cell…that we're checking.…
If we find something in there,…it's obviously going to be a queen…because there are no other pieces in this problem.…We're going to print a Q…representing the queen here,…and a separator.…We're going to add an else statement because…if there is no queen,…then we can imply that it is an empty cell.…
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, PHP, Python, and Ruby.
Skill Level Intermediate
1. Problem 1: Pond Oreille
2. Problem 2: Where Am I?
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Facial Recognition
6. Problem 6: Real-Time Information Dashboard
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.