Using inner class discussed in class, simulate that you are playing Match4:
The program must continue running until one of these two situations occurs: 1. Press Ok on the JOptionPane (if you press the button it should say "You lost !!!"). 2. If the number entered is in the Paste4, you must say You won !. They must implement an interface called ask (). Which will ask the desired number.
The interval that is every 1 second and that makes a "beep". Show how many rolls were made.
Note: Investigate how to generate random numbers. Remember that Match4 goes from 1000 to 9999.
The output would be as follows:
-------------------------------------------------- -------------------------------------------------
Enter desired number: 3267
07/09/2019 09:50:23:
roll # 1: 4392
roll # 2: 8391
You lost !!!
-------------------------------------------------- -------------------------------------------------
Enter desired number: 4912
07/09/2019 09:50:23:
roll # 1: 4931
roll # 2: 9450
roll # 3: 4912
Won !!!
This must be done in Eclipse Java 2019-09 (Java language of course)
The paste is where the number added will be the paste that will conclude whether the person won or lost
This also must contain a public static void main(String[] args) with an ask and show
This is an example of the original code. Now I need a public static void main (Strings [] args) containing an ask and show
that is why i want it to be redesigned with public static void like i mentioned earlier. i want it to be replaced with a public static void
NO 100% 18:54 AM + Expert Q&A W + import java.awt.Toolkit; import java.time.LocalDate Time; import java.time.format.Date Time Formatter; import java.util.Random; import java.util.Scanner; import java.util.concurrent.TimeUnit; import javax.swing.JFrame; import javax.swing.JOptionPane; public class Test2 implements ask { static int num; public static void main(Stringargs) { Test2 t = new Test20); t.askDesiredNumber(); JFrame f = new JFrame(); Object( options = { "OK", "Cancel"); // create an object // Joption pane for ok cancel button int n = JOptionPane.showOptionDialog(new JFrame(), "hello", "", JOptionPane.YES_NO_OPTION, JOptionPane. QUESTION_MESSAGE, null, options, options[1]); if (n == JOptionPane.OK OPTION) { // if click ok you lost System.out.println("You lost !!!"); System.exit(0); // print the current date and time Date Time Formatter dtf = Date Time Formatter.ofPattern("yyyy/MM/dd I 0 0 0 OM- NO 100% 18:54 AM Expert Q&A W + // print the current date and time Date Time Formatter dtf = Date Time Formatter.ofPattern("yyyy/MM/dd HH: mm:ss"); LocalDateTime now = LocalDate Time now(); System.out.println(dtf.format(now)); // declare the variable int rNum; int i = 1; while (true) { // loop until generate number match input number try { TimeUnit. SECONDS. sleep(1); // wait 1 second } catch (InterruptedException e) { e.printStackTrace(); Toolkit.getDefaultToolkit().beep(); // beep sound Random r = new Random(); rNum = r.nextInt(9999 - 1000) + 1000; // generate random number between 1000- 9999 System.out.println("Roll #" + i + ":" + rNum): if (num == Num) { // check for the input number equals random number System.out.println("Won!!!"); System.exit(0); III OM- NO 100% 18:55 AM f Expert Q&A W + C.PUTULAUTTALC, Toolkit.getDefaultToolkit().beepO; // beep sound Random r = new Random(); rNum = rnextInt(9999 - 1000) + 1000; // generate random number between 1000- 9999 System.out.println("Roll #" + i +""+ rNum); if (num == rNum) { // check for the input number equals random number System.out.println("Won!!!"); System.exit(0); i++; public void askDesired Number() { // scanner class to input number Scanner in = new Scanner(System.in); System.out.print("Enter desired number:"); num = in.nextInt(); public interface ask { public void askDesiredNumber(); . I 0 0 NO 100% 18:54 AM + Expert Q&A W + import java.awt.Toolkit; import java.time.LocalDate Time; import java.time.format.Date Time Formatter; import java.util.Random; import java.util.Scanner; import java.util.concurrent.TimeUnit; import javax.swing.JFrame; import javax.swing.JOptionPane; public class Test2 implements ask { static int num; public static void main(Stringargs) { Test2 t = new Test20); t.askDesiredNumber(); JFrame f = new JFrame(); Object( options = { "OK", "Cancel"); // create an object // Joption pane for ok cancel button int n = JOptionPane.showOptionDialog(new JFrame(), "hello", "", JOptionPane.YES_NO_OPTION, JOptionPane. QUESTION_MESSAGE, null, options, options[1]); if (n == JOptionPane.OK OPTION) { // if click ok you lost System.out.println("You lost !!!"); System.exit(0); // print the current date and time Date Time Formatter dtf = Date Time Formatter.ofPattern("yyyy/MM/dd I 0 0 0 OM- NO 100% 18:54 AM Expert Q&A W + // print the current date and time Date Time Formatter dtf = Date Time Formatter.ofPattern("yyyy/MM/dd HH: mm:ss"); LocalDateTime now = LocalDate Time now(); System.out.println(dtf.format(now)); // declare the variable int rNum; int i = 1; while (true) { // loop until generate number match input number try { TimeUnit. SECONDS. sleep(1); // wait 1 second } catch (InterruptedException e) { e.printStackTrace(); Toolkit.getDefaultToolkit().beep(); // beep sound Random r = new Random(); rNum = r.nextInt(9999 - 1000) + 1000; // generate random number between 1000- 9999 System.out.println("Roll #" + i + ":" + rNum): if (num == Num) { // check for the input number equals random number System.out.println("Won!!!"); System.exit(0); III OM- NO 100% 18:55 AM f Expert Q&A W + C.PUTULAUTTALC, Toolkit.getDefaultToolkit().beepO; // beep sound Random r = new Random(); rNum = rnextInt(9999 - 1000) + 1000; // generate random number between 1000- 9999 System.out.println("Roll #" + i +""+ rNum); if (num == rNum) { // check for the input number equals random number System.out.println("Won!!!"); System.exit(0); i++; public void askDesired Number() { // scanner class to input number Scanner in = new Scanner(System.in); System.out.print("Enter desired number:"); num = in.nextInt(); public interface ask { public void askDesiredNumber(); . I 0 0