java--Random Card Game __java

Source: Internet
Author: User

/*
* Copyright (c) 2014, Computer College, Yantai University
* All rights reserved.
* File name: test.cpp
* Author: Li Xiaokei
* Date of Completion: September 23, 2015
* Version Number: v1.0
*
* Problem Description: Use Java to write a small game, simulation random take poker details down.
* Input Description:
* Program output:

*/

Import Java.util.Scanner; public class Pro1 {/** * @param args */public static void main (string[] args) {//TODO auto-generated method s
		tub int number1= (int) (System.currenttimemillis ()%12);
		int number2= (int) (System.currenttimemillis ()%4); 
		String str1 = null,str2=null;
			Switch (number1) {case 0:str1= "Ace";
		Break
			Case 1:str1= "2";
		Break
			Case 2:str1= "3";
		Break
			Case 3:str1= "4";
		Break
			Case 4:str1= "5";
		Break
			Case 5:str1= "6";
		Break
			Case 6:str1= "7";
		Break
			Case 7:str1= "8";
		Break
			Case 8:str1= "9";
		Break
			Case 9:str1= "10";
		Break
			Case 10:str1= "Jack";
		Break
			Case 11:str1= "Queen";
		Break
			Case 12:str1= "King";
		Break
			Switch (number2) {case 0:str2= "clubs";
		Break
			Case 1:str2= "Diamonds";
		Break
			Case 2:str2= "Hearts";
		Break
			Case 3:str2= "Spades";
		Break
	} System.out.println ("The card you picked are" +str1+ "of" +str2);}
}
 




Summary: This in Java is still relatively good to write, as long as can randomly take out two number, one for 0~12, the size of the card, a 0~3, representative of the color of the card, so you can simulate the random card game.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.