bool运算符的使用方法
How to use bool operator in
我的主要问题是,如何将索引发送到我的 bool 运算符?
我尝试在我的 PlayerContainer
class 中执行 int = 0;
然后 this player.GetPlayer(i++).KA
,但一直 i = 0
。
player.GetPlayer(i).KA
是玩家的杀戮+助攻,如果这样更容易理解的话。
此代码为PlayerContainer.csclass。
class PlayerContainer {
public Player[] Players;
public int Count {
get;
set;
}
public int cycle {
get;
set;
}
public DateTime date {
get;
set;
}
public PlayerContainer(int size) {
Players = new Player[size];
}
public void AddPlayer(Player player) {
Players[Count++] = player;
}
public void AddPlayer(Player player, int index) {
Players[index] = player;
}
public Player GetPlayer(int index) {
return Players[index];
}
public static bool operator < (int max, PlayerContainer player) {
if (max < player.GetPlayer(i++).KA) {
return true;
} else
return false;
}
public static bool operator > (int max, PlayerContainer player) {
int i = 0;
if (max < player.GetPlayer(i++).KA)
return true;
else
return false;
}
这是我的 Program.cs class
中的方法 BestPlayer
Player BestPlayer(PlayerContainer AllPlayers) {
Player player = AllPlayers.GetPlayer(0);
int max = AllPlayers.GetPlayer(0).KA;
for (int i = 0; i < AllPlayers.Count; i++) {
if (max < AllPlayers) {
max = AllPlayers.GetPlayer(i).KA;
player = AllPlayers.GetPlayer(i);
}
}
return player;
}
Player BestPlayer(PlayerContainer AllPlayers)
{
Player player;
int max = AllPlayers.GetPlayer(0).KA;
Player best = AllPlayers.GetPlayer(0);
int tmp;
for (int i = 1; i < AllPlayers.Count; i++)
{
tmp = AllPlayers.GetPlayer(i).KA;
player = AllPlayers.GetPlayer(i);
if (tmp > AllPlayers)
{
max = tmp;
best = player;
}
}
return best;
}
我的主要问题是,如何将索引发送到我的 bool 运算符?
我尝试在我的 PlayerContainer
class 中执行 int = 0;
然后 this player.GetPlayer(i++).KA
,但一直 i = 0
。
player.GetPlayer(i).KA
是玩家的杀戮+助攻,如果这样更容易理解的话。
此代码为PlayerContainer.csclass。
class PlayerContainer {
public Player[] Players;
public int Count {
get;
set;
}
public int cycle {
get;
set;
}
public DateTime date {
get;
set;
}
public PlayerContainer(int size) {
Players = new Player[size];
}
public void AddPlayer(Player player) {
Players[Count++] = player;
}
public void AddPlayer(Player player, int index) {
Players[index] = player;
}
public Player GetPlayer(int index) {
return Players[index];
}
public static bool operator < (int max, PlayerContainer player) {
if (max < player.GetPlayer(i++).KA) {
return true;
} else
return false;
}
public static bool operator > (int max, PlayerContainer player) {
int i = 0;
if (max < player.GetPlayer(i++).KA)
return true;
else
return false;
}
这是我的 Program.cs class
中的方法 BestPlayerPlayer BestPlayer(PlayerContainer AllPlayers) {
Player player = AllPlayers.GetPlayer(0);
int max = AllPlayers.GetPlayer(0).KA;
for (int i = 0; i < AllPlayers.Count; i++) {
if (max < AllPlayers) {
max = AllPlayers.GetPlayer(i).KA;
player = AllPlayers.GetPlayer(i);
}
}
return player;
}
Player BestPlayer(PlayerContainer AllPlayers)
{
Player player;
int max = AllPlayers.GetPlayer(0).KA;
Player best = AllPlayers.GetPlayer(0);
int tmp;
for (int i = 1; i < AllPlayers.Count; i++)
{
tmp = AllPlayers.GetPlayer(i).KA;
player = AllPlayers.GetPlayer(i);
if (tmp > AllPlayers)
{
max = tmp;
best = player;
}
}
return best;
}