question

callabud avatar image
callabud asked

mini lottery game written in java

I written a mini java project, which can do lottery ,for example if you have two sewing machines ,and get head ace to decide to sell or not to sell one of them, the application can do this, and bring some fun just want to show public class card { String cardname; public card(String temp) { // TODO Auto-generated constructor stub cardname =new String(temp); } //Constructor } import java.util.Random; import java.util.Scanner; public class stage { static int tempint; static boolean loopstage=true; static card oktosale; static card nottosale; static String input; public static void main(String[] args) { oktosale =new card("OK TO SALE ^_^"); nottosale=new card("NOT TO SAlE ~_~"); Random drawcard=new Random(); //stage I initialize System.out.print("Type 'OK' to start draw card"); System.out.println(",type any other word byebye"); // waiting to get input Scanner scan = new Scanner( System.in); String x= scan.next(); boolean temp=(x.contentEquals("OK"))|(x.contentEquals("Ok"))|(x.contentEquals("oK"))|(x.contentEquals("ok")); if(temp==false) { System.out.println("Byebye, see you next time, pretty boy"); System.exit(0); } while (loopstage==true) /*had a bug if*/ { //stage II shuffle cards //random tempint=drawcard.nextInt(2); //random //System.out.println(tempint); //test end //stage III show card if(tempint==0) { System.out.println(oktosale.cardname); } else { System.out.println(nottosale.cardname); } //stageIV to again or not agin System.out.print("type AGAIN and then play again,"); System.out.println("type any other word to byebye"); //loopstage=false; //wating the choice part //choice part x=scan.next(); //System.out.println("x.length="+x.length()); if((x.length()==5))/*bug the'again''s length is five, not four*/ {temp= ((x.charAt(0)=='A')|(x.charAt(0)=='a'))& ((x.charAt(1)=='G')|(x.charAt(1)=='g'))&/* this line hand a bug (x.charAt(0)=='g')*/ ((x.charAt(2)=='A')|(x.charAt(2)=='a'))& ((x.charAt(3)=='I')|(x.charAt(3)=='i'))& ((x.charAt(4)=='N')|(x.charAt(4)=='n')); //System.out.println("process whether is 'again'."+"temp="+temp); } else temp=false ; //System.out.println(((x.charAt(0)=='A')|(x.charAt(0)=='a'))& // ((x.charAt(1)=='G')|(x.charAt(1)=='g'))); /*test for(int i=0;i<=4; i++){ System.out.println(x.charAt(i)); } test*/ if(temp==false) { System.out.println("Byebye. Thank you for playing"); System.exit(0); } //choice part //loopstage=true; } //else System.exit(0); } }
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Nothing to answer here. Assuming as answered.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

callabud avatar image
callabud answered
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.