请多多包涵,因为我只是在学习 C#。只是在搞乱 C# 我决定想出一个库存系统来测试,但我的脚本中有一个问题:
using System;
using System.Collections.Generic;
public class Item
{
public String name;
public int pesos;
public int getPesos()
{
return pesos;
}
public String getName()
{
return name;
}
}
public class statuseffect
{
statuseffect(string Effect,int Amount,int Duration)
{
string effect = Effect;
int amount = Amount;
int duration = Duration;
}
}
public class Potion : Item
{
public int hpeffect;
public int mpeffect;
List<statuseffect> effects = new List<statuseffect>();
public Potion(int hp,int mp)
{
hpeffect = hp;
mpeffect = mp;
}
public void addEffect(statuseffect eff)
{
effects.Add(eff);
}
}
class game
{
public static void Main()
{
Potion healthPotion = new Potion(200,50);
healthPotion.pesos = 23;
Console.WriteLine(healthPotion.hpeffect);
statuseffect slow = new statuseffect("slow",10,30);
}
}
在最后一行,编译器告诉我 statuseffect 不包含带有 3 个参数的构造函数。据我所知,它确实包含 3 个论点。我在这里缺少什么吗?
作为旁注。如果你们对我的脚本有任何意见或建议,那也会很有帮助。