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)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 新兴县| 大冶市| 武汉市| 河东区| 霍城县| 拉萨市| 鹿邑县| 五河县| 锡林郭勒盟| 桃江县| 娄烦县| 拉萨市| 门源| 莒南县| 博罗县| 泸州市| 开封市| 梁山县| 鄱阳县| 伊金霍洛旗| 平原县| 大宁县| 山阳县| 临武县| 定南县| 伊春市| 共和县| 万盛区| 富川| 息烽县| 孟连| 莆田市| 会昌县| 麻江县| 海安县| 新泰市| 澄城县| 太原市| 宜春市| 肇源县| 镇江市|