求一个Java棋类游戏源码学习用,要求如下
import java.util.Scanner;
import java.util.Random;
public class Fangfa{
static int sum,sum1=0;
public static void main(String [] args){
int a=1,b=1,c=1;
int k=0,m=1;
int money =5000;
int zhu =0;
boolean flag = true;
Random rand = new Random();
Scanner input = new Scanner(System.in);
while(m==1){
while(flag){
System.out.println("掷色子开始!");
System.out.println("请下注 注:下注金额只能是50的倍数且不能超过1000");
zhu=input.nextInt();
if(zhu%50==0&&zhu<=1000&&zhu<=money){
System.out.println("下注成功");
System.out.println("买大请输入数字1,买小输入数字2");
k=input.nextInt();
a= rand.nextInt(6)+1;
b= rand.nextInt(6)+1;
c= rand.nextInt(6)+1;
sum=a+b+c;
if(k==1){
if(sum>9){
money+=zhu;
System.out.println("恭喜您猜对了,骰子点数为"+sum+"结果是大"+"余额为"+money);
}else{
money-=zhu;
System.out.println("很遗憾,骰子点数为"+sum+"结果是小"+"余额为"+money);
}
}
if(k==2){
if(sum<=9){
money+=zhu;
System.out.println("恭喜您猜对了,骰子点数为"+sum+"结果是小"+"余额为"+money);
}else{
money-=zhu;
System.out.println("很遗憾,骰子点数为"+sum+"结果是大"+"余额为"+money);
}
}
flag= false;
System.out.println("继续请按1,退出请按任意键");
m=input.nextInt();
if(m==1){
flag=true;
System.out.println("您选择的是继续");
}else{
flag=false;
System.out.println("欢迎您下次再来玩");
}
}else{
System.out.println("下注失败"+"余额为"+money);
}
}
}
}
}