All the 0's are Jbuttons and when a user clicks a button it turns into a 1 button
then i need to click a solve button and give the reduced boolean expression. So my logic needs to somehow group all the buttons into pairs.and then if there are larger pairs of two like pairs of four or eight use that pair because you need the most simplified map as possible.
So can anyone help me to figure out how i would go about doing this. I was thinking of since each button is an array of buttons .Example the top left corner is button[0],button[1],to the right of it etc......... So i'd somehow create a for vloop and say
for(inti = 0; i< 3 ;i++;)
{
if (button[i].getText() && button[i+1].getText() == "1")
then its a group of two so do something with it to remember but not sure what to do add it to a stack or something? because i need to check if its bigger than a pair and also if it's vertically a pair not just horizontilly.
}
please if anyone can help me get started i'd be forever in their debt!!
What you need is:
1) a display : try a 5 x 5 gridbaglayout in which the 1st element is a place holder only.
Make the 8 buttons toggle buttons that control 8 boolean variables.
Make the 16 'infielders' JTextField's.
Setup a suitable Dimension (square?) that will be the preferred size and the maximum size of all
visible elements.
2) setup an actionlistener on every button, to be caught in one actionPerformed().
In there determine which button fired by comparing the action object against the buttons.
So put everything in ONE class.
3) firing buttons set or clear a boolean; from there conpute new contents of
associated JTextFields.
I think this is classwork, so I leave it to you to use colours instead on 1/0 values.
A Karnaugh map is widely used in education; you won't see it much in real-life
development, but I'm a devotede user.
If you know what it is used for you know that boolean expressions
can not just be delivered from any map setting.
It is up to the programmer to combine states into a smart expression.
It will be hard to do it in a program.
But that's your next step; try the above first.
;JOOP!
0
tyweed420Author Commented:
i'v got the buttons listening and the gui setup up fine i just don't know how to setup the algorithim to group the ones into the pairs . I just need a little idea what i could do to get me going some ideas psuedocode whatever! i'm stuck!
Basicly you could see a 4(ABCD) x 4(abcd) map as:
boolean decision = (
A && a || A && b || A && c || A && d
|| B && a || B && b || B && c || B && d
|| C && a || C && b || C && c || C && d
|| D && a || D && b || D && c || D && d
);
For easy cases you can simplify the expression into something like A || B || C && d
but do not expect that a program in this case can simplify everything.
Some complex situations simply can not. In such a case you have to produce the whole formula.
A Karnaugh map is to make visible what one can not understand from a formula.
It is NOT a panace!
;JOOP!
0
This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.
i'm confused how ABCD x abcd woild look? ABCD going horizontal and abcd vertical?
is this the idea?
ab/cd 00 01 11 10
------------------------
00 A a | B a | C a | D a
------------------------
01 A b | B b | C b | D b
-------------------------
11 A c | B c | C c | D c
---------------------------
A d| B d | C d | D d
------------------------------
0
tyweed420Author Commented:
Just increased points to 300 please i'm willing to increase points to max or pay if i have to. I need to learn how to implement this algorithm . there is no way i'll learn just spinning my wheels like i'm doing ........... help!
Sorry, your conditions are a, b, c ,d independently true(uppercase) or false(lowercase) , so it should be:
ab/cd cd Cd cD CD
ab abcd abCd abcD abCD
Ab Abcd AbCd AbcD AbCD
... etc.
;JOOP!
0
tyweed420Author Commented:
ab/cd cd Cd cD CD
ab abcd abCd abcD abCD
Ab Abcd AbCd AbcD AbCD
aB aBcd aBCd aBcD aBCD
AB ABcd ABCd ABcD ABCD
^
is this A || B ||C && d? or does it mean look vertically through the entire first two rows because they are the ones with a small d hence && d?
ok here is the graph i'm trying like hell to figure out what to do with this sucker? ok lets say for edxample the statement you gave in an earlier statement
A || B ||C && d does this mean look in the last row second column.Or does this statement Forgive my ignorance i'm trying hard to understand how this will help to simplify the expressions
Again, a Karnaugh map is a means to enable you to do smart grouping on boolean matrices.
ABCd stands for A && B && C && d
Now, the trick is to see if you can simplify the overall formula.
Example given: you should stop before a red sign and preferrably before a yellow sign,
but only if no police is around:
Red Yellow Green
no cop stop stop go
cop stop stop stop
simplifies to : drive if green and no cop.
It will be tough to do it with large maps!
;JOOP!
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
What you need is:
1) a display : try a 5 x 5 gridbaglayout in which the 1st element is a place holder only.
Make the 8 buttons toggle buttons that control 8 boolean variables.
Make the 16 'infielders' JTextField's.
Setup a suitable Dimension (square?) that will be the preferred size and the maximum size of all
visible elements.
2) setup an actionlistener on every button, to be caught in one actionPerformed().
In there determine which button fired by comparing the action object against the buttons.
So put everything in ONE class.
3) firing buttons set or clear a boolean; from there conpute new contents of
associated JTextFields.
I think this is classwork, so I leave it to you to use colours instead on 1/0 values.
A Karnaugh map is widely used in education; you won't see it much in real-life
development, but I'm a devotede user.
If you know what it is used for you know that boolean expressions
can not just be delivered from any map setting.
It is up to the programmer to combine states into a smart expression.
It will be hard to do it in a program.
But that's your next step; try the above first.
;JOOP!