如何从一串数组中添加 int 作为我的纸牌游戏的攻击伤害



我正在与我的学校项目合作,制作一个 2 人纸牌游戏。我正在尝试开始制作英雄数组,但我不知道在哪里可以存储攻击/伤害的 int。我即将制作 100 个英雄并随机处理给每个玩家将有 5 张牌的用户。

import java.util.Scanner;
public class AngelsAndMinions {
public static void main(String[]args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Player 1 Name : ");
String Player1 = in.next();
System.out.println("Enter Player 2 Name : ");
String Player2 = in.next();
String [] Heroes =  new String[5];
Heroes[0] = "Winter Wyvern - Like many great poets, Auroth just wants time to write, but the Winter Wyvern's life is full of interruptions.";
Heroes[1] = "Visage - Perched atop the entrance to the Narrow Maze sit the looming shapes of sneering gargoyles, the paths into the hereafter forever in their gaze.";
Heroes[2] = "Skywrath Mage - A highly placed mage in the court of the Ghastly Eyrie, Dragonus lives a troubled existence. "; 
Heroes[3] = "Jakiro - Even among magical beasts, a twin-headed dragon is a freak.";     
Heroes[4] = "Puck - While Puck seems at first glance a mischievous, childish character, this quality masks an alien personality.";
}

为英雄创建一个类:

public class Hero {
public String name;
public String description;
public int damage;
public Hero(String name, String description, int damage) {
this.name = name;
this.description = description;
this.damage = damage;
}   
}

在你的main((方法中创建一个英雄数组并创建英雄对象:

Hero[] heroes =  new Hero[5];
heroes[0] = new Hero("Example Hero", "Example description", 50);

最新更新