New answers tagged

1

There is a lot to unpack here, so this review will be in multiple edits. GUI Creation You are creating and storing some widgets unnecessarily in member variables. For instance, self.truelabel is only used in the TruePosition constructor, it could be a local variable instead of a member variable. The same is true for almost all of the other labels. Your ...


2

GUI Design Changes BorderLayout You are adding subpanels with: panel.add(subpanel1, BorderLayout.WEST); panel.add(subpanel2, BorderLayout.EAST); but you declare panel with: JPanel panel = new JPanel(); which by default uses FlowLayout. You probably want to explicitly use BorderLayout: JPanel panel = new JPanel(new BorderLayout()); and then I ...


2

Solver Your back-tracking algorithm to find the solution to the puzzle is fine, although it is fairly inefficient. On each recursive call, the algorithm must search for the position of the next unknown, which means starting at [0][0] and searching over the same locations over and over on each call. You could improve it by creating an ArrayList<> of ...


2

In addition to what @Carcigenicate said: Spell out color instead of col - I thought it was short for column. pygame has a Rect class. Use it instead of separate x,y,width,height attributes. The Rect class already implements is_over-functionality. If desired, some common code can be pulled out into a parent/base class. Make text bliting into a standalone ...


3

(I'm on my phone on a road trip, so I can't do anything fancy here) Your issues with roster are because you have it as a attribute of the class, not an instance attribute. That means that every instance shares the same roster. You need to define it in the __init__ (or elsewhere, but ideally in the initializer) as self.roster, just like you did with the ...


Top 50 recent answers are included