1.zengl编程语言详述
2.求助!点游!戏源用Java编写黑杰克?(完整代码)
3.跪求简单的点游,不用构造函数的戏源java编程 21点纸牌游戏..谢谢..
4.用java编程21点牌简单最好
5.汇鑫佳纳斯达克上市最新消息股票代吗?
zengl编程语言详述
Zengl编程语言的初衷是为了帮助人们理解编译原理的奥秘,遵循开源精神,点游作者将编程语言的戏源tcpdump源码解析开发过程逐步公开,包括Windows系统下的点游VS版本和Linux下的源代码,且每个版本都附有测试脚本,戏源验证其实用性和中文文档,点游便于学习者深入理解核心内容。戏源
作者从词法解析开始,点游逐步构建,戏源包括第一个词法扫描器版本,点游接着是戏源抽象语法树生成,乃至创建了类似Java虚拟机的点游网格交易量化源码解释器,用简洁的C语言结构构建,注重注释和文档,引导读者逐步掌握。学习者可以通过逐步升级的版本,从基础到深入,领略编译原理和编程语言的魅力,最终可能发展出自己的编程语言,或在其他项目中应用编译原理的知识。
作者用Zengl v1.0.5开发了俄罗斯方块游戏,并分享了Linux下暂停时的截图。在产品应用中,Zengl被嵌入到一个采集器中,作为动态脚本规则,展示了其在实际应用中的聚合登录API程序源码灵活性。作者还开发了点扑克小游戏和使用SDL的游戏截图,进一步证实了其实用性。
编程语言的教育性在笑话中也得到了体现,强调了编程不仅仅是技术,更是创新和独立精神的体现。编程需要自主学习和创新,开发属于自己的编程语言,摆脱单纯模仿和商业炒作,形成真正的编程自主权和创新力。
通过发布所有版本,作者希望鼓励更多人参与开源软件行业,学习编译原理从最基础的版本开始,如《龙书》是很好的入门教材。Zengl编程语言支持的战神代理管理系统源码关键词包括打印、条件选择、循环、函数、全局变量等,提供了一个实用且易理解的学习平台。
求助!!用Java编写黑杰克?(完整代码)
package pkt2;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;
public class Game extends JFrame implements ActionListener
{
int a,a2,rdm,YorN,Z=0,s,s2,th=0,Zth=0;
JPanel pnlMain,pnlCard,pnlZCard;
JLabel lblCarded,lblCout,lblZCarded,lblZCout,lblCard,lblZCard;
JButton btnSend,btnGetCard,btnStopCard,btnExit;
public Game()
{
super("二十一点游戏");
pnlMain=new JPanel();
pnlCard=new JPanel();
pnlZCard=new JPanel();
this.setContentPane(pnlMain);
pnlMain.setLayout(null);
pnlCard.setLayout(null);
pnlZCard.setLayout(null);
pnlMain.add(pnlCard);
pnlMain.add(pnlZCard);
pnlCard.setBounds(, , , );
pnlZCard.setBounds(, , , );
lblCarded=new JLabel("当前的牌:");
lblCarded.setBounds(, , , );
lblCout=new JLabel("当前点数:");
lblCout.setBounds(, , , );
lblZCarded=new JLabel("庄家的牌:");
lblZCarded.setBounds(, , , );
lblZCout=new JLabel("庄家点数:");
lblZCout.setBounds(, , , );
btnSend=new JButton("开局发牌");
btnSend.setBounds(, , , );
btnSend.addActionListener(this);
btnGetCard=new JButton("要牌");
btnGetCard.setBounds(, , , );
btnGetCard.addActionListener(this);
btnStopCard=new JButton("停牌");
btnStopCard.setBounds(, , , );
btnStopCard.addActionListener(this);
btnExit=new JButton("退出游戏");
btnExit.setBounds(, , , );
btnExit.addActionListener(this);
pnlMain.add(lblCarded);
pnlMain.add(lblCout);
pnlMain.add(lblZCarded);
pnlMain.add(lblZCout);
pnlMain.add(btnSend);
pnlMain.add(btnGetCard);
pnlMain.add(btnStopCard);
pnlMain.add(btnExit);
setSize(,);
setVisible(true);
setLocation(,);
setResizable(false);
}
public void GetRdm()
{
Random rdm=new Random();
a=Math.abs(rdm.nextInt())%+1;
String strCardFile="images/"+String.valueOf(a)+".gif";
if(a>)
a=;
lblCard=new JLabel(new ImageIcon(strCardFile),2);
th+=;
lblCard.setBounds(th, 0, , );
pnlCard.add(lblCard);
}
public void ZGetRdm()
{
Random rdm2=new Random();
a2=Math.abs(rdm2.nextInt())%+1;
String strZCardFile="images/"+String.valueOf(a2)+".gif";
if(a2>)
a2=;
lblZCard=new JLabel(new ImageIcon(strZCardFile),2);
Zth+=;
lblZCard.setBounds(Zth, 0, , );
pnlZCard.add(lblZCard);
}
public void Send()
{
pnlCard.removeAll();
pnlZCard.removeAll();
Z=0;th=0;Zth=0;
s=a;
this.GetRdm();this.ZGetRdm();
lblCarded.setText("当前的牌:"+a);
lblCout.setText("当前点数:"+a);
lblZCarded.setText("庄家的牌:"+a2);
lblZCout.setText("庄家点数:"+a2);
s=a;s2=a2;
}
public void GetCard()
{
YorN=JOptionPane.showConfirmDialog(null, "选择“是”继续要牌,选择“否”结束要牌","你是否继续要牌?",JOptionPane.YES_NO_OPTION);
if(YorN==JOptionPane.OK_OPTION)
{
this.GetRdm();
s+=a;
lblCarded.setText("当前的牌:"+a);
lblCout.setText("当前点数:"+s);
if(s>)
JOptionPane.showMessageDialog(null, "你的点数大于点,你爆了!");
}
}
public void ZGetCard()
{
YorN=JOptionPane.showConfirmDialog(null, "选择“是”继续要牌,选择“否”亮牌","庄家是否继续要牌?",JOptionPane.YES_NO_OPTION);
if(YorN==JOptionPane.OK_OPTION)
{
this.ZGetRdm();
s2+=a2;
lblZCarded.setText("庄家的牌:"+a2);
lblZCout.setText("庄家点数:"+s2);
if(s2>)
JOptionPane.showMessageDialog(null, "庄家的点数大于点,庄家爆了!");
}
}
public void StopCard()
{
pnlCard.removeAll();
lblCard=new JLabel(new ImageIcon("images/back.gif"));
lblCard.setBounds(0, 0, , );
pnlCard.add(lblCard);
JOptionPane.showMessageDialog(null, "你已结束要牌,庄家要牌!");
Z=1;
}
public void ZStopCard()
{
pnlCard.removeAll();
Z=0;
if(s>s2)
JOptionPane.showMessageDialog(null, "你的点数大于庄家点数,你赢了!");
if(s==s2)
JOptionPane.showMessageDialog(null,平均成本线的源码 "你的点数等于庄家点数,平局!");
if(s<s2)
JOptionPane.showMessageDialog(null, "你的点数小于庄家点数,你输了!");
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btnSend)
this.Send();
if(e.getSource()==btnGetCard)
{
if(Z==0)
this.GetCard();
else
this.ZGetCard();
}
if(e.getSource()==btnStopCard)
{
if(Z==0)
this.StopCard();
else
this.ZStopCard();
}
if(e.getSource()==btnExit)
System.exit(0);
}
public static void main(String[] args)
{
new Game();
}
}
我们java第一课的作业,这是我做的,给你参考一下吧
文件放在工程根目录下
跪求简单的,不用构造函数的java编程 点纸牌游戏..谢谢..
import java.util.Scanner;
public class TestsGumble { public static void main(String args[])
{
int point=;
Scanner scanner=new Scanner(System.in);
while(true)
{
System.out.println("您现在"+point+","+"您还继续玩吗?");
String s=scanner.next();
if ("n".equals(s)){
System.out.print("游戏结束");
break;
}
int sum=0;
int r=(int)(Math.random()*);
sum=sum+r;
while(true)
{
System.out.println("你现在已经"+sum+",你还要吗?");
String result=scanner.next();
if ("n".equals(result))
{
System.out.println("本局结束");
break;
}
else
{
r=(int)(Math.random()*);
sum=sum+r;
if (sum>)
break;
}
}
if (sum>)
{
point=point-;
}
else if (sum>){
point=point+;
}else{
point=point-;
}
}
}
}
用java编程点牌简单最好
public class Point {
private static ArrayList<CardBean> cardsOfCom;
private static ArrayList<CardBean> mycards;
private static int comStatus = 0;
private static int myStatus = 0;
private static int comMoney = ;//电脑当前的钱
private static int playerMoney = ;//游戏者当前的钱
private static int betScore = 1;//游戏者下注数
private static int fact = 1;//下注倍数
private static CardBean getOneCard(CardBean src) {
CardBean cardnew = new CardBean();
cardnew.setName(src.getName());
cardnew.setScore(src.getScore());
return cardnew;
}
private static int startGame(Cards c) {
cardsOfCom.clear();
mycards.clear();
betScore = 1;
fact = 1;
CardBean cb = null;
CardBean newcard = null;
for (int i = 0; i < 2; i++) {
cb = c.getOneCard();
if (cb == null) {
return 0;
}
newcard = getOneCard(cb);
cardsOfCom.add(newcard);
cb = c.getOneCard();
if (cb == null) {
return 0;
}
newcard = getOneCard(cb);
mycards.add(newcard);
}
return 1;
}
/
*** 显示电脑目前的牌和分数,如果返回值为0,则电脑“爆炸”了
* @return
*/
private static int showComputerCards() {
String cards = " ";
int total = 0;
for (int i = 0; i < cardsOfCom.size(); i++) {
CardBean cb = (CardBean) cardsOfCom.get(i);
cards = cards + cb.getName() + " ";
total += cb.getScore();
}
System.out.println("Computer's cards:" + cards + ";Computer's score:"
+ total);
if(total==)//当游戏双方有一方刚好是点的时候,赌注的赔率翻倍..
{
fact = 2;
}
if (total > ) {
return 0;
}
return 1;
}
/
*** 显示游戏者目前的牌和分数,如果返回值为0,则游戏者“爆炸”了
* @return
*/
private static int showPlayerCards() {
String cards = " ";
int total = 0;
for (int i = 0; i < mycards.size(); i++) {
CardBean cb = (CardBean) mycards.get(i);
cards = cards + cb.getName() + " ";
total += cb.getScore();
}
System.out.println("your cards:" + cards + ";your score:" + total);
if(total==)//当游戏双方有一方刚好是点的时候,赌注的赔率翻倍..
{
fact = 2;
}
if (total > ) {
return 0;
}
return 1;
}
/
***
* @return 返回1则表明还有牌发,如果为0则表示最后一张牌发完,游戏结束!
*/
private static int computerGetOneCard(Cards c) {
if (comStatus == 1)//如果这一局电脑已经不要牌了,则不能再次要牌
{
return 1;
}
int total = 0;
for (int i = 0; i < cardsOfCom.size(); i++) {
CardBean cb = (CardBean) cardsOfCom.get(i);
total += cb.getScore();
}
if (total >= ) {
comStatus = 1;//超过分电脑就不再要牌
return 2;
}
CardBean src = c.getOneCard();
if (src == null)//牌已经全部发完,退出并返回0已告知主程序
{
return 0;
}
CardBean newcard = getOneCard(src);
cardsOfCom.add(newcard);
System.out.println("Computer get one card:" + newcard.getName());
return 1;
}
/
***
* @return 返回1则表明还有牌发,如果为0则表示最后一张牌发完,游戏结束!
*/
private static int playerGetOneCard(Cards c) {
if (myStatus == 1)//如果这一局游戏者已经不要牌了,则不能再次要牌
{
return 1;
}
System.out.println("您是否还要牌?是(y)/否(n)");
int ii = -1;
try {
ii = System.in.read();
} catch (Exception e) {
e.printStackTrace();
return 0;
}
clearEnter();
char ch = Character.toChars(ii)[0];
if (ch == 'n') {
myStatus = 1;
return 2;
}
CardBean src = c.getOneCard();
if (src == null)//牌已经全部发完,退出并返回0已告知主程序
{
return 0;
}
CardBean newcard = getOneCard(src);
mycards.add(newcard);
System.out.println("You get a card:" + newcard.getName());
return 1;
}
private static int compareScores() {
int pScore = 0;
int cScore = 0;
for (int i = 0; i < mycards.size(); i++) {
CardBean cb = (CardBean) mycards.get(i);
pScore += cb.getScore();
}
for (int i = 0; i < cardsOfCom.size(); i++) {
CardBean cb = (CardBean) cardsOfCom.get(i);
cScore += cb.getScore();
}
if (pScore > cScore) {
return 1;
}
if (pScore < cScore) {
return -1;
}
return 0;
}
private static void clearEnter() {
int ii = ;
try {
while (ii == ) {
ii = System.in.read();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public Point() {
}
public static int play(Cards cards) {
comStatus = 0;
myStatus = 0;
int ret = 0;
//如果把Cards 放在这里来new的话。就是每次打完一局都会重新洗牌,程序永远不会结束
//Cards cards = new Cards();
if (startGame(cards) == 0) {
System.out.println("牌已发完,退出程序!");
return 1;
}
showComputerCards();
showPlayerCards();
doBetScore();//选择把下注的时机放在刚发两张牌的时候,这样比较刺激点^_^
int nofinish = 1;
int noabort = 1;
int finished = 0;
while (finished < 2) {
noabort = computerGetOneCard(cards);
if (noabort == 0) {
System.out.println("牌发完鸟,游戏结束!");
return 1;
} else if (noabort == 2) {
finished++;
if (finished == 2) {
break;
}
}
nofinish = showComputerCards();
if (nofinish == 0) {
System.out.println("电脑爆咯,你赢了!");
return 0;
}
noabort = playerGetOneCard(cards);
if (noabort == 0) {
System.out.println("牌发完鸟,游戏结束!");
return 1;
} else if (noabort == 2) {
finished++;
}
nofinish = showPlayerCards();
if (nofinish == 0) {
System.out.println("你爆咯,你Failed!");
return 0;
}
}
if (finished == 2) {
int result = compareScores();
if (result == 1) {
System.out.println("你赢了!");
} else if (result == -1) {
System.out.println("你输了!");
} else {
System.out.println("打平!");
}
}
return ret;
}
private static void finishOneGame(int isfinish) {
try {
if(isfinish==0)//如果不是牌发完而导致游戏退出,则需算分...
{
calculateScores();
}
System.out.println("游戏结束!!!请按回车键继续");
System.in.read();
clearEnter();
//System.out.print("这里应该输入清屏...");
} catch (Exception e) {
System.out.println("error while game finished:" + e.getMessage());
}
}
private static void calculateScores()
{
//int nFact = 0;//决定游戏者,电脑是加分还是减分的因子
int pScore = 0;//游戏者的分数
int cScore = 0;//计算机的分数
int reward = 0;//最终得分
for (int i = 0; i < mycards.size(); i++) {
CardBean cb = (CardBean) mycards.get(i);
pScore += cb.getScore();
}
for (int i = 0; i < cardsOfCom.size(); i++) {
CardBean cb = (CardBean) cardsOfCom.get(i);
cScore += cb.getScore();
}
if(cScore>)//如果电脑爆了..
{
int s1 = cScore - ;
reward = betScore * fact + s1;
}
else if(pScore>)//如果游戏者爆了
{
int s1 = pScore - ;
reward = -(betScore * fact + s1);
}
else if(pScore>cScore)//如果游戏者比电脑接近点
{
reward = betScore * fact + (pScore - cScore);
}
else if(pScore<cScore)//如果电脑比游戏者接近点
{
reward = -(betScore * fact) + (pScore - cScore);
}
playerMoney += reward;
comMoney -= reward;
System.out.println("您现在的余额是:"+playerMoney+",电脑的余额:"+comMoney);
}
private static void doBetScore()
{
System.out.println("请输入 1~9 进行下注(如果输入其他字符,将默认为下注1)");
String str = readinOneString();
if("".indexOf(str)>=0)//正确的下注将按实际的下注值
{
betScore = Integer.parseInt(str);
}
else//非法的输入将认为是下1块钱注
{
betScore = 1;
}
}
private static String readinOneString()
{
String ret = null;
try
{
int ii = System.in.read();
clearEnter();
ret = "" + Character.toChars(ii)[0];
}
catch(Exception e)
{
e.printStackTrace();
}
return ret;
}
public static void main(String[] args) {
mycards = new ArrayList<CardBean>();
cardsOfCom = new ArrayList<CardBean>();
Cards cards = new Cards(2);
int isfinish = 0;
while (isfinish == 0) {
isfinish = play(cards);
finishOneGame(isfinish);
}
System.out.println("最后得分:游戏者"+playerMoney+";电脑"+comMoney);
}
}
public class CardBean {
private String name;
private String color;
private int score;
private int status;
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
public class Cards {
public static final int ONE_PAIR_COUNT = ;
//有多少副牌
private int size = 1;
private int unused = 0;
private ArrayList<CardBean> cards = null;
public Cards()
{
initialize();
}
public Cards(int nSize)
{
size = nSize;
initialize();
}
protected void initialize()
{
cards = new ArrayList<CardBean>();
for(int i=0;i<4*size;i++)
{
for(int j=0;j<;j++)
{
initCardBean(j);
}
}
unused = ONE_PAIR_COUNT * size;
}
private void initCardBean(int index)
{
CardBean cd = new CardBean();
if(index==0)
{
cd.setName("A");
cd.setScore();
}
else if(index==)
{
cd.setName("J");
cd.setScore(1);
}
else if(index==)
{
cd.setName("Q");
cd.setScore(1);
}
else if(index==)
{
cd.setName("K");
cd.setScore(1);
}
else
{
cd.setName(String.valueOf(index+1));
cd.setScore(index+1);
}
cd.setStatus(0);
cards.add(cd);
}
public CardBean getOneCard()
{
if(unused==0)
{
return null;
}
int seed = (int)System.currentTimeMillis() % ;
Random rd = new Random();
int n = rd.nextInt(seed);
n = (Math.abs(n)) % cards.size();
CardBean cb = (CardBean)cards.get(n);
while(cb.getStatus()!=0)
{
n = (n+1) % cards.size();
cb = (CardBean)cards.get(n);
}
cb.setStatus(1);//这张牌已经发出去了,下次不能选了
unused--;
return cb;
}
}
汇鑫佳纳斯达克上市最新消息股票代吗?
汇鑫佳纳斯达克上市最新消息股票代码:import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;/
*** 点游戏。
* 1、洗牌
* 2、发牌
* 3、计算点数
* 4、 是否要牌
* 5、计算机发牌
* 6、计算结果
*/
public class TPoint{
private int[] pai = new int[]; //张牌
private String[] huase= { "黑","红","梅","方"};
private String[] paiM = { "A","2","3","4","5","6","7","8","9","","J","Q","K"};//牌面显示
private ArrayList<Integer> al = new ArrayList<Integer>(); //存储玩家手中的牌
private int currentPoint;
private int computerPoint = 0;
private int currentPage=0;
public TPoint() {
super();
xipai();// 洗牌
fapai();//发牌
needPai();//是否要牌
computerPai();//电脑发牌
result(); //计算结果
}
private void xipai() {
for(int i = 0; i < ;i++ ){
pai[i]=i; //张牌赋值
}
for(int j = 0;j<;j++){ //打乱次
Random r = new Random();
int i1 = Math.abs(r.nextInt()%); //在张中牌中找到第一张
int i2 =Math.abs(r.nextInt()%);//在张中牌中找到第二张
int temp = pai[i2];
pai[i2] = pai[i1];
pai[i1] = temp;
}
}
private void fapai() {
/* for(int i = 0;i<;i++){
System.out.print(pai[i]+"\t");
}*/
//先发两张给玩家
al.add(pai[0]);
al.add(pai[1]);
currentPoint += calPoint(pai[0]);
currentPoint+= calPoint(pai[1]);
currentPage= 2;
}
private int calPoint(int i) { //计算牌的点数
int temp = 0;
if(i%+1>){ //JQK都是
temp = ;
}
else{
temp = (i+1)%;}return temp;}
private void needPai() {
while(true){
xianshi(); //显示牌面
if(currentPoint>=){ //玩家点数大于则不能再要牌
break;
}
System.out.println("是否还要牌,输入N不要!");
Scanner sc = new Scanner(System.in);
if(sc.next().equalsIgnoreCase("N")){
break; //输入N则结束
}else {
al.add(pai[currentPage]); //继续添加牌
currentPoint+=calPoint(pai[currentPage]); //牌点数+
currentPage++;
}
}
}
private void xianshi() {
for(Integer in:al){ //显示玩家手中的牌
System.out.print(huase[in/]+" "+paiM[in%]+"\t"); //显示花色 和牌面
System.out.println("当前总分:"+currentPoint);
}
private void computerPai() {
Random r = new Random();
computerPoint = Math.abs(r.nextInt())%+; //电脑的点数在点到点
System.out.println("\n电脑 的牌面:"+computerPoint);
}
private void result() {
if(currentPoint>){ //玩家点数大于则不能再要牌
System.out.println("you lost!");
}else if(currentPoint==computerPoint){
System.out.println("you lost!");
}else if(computerPoint>){
System.out.println("you Win!");
}else if(currentPoint>computerPoint){
System.out.println("you Win!");
}else{
System.out.println("you Lost!");
}
}
public static void main(String[] args){
new TPoint();
}
}
扩展资料:
对于计算机而言,并不存在真正意义上的“好”的源代码;然而作为一个人,书写习惯的好坏将决定源代码的好坏。源代码是否具有可读性,是判断其好坏的重要标准。软件文档则是表明可读性的关键。
代码作为程序员用开发工具所支持的语言写出来的源文件,设计的原则包括唯一确定性、标准化和通用性、可扩充性与稳定性、便于识别与记忆、力求短小与格式统一以及容易修改等。
源代码是代码的分支,某种意义上来说,源代码相当于代码。现代程序语言中,源代码可以书籍或磁带形式出现,但最为常用格式是文本文件,这种典型格式的目的是为了编译出计算机程序。计算机源代码最终目的是将人类可读文本翻译成为计算机可执行的二进制指令,这种过程叫编译,它由通过编译器完成。