Login Register






lottery games filter_list
Author
Message
lottery games #1
hello guys, i have bored and have make one game, the game i make i lottery games. so i want shared resources... take it..

Code:
import javax.swing.*; import java.text.*; public class lotterygames { public static void main(String [] args) { lotterygames startx=new lotterygames(); startx.start(); } public void start() { try { String ch=JOptionPane.showInputDialog("1.lottery games \n 2.about \n 3.Exit"); int x=Integer.parseInt(ch); String aboutt="qoley.tseven"; String err="please enter only number one and two"; switch(x) { case 1: lotterygames lg=new lotterygames(); lg.lottery(); break; case 2: JOptionPane.showMessageDialog(null,aboutt, "by QOLEY TSEVEN",JOptionPane.INFORMATION_MESSAGE); lotterygames startx2=new lotterygames(); startx2.start(); case 3: String bye="are you sure want to exit and go to toilet?"; int ss=JOptionPane.showConfirmDialog(null,bye,"qoley tseven",JOptionPane.YES_NO_OPTION); if(ss==JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null,"booooo, i know u want go to toilet... it's ok...\n bye bye","qoley tseven",JOptionPane.INFORMATION_MESSAGE); System.exit(0); } else if(ss==JOptionPane.NO_OPTION) { JOptionPane.showMessageDialog(null, "i think you're lucky","qoley tseven",JOptionPane.INFORMATION_MESSAGE); lotterygames startx50=new lotterygames(); startx50.start(); } break; default: JOptionPane.showMessageDialog(null, err, "error",JOptionPane.ERROR_MESSAGE); lotterygames startx3=new lotterygames(); startx3.start(); } } catch(Exception e) { String err1="please enter only number one and two"; JOptionPane.showMessageDialog(null, err1, "error",JOptionPane.ERROR_MESSAGE); lotterygames startx1=new lotterygames(); startx1.start(); } } public void lottery() { try { String num=JOptionPane.showInputDialog("please enter your four digit lottery number"); int z=Integer.parseInt(num); String about1="are you want continue?"; int lt=(int) (Math.random() *9999) +1; if((z>=10000)) { JOptionPane.showMessageDialog(null,"please enter only 4 digit number"); lotterygames startx35=new lotterygames(); startx35.lottery(); } else if(z==lt) { JOptionPane.showMessageDialog(null,"wow. you're a winner.. thanks..."); int n=JOptionPane.showConfirmDialog(null,about1,"ARE YOU WANT CONTINUE?",JOptionPane.YES_NO_OPTION); if(n==JOptionPane.YES_OPTION) { lotterygames startx32=new lotterygames(); startx32.lottery(); } else if(n==JOptionPane.NO_OPTION) { System.exit(0); } } else { String aboutt=""; aboutt=aboutt+"boooo.... you're loser.. please try again ... \n the winnner number is :"+lt; JOptionPane.showMessageDialog(null,aboutt,"qoley tseven",JOptionPane.INFORMATION_MESSAGE); lotterygames startx3=new lotterygames(); startx3.start(); } } catch(Exception e) { JOptionPane.showMessageDialog(null, "please enter only four digit number. symbol and character not allowed \n press OK for continue"); lotterygames startx31=new lotterygames(); startx31.start(); } } }

-changed quote tags to code tags- staff
don't try learn to hack, hack to learn
[Image: 2nqunnkjpg_zps9b76c611.gif]

Reply

RE: lottery games #2
You should indent your code, makes it easier to read.


Reply

RE: lottery games #3
yeah... thanks for your feedback. i have put list of command in my code. you can see now..

Quote:import javax.swing.*;
import java.text.*;

public class lotterygames
{
public static void main(String [] args)
{
lotterygames startx=new lotterygames();
startx.start();
}
public void start()
{
//try catch for syntax if have error
try
{
//list of menu
String ch=JOptionPane.showInputDialog("1.lottery games \n 2.about \n 3.Exit");
int x=Integer.parseInt(ch);
//sting about from menu
String aboutt="qoley.tseven";
String err="please enter only number one and two";

switch(x)
{
//for choosing number 1, 2, 3
case 1:
//go to lottery method
lotterygames lg=new lotterygames();
lg.lottery();
break;
case 2:
//go to start menthod
JOptionPane.showMessageDialog(null,aboutt, "by QOLEY TSEVEN",JOptionPane.INFORMATION_MESSAGE);
lotterygames startx2=new lotterygames();
startx2.start();
case 3:
//command for yes no option
String bye="are you sure want to exit and go to toilet?";
int ss=JOptionPane.showConfirmDialog(null,bye,"qoley tseven",JOptionPane.YES_NO_OPTION);

//if click yes
if(ss==JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(null,"booooo, i know u want go to toilet... it's ok...\n bye bye","qoley tseven",JOptionPane.INFORMATION_MESSAGE);

System.exit(0);
}
//if click no
else if(ss==JOptionPane.NO_OPTION)
{
JOptionPane.showMessageDialog(null, "i think you're lucky","qoley tseven",JOptionPane.INFORMATION_MESSAGE);
lotterygames startx50=new lotterygames();
startx50.start();
}
break;
//if put other number not in menu
default:
JOptionPane.showMessageDialog(null, err, "error",JOptionPane.ERROR_MESSAGE);
lotterygames startx3=new lotterygames();
startx3.start();
}
}
catch(Exception e)
{
String err1="please enter only number one and two";
JOptionPane.showMessageDialog(null, err1, "error",JOptionPane.ERROR_MESSAGE);
lotterygames startx1=new lotterygames();
startx1.start();
}
}
public void lottery()
{
try
{
//enter 4 digit number
String num=JOptionPane.showInputDialog("please enter your four digit lottery number");
//sting num change to int z for number only
int z=Integer.parseInt(num);
String about1="are you want continue?";
//number only will show four digit
int lt=(int) (Math.random() *9999) +1;

//if someone put 5 digit number
if((z>=10000))
{


JOptionPane.showMessageDialog(null,"please enter only 4 digit number");
lotterygames startx35=new lotterygames();
startx35.lottery();

}
//if number input same with lottery number
else if(z==lt)
{
JOptionPane.showMessageDialog(null,"wow. you're a winner.. thanks...");
int n=JOptionPane.showConfirmDialog(null,about1,"ARE YOU WANT CONTINUE?",JOptionPane.YES_NO_OPTION);
if(n==JOptionPane.YES_OPTION)
{
lotterygames startx32=new lotterygames();
startx32.lottery();
}
else if(n==JOptionPane.NO_OPTION)
{
System.exit(0);
}


}
else
//if number input not same
{
String aboutt="";
aboutt=aboutt+"boooo.... you're loser.. please try again ... \n the winnner number is :"+lt;
JOptionPane.showMessageDialog(null,aboutt,"qoley tseven",JOptionPane.INFORMATION_MESSAGE);
lotterygames startx3=new lotterygames();
startx3.start();
}

}
catch(Exception e)

//catch, if not put integer
{
JOptionPane.showMessageDialog(null, "please enter only four digit number. symbol and character not allowed \n press OK for continue");
lotterygames startx31=new lotterygames();
startx31.start();
}

}
}
don't try learn to hack, hack to learn
[Image: 2nqunnkjpg_zps9b76c611.gif]

Reply

RE: lottery games #4
My appolagies for being the biggest a noob can get, but where am i supposed to enter this code?

Reply

RE: lottery games #5
(12-22-2013, 04:21 PM)toob223 Wrote: My appolagies for being the biggest a noob can get, but where am i supposed to enter this code?

Something as simple as notepad will suffice Smile You will need to compile it using command prompt to create the class file, and then run itSmile
For this example, save the code as lotterygames.java to your desktop Smile


For example:

Go to your command prompt, type
Code:
cd desktop

Then type

Code:
javac lotterygames.java

Once it has finished compiling you will see a class file appear on your desktop.

Then type
Code:
java lotterygames

and it will run the program! Smile
"Impossible is nothing." - Muhammad Ali

Reply

RE: lottery games #6
Euhm... thanks, but i'm using a PC with windows 7 installed, so the "javac" command won't work

Reply

RE: lottery games #7
if you cannot use javac, press start>right click on my computer> properties > advance system setting > environment variables > choose path on system variable > edit > and paste your path where your java bin installed.

after your paste your path, make sure you have java installed and make sure you put semicolon before path. like this:

;C:/Program%20Files%20(x86)/java/jdk1.7.0_40/bin/
don't try learn to hack, hack to learn
[Image: 2nqunnkjpg_zps9b76c611.gif]

Reply