java猜谜游戏
import java.io.*;
public class Luckyman {
public static void main(String []args){
int coins,i,j,bets,rand,rewards,unit;
char choiceID,luckyID;
boolean flag=true;
int in;
coins=10;
bets=0;
unit=1;
choiceID='N';
luckyID='N';
BufferedReader br,bw;
intro();
while(flag==true){
System.out.println("您当前的金币总计:¥"+coins);
if(coins<=0){
System.out.println("您的金币已经用完,游戏结束。");
flag=false;
return;
}
System.out.println("欢迎进入幸运苹果机,新的一轮游戏马上开始!");
System.out.println("猜中的物品及对应的奖励如下:");
System.out.println("A.苹果---2 金币");
System.out.println("B.木瓜--5 金币");
System.out.println("C.西瓜--10 金币");
System.out.println("D 香蕉--20 金币");
System.out.println("E 橙子--50 金币");
System.out.println("F.葡萄--100 金币");
System.out.println("游戏结束,请按Q!");
try{
System.out.print("请输入您选中的水果(输入大写字母A~F):");
br=new BufferedReader(new InputStreamReader(System.in));
choiceID=(char)br.read();
if(choiceID=='Q'){
flag=false;
return;
}
do{
System.out.print("请输入您要押的金币数");
System.out.print(coins+"金币");
bw=new BufferedReader(new InputStreamReader(System.in));
bets=Integer.parseIn
相关文档:
public static void replaceString(String a,String b,String c){
System.out.println(a);
String result = a.replaceAll("(?i)"+b, c); //大小写不敏感
......
转 : http://wintys.blog.51cto.com/425414/94051
/**
*名称:BinarySearch
*功能:实现了折半查找(二分查找)的递归和非递归算法.
*说明:
* 1、要求所查找的数组已有序,并且其中元素已实现Comparable<T>接口,如Integer、String等.
* 2、非递归查找使用search( ......
Java中的我们可以利用split把字符串按照指定的分割符进行分割,然后返回字符串数组,下面是string.split的用法实例及注意事项:
java.lang.string.split
split 方法
将一个字符串分割为子字符串,然后将结果作为字符串数组返回。
stringObj.split([separator,[limit]]) 免费资源收集网(http://www.freezq.cn)
strin ......
List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1 List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......