重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
首先配置环境 配置好J2ME环境
创新互联公司主要从事成都网站设计、网站制作、外贸营销网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务兴海,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220
–安装EclipseME插件
–配置EclipseME插件
–加载WTK
使用Eclipse进行JAVAME程序开发
最后你的手机要能运行java程序
ps:不建议学习JAVA手机开发,应用范围不广,手机开发一般都是嵌入式开发一类,JAVA开发还是侧重于网络开发
控制台小游戏 class YZDEL
{
public static void main(String[] args)
{
java.util.Random Shiji = new java.util.Random();
java.util.Scanner Shuru = new java.util.Scanner(System.in);
java.util.Scanner Nandu = new java.util.Scanner(System.in);
int YingxHP = 20;
int YingxMP = 0;
int MogHP = 20;
int MogMP = 0;
int MogDo = 0;
int fangyu = 0;
System.out.println("┏━━━━╮┏━━┣┣┓ ╮ ┓┏━┳━┳┓┓━┓ ");
System.out.println("┏┣━━━┓┏━━┣┣┓ ┃┏ ┃ ┃┓┃ ╯ ");
System.out.println("┣┣━━━┫╭━━┻╯╮ ┃╰┓┃ ┃╯┏━┣━━┓");
System.out.println("┣┣━━━┫┏━━━━┓╭━━┣━┛┗━┻━┻┛┃┃");
System.out.println("┏┣━━━┓┣━━━━┫ ┃┃┃┗╮╮┃┃┣━╯");
System.out.println(" ┛┗╯┗━━━━╯┗╯╰╰━━┛┛┗━╯╰━┛");
System.out.println();
System.out.println(" 作者:天狐空幻");
System.out.println();
System.out.println("说明:勇者的操作方式为以下所示:");
System.out.println(" 使用攻击需消耗1MP 伤害1HP");
System.out.println(" 使用蓄力可增加1MP 伤害0HP");
System.out.println(" 使用躲闪需消耗0MP 伤害0HP 躲避攻击");
System.out.println(" 使用重击需消耗3MP 伤害2HP 防御无效");
System.out.println(" 恶龙攻击力高, 注意防御是取胜的关键");
System.out.println(" 恶龙MP达到4时可能会放出火焰无法躲避");
System.out.println(" 准备说明完毕,那么让我们来挑战恶龙吧!");
System.out.println("==================================");
//难度选择
System.out.println("请选择难度");
System.out.println("1.娱乐 2.挑战 3.噩梦");
int ND = Nandu.nextInt();
System.out.println("==================================");
while(true)
{
//HP,MP的显示
System.out.print("勇者: ");
System.out.print(" HP ");
for(int x=YingxHP;x0;x--) System.out.print("*");
System.out.print(" "+YingxHP);
System.out.println();
System.out.print(" ");
System.out.print(" MP ");
for(int x=YingxMP;x0;x--) System.out.print("*");
System.out.print(" "+YingxMP);
System.out.println();
System.out.print("恶龙: ");
System.out.print(" HP ");
for(int y=MogHP;y0;y--) System.out.print("*");
System.out.print(" "+MogHP);
System.out.println();
System.out.print(" ");
System.out.print(" MP ");
for(int y=MogMP;y0;y--) System.out.print("*");
System.out.print(" "+MogMP);
System.out.println();
System.out.println("==================================");
//胜利判定
if(YingxHP1) {System.out.println();System.out.println("勇者HP为0! 不..不可能..我怎么会..勇者倒下了。再接再厉吧!~");System.out.println();break;}
if(MogHP1) {System.out.println();System.out.println("恶龙HP为0! 恶龙绝望的哀鸣中倒了下去。勇者胜利了。恭喜你挑战成功!!");System.out.println();break;}
//角色输入判定
System.out.println("你要做什么:");
System.out.println("1.攻击 2.蓄力");
System.out.println("3.躲闪 4.重击");
System.out.println("____________________");
int Do = Shuru.nextInt();
//敌人输入判定
//娱乐难度
if(ND==1){
for(int i=1;i3;i++) MogDo = Shiji.nextInt(4);}
//挑战难度
if(ND==2){
if(YingxMP==0MogMP==0) {MogDo = 0;}
else if(MogMP==0){for(int i=1;i3;i++) MogDo = Shiji.nextInt(2);}
else if(YingxMP2MogMP2) MogDo = 2;
else if(MogMP4) {for(int i=1;i4;i++) MogDo = Shiji.nextInt(3);}
else MogDo = 3;}
//噩梦难度
if(ND==3){
if(Do==1) MogDo=1;
if(Do==2MogMP0) MogDo=2;
if(Do==2MogMP==0) MogDo=0;
if(Do==3MogMP4) MogDo=0;
if(Do==3MogMP=4) MogDo=3;}//变态判定。。
//战斗分析
//防御
if(Do==3) {fangyu=1;System.out.println("你灵巧的躲避攻击!");}
if(MogDo==1) {fangyu=1;System.out.println("恶龙进行防御!");}
//角色判定
if(Do==1YingxMP==0) {System.out.println("MP不足!");}
if(Do==1YingxMP0) {
if(fangyu==0) {MogHP=MogHP-1;YingxMP=YingxMP-1;System.out.println("你发动攻击!");}
if(fangyu==1) {YingxMP=YingxMP-1;System.out.println("你的攻击被格挡!");}}
if(Do==2) {YingxMP=YingxMP+1;System.out.println("你进行蓄力!");}
if(Do==4YingxMP3) {System.out.println("MP不足!");}
if(Do==4YingxMP2) {MogHP=MogHP-2;YingxMP=YingxMP-3;System.out.println("你发动重击!");}
if(Do 4) System.out.println("你不知所措...");
//敌人判定
if(MogDo==2MogMP==0) {System.out.println("恶龙在发呆!");}
if(MogDo==2MogMP0) {
if(fangyu==0) {YingxHP=YingxHP-2;MogMP=MogMP-1;System.out.println("恶龙发动攻击!");}
if(fangyu==1) {MogMP=MogMP-1;System.out.println("恶龙的攻击被躲开了!");}}
if(MogDo==0) {MogMP=MogMP+1;System.out.println("恶龙进行蓄力!");}
if(MogDo==3MogMP4) {System.out.println("恶龙在发呆!");}
if(MogDo==3MogMP3) {YingxHP=YingxHP-4;MogMP=MogMP-4;System.out.println("恶龙发动火焰吐吸!躲避不能!");}
//结束
fangyu = 0;
MogDo = 0;
System.out.println("____________________");
System.out.println();
System.out.println("=================================="); }
}
}
import java.util.Scanner;
public class NumberConvertor {
/**
* @param args
*/
public int input() {
Scanner scan = new Scanner(System.in);
int inputInt = 0;
while (true) {
try {
System.out.println("输入一个0-100的正整数(默认为0): ");
inputInt = scan.nextInt();
if (inputInt 0 || inputInt = 100) {
System.out.println("越界");
continue;
} else {
break;
}
} catch (Exception e) {
System.out.println("输入有误,重新输入");
break;
}
}
return inputInt;
}
public String convert(int aInt) {
String[] table = new String[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒",
"捌", "玖", "拾" };
String result;
String left;
String right;
int leftInt;
int rightInt;
if (aInt = 10) {
result = table[aInt];
} else {
leftInt = Integer.parseInt((String.valueOf(aInt)).substring(0, 1));
rightInt = Integer.parseInt((String.valueOf(aInt)).substring(1));
left = table[leftInt];
right = table[rightInt];
result = left + table[10] + right;
}
return result;
}
public static void main(String[] args) {
NumberConvertor nc = new NumberConvertor();
int val;
val = nc.input();
System.out.println(nc.convert(val));
}
}
public test_03(){
init();
}
public void init(){
JLabel jl_1=new JLabel("用户名");
JLabel jl_2=new JLabel("密码");
JTextField jtf=new JTextField();
JPasswordField jpf=new JPasswordField();
JButton button_1=new JButton("确定");
JPanel panel=new JPanel();
panel.setLayout(null);
jl_1.setBounds(30, 50, 50, 30);
jl_2.setBounds(30,90,50,30);
jtf.setBounds(100, 50, 100, 30);
jpf.setBounds(100, 90, 100, 30);
button_1.setBounds(110, 130, 80, 30);
panel.add(jl_1);
panel.add(jl_2);
panel.add(jtf);
panel.add(jpf);
panel.add(button_1);
this.add(panel);
this.setSize(300, 250);
this.setLocation(400, 300);
this.setVisible(true);
}
public static void main(String[] args) {
new test_03();
}