CoreJava

          code_zone
          隨筆 - 1, 文章 - 2, 評論 - 0, 引用 - 0
          數據加載中……

          抽獎的實現

          import java.util.Random;

          public class Control {
              
          private int num = 4;
              
          private String str = "";
              
          public static void main(String[] args) {
                  Control c 
          = new Control();
                  isWin(c.productRandom());
              }
              
              
          public  String productRandom(){
                  Random d 
          = new Random();
                  
          for(int i=0;i<num;i++){
                      String s 
          = d.nextInt(2)+"";
                      str 
          = randomSelection(s)+str;
                  }
                  System.out.println(
          "您抽到的數字是:"+str);
                  
          return str;
              }
              
          public static String randomSelection(String str){
                  
          if(str.equals("1")){
                      
          return "";
                  }
          else{
                      
          return "";
                  }
              }
              
              
          public static void isWin(String str){
                  
          if(str.equals("★★★★")){
                      System.out.println(
          "恭喜您!中了一等獎!!!");
                  }
          else if(str.equals("★★★☆")){
                      System.out.println(
          "恭喜您,中了二等獎!!!");
                  }
          else if(str.equals("★★☆☆")){
                      System.out.println(
          "恭喜您,中了三等獎!!!");
                  }
          else{
                      System.out.println(
          "不要灰心,希望下次中獎!!!");
                  }
              }
          }

          posted on 2011-06-03 15:10 葛方帥 閱讀(47) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 安陆市| 长兴县| 若羌县| 蕉岭县| 巧家县| 衡阳县| 宁阳县| 新兴县| 吉首市| 金阳县| 行唐县| 慈溪市| 孙吴县| 白城市| 内黄县| 临湘市| 五河县| 安达市| 米泉市| 晋宁县| 布拖县| 昌邑市| 沿河| 越西县| 天长市| 晋宁县| 海门市| 白水县| 杭锦后旗| 甘肃省| 七台河市| 白朗县| 桦甸市| 蓬莱市| 蕉岭县| 南郑县| 贡觉县| 荥经县| 康乐县| 班玛县| 夹江县|