04-20-2004, 07:11 PM | #1 (permalink) |
Dreams In Digital
Location: Iowa
|
[Java AWT] problem with my mastermind game
Okay, so here's the deal. I'm making a Mastermind game. Mastermind is where you try to guess the passcode.. yeah. If you don't know what it is, go google it (Milton Bradley game ).
Anyway, I'm making my game so that 2 windows pop up. One window is the options panel, where you string together your guess for the turn using radio buttons and regular buttons. The radio buttons are in a class that extends Panel, and the regular buttons are also in a class that extends Panel. How do I write my ActionListener so that when "Enter" or whatever is pressed on it's panel, it can capture the radio button currently selected? In other words, how can I make these two classes "talk" to one another? By the way, the class that keeps the key, the guess (either getting the guess after the "Submit" button or concatenating the guess as it goes along, haven't decided yet), checks for win/right/wrong situations, that class is passed in as a param to both the panels, so they can communicate with the game directly. I've been having these kind of problems all semester with OOP, trying to get my objects to talk to one another, I've ended up with some really bad cheats in order to make things work.. Any ideas?
__________________
I can't seem to remember now What it was like- to live life, before you.. symbiont |
04-20-2004, 11:10 PM | #2 (permalink) |
Dreams In Digital
Location: Iowa
|
Nevermind, I came up with a solution- make them private classes within the frame. This seems to work fairly well. Hmm. Okay. Well, I guess if anybody has any better ideas/words of wisdom/etc..
__________________
I can't seem to remember now What it was like- to live life, before you.. symbiont |
04-21-2004, 12:16 PM | #3 (permalink) |
Once upon a time...
|
I would watch those cheats. you might want to think about a design paradigm such as separating the Modekl, View and Controller so that the objects are coherent.
http://java.sun.com/blueprints/patterns/MVC.html
__________________
-- Man Alone ======= Abstainer: a weak person who yields to the temptation of denying himself a pleasure. Ambrose Bierce, The Devil's Dictionary. |
Tags |
awt, game, java, mastermind, problem |
|
|