Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Othello game Swing

 
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do have a lit or big problem. When I am running my program it asks for the first player name and for the second. however, after I enter the second user name the boards do not want to display.

I am new to the GUI. Any suggestion?


Board class


Constans class


disc class



Game class


Player Class



Othello class



 
Master Rancher
Posts: 4281
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

 boards do not want to display.


What method displays the boards?
Where is that method called from?

What is line 40 in the Game class supposed to do? The called method is empty.
 
Tomy Alexsander
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in line 40 it should add the player to the array. But how I can understand it does not work.

This is initialising the board and the rest of the methods



It is a which getting the board from the class

 
Norm Radder
Master Rancher
Posts: 4281
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To add an item to a List, call the List's add method:
 
Marshal
Posts: 72595
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those getXXX() and setXXX() methods look very iffy to me. You are polluting your program space with multiple references to the same object, and it is only a matter of time before somebody changes its state elsewhere, probably without even knowing they are doing anything wrong. You need to take defensive copies of mutable objects coming into your object, and retain defensive copies of mutable objects going out of your object.
The Constants class should have all its fields marked final. Otherwise other code can readily change their identity again probably without noticing. Only make primitives and immutable reference types into public constants. I am not sure about Color, but I think it is all right as a constant.
 
Saloon Keeper
Posts: 4377
163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you know about JPanels and JFrames?
 
Campbell Ritchie
Marshal
Posts: 72595
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I wouldn't touch a JPanel or a JFrame until I got the logic for the game working. Fortunately OP is working on that basis already
 
Piet Souris
Saloon Keeper
Posts: 4377
163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Getting a working GUI as son as possible makes testing so much easier
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic