Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8183207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:05:30+00:00 2026-06-07T01:05:30+00:00

I am making a knight’s tour implementation in java, and currently I have everything

  • 0

I am making a knight’s tour implementation in java, and currently I have everything jumbled into one giant mess of code.

I have a class called MainFrame which includes the code to solve the knights tour as well as methods for the menu, etc.

I want to create a new class called KT (for knights tour) which will contain the code for the algorithm, but I’m having lots of issues doing that.

I don’t want to post code here because i dont want someone from my class copying or something, so I will just briefly explain.

In class KT, I have declared the variables, arrays, etc. I have methods such as printSolution, move, redo (the backtracking), etc.

However I am unsure how to tie in the code for the buttons (which is declared in MainFrame). For example, I have a loop in the print method that prints the correct solution on the 8×8 board. Right now I’m being asked to create a new method for the button even though I have the button in class MainFrame.

I have a KT k = new KT(); and then I’m launching MainFrame. Is that where I am doing it wrong or is it something really simple that I’m being too dumb to figure out?

tl;dr program works well when i have everything in one class, but i want to make two classes and make everything “look” nice

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T01:05:31+00:00Added an answer on June 7, 2026 at 1:05 am

    First of all, give your KnightTour class an actual name. Like, you know, KnightTour. If you were coding this for cash money, the next guy who had to read your code would want to punch the guy who called a class something like KT.

    Think about creating this class so that you can use it from a GUI controller like your button and menu laden applet. But so that it can ALSO be used from, say, a character based application where you type commands at a prompt and have your new class evaluate those commands.

    The reason I suggest this is because it will force you to create your KnightTour class so that it is PURELY the “business logic” for your app. By that I mean that your KnightTour class should not know anything about buttons, menus, GUIs, text interfaces, or anything like that. You need to think about your KnightTour class in terms of what it must accomplish.

    I don’t really know what KnightTour does. So I’ll just throw out some ideas of what kind of functionality it might need to support. I’m assuming everything takes place on a chess board?

    1. Get the state (occupied, unoccupied) for a given board location (x,y)
    2. Put a chess piece (piece enumerator) on a given location (x,y)
    3. Validate placement of a piece (piece enumerator, location x,y)
    4. Suggest a move, returning a Suggestion object with a piece enumerator and location
    5. Reset the board to start all over.

    Now, when you push a button that says “place a piece on 5,5” then you’ll handle that event in your GUI controller, and then call the “set piece” method (#2 above) to do that work. If you have a character based application, when you type “put knight at 5,5” then you’ll parse that text, and then invoke #2 above. The key point is that both of those user interfaces access the same KnightTour methods to do the same work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

making a multi-language site with codeginiter. I have created two folders. One for french
I'm making a chess program and currently have the movement done for the pawn
Making a simple Java code for Blackjack and need some advice. OK I am
Making a server in java, First off, Here's the code. AnsiConsole.out.println(This is a Test.);
Making a word document of our network set-up. We have about 7 servers and
Making a mobile friendly site, I have a single field and a submit button.
Background: For one of my university courses, I am making Chess. The GUI is
Making a simple program which will generate a multiple choice form. I have an
implementing code for customized mini(less squares, less pieces ) chess board in java or
making an infinite loop in javascript, and jQuery... this is my current code: $(#bg2).css({opacity:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.