Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am trying to make a roulette game but I don't know what to do here as I have made the code but it is
I am trying to make a roulette game but I don't know what to do here as I have made the code but it is not working and not organized. For example, when the user clicks on spin button a random number gets generated and put onto the textarea where if it even it will go on the even column, odd than odd column, zero than zero columm
the best represention of the area would be this:
Odd Even Zero
this is my code now:
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.;
public class Rol implements ActionListener
private JButton btnSpin;
private JButton btnClear;
private JButton btnExit;
private JTextArea resultArea;
private JLabel lblOutcomes;
public Rol
btnSpin new JButtonSpin;
btnSpin.setBounds;
btnSpin.addActionListenerthis;
btnClear new JButtonClear;
btnClear.setBounds;
btnClear.addActionListenerthis;
btnExit new JButtonExit;
btnExit.setBounds;
btnExit.addActionListenerthis;
resultArea new JTextArea;
resultArea.setBounds;
lblOutcomes new JLabel;
String outcomes Odd "Even", "Zero", st nd rd "Red", "Black";
for int i ; i outcomes.length; i
lblOutcomesi new JLabel;
lblOutcomesisetBoundsi ;
lblOutcomesisetBorderBorderFactorycreateLineBorderColorwhite;
lblOutcomesisetBorderBorderFactorycreateRaisedBevelBorder;
lblOutcomesisetBorderBorderFactorycreateTitledBorderoutcomesi;
public void addComponetJPanel p
paddbtnClear;
paddbtnSpin;
paddbtnExit;
paddresultArea;
for int i ; i lblOutcomes.length; i
paddlblOutcomesi;
public void actionPerformedActionEvent e
int ran random;
int event eventsran;
ifegetSourcebtnSpin
ifevent
resultArea.appendStringformatsran
;
else ifevent
resultArea.appendStringformatsran
;
else ifevent
resultArea.appendStringformatsran
;
public int random
int RNG;
RNG intMathrandom;
return RNG;
public int eventsint ran
int even ;
int odd ;
ifran even.length
return ;
else ifran odd.length
return ;
else
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started