Complete the given [url removed, login to view] program.

В роботі

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([url removed, login to view]().equals("START")) {

[url removed, login to view]("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", [url removed, login to view]);

[url removed, login to view](new Font(null, [url removed, login to view], 40));

[url removed, login to view](spinner1);

spinner2 = new JLabel("0", [url removed, login to view]);

[url removed, login to view](new Font(null, [url removed, login to view], 40));

[url removed, login to view](spinner2);

spinner3 = new JLabel("0", [url removed, login to view]);

[url removed, login to view](new Font(null, [url removed, login to view], 40));

[url removed, login to view](spinner3);

add(spinnerPanel, [url removed, login to view]);

startStop = new JButton("START");

[url removed, login to view](new Font(null, [url removed, login to view], 20));

[url removed, login to view](this);

add(startStop, [url removed, login to view]);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setSize(200, 150);

setLocationRelativeTo(null);

setVisible(true);

}

}

Навички: Java

Показати більше: java gui atm complete program, simple project gui program java, simple gui math program java, bidding program java randomly generated items price, page replacement program java code, election program java, tiny college program java, program java gui, simple quiz program java, gui program java, finish program java, java read file complete, message program java, quiz program java

ID проекту: #11792616

Доручено:

megaluck

When you need this done by tomorrow ? or today ? Let me know i will be on the chat for a while Best Regards Gustavo

$30 USD за 1 день
(2 відгуків(-и))
1.2

6 фрілансерів(-а) подали заявки на цю роботу; середня заявка - $33

$55 USD за 1 день
(28 відгуків(-и))
4.9
JinTaiZhe

High Quality + Fast Speed = Excellent Result + Business Success, this is my working style. In this site, if you want to implement your idea, then I am always ready for you. My Skills are as follows: - Social App - Onli Більше

$20 USD за 1 день
(5 відгуків(-и))
3.3
$35 USD за 1 день
(0 відгуків(-и))
0.0
arigarcia

Experience in developing websites using php, java and go. I am expert in JEE, JME and JSE. P.S: I not speak english

$35 USD за 1 день
(0 відгуків(-и))
0.0
Epxilon

Hi Sir, I'm experienced developer. I will do your project in short amount of time. You will get quality job with commented code. Contact me so we discuss in detail and move forward. Best Regards Qasim Saleem

$20 USD за 1 день
(0 відгуків(-и))
0.0