用java开发dota英雄最华丽的技能(实例讲解)
作者:SXT明辉 时间:2022-05-27 00:10:20
爱java 爱dota,突发奇想想用java开发dota操作最华丽的英雄之一的卡尔的技能,因为本人系小白,代码不足的地方还请包涵,有同样爱好的同学欢迎一起研究学习。
先把我的代码呈上
import java.util.*;
public class TestDotakaer{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("请输入q、w、e中的三个字母");
int count1=0;
int count2=0;
int count3=0;
for(int i=0;i<3;i++){
String a=sc.next();
if(a.equals("q")){
System.out.println("冰元素");
count1++;
}
if(a.equals("w")){
System.out.println("雷元素");
count2++;
}
if(a.equals("e")){
System.out.println("火元素");
count3++;
}
}
System.out.println("您需要按按键r来整合元素成为技能");
String d = sc.next();
if(d.equals("r")){
if(count1==0){
if(count2==0){
System.out.println("您已经切出了技能三阳之炎(eee)");
}
if(count2==1){
System.out.println("您已经切出了技能混沌陨石(eew)");
}
if(count2==2){
System.out.println("您已经切出了技能灵动迅捷(wwe)");
}
if(count2==3){
System.out.println("您已经切出了技能电磁脉冲(www)");
}
}
if(count1==1){
if(count2==0){
System.out.println("您已经切出了技能熔炉精灵(qee)");
}
if(count2==1){
System.out.println("您已经切出了技能超震声波(qwe)");
}
if(count2==2){
System.out.println("您已经切出了技能强袭飓风(qww)");
}
}
if(count1==2){
if(count2==0){
System.out.println("您已经切出了技能寒冰之墙(qqe)");
}
if(count2==1){
System.out.println("您已经切出了技能幽灵漫步(qqw)");
}
}
if(count1==3){
System.out.println("您已经切出了技能急速冷却(qqq)");
}
}
else{
System.out.println("您需要按r,如果不按r您不能够合成技能");
}
}
}
首先介绍下我的代码的大致执行过程
1、先是引用Scanner来定义一个对象sc,再去定义卡尔冰、雷、火三种不同的元素(q----冰、w----雷、e----火)
2、用键盘输入三次元素(q、w、e随意输入三次)
3、用for语句做三次循环并计数(执行一次q,count1加1,执行一次w,count2加1,执行一次q,count3加1)
4、输入三次元素之后,在输入r,来合成技能,用一个if语句来判断是否输入r,如果输入继续执行,如果输入错误那么切技能失败,并且输出"您需要按r,如果不按r您不能够合成技能"。
5、输入r没问题且继续执行,用if语句去判断三次元素具体输入结果,并根据结果的不同,切出不同的技能(为了简便直接用字母代替技能EEE、WEE、WWE、WWW、QEE、QWE、QWW、QQW、QQE、QQQ)
这样一来,卡尔技能程序就已经被简单的编译出来,老生常谈,程序还有很多要修改提高的地方,我会一边学习,一遍完善这个程序,有兴趣的同学可以一起研究,也可以创新新英雄技能的施法过程!
来源:http://www.cnblogs.com/shsxt/p/7839167.html
标签:java,dota,英雄技能
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SpringBoot 开发提速神器 Lombok+MybatisPlus+SwaggerUI
2022-07-08 07:40:23
![](https://img.aspxhome.com/file/2023/6/61516_0s.jpg)
阿里、华为、腾讯Java技术面试题精选
2023-11-25 02:29:39
![](https://img.aspxhome.com/file/2023/4/59904_0s.jpg)
java利用Future实现多线程执行与结果聚合实例代码
2023-09-24 11:07:18
Java的System.getProperty()方法获取大全
2023-11-10 20:12:12
详解C++ STL模拟实现forward_list
2023-06-21 02:36:04
![](https://img.aspxhome.com/file/2023/0/60100_0s.jpg)
基于java构造方法Vector删除元素源码分析
2023-11-25 14:54:45
![](https://img.aspxhome.com/file/2023/8/60238_0s.png)
mybatis 对于生成的sql语句 自动加上单引号的情况详解
2023-09-21 15:25:00
![](https://img.aspxhome.com/file/2023/2/61342_0s.jpg)
android6.0权限动态申请框架permissiondispatcher的方法
2023-07-31 10:51:57
IDEA不编译除了.java之外的文件的解决办法(推荐)
2023-09-16 15:50:44
![](https://img.aspxhome.com/file/2023/0/58570_0s.png)
Java多线程之彻底搞懂线程池
2023-12-18 23:54:09
![](https://img.aspxhome.com/file/2023/5/62135_0s.png)
如何使用Spring AOP的通知类型及创建通知
2022-03-19 19:32:51
![](https://img.aspxhome.com/file/2023/2/61242_0s.png)
基于ReentrantLock的实现原理讲解
2023-11-23 22:43:23
![](https://img.aspxhome.com/file/2023/9/59849_0s.jpg)
springboot 文件上传大小配置的方法
2023-08-02 11:49:16
SpringMVC中使用@PathVariable绑定路由中的数组的方法
2023-11-27 14:21:01
![](https://img.aspxhome.com/file/2023/9/61289_0s.png)
java中的this引用及对象构造初始化
2023-03-07 09:38:17
![](https://img.aspxhome.com/file/2023/6/60996_0s.png)
SpringBoot整合freemarker实现代码生成器
2023-07-17 20:31:08
![](https://img.aspxhome.com/file/2023/5/57505_0s.jpg)
SpringIOC BeanDefinition的加载流程详解
2023-11-25 18:06:22
![](https://img.aspxhome.com/file/2023/8/59938_0s.png)
Java数据结构之二叉排序树的实现
2023-07-05 02:27:25
![](https://img.aspxhome.com/file/2023/0/61600_0s.png)
Spring Boot 整合JPA 数据模型关联使用操作(一对一、一对多、多对多)
2022-11-18 23:14:29
Java分页查询--分页显示(实例讲解)
2023-02-05 11:07:15