Find Jobs
Hire Freelancers

Complete the given SlotMachine.java program.

$10-30 USD

已完成
已发布将近 9 年前

$10-30 USD

货到付款
The program displays a window with three digits and a START button. You must complete the two methods startSpinning() and stopSpinnin() that have already been included. You must also create a thread class. When the user clicks the START button, all three digits start spinning and the START button becomes a STOP button. When the user clicks the STOP button, the first digit stops spinning. When the user clicks the STOP button again, the second digit stops spinning. When the user clicks the STOP button for the third time, the third digit stops spinning, the STOP button becomes a START button, and a message is displayed indicating whether or not the user won. The user can then click the START button to play again. startSpinning() method: This method is called when the user clicks the START button. The method must create three threads, one for each digit. Each thread increments one of the displayed digits (the digits go from 0 to 9 and then back to 0 again) continuously. stopSpinning() method: This method is called when the user clicks the STOP button. One or more of the digits must be spinning. This method stops ONE of the spinning digits. When the last digit stops spinning, the button must be re-named "START" and a message must be displayed indicated whether or not the user won. The user wins if all three digits are the same. thread class: You must write a class for the threads that spin the digits. You can use the Counter example on Shared Files as a guide on how to write this class. Please note that each thread must only spin one digit. This is the program package slotmachine; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SlotMachine extends JFrame implements ActionListener { public static void main(String[] args) { new SlotMachine(); } private JLabel spinner1; // Left digit display private JLabel spinner2; // Middle digit display private JLabel spinner3; // Right digit display private int[] values; // Digit values private JButton startStop; // Button to start or stop spinner(s) // Constructor public SlotMachine() { super("Slots!"); values = new int[3]; makeFrame(); } // Makes all three digits start spinning. public void startSpinning() { // WRITE ME!!! } // Makes one digit stop spinning. // If all digits stop, displays a message if all three digits are the same. public void stopSpinning() { // WRITE ME TOO!!! } // This method is called when Start/Stop button is clicked. public void actionPerformed(ActionEvent e) { if([login to view URL]().equals("START")) { [login to view URL]("STOP"); startSpinning(); } else { stopSpinning(); } } // Builds the window and makes it appear! private void makeFrame() { setLayout(new BorderLayout(5, 5)); JPanel spinnerPanel = new JPanel(new GridLayout(1, 3, 5, 5)); spinner1 = new JLabel("0", [login to view URL]); [login to view URL](new Font(null, [login to view URL], 40)); [login to view URL](spinner1); spinner2 = new JLabel("0", [login to view URL]); [login to view URL](new Font(null, [login to view URL], 40)); [login to view URL](spinner2); spinner3 = new JLabel("0", [login to view URL]); [login to view URL](new Font(null, [login to view URL], 40)); [login to view URL](spinner3); add(spinnerPanel, [login to view URL]); startStop = new JButton("START"); [login to view URL](new Font(null, [login to view URL], 20)); [login to view URL](this); add(startStop, [login to view URL]); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(200, 150); setLocationRelativeTo(null); setVisible(true); } }
项目 ID: 7987533

关于此项目

5提案
远程项目
活跃9 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
颁发给:
用户头像
Hi there, I'm a senior software developer who have about 200 completed projects and my account is qualified by this site (my page: https://www.freelancer.com/u/DucNA.html). Could you please send (or discuss with) me more detail? I'll check and then will let you know my estimation (time and coding effort) for this task. Best regards, Duc Nguyen
$25 USD 在1天之内
4.9 (271条评论)
6.6
6.6
5威客以平均价$26 USD来参与此工作竞价
用户头像
A proposal has not yet been provided
$35 USD 在1天之内
4.9 (92条评论)
6.7
6.7
用户头像
A proposal has not yet been provided
$25 USD 在2天之内
4.7 (20条评论)
4.3
4.3
用户头像
Senior Software Engineer 3 years of Industry experience I am full time employee working in Java only.
$20 USD 在1天之内
5.0 (1条评论)
1.6
1.6
用户头像
As Certified Java programmer I can help with this problem quickly. I would like to help you and your problem will soon be solved. I'm new to this site and for that reason I ask little money.
$25 USD 在3天之内
0.0 (0条评论)
0.0
0.0

关于客户

UNITED STATES的国旗
norwood, United States
5.0
3
付款方式已验证
会员自9月 29, 2014起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。