首页 / JAVA / Javadoc示例代码
Javadoc示例代码
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Javadoc示例代码,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2696字,纯文字阅读大概需要4分钟。
内容图文
![Javadoc示例代码](/upload/InfoBanner/zyjiaocheng/854/8791e98871244442a8508781b7c89913.jpg)
方法要想显示注释的话得把它定义成public,而且注释放在想注释的方法的前面
package com.test;
import java.util.*;
/**
*
* role类的简述
* role为角色,包含生命值和攻击力两个属性
*
*
*/
class role{
public int health;
public int attack;
public role(int a, int h) {
attack= a;
health= h;
}
}
/**
* 炉石传说的代码
* @author 谭文彪
*
*/
public class Main {
/**
* 设置两个角色
*/
static Vector<role> herroAndFollow1= new Vector<>();
static Vector<role> herroAndFollow2= new Vector<>();
/**
* 判断两个英雄的生命值是否还大于0
* @return 1表示先手赢,-1表示后手赢,0表示没有赢家
*/
public int herroStillExist() {
/**
* @return 1表示先手赢
*/
if(herroAndFollow1.get(0).health<= 0)
return -1;
if(herroAndFollow2.get(0).health<= 0)
return 1;
return 0;
}
/**
* 按照题目的要求格式输出
*/
public void print() {
System.out.println(herroStillExist());
System.out.println((int)herroAndFollow1.get(0).health);
System.out.print(herroAndFollow1.size()- 1);
for(int i= 1; i< herroAndFollow1.size(); i++) {
System.out.print(" "+ herroAndFollow1.get(i).health);
}
System.out.println();
System.out.println(herroAndFollow2.get(0).health);
System.out.print(herroAndFollow2.size()- 1);
for(int i= 1; i< herroAndFollow2.size(); i++) {
System.out.print(" "+ herroAndFollow2.get(i).health);
}
System.out.println();
}
/**
* 炉石传说的main函数
* @param args 没有输入
*/
public static void main(String[] args) {
Scanner scanner= new Scanner(System.in);
Main mainclass= new Main();
herroAndFollow1.add(0, new role(0, 30));
herroAndFollow2.add(new role(0, 30));
int n= scanner.nextInt();
int count= 1;
while((n--)!= 0) {
String operator= scanner.next();
if(operator.equals("summon")) {
int position = scanner.nextInt();
int attack= scanner.nextInt();
int health= scanner.nextInt();
if(count% 2!= 0)
herroAndFollow1.add(position, new role(attack, health));
else
herroAndFollow2.add(position, new role(attack, health));
}
else if(operator.equals("end")) {
count++;
}
else if(operator.equals("attack")) {
int attacker= scanner.nextInt();
int deffender= scanner.nextInt();
if(count%2!= 0) {
herroAndFollow1.get(attacker).health-= herroAndFollow2.get(deffender).attack;
herroAndFollow2.get(deffender).health-= herroAndFollow1.get(attacker).attack;
if(herroAndFollow1.get(attacker).health<= 0&&attacker!= 0) {
herroAndFollow1.remove(attacker);
}
if(herroAndFollow2.get(deffender).health<= 0&&deffender!= 0) {
herroAndFollow2.remove(deffender);
}
}
else {
herroAndFollow1.get(deffender).health-= herroAndFollow2.get(attacker).attack;
herroAndFollow2.get(attacker).health-= herroAndFollow1.get(deffender).attack;
if(herroAndFollow2.get(attacker).health<= 0&&attacker!= 0) {
herroAndFollow2.remove(attacker);
}
if(herroAndFollow1.get(deffender).health<= 0&&deffender!= 0) {
herroAndFollow1.remove(deffender);
}
}
}
}
mainclass.print();
scanner.close();
}
}
内容总结
以上是互联网集市为您收集整理的Javadoc示例代码全部内容,希望文章能够帮你解决Javadoc示例代码所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。