![]() |
|
lottery games - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Java, JVM, & JRE (https://sinister.li/Forum-Java-JVM-JRE) +--- Thread: lottery games (/Thread-lottery-games) |
lottery games - vqoley - 10-17-2013 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 RE: lottery games - Slarek - 10-17-2013 You should indent your code, makes it easier to read. RE: lottery games - vqoley - 10-19-2013 yeah... thanks for your feedback. i have put list of command in my code. you can see now.. Quote:import javax.swing.*; RE: lottery games - toob223 - 12-22-2013 My appolagies for being the biggest a noob can get, but where am i supposed to enter this code? RE: lottery games - One_ - 12-25-2013 (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 You will need to compile it using command prompt to create the class file, and then run it![]() For this example, save the code as lotterygames.java to your desktop ![]() For example: Go to your command prompt, type Code: cd desktopThen type Code: javac lotterygames.javaOnce it has finished compiling you will see a class file appear on your desktop. Then type Code: java lotterygamesand it will run the program!
RE: lottery games - toob223 - 01-08-2014 Euhm... thanks, but i'm using a PC with windows 7 installed, so the "javac" command won't work RE: lottery games - vqoley - 01-10-2014 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/ |